Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 262 lines (223 sloc) 8.446 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.
23 #
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 require 'rake/gempackagetask'
33
6d78429 Merge of branches/raggi
raggi authored
34 Package = false # Build zips and tarballs?
35 Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
9d5b7ca migrated version_0 to trunk
blackhedd authored
36
6d78429 Merge of branches/raggi
raggi authored
37 # e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults!
38 $eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java'
39 $eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby'
9d5b7ca migrated version_0 to trunk
blackhedd authored
40
39b7476 Another make adjustment for win32
raggi authored
41 MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
42 'nmake'
43 else
44 'make'
45 end
46
6d78429 Merge of branches/raggi
raggi authored
47 # If running under rubygems...
48 __DIR__ ||= File.expand_path(File.dirname(__FILE__))
b1c85cb @tmm1 Catch errors in 'running under rubygems' check
tmm1 authored
49 if Gem.path.map{|path| Dir.chdir(path){ Dir.pwd } rescue path }.any? {|path| %r(^#{Regexp.escape path}) =~ __DIR__}
6d78429 Merge of branches/raggi
raggi authored
50 task :default => :gem_build
51 else
944417f Added gemspec task, and gemspec file for use on github. Reversioned to d...
raggi authored
52 desc "Build gemspec, then build eventmachine, then run tests."
ae1f407 @raggi Don't need to clean + clobber by default
raggi authored
53 task :default => [:build, :test]
9d5b7ca migrated version_0 to trunk
blackhedd authored
54 end
55
6d78429 Merge of branches/raggi
raggi authored
56 desc ":default build when running under rubygems."
57 task :gem_build => :build
9d5b7ca migrated version_0 to trunk
blackhedd authored
58
50845ea corrected misspelling in desc text
francis authored
59 desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
6d78429 Merge of branches/raggi
raggi authored
60 build_task = 'ext:build'
61 build_task = 'java:build' if $eventmachine_library == :java
62 build_task = :dummy_build if $eventmachine_library == :pure_ruby
63 task :build => build_task do |t|
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
64 Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
6d78429 Merge of branches/raggi
raggi authored
65 mv f, "lib"
9d5b7ca migrated version_0 to trunk
blackhedd authored
66 end
67 end
68
6d78429 Merge of branches/raggi
raggi authored
69 task :dummy_build
9d5b7ca migrated version_0 to trunk
blackhedd authored
70
6d78429 Merge of branches/raggi
raggi authored
71 # Basic clean definition, this is enhanced by imports aswell.
72 task :clean do
73 chdir 'ext' do
39b7476 Another make adjustment for win32
raggi authored
74 sh "#{MAKE} clean" if test ?e, 'Makefile'
9d5b7ca migrated version_0 to trunk
blackhedd authored
75 end
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
76 chdir 'ext/fastfilereader' do
77 sh "#{MAKE} clean" if test ?e, 'Makefile'
78 end
6d78429 Merge of branches/raggi
raggi authored
79 Dir.glob('**/Makefile').each { |file| rm file }
80 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
81 Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
6d78429 Merge of branches/raggi
raggi authored
82 end
83
84 Spec = Gem::Specification.new do |s|
85 s.name = "eventmachine"
86 s.summary = "Ruby/EventMachine library"
87 s.platform = Gem::Platform::RUBY
88
89 s.has_rdoc = true
1a50af6 @tmm1 Move eventmachine_version to em/version.rb
tmm1 authored
90 s.rdoc_options = %w(--title EventMachine --main docs/README --line-numbers -x lib/em/version -x lib/emva -x lib/evma/ -x lib/pr_eventmachine -x lib/jeventmachine)
6d78429 Merge of branches/raggi
raggi authored
91 s.extra_rdoc_files = Dir['docs/*']
92
8d52c76 @tmm1 Package all checked-in files into gem
tmm1 authored
93 s.files = `git ls-files`.split("\n")
6d78429 Merge of branches/raggi
raggi authored
94
95 s.require_path = 'lib'
96
4b7b188 Remove test_file from gemspec - test dependent installs can be a pain
raggi authored
97 # TODO / XXX - should we enable this? rubygems fails the install if anything
98 # is broken. What we could do is CI submission, though, and always terminate
99 # with a positive code...
100 # s.test_file = "tests/testem.rb"
baf9aac @tmm1 Switch back to extconf for compiling gem extensions
tmm1 authored
101
102 # XXX Using rake to compile extensions breaks when you have multiple ruby installations
103 # and your path isn't set. We can switch back to this once the Gem.exec patch is merged.
104 # s.extensions = "Rakefile"
105 s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
6d78429 Merge of branches/raggi
raggi authored
106
107 s.author = "Francis Cianfrocca"
108 s.email = "garbagecat10@gmail.com"
109 s.rubyforge_project = 'eventmachine'
110 s.homepage = "http://rubyeventmachine.com"
111
112 # Pulled in from readme, as code to pull from readme was not working!
113 # Might be worth removing as no one seems to use gem info anyway.
114 s.description = <<-EOD
115 EventMachine implements a fast, single-threaded engine for arbitrary network
116 communications. It's extremely easy to use in Ruby. EventMachine wraps all
117 interactions with IP sockets, allowing programs to concentrate on the
118 implementation of network protocols. It can be used to create both network
119 servers and clients. To create a server or client, a Ruby program only needs
120 to specify the IP address and port, and provide a Module that implements the
121 communications protocol. Implementations of several standard network protocols
122 are provided with the package, primarily to serve as examples. The real goal
123 of EventMachine is to enable programs to easily interface with other programs
124 using TCP/IP, especially if custom protocols are required.
125 EOD
126
1a50af6 @tmm1 Move eventmachine_version to em/version.rb
tmm1 authored
127 require 'lib/em/version'
6d78429 Merge of branches/raggi
raggi authored
128 s.version = EventMachine::VERSION
129 end
130
92eca0a @tmm1 rake win32:gem task to build openssl and a win32 binary gem (requires ms...
tmm1 authored
131 if RUBY_PLATFORM =~ /mswin/
132 Spec.platform = 'x86-mswin32-60'
133 Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
134 Spec.extensions = nil
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
135 elsif RUBY_PLATFORM =~ /java/
136 Spec.platform = 'jruby'
137 Spec.files += %w[ lib/em_reactor.jar ]
138 Spec.extensions = nil
92eca0a @tmm1 rake win32:gem task to build openssl and a win32 binary gem (requires ms...
tmm1 authored
139 end
140
141 # this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
142 namespace :win32 do
143 task :check_git do
144 unless `git` =~ /rebase/
145 raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
146 end
147 end
148
149 task :check_vc6 do
150 begin
151 raise unless `nmake 2>&1` =~ /Microsoft/
152 rescue
153 raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
154 end
155 end
156
157 task :check_perl do
158 unless `perl --version` =~ /ActiveState/
159 raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
160 end
161 end
162
163 task :build_openssl => [:check_git, :check_perl, :check_vc6] do
164 mkdir_p 'build'
165 chdir 'build' do
166 unless File.exists?('openssl-0.9.8j')
167 sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
168 sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
169 end
170
171 mkdir_p 'local'
172 chdir 'openssl-0.9.8j' do
173 sh "perl Configure VC-WIN32 --prefix=\"../local/\""
174 sh 'ms\do_ms.bat'
175 sh 'nmake -f ms\nt.mak install'
176 end
177
178 chdir '../ext' do
179 sh 'git clean -fd .'
180 end
181
182 mv 'local/include/openssl', '../ext/'
183 mv 'local/lib/ssleay32.lib', '../ext/'
184 mv 'local/lib/libeay32.lib', '../ext/'
185 end
186 end
187
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}']
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
197
6d78429 Merge of branches/raggi
raggi authored
198 desc "Build C++ extension"
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
199 task :build => [:make]
6d78429 Merge of branches/raggi
raggi authored
200
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
201 desc "make extensions"
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
202 task :make => ext_sources + ['ext/Makefile'] do
6d78429 Merge of branches/raggi
raggi authored
203 chdir 'ext' do
39b7476 Another make adjustment for win32
raggi authored
204 sh MAKE
6d78429 Merge of branches/raggi
raggi authored
205 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
206 end
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
207 task :make => ffr_sources + ['ext/fastfilereader/Makefile'] do
208 chdir 'ext/fastfilereader' do
209 sh MAKE
210 end
211 end
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
212
6d78429 Merge of branches/raggi
raggi authored
213 desc 'Compile the makefile'
6e5ea50 @raggi Speed up build now that we're doing it ahead of tests
raggi authored
214 file 'ext/Makefile' => ext_sources do
6d78429 Merge of branches/raggi
raggi authored
215 chdir 'ext' do
216 ruby 'extconf.rb'
9d5b7ca migrated version_0 to trunk
blackhedd authored
217 end
218 end
6cb61ed @tmm1 Add rake tasks to build fastfilereader extension
tmm1 authored
219
220 desc 'Compile fastfilereader makefile'
221 file 'ext/fastfilereader/Makefile' => ffr_sources do
222 chdir 'ext/fastfilereader' do
223 ruby 'extconf.rb'
224 end
225 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
226 end
6d78429 Merge of branches/raggi
raggi authored
227
228 namespace :java do
229 # This task creates the JRuby JAR file and leaves it in the lib directory.
230 # This step is required before executing the jgem task.
231 desc "Build java extension"
232 task :build => [:jar] do |t|
233 chdir('java/src') do
234 mv 'em_reactor.jar', '../../lib/em_reactor.jar'
9d5b7ca migrated version_0 to trunk
blackhedd authored
235 end
236 end
6d78429 Merge of branches/raggi
raggi authored
237
238 desc "compile .java to .class"
239 task :compile do
240 chdir('java/src') do
241 sh 'javac com/rubyeventmachine/*.java'
242 end
243 end
244
245 desc "compile .classes to .jar"
246 task :jar => [:compile] do
247 chdir('java/src') do
248 sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class"
249 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
250 end
ff9b3d0 @tmm1 rake java:gem to build a binary jruby gem
tmm1 authored
251
252 task :gem => :build do
253 Rake::Task['gem'].invoke
254 end
9d5b7ca migrated version_0 to trunk
blackhedd authored
255 end
944417f Added gemspec task, and gemspec file for use on github. Reversioned to d...
raggi authored
256
5394f05 @raggi Use clobber before generating gemspec, and ensure clobber runs clean
raggi authored
257 task :gemspec => :clobber do
944417f Added gemspec task, and gemspec file for use on github. Reversioned to d...
raggi authored
258 open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
50845ea corrected misspelling in desc text
francis authored
259 end
5394f05 @raggi Use clobber before generating gemspec, and ensure clobber runs clean
raggi authored
260
402923d @raggi Run build before test
raggi authored
261 task :clobber => :clean
262 task :test => :build
Something went wrong with that request. Please try again.