Rakefile in json_pure-1.5.3 vs Rakefile in json_pure-1.5.4

- old
+ new

@@ -2,12 +2,17 @@ require 'rubygems/package_task' rescue LoadError end require 'rbconfig' -include Config +begin + include RbConfig +rescue NameError + include Config +end + require 'rake/clean' CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], 'doc', 'Gemfile.lock' CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp', FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'], FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"], @@ -61,10 +66,11 @@ for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"] d = File.join(sitearchdir, file) mkdir_p File.dirname(d) install(file, d) end + warn " *** Installed EXT ruby library." end end desc "Installing library (extension)" task :install_ext => [ :compile, :install_pure, :install_ext_really ] @@ -87,10 +93,12 @@ s.require_path = 'lib' s.add_development_dependency 'permutation' s.add_development_dependency 'bullshit' s.add_development_dependency 'sdoc' + s.add_development_dependency 'rake', '~>0.9.2' + s.add_dependency 'spruz', '~>0.2.8' s.bindir = "bin" s.executables = [ "edit_json.rb", "prettify_json.rb" ] s.extra_rdoc_files << 'README.rdoc' @@ -189,11 +197,26 @@ end desc "Testing library (pure ruby and extension)" task :test => [ :test_pure, :test_ext ] +namespace :gems do + task :install do + sh 'bundle' + end +end + if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby' + if ENV.key?('JAVA_HOME') + warn " *** JAVA_HOME was set to #{ENV['JAVA_HOME'].inspect}" + else File.directory?(local_java = '/usr/local/java/jdk') + ENV['JAVA_HOME'] = local_java + warn " *** JAVA_HOME is set to #{ENV['JAVA_HOME'].inspect}" + ENV['PATH'] = ENV['PATH'].split(/:/).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * ':' + warn " *** java binaries are assumed to be in #{java_path.inspect}" + end + file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do cd JAVA_DIR do if RAGEL_CODEGEN == 'ragel' sh "ragel Parser.rl -J -o Parser.java" else @@ -208,11 +231,11 @@ desc "Delete the ragel generated Java source" task :ragel_clean do rm_rf JAVA_PARSER_SRC end - JRUBY_JAR = File.join(Config::CONFIG["libdir"], "jruby.jar") + JRUBY_JAR = File.join(CONFIG["libdir"], "jruby.jar") if File.exist?(JRUBY_JAR) JAVA_SOURCES.each do |src| classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':' obj = src.sub(/\.java\Z/, '.class') file obj => src do @@ -278,11 +301,13 @@ desc "Create parser and generator jars" task :create_jar => [ :create_parser_jar, :create_generator_jar ] desc "Build all gems and archives for a new release of the jruby extension." - task :release => [ :clean, :version, :jruby_gem ] + task :build => [ :clean, :version, :jruby_gem ] + + task :release => :build else desc "Compiling extension" task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ] file EXT_PARSER_DL => EXT_PARSER_SRC do @@ -343,10 +368,12 @@ if RAGEL_CODEGEN == 'ragel' sh "ragel parser.rl -G2 -o parser.c" else sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2" end + src = File.read("parser.c").gsub(/[ \t]+$/, '') + File.open("parser.c", "w") {|f| f.print src} end end desc "Generate diagrams of ragel parser (ps)" task :ragel_dot_ps do @@ -378,10 +405,12 @@ desc "Generate diagrams of ragel parser" task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ] desc "Build all gems and archives for a new release of json and json_pure." - task :release => [ :clean, :gemspec, :package ] + task :build => [ :clean, :gemspec, :package ] + + task :release => :build end desc "Compile in the the source directory" -task :default => [ :clean, :gemspec, :compile ] +task :default => [ :clean, :gemspec, :test ]