Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 392 lines (332 sloc) 12.149 kb
6d78429 Merge of branches/raggi
raggi authored
1 #!/usr/bin/env rake
9d5b7ca migrated version_0 to trunk
blackhedd authored
2 #--
3 # Ruby/EventMachine
4 # http://rubyeventmachine.com
5 # Copyright (C) 2006-07 by Francis Cianfrocca
6 #
7 # This program is copyrighted free software. You may use it under
8 # the terms of either the GPL or Ruby's License. See the file
9 # COPYING in the EventMachine distribution for full licensing
10 # information.
11 #
12 # $Id$
13 #++
14
6d78429 Merge of branches/raggi
raggi authored
15 ### OLD RAKE: ###
16 # # The tasks and external gemspecs we used to generate binary gems are now
17 # # obsolete. Use Patrick Hurley's gembuilder to build binary gems for any
18 # # desired platform.
19 # # To build a binary gem on Win32, ensure that the include and lib paths
20 # # both contain the proper references to OPENSSL. Use the static version
21 # # of the libraries, not the dynamic, otherwise we expose the user to a
22 # # runtime dependency.
a8ce207 @gnufied update rakefile for better path
gnufied authored
23 #
6d78429 Merge of branches/raggi
raggi authored
24 # # To build a binary gem for win32, first build rubyeventmachine.so
25 # # using VC6 outside of the build tree (the normal way: ruby extconf.rb,
26 # # and then nmake). Then copy rubyeventmachine.so into the lib directory,
27 # # and run rake gemwin32.
28 #
9d5b7ca migrated version_0 to trunk
blackhedd authored
29
6d78429 Merge of branches/raggi
raggi authored
30 require 'rubygems' unless defined?(Gem)
31 require 'rake' unless defined?(Rake)
9d5b7ca migrated version_0 to trunk
blackhedd authored
32
6d78429 Merge of branches/raggi
raggi authored
33 Package = false # Build zips and tarballs?
34 Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
9d5b7ca migrated version_0 to trunk
blackhedd authored
35
6d78429 Merge of branches/raggi
raggi authored
36 # e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults!
37 $eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java'
38 $eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby'
9d5b7ca migrated version_0 to trunk
blackhedd authored
39
39b7476 Another make adjustment for win32
raggi authored
40 MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
41 'nmake'
42 else
43 'make'
44 end
45
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
46 desc "Build gemspec, then build eventmachine, then run tests."
47 task :default => [:build, :test]
9d5b7ca migrated version_0 to trunk
blackhedd authored
48
50845ea corrected misspelling in desc text
francis authored
49 desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
6d78429 Merge of branches/raggi
raggi authored
50 build_task = 'ext:build'
51 build_task = 'java:build' if $eventmachine_library == :java
52 build_task = :dummy_build if $eventmachine_library == :pure_ruby
53 task :build => build_task do |t|
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
54 Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
6d78429 Merge of branches/raggi
raggi authored
55 mv f, "lib"
9d5b7ca migrated version_0 to trunk
blackhedd authored
56 end
57 end
58
6d78429 Merge of branches/raggi
raggi authored
59 task :dummy_build
9d5b7ca migrated version_0 to trunk
blackhedd authored
60
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
61 require 'rake/testtask'
62 Rake::TestTask.new(:test) do |t|
63 t.pattern = 'tests/**/test_*.rb'
64 t.warning = true
65 end
66
6d78429 Merge of branches/raggi
raggi authored
67 # Basic clean definition, this is enhanced by imports aswell.
68 task :clean do
69 chdir 'ext' do
39b7476 Another make adjustment for win32
raggi authored
70 sh "#{MAKE} clean" if test ?e, 'Makefile'
9d5b7ca migrated version_0 to trunk
blackhedd authored
71 end
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
72 chdir 'ext/fastfilereader' do
73 sh "#{MAKE} clean" if test ?e, 'Makefile'
74 end
e55477c @jakedouglas initial native hooks work
jakedouglas authored
75 chdir 'tests/emtestext' do
76 sh "#{MAKE} clean" if test ?e, 'Makefile'
77 end
6d78429 Merge of branches/raggi
raggi authored
78 Dir.glob('**/Makefile').each { |file| rm file }
79 Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
5a3fa5f @tmm1 Clean up conftest.dSYM dirs generated on OSX
tmm1 authored
80 Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
6d78429 Merge of branches/raggi
raggi authored
81 end
82
83 Spec = Gem::Specification.new do |s|
84 s.name = "eventmachine"
85 s.summary = "Ruby/EventMachine library"
86 s.platform = Gem::Platform::RUBY
87
88 s.has_rdoc = true
2db07fe @tmm1 Fix gemspec for top-level README
tmm1 authored
89 s.rdoc_options = %w(--title EventMachine --main README --line-numbers -x lib/em/version -x lib/emva -x lib/evma/ -x lib/pr_eventmachine -x lib/jeventmachine)
90 s.extra_rdoc_files = Dir['README,docs/*']
6d78429 Merge of branches/raggi
raggi authored
91
8d52c76 @tmm1 Package all checked-in files into gem
tmm1 authored
92 s.files = `git ls-files`.split("\n")
6d78429 Merge of branches/raggi
raggi authored
93
94 s.require_path = 'lib'
95
a8ce207 @gnufied update rakefile for better path
gnufied authored
96 # TODO / XXX - should we enable this? rubygems fails the install if anything
4b7b188 Remove test_file from gemspec - test dependent installs can be a pain
raggi authored
97 # is broken. What we could do is CI submission, though, and always terminate
98 # with a positive code...
99 # s.test_file = "tests/testem.rb"
baf9aac @tmm1 Switch back to extconf for compiling gem extensions
tmm1 authored
100
101 # XXX Using rake to compile extensions breaks when you have multiple ruby installations
102 # and your path isn't set. We can switch back to this once the Gem.exec patch is merged.
103 # s.extensions = "Rakefile"
104 s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
6d78429 Merge of branches/raggi
raggi authored
105
106 s.author = "Francis Cianfrocca"
107 s.email = "garbagecat10@gmail.com"
108 s.rubyforge_project = 'eventmachine'
109 s.homepage = "http://rubyeventmachine.com"
110
111 # Pulled in from readme, as code to pull from readme was not working!
112 # Might be worth removing as no one seems to use gem info anyway.
113 s.description = <<-EOD
114 EventMachine implements a fast, single-threaded engine for arbitrary network
115 communications. It's extremely easy to use in Ruby. EventMachine wraps all
116 interactions with IP sockets, allowing programs to concentrate on the
117 implementation of network protocols. It can be used to create both network
118 servers and clients. To create a server or client, a Ruby program only needs
119 to specify the IP address and port, and provide a Module that implements the
120 communications protocol. Implementations of several standard network protocols
121 are provided with the package, primarily to serve as examples. The real goal
122 of EventMachine is to enable programs to easily interface with other programs
123 using TCP/IP, especially if custom protocols are required.
124 EOD
125
1a50af6 @tmm1 Move eventmachine_version to em/version.rb
tmm1 authored
126 require 'lib/em/version'
6d78429 Merge of branches/raggi
raggi authored
127 s.version = EventMachine::VERSION
128 end
129
92eca0a @tmm1 rake win32:gem task to build openssl and a win32 binary gem (requires ms...
tmm1 authored
130 if RUBY_PLATFORM =~ /mswin/
131 Spec.platform = 'x86-mswin32-60'
132 Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
133 Spec.extensions = nil
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
134 elsif RUBY_PLATFORM =~ /java/
9324f20 @tmm1 JRuby gem platform is java, not jruby
tmm1 authored
135 Spec.platform = 'java'
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
136 Spec.files += %w[ lib/em_reactor.jar ]
137 Spec.extensions = nil
92eca0a @tmm1 rake win32:gem task to build openssl and a win32 binary gem (requires ms...
tmm1 authored
138 end
139
140 # this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
141 namespace :win32 do
142 task :check_git do
143 unless `git` =~ /rebase/
144 raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
145 end
146 end
147
148 task :check_vc6 do
149 begin
150 raise unless `nmake 2>&1` =~ /Microsoft/
151 rescue
152 raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
153 end
154 end
155
156 task :check_perl do
157 unless `perl --version` =~ /ActiveState/
158 raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
159 end
160 end
161
162 task :build_openssl => [:check_git, :check_perl, :check_vc6] do
163 mkdir_p 'build'
164 chdir 'build' do
165 unless File.exists?('openssl-0.9.8j')
166 sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
167 sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
168 end
169
170 mkdir_p 'local'
171 chdir 'openssl-0.9.8j' do
172 sh "perl Configure VC-WIN32 --prefix=\"../local/\""
173 sh 'ms\do_ms.bat'
174 sh 'nmake -f ms\nt.mak install'
175 end
176
177 chdir '../ext' do
178 sh 'git clean -fd .'
179 end
180
181 mv 'local/include/openssl', '../ext/'
182 mv 'local/lib/ssleay32.lib', '../ext/'
183 mv 'local/lib/libeay32.lib', '../ext/'
184 end
185 end
186
59aa017 @tmm1 Some rake task descriptions
tmm1 authored
187 desc "build binary win32 gem"
92eca0a @tmm1 rake win32:gem task to build openssl and a win32 binary gem (requires ms...
tmm1 authored
188 task :gem => :build_openssl do
189 Rake::Task['build'].invoke
190 Rake::Task['gem'].invoke
191 end
192 end
193
6d78429 Merge of branches/raggi
raggi authored
194 namespace :ext do
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
195 ext_sources = FileList['ext/*.{h,cpp,rb,c}']
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
196 ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
e55477c @jakedouglas initial native hooks work
jakedouglas authored
197 emtestext_sources = FileList['tests/emtestext/*.{h,cpp,rb,c}']
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
198 file ext_extconf = 'ext/extconf.rb'
199 file ffr_extconf = 'ext/fastfilereader/extconf.rb'
e55477c @jakedouglas initial native hooks work
jakedouglas authored
200 file emtestext_extconf = 'tests/emtestext/extconf.rb'
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
201 ext_libname = "lib/rubyeventmachine.#{Config::CONFIG['DLEXT']}"
202 ffr_libname = "lib/fastfilereaderext.#{Config::CONFIG['DLEXT']}"
e55477c @jakedouglas initial native hooks work
jakedouglas authored
203 emtestext_libname = "tests/emtestext/emtestext.#{Config::CONFIG['DLEXT']}"
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
204
205 file ext_libname => ext_sources + ['ext/Makefile'] do
206 chdir('ext') { sh MAKE }
207 end
208
209 file ffr_libname => ffr_sources + ['ext/fastfilereader/Makefile'] do
210 chdir('ext/fastfilereader') { sh MAKE }
211 end
a8ce207 @gnufied update rakefile for better path
gnufied authored
212
e55477c @jakedouglas initial native hooks work
jakedouglas authored
213 file emtestext_libname => emtestext_sources + ['tests/emtestext/Makefile'] do
214 chdir('tests/emtestext') { sh MAKE }
215 end
216
6d78429 Merge of branches/raggi
raggi authored
217 desc "Build C++ extension"
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
218 task :build => [:make]
a8ce207 @gnufied update rakefile for better path
gnufied authored
219
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
220 task :make => ext_libname
221 task :make => ffr_libname
e55477c @jakedouglas initial native hooks work
jakedouglas authored
222 task :make => emtestext_libname
a8ce207 @gnufied update rakefile for better path
gnufied authored
223
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
224 file 'ext/Makefile' => ext_extconf do
6d78429 Merge of branches/raggi
raggi authored
225 chdir 'ext' do
226 ruby 'extconf.rb'
9d5b7ca migrated version_0 to trunk
blackhedd authored
227 end
228 end
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
229
766b201 @raggi Don't rebuild unless there's a need to
raggi authored
230 file 'ext/fastfilereader/Makefile' => ffr_extconf do
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
231 chdir 'ext/fastfilereader' do
232 ruby 'extconf.rb'
233 end
234 end
e55477c @jakedouglas initial native hooks work
jakedouglas authored
235
236 file 'tests/emtestext/Makefile' => emtestext_extconf do
237 chdir 'tests/emtestext' do
238 ruby 'extconf.rb'
239 end
240 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
241 end
59aa017 @tmm1 Some rake task descriptions
tmm1 authored
242
6d78429 Merge of branches/raggi
raggi authored
243 namespace :java do
244 # This task creates the JRuby JAR file and leaves it in the lib directory.
245 # This step is required before executing the jgem task.
246 desc "Build java extension"
247 task :build => [:jar] do |t|
4731d6f @tmm1 Fix java:gem rake task
tmm1 authored
248 mv 'java/em_reactor.jar', 'lib/'
9d5b7ca migrated version_0 to trunk
blackhedd authored
249 end
a8ce207 @gnufied update rakefile for better path
gnufied authored
250
6d78429 Merge of branches/raggi
raggi authored
251 task :compile do
a8ce207 @gnufied update rakefile for better path
gnufied authored
252 chdir('java') do
4731d6f @tmm1 Fix java:gem rake task
tmm1 authored
253 mkdir_p "build"
453977b @tmm1 Oops, actually fix java:gem rake task
tmm1 authored
254 sh 'javac src/com/rubyeventmachine/*.java -d build'
6d78429 Merge of branches/raggi
raggi authored
255 end
256 end
a8ce207 @gnufied update rakefile for better path
gnufied authored
257
6d78429 Merge of branches/raggi
raggi authored
258 task :jar => [:compile] do
453977b @tmm1 Oops, actually fix java:gem rake task
tmm1 authored
259 chdir('java/build') do
4731d6f @tmm1 Fix java:gem rake task
tmm1 authored
260 sh "jar -cf ../em_reactor.jar com/rubyeventmachine/*.class"
6d78429 Merge of branches/raggi
raggi authored
261 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
262 end
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
263
59aa017 @tmm1 Some rake task descriptions
tmm1 authored
264 desc "build a java binary gem"
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
265 task :gem => :build do
4731d6f @tmm1 Fix java:gem rake task
tmm1 authored
266 Spec.platform = 'java'
267 Spec.files += %w[ lib/em_reactor.jar ]
268 Spec.extensions = nil
269
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
270 Rake::Task['gem'].invoke
271 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
272 end
944417f Added gemspec task, and gemspec file for use on github. Reversioned to d...
raggi authored
273
9d473be @tmm1 Add rake osx:gem task to build binary darwin gems
tmm1 authored
274 namespace :osx do
275 desc "Build OSX binary gem"
276 task :gem do
277 Spec.platform = RUBY_PLATFORM.sub(/darwin.+$/, 'darwin')
278 Spec.files += %w[ lib/rubyeventmachine.bundle lib/fastfilereaderext.bundle ]
279 Spec.extensions = nil
280
281 Rake::Task['build'].invoke
282 Rake::Task['gem'].invoke
283 end
cb8e438 Added osx:static_gem task to compile ssl locally for the OSX gem
Dan Mayer authored
284
285 # XXX gcc will still prefer the shared libssl on the system, so we need to hack the extconf
286 # XXX to use the static library to make this actually work
287 task :static_gem => [:build_openssl, :gem]
288
289 task :build_openssl do
290 mkdir_p 'build'
291 chdir 'build' do
292 unless File.exists?('openssl-0.9.8j')
293 sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl-0.9.8j.tar.gz'
294 sh 'tar zxvf openssl-0.9.8j.tar.gz'
295 end
296
297 mkdir_p 'local'
298 chdir 'openssl-0.9.8j' do
299 local_dir = File.expand_path(File.join(File.dirname(__FILE__),'build','local'))
300 sh "./config --prefix=#{local_dir}"
301 sh 'make'
302 sh 'make install'
303 end
304
305 chdir '../ext' do
306 sh 'git clean -fd .'
307 end
308
309 mv 'local/include/openssl', '../ext/'
310 mv 'local/lib/libssl.a', '../ext/'
311 mv 'local/lib/libcrypto.a', '../ext/'
312 end
313 end
9d473be @tmm1 Add rake osx:gem task to build binary darwin gems
tmm1 authored
314 end
315
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
316 require 'rake/clean'
317
318 rdoc_task_type = begin
319 require 'rdoc/task'
320 RDoc::Task
321 rescue LoadError
322 require 'rake/rdoctask'
323 Rake::RDocTask
324 end
325 df = begin; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
326 rdtask = rdoc_task_type.new do |rd|
327 rd.title = Spec.name
328 rd.rdoc_dir = 'rdoc'
329 rd.main = "README"
330 rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
331 rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
332 rd.template = 'darkfish' if df
333 end
334 Rake::Task[:clean].enhance [:clobber_rdoc]
335
336 desc 'Generate and open documentation'
337 task :docs => :rdoc do
338 case RUBY_PLATFORM
339 when /darwin/ ; sh 'open rdoc/index.html'
340 when /mswin|mingw/ ; sh 'start rdoc\index.html'
341 else
342 sh 'firefox rdoc/index.html'
343 end
344 end
345
346 def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
347 def sudo(cmd)
348 if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
349 sh cmd
350 else
351 sh "sudo #{cmd}"
352 end
353 end
354 def gem_cmd(action, name, *args)
355 rb = Gem.ruby rescue nil
356 rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
357 sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
358 end
359
72bd711 @tmm1 Simplify gem task in Rakefile
tmm1 authored
360 begin
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
361 require 'rubygems/package_task'
362 Gem::PackageTask
363 rescue LoadError
364 require 'rake/gempackagetask'
365 Rake::GemPackageTask
72bd711 @tmm1 Simplify gem task in Rakefile
tmm1 authored
366 end.new(Spec) do |pkg|
367 pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
368 pkg.gem_spec = Spec
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
369 end
72bd711 @tmm1 Simplify gem task in Rakefile
tmm1 authored
370
9053357 @raggi more rakefile cleaning. bayshore servers returning errors again, switch ...
raggi authored
371 Rake::Task[:clean].enhance [:clobber_package]
372
373 namespace :gem do
374 desc 'Install gem (and sudo if required)'
375 task :install => :package do
376 gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
377 end
378
379 desc 'Uninstall gem (and sudo if required)'
380 task :uninstall do
381 gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
382 end
383
384 desc "Generate new gemspec"
385 task :spec => :clobber do
386 open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
387 end
50845ea corrected misspelling in desc text
francis authored
388 end
5394f05 @raggi Use clobber before generating gemspec, and ensure clobber runs clean
raggi authored
389
402923d @raggi Run build before test
raggi authored
390 task :clobber => :clean
a8ce207 @gnufied update rakefile for better path
gnufied authored
391 task :test => :build
Something went wrong with that request. Please try again.