From e045f787e126f40d6cd2539632ceb02221c1e8d8 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Fri, 26 Oct 2007 03:07:30 +0000 Subject: revert trunk to 1.1 git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@744 19e92222-5c0b-0410-8929-a290d50e31e9 --- Rakefile | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 4df1352..4d7e389 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ require 'echoe' e = Echoe.new("mongrel") do |p| p.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps." p.author ="Zed A. Shaw" - p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config'] + p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config', 'lib/http11.jar', 'ext/http11_java/classes'] p.rdoc_pattern = ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc', 'ext/http11/http11.c'] p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/ p.ruby_version = '>= 1.8.4' @@ -30,6 +30,10 @@ e = Echoe.new("mongrel") do |p| extensions.clear self.files += ['lib/http11.so'] self.platform = Gem::Platform::WIN32 + when /java/ + extensions.clear + self.files += ['lib/http11.jar'] + self.platform = 'jruby' else add_dependency('daemons', '>= 1.0.3') add_dependency('fastthread', '>= 1.0.1') @@ -48,6 +52,21 @@ task :ragel do sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}" raise "Failed to build C source" unless File.exist? target end + Dir.chdir "ext/http11" do + target = "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" + File.unlink target if File.exist? target + sh "ragel -J http11_parser.java.rl | rlgen-java -o #{target}" + raise "Failed to build Java source" unless File.exist? target + end +end + +#### XXX Hack around JRuby test/unit interaction problems + +desc "Run each test suite in isolation on JRuby" +task :test_java do + e.test_pattern.each do |f| + sh "/opt/local/jruby/bin/jruby -w -Ilib:ext:bin:test -e 'require \"#{f}\"'" rescue nil + end end #### XXX Hack around RubyGems and Echoe for pre-compiled extensions. @@ -56,6 +75,18 @@ def move_extensions Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"].each { |file| cp file, "lib/" } end +def java_classpath_arg + # A myriad of ways to discover the JRuby classpath + classpath = begin + require 'java' + # Already running in a JRuby JVM + Java::java.lang.System.getProperty('java.class.path') + rescue LoadError + ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR) + end + classpath ? "-cp #{classpath}" : "" +end + case RUBY_PLATFORM when /mswin/ filename = "lib/http11.so" @@ -67,6 +98,19 @@ when /mswin/ move_extensions end task :compile => [filename] + +when /java/ + filename = "lib/http11.jar" + file filename do + build_dir = "ext/http11_java/classes" + mkdir_p build_dir + sources = FileList['ext/http11_java/**/*.java'].join(' ') + sh "javac -target 1.4 -source 1.4 -d #{build_dir} #{java_classpath_arg} #{sources}" + sh "jar cf lib/http11.jar -C #{build_dir} ." + move_extensions + end + task :compile => [filename] + end #### Project-wide install and uninstall tasks @@ -89,6 +133,7 @@ task :package_all => [:package] do sub_project("mongrel_console", :package) sub_project("mongrel_cluster", :package) sub_project("mongrel_service", :package) if RUBY_PLATFORM =~ /mswin/ + sh("rake java package") unless RUBY_PLATFORM =~ /java/ end task :install_requirements do -- cgit v1.2.3-24-ge0c7