root/trunk/Rakefile

Revision 997, 7.7 kB (checked in by luislavena, 5 months ago)

Remove deprecated WIN32 and use Gem::Platform::CURRENT instead.

Line 
1
2 require 'rubygems'
3 gem 'echoe', '>=2.7.5'
4 require 'echoe'
5
6 e = Echoe.new("mongrel") do |p|
7   p.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps."
8   p.author ="Zed A. Shaw"
9   p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{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', 'coverage']
10   p.url = "http://mongrel.rubyforge.org"
11   p.rdoc_pattern = ['README', 'LICENSE', 'CHANGELOG', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
12   p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/
13   p.ruby_version = '>=1.8.4'
14   p.dependencies = ['gem_plugin >=0.2.3'] 
15   p.extension_pattern = nil
16  
17   p.certificate_chain = case ENV['USER']
18     when 'eweaver'
19       ['~/p/configuration/gem_certificates/mongrel/mongrel-public_cert.pem',
20        '~/p/configuration/gem_certificates/evan_weaver-mongrel-public_cert.pem']
21     when 'luislavena'
22       ['~/gem_certificates/mongrel-public_cert.pem',
23         '~/gem_certificates/luislavena-mongrel-public_cert.pem']   
24   end
25  
26   p.need_tar_gz = false
27   p.need_tgz = true
28
29   if RUBY_PLATFORM !~ /mswin|java/
30     p.extension_pattern = ["ext/**/extconf.rb"]
31   end
32
33   p.eval = proc do
34     case RUBY_PLATFORM
35     when /mswin/
36       self.files += ['lib/http11.so']
37       self.platform = Gem::Platform::CURRENT
38       add_dependency('cgi_multipart_eof_fix', '>= 2.4')
39     when /java/
40       self.files += ['lib/http11.jar']
41       self.platform = 'jruby' # XXX Is this right?
42     else
43       add_dependency('daemons', '>= 1.0.3')
44       add_dependency('fastthread', '>= 1.0.1')
45       add_dependency('cgi_multipart_eof_fix', '>= 2.4')
46     end
47   end
48
49 end
50
51 #### Ragel builder
52
53 desc "Rebuild the Ragel sources"
54 task :ragel do
55   Dir.chdir "ext/http11" do
56     target = "http11_parser.c"
57     File.unlink target if File.exist? target
58     sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}"
59     raise "Failed to build C source" unless File.exist? target
60   end
61   Dir.chdir "ext/http11" do
62     target = "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java"
63     File.unlink target if File.exist? target
64     sh "ragel -J http11_parser.java.rl | rlgen-java -o #{target}"
65     raise "Failed to build Java source" unless File.exist? target
66   end
67 end
68
69 #### Pre-compiled extensions for alternative platforms
70
71 def move_extensions
72   Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"].each { |file| mv file, "lib/" }
73 end
74
75 def java_classpath_arg
76   # A myriad of ways to discover the JRuby classpath
77   classpath = begin
78     require 'java'
79     # Already running in a JRuby JVM
80     Java::java.lang.System.getProperty('java.class.path')
81   rescue LoadError
82     ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
83   end
84   classpath ? "-cp #{classpath}" : ""
85 end
86
87 case RUBY_PLATFORM
88 when /mswin/
89   filename = "lib/http11.so"
90   file filename do
91     Dir.chdir("ext/http11") do
92       ruby "extconf.rb"
93       system(PLATFORM =~ /mswin/ ? 'nmake' : 'make')
94     end
95     move_extensions
96   end
97   task :compile => [filename]
98
99 when /java/
100
101   # Avoid JRuby in-process launching problem
102   begin
103     require 'jruby'
104     JRuby.runtime.instance_config.run_ruby_in_process = false
105   rescue LoadError
106   end
107
108   filename = "lib/http11.jar"
109   file filename do
110     build_dir = "ext/http11_java/classes"
111     mkdir_p build_dir
112     sources = FileList['ext/http11_java/**/*.java'].join(' ')
113     sh "javac -target 1.4 -source 1.4 -d #{build_dir} #{java_classpath_arg} #{sources}"
114     sh "jar cf lib/http11.jar -C #{build_dir} ."
115     move_extensions
116   end
117   task :compile => [filename]
118
119 end
120
121 #### Project-wide install and uninstall tasks
122
123 def sub_project(project, *targets)
124   targets.each do |target|
125     Dir.chdir "projects/#{project}" do
126       unless RUBY_PLATFORM =~ /mswin/
127         sh("rake #{target.to_s}") # --trace
128       end
129     end
130   end
131 end
132
133 desc "Package Mongrel and all subprojects"
134 task :package_all => [:package] do
135   sub_project("gem_plugin", :package)
136   sub_project("cgi_multipart_eof_fix", :package)
137   sub_project("fastthread", :package)
138   sub_project("mongrel_status", :package)
139   sub_project("mongrel_upload_progress", :package)
140   sub_project("mongrel_console", :package)
141   sub_project("mongrel_cluster", :package)
142   sub_project("mongrel_experimental", :package)
143
144   sh("rake java package") unless RUBY_PLATFORM =~ /java/
145  
146   # XXX Broken by RubyGems 0.9.5
147   # sub_project("mongrel_service", :package) if RUBY_PLATFORM =~ /mswin/
148   # sh("rake mswin package") unless RUBY_PLATFORM =~ /mswin/
149 end
150
151 task :install_requirements do
152   # These run before Mongrel is installed
153   sub_project("gem_plugin", :install)
154   sub_project("cgi_multipart_eof_fix", :install)
155   sub_project("fastthread", :install)
156 end
157
158 desc "for Mongrel and all subprojects"
159 task :install => [:install_requirements] do
160   # These run after Mongrel is installed
161   sub_project("mongrel_status", :install)
162   sub_project("mongrel_upload_progress", :install)
163   sub_project("mongrel_console", :install)
164   sub_project("mongrel_cluster", :install)
165   # sub_project("mongrel_experimental", :install)
166   sub_project("mongrel_service", :install) if RUBY_PLATFORM =~ /mswin/
167 end
168
169 desc "for Mongrel and all its subprojects"
170 task :uninstall => [:clean] do
171   sub_project("mongrel_status", :uninstall)
172   sub_project("cgi_multipart_eof_fix", :uninstall)
173   sub_project("mongrel_upload_progress", :uninstall)
174   sub_project("mongrel_console", :uninstall)
175   sub_project("gem_plugin", :uninstall)
176   sub_project("fastthread", :uninstall)
177   # sub_project("mongrel_experimental", :uninstall)
178   sub_project("mongrel_service", :uninstall) if RUBY_PLATFORM =~ /mswin/
179 end
180
181 desc "for Mongrel and all its subprojects"
182 task :clean do
183   sub_project("gem_plugin", :clean)
184   sub_project("cgi_multipart_eof_fix", :clean)
185   sub_project("fastthread", :clean)
186   sub_project("mongrel_status", :clean)
187   sub_project("mongrel_upload_progress", :clean)
188   sub_project("mongrel_console", :clean)
189   sub_project("mongrel_cluster", :clean)
190   sub_project("mongrel_experimental", :clean)
191   sub_project("mongrel_service", :clean) if RUBY_PLATFORM =~ /mswin/
192 end
193
194 #### Site upload tasks
195
196 namespace :site do
197
198   desc "Package and upload .gem files and .tgz files for Mongrel and all subprojects to http://mongrel.rubyforge.org/releases/"
199   task :source => [:package_all] do
200     rm_rf "pkg/gems"
201     rm_rf "pkg/tars"
202     mkdir_p "pkg/gems"
203     mkdir_p "pkg/tars"
204
205     FileList["**/*.gem"].each { |gem| mv gem, "pkg/gems" }
206     FileList["**/*.tgz"].each {|tgz| mv tgz, "pkg/tars" }
207
208     sh "rm -rf pkg/mongrel*"
209     sh "gem generate_index -d pkg"
210     sh "scp -r CHANGELOG pkg/* rubyforge.org:/var/www/gforge-projects/mongrel/releases/"
211     sh "svn log -v > SVN_LOG"
212     sh "scp -r SVN_LOG pkg/* rubyforge.org:/var/www/gforge-projects/mongrel/releases/"
213     rm "SVN_LOG"
214   end
215
216   desc "Upload the website"
217   task :web do
218     # Requires the 'webgem' gem
219     sh "cd site; webgen; webgen; curl 'http://feed43.com/mongrel.xml' > output/rss.xml; rsync -azv --no-perms --no-times output/* rubyforge.org:/var/www/gforge-projects/mongrel/"
220     puts "\nMake sure to re-run the site update 6 hours later if you updated the news. This delay is required for Feed43 to pick up the site changes."
221   end
222
223   desc "Upload the rdocs"
224   task :rdoc => [:doc] do
225     sh "rsync -azv --no-perms --no-times doc/* rubyforge.org:/var/www/gforge-projects/mongrel/rdoc/"
226     sh "cd projects/gem_plugin; rake site:rdoc"
227   end
228
229   desc "Upload the coverage report"
230   task :coverage => [:rcov] do
231     sh "rsync -azv --no-perms --no-times test/coverage/* rubyforge.org:/var/www/gforge-projects/mongrel/coverage/" rescue nil
232   end
233
234   desc "Upload the website, the rdocs, and the coverage report"
235   task :all => [:clean, :web, :rdoc, :coverage]
236
237 end
Note: See TracBrowser for help on using the browser.