eventmachine 0.12.8-x86-mswin32-60 → 0.12.10-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +14 -13
  2. data/Rakefile +374 -264
  3. data/eventmachine.gemspec +4 -5
  4. data/ext/binder.cpp +125 -126
  5. data/ext/binder.h +46 -48
  6. data/ext/cmain.cpp +184 -42
  7. data/ext/cplusplus.cpp +202 -202
  8. data/ext/ed.cpp +242 -81
  9. data/ext/ed.h +39 -22
  10. data/ext/em.cpp +127 -108
  11. data/ext/em.h +27 -18
  12. data/ext/emwin.cpp +3 -3
  13. data/ext/eventmachine.h +49 -38
  14. data/ext/eventmachine_cpp.h +96 -96
  15. data/ext/extconf.rb +147 -132
  16. data/ext/fastfilereader/extconf.rb +82 -76
  17. data/ext/project.h +151 -140
  18. data/ext/rubymain.cpp +222 -103
  19. data/ext/ssl.cpp +460 -460
  20. data/ext/ssl.h +94 -94
  21. data/java/src/com/rubyeventmachine/EmReactor.java +570 -423
  22. data/java/src/com/rubyeventmachine/EventableChannel.java +69 -57
  23. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -171
  24. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -244
  25. data/java/src/com/rubyeventmachine/{Application.java → application/Application.java} +194 -200
  26. data/java/src/com/rubyeventmachine/{Connection.java → application/Connection.java} +74 -74
  27. data/java/src/com/rubyeventmachine/{ConnectionFactory.java → application/ConnectionFactory.java} +36 -36
  28. data/java/src/com/rubyeventmachine/{DefaultConnectionFactory.java → application/DefaultConnectionFactory.java} +46 -46
  29. data/java/src/com/rubyeventmachine/{PeriodicTimer.java → application/PeriodicTimer.java} +38 -38
  30. data/java/src/com/rubyeventmachine/{Timer.java → application/Timer.java} +54 -54
  31. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -108
  32. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -146
  33. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -53
  34. data/java/src/com/rubyeventmachine/tests/TestServers.java +75 -74
  35. data/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -89
  36. data/lib/em/connection.rb +71 -12
  37. data/lib/em/deferrable.rb +191 -186
  38. data/lib/em/protocols.rb +36 -35
  39. data/lib/em/protocols/httpclient2.rb +590 -582
  40. data/lib/em/protocols/line_and_text.rb +125 -126
  41. data/lib/em/protocols/linetext2.rb +161 -160
  42. data/lib/em/protocols/object_protocol.rb +45 -39
  43. data/lib/em/protocols/smtpclient.rb +357 -331
  44. data/lib/em/protocols/socks4.rb +66 -0
  45. data/lib/em/queue.rb +60 -60
  46. data/lib/em/timers.rb +56 -55
  47. data/lib/em/version.rb +1 -1
  48. data/lib/eventmachine.rb +125 -169
  49. data/lib/jeventmachine.rb +257 -142
  50. data/tasks/{cpp.rake → cpp.rake_example} +76 -76
  51. data/tests/test_attach.rb +125 -100
  52. data/tests/test_basic.rb +1 -2
  53. data/tests/test_connection_count.rb +34 -44
  54. data/tests/test_epoll.rb +0 -2
  55. data/tests/test_get_sock_opt.rb +30 -0
  56. data/tests/test_httpclient2.rb +3 -3
  57. data/tests/test_inactivity_timeout.rb +21 -1
  58. data/tests/test_ltp.rb +182 -188
  59. data/tests/test_next_tick.rb +0 -2
  60. data/tests/test_pause.rb +70 -0
  61. data/tests/test_pending_connect_timeout.rb +48 -0
  62. data/tests/test_ssl_args.rb +78 -67
  63. data/tests/test_timers.rb +162 -141
  64. metadata +13 -11
  65. data/tasks/project.rake +0 -79
  66. data/tasks/tests.rake +0 -193
data/.gitignore CHANGED
@@ -1,13 +1,14 @@
1
- pkg
2
- rdoc
3
- Makefile
4
-
5
- *.bundle
6
- *.dll
7
- *.so
8
- *.jar
9
- *.class
10
- *.o
11
- *.log
12
- *.def
13
- *.pdb
1
+ pkg
2
+ rdoc
3
+ Makefile
4
+
5
+ *.bundle
6
+ *.dll
7
+ *.so
8
+ *.jar
9
+ *.class
10
+ *.o
11
+ *.log
12
+ *.def
13
+ *.pdb
14
+ java/src/.project
data/Rakefile CHANGED
@@ -1,264 +1,374 @@
1
- #!/usr/bin/env rake
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
-
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
- #
29
-
30
- require 'rubygems' unless defined?(Gem)
31
- require 'rake' unless defined?(Rake)
32
- require 'rake/gempackagetask'
33
-
34
- Package = false # Build zips and tarballs?
35
- Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
36
-
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'
40
-
41
- MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
42
- 'nmake'
43
- else
44
- 'make'
45
- end
46
-
47
- # If running under rubygems...
48
- __DIR__ ||= File.expand_path(File.dirname(__FILE__))
49
- if Gem.path.map{|path| Dir.chdir(path){ Dir.pwd } rescue path }.any? {|path| %r(^#{Regexp.escape path}) =~ __DIR__}
50
- task :default => :gem_build
51
- else
52
- desc "Build gemspec, then build eventmachine, then run tests."
53
- task :default => [:build, :test]
54
- end
55
-
56
- desc ":default build when running under rubygems."
57
- task :gem_build => :build
58
-
59
- desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
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|
64
- Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
65
- mv f, "lib"
66
- end
67
- end
68
-
69
- task :dummy_build
70
-
71
- # Basic clean definition, this is enhanced by imports aswell.
72
- task :clean do
73
- chdir 'ext' do
74
- sh "#{MAKE} clean" if test ?e, 'Makefile'
75
- end
76
- chdir 'ext/fastfilereader' do
77
- sh "#{MAKE} clean" if test ?e, 'Makefile'
78
- end
79
- Dir.glob('**/Makefile').each { |file| rm file }
80
- Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
81
- Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
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
90
- 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)
91
- s.extra_rdoc_files = Dir['README,docs/*']
92
-
93
- s.files = `git ls-files`.split("\n")
94
-
95
- s.require_path = 'lib'
96
-
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"
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"]
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
-
127
- require 'lib/em/version'
128
- s.version = EventMachine::VERSION
129
- end
130
-
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
135
- elsif RUBY_PLATFORM =~ /java/
136
- Spec.platform = 'java'
137
- Spec.files += %w[ lib/em_reactor.jar ]
138
- Spec.extensions = nil
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
- desc "build binary win32 gem"
189
- task :gem => :build_openssl do
190
- Rake::Task['build'].invoke
191
- Rake::Task['gem'].invoke
192
- end
193
- end
194
-
195
- namespace :ext do
196
- ext_sources = FileList['ext/*.{h,cpp,rb,c}']
197
- ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
198
-
199
- desc "Build C++ extension"
200
- task :build => [:make]
201
-
202
- desc "make extensions"
203
- task :make => ext_sources + ['ext/Makefile'] do
204
- chdir 'ext' do
205
- sh MAKE
206
- end
207
- end
208
- task :make => ffr_sources + ['ext/fastfilereader/Makefile'] do
209
- chdir 'ext/fastfilereader' do
210
- sh MAKE
211
- end
212
- end
213
-
214
- desc 'Compile the makefile'
215
- file 'ext/Makefile' => ext_sources do
216
- chdir 'ext' do
217
- ruby 'extconf.rb'
218
- end
219
- end
220
-
221
- desc 'Compile fastfilereader makefile'
222
- file 'ext/fastfilereader/Makefile' => ffr_sources do
223
- chdir 'ext/fastfilereader' do
224
- ruby 'extconf.rb'
225
- end
226
- end
227
- end
228
-
229
- namespace :java do
230
- # This task creates the JRuby JAR file and leaves it in the lib directory.
231
- # This step is required before executing the jgem task.
232
- desc "Build java extension"
233
- task :build => [:jar] do |t|
234
- chdir('java/src') do
235
- mv 'em_reactor.jar', '../../lib/em_reactor.jar'
236
- end
237
- end
238
-
239
- desc "compile .java to .class"
240
- task :compile do
241
- chdir('java/src') do
242
- sh 'javac com/rubyeventmachine/*.java'
243
- end
244
- end
245
-
246
- desc "compile .classes to .jar"
247
- task :jar => [:compile] do
248
- chdir('java/src') do
249
- sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class"
250
- end
251
- end
252
-
253
- desc "build a java binary gem"
254
- task :gem => :build do
255
- Rake::Task['gem'].invoke
256
- end
257
- end
258
-
259
- task :gemspec => :clobber do
260
- open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
261
- end
262
-
263
- task :clobber => :clean
264
- task :test => :build
1
+ #!/usr/bin/env rake
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
+
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
+ #
29
+
30
+ require 'rubygems' unless defined?(Gem)
31
+ require 'rake' unless defined?(Rake)
32
+
33
+ Package = false # Build zips and tarballs?
34
+ Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
35
+
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'
39
+
40
+ MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
41
+ 'nmake'
42
+ else
43
+ 'make'
44
+ end
45
+
46
+ desc "Build gemspec, then build eventmachine, then run tests."
47
+ task :default => [:build, :test]
48
+
49
+ desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
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|
54
+ Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
55
+ mv f, "lib"
56
+ end
57
+ end
58
+
59
+ task :dummy_build
60
+
61
+ require 'rake/testtask'
62
+ Rake::TestTask.new(:test) do |t|
63
+ t.pattern = 'tests/**/test_*.rb'
64
+ t.warning = true
65
+ end
66
+
67
+ # Basic clean definition, this is enhanced by imports aswell.
68
+ task :clean do
69
+ chdir 'ext' do
70
+ sh "#{MAKE} clean" if test ?e, 'Makefile'
71
+ end
72
+ chdir 'ext/fastfilereader' do
73
+ sh "#{MAKE} clean" if test ?e, 'Makefile'
74
+ end
75
+ Dir.glob('**/Makefile').each { |file| rm file }
76
+ Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
77
+ Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
78
+ end
79
+
80
+ Spec = Gem::Specification.new do |s|
81
+ s.name = "eventmachine"
82
+ s.summary = "Ruby/EventMachine library"
83
+ s.platform = Gem::Platform::RUBY
84
+
85
+ s.has_rdoc = true
86
+ 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)
87
+ s.extra_rdoc_files = Dir['README,docs/*']
88
+
89
+ s.files = `git ls-files`.split("\n")
90
+
91
+ s.require_path = 'lib'
92
+
93
+ # TODO / XXX - should we enable this? rubygems fails the install if anything
94
+ # is broken. What we could do is CI submission, though, and always terminate
95
+ # with a positive code...
96
+ # s.test_file = "tests/testem.rb"
97
+
98
+ # XXX Using rake to compile extensions breaks when you have multiple ruby installations
99
+ # and your path isn't set. We can switch back to this once the Gem.exec patch is merged.
100
+ # s.extensions = "Rakefile"
101
+ s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
102
+
103
+ s.author = "Francis Cianfrocca"
104
+ s.email = "garbagecat10@gmail.com"
105
+ s.rubyforge_project = 'eventmachine'
106
+ s.homepage = "http://rubyeventmachine.com"
107
+
108
+ # Pulled in from readme, as code to pull from readme was not working!
109
+ # Might be worth removing as no one seems to use gem info anyway.
110
+ s.description = <<-EOD
111
+ EventMachine implements a fast, single-threaded engine for arbitrary network
112
+ communications. It's extremely easy to use in Ruby. EventMachine wraps all
113
+ interactions with IP sockets, allowing programs to concentrate on the
114
+ implementation of network protocols. It can be used to create both network
115
+ servers and clients. To create a server or client, a Ruby program only needs
116
+ to specify the IP address and port, and provide a Module that implements the
117
+ communications protocol. Implementations of several standard network protocols
118
+ are provided with the package, primarily to serve as examples. The real goal
119
+ of EventMachine is to enable programs to easily interface with other programs
120
+ using TCP/IP, especially if custom protocols are required.
121
+ EOD
122
+
123
+ require 'lib/em/version'
124
+ s.version = EventMachine::VERSION
125
+ end
126
+
127
+ if RUBY_PLATFORM =~ /mswin/
128
+ Spec.platform = 'x86-mswin32-60'
129
+ Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
130
+ Spec.extensions = nil
131
+ elsif RUBY_PLATFORM =~ /java/
132
+ Spec.platform = 'java'
133
+ Spec.files += %w[ lib/em_reactor.jar ]
134
+ Spec.extensions = nil
135
+ end
136
+
137
+ # this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
138
+ namespace :win32 do
139
+ task :check_git do
140
+ unless `git` =~ /rebase/
141
+ raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
142
+ end
143
+ end
144
+
145
+ task :check_vc6 do
146
+ begin
147
+ raise unless `nmake 2>&1` =~ /Microsoft/
148
+ rescue
149
+ raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
150
+ end
151
+ end
152
+
153
+ task :check_perl do
154
+ unless `perl --version` =~ /ActiveState/
155
+ raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
156
+ end
157
+ end
158
+
159
+ task :build_openssl => [:check_git, :check_perl, :check_vc6] do
160
+ mkdir_p 'build'
161
+ chdir 'build' do
162
+ unless File.exists?('openssl-0.9.8j')
163
+ sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
164
+ sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
165
+ end
166
+
167
+ mkdir_p 'local'
168
+ chdir 'openssl-0.9.8j' do
169
+ sh "perl Configure VC-WIN32 --prefix=\"../local/\""
170
+ sh 'ms\do_ms.bat'
171
+ sh 'nmake -f ms\nt.mak install'
172
+ end
173
+
174
+ chdir '../ext' do
175
+ sh 'git clean -fd .'
176
+ end
177
+
178
+ mv 'local/include/openssl', '../ext/'
179
+ mv 'local/lib/ssleay32.lib', '../ext/'
180
+ mv 'local/lib/libeay32.lib', '../ext/'
181
+ end
182
+ end
183
+
184
+ desc "build binary win32 gem"
185
+ task :gem => :build_openssl do
186
+ Rake::Task['build'].invoke
187
+ Rake::Task['gem'].invoke
188
+ end
189
+ end
190
+
191
+ namespace :ext do
192
+ ext_sources = FileList['ext/*.{h,cpp,rb,c}']
193
+ ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
194
+ file ext_extconf = 'ext/extconf.rb'
195
+ file ffr_extconf = 'ext/fastfilereader/extconf.rb'
196
+ ext_libname = "lib/rubyeventmachine.#{Config::CONFIG['DLEXT']}"
197
+ ffr_libname = "lib/fastfilereaderext.#{Config::CONFIG['DLEXT']}"
198
+
199
+ file ext_libname => ext_sources + ['ext/Makefile'] do
200
+ chdir('ext') { sh MAKE }
201
+ end
202
+
203
+ file ffr_libname => ffr_sources + ['ext/fastfilereader/Makefile'] do
204
+ chdir('ext/fastfilereader') { sh MAKE }
205
+ end
206
+
207
+ desc "Build C++ extension"
208
+ task :build => [:make]
209
+
210
+ task :make => ext_libname
211
+ task :make => ffr_libname
212
+
213
+ file 'ext/Makefile' => ext_extconf do
214
+ chdir 'ext' do
215
+ ruby 'extconf.rb'
216
+ end
217
+ end
218
+
219
+ file 'ext/fastfilereader/Makefile' => ffr_extconf do
220
+ chdir 'ext/fastfilereader' do
221
+ ruby 'extconf.rb'
222
+ end
223
+ end
224
+ end
225
+
226
+ namespace :java do
227
+ # This task creates the JRuby JAR file and leaves it in the lib directory.
228
+ # This step is required before executing the jgem task.
229
+ desc "Build java extension"
230
+ task :build => [:jar] do |t|
231
+ mv 'java/em_reactor.jar', 'lib/'
232
+ end
233
+
234
+ task :compile do
235
+ chdir('java') do
236
+ mkdir_p "build"
237
+ sh 'javac src/com/rubyeventmachine/*.java -d build'
238
+ end
239
+ end
240
+
241
+ task :jar => [:compile] do
242
+ chdir('java/build') do
243
+ sh "jar -cf ../em_reactor.jar com/rubyeventmachine/*.class"
244
+ end
245
+ end
246
+
247
+ desc "build a java binary gem"
248
+ task :gem => :build do
249
+ Spec.platform = 'java'
250
+ Spec.files += %w[ lib/em_reactor.jar ]
251
+ Spec.extensions = nil
252
+
253
+ Rake::Task['gem'].invoke
254
+ end
255
+ end
256
+
257
+ namespace :osx do
258
+ desc "Build OSX binary gem"
259
+ task :gem do
260
+ Spec.platform = RUBY_PLATFORM.sub(/darwin.+$/, 'darwin')
261
+ Spec.files += %w[ lib/rubyeventmachine.bundle lib/fastfilereaderext.bundle ]
262
+ Spec.extensions = nil
263
+
264
+ Rake::Task['build'].invoke
265
+ Rake::Task['gem'].invoke
266
+ end
267
+
268
+ # XXX gcc will still prefer the shared libssl on the system, so we need to hack the extconf
269
+ # XXX to use the static library to make this actually work
270
+ task :static_gem => [:build_openssl, :gem]
271
+
272
+ task :build_openssl do
273
+ mkdir_p 'build'
274
+ chdir 'build' do
275
+ unless File.exists?('openssl-0.9.8j')
276
+ sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl-0.9.8j.tar.gz'
277
+ sh 'tar zxvf openssl-0.9.8j.tar.gz'
278
+ end
279
+
280
+ mkdir_p 'local'
281
+ chdir 'openssl-0.9.8j' do
282
+ local_dir = File.expand_path(File.join(File.dirname(__FILE__),'build','local'))
283
+ sh "./config --prefix=#{local_dir}"
284
+ sh 'make'
285
+ sh 'make install'
286
+ end
287
+
288
+ chdir '../ext' do
289
+ sh 'git clean -fd .'
290
+ end
291
+
292
+ mv 'local/include/openssl', '../ext/'
293
+ mv 'local/lib/libssl.a', '../ext/'
294
+ mv 'local/lib/libcrypto.a', '../ext/'
295
+ end
296
+ end
297
+ end
298
+
299
+ require 'rake/clean'
300
+
301
+ rdoc_task_type = begin
302
+ require 'rdoc/task'
303
+ RDoc::Task
304
+ rescue LoadError
305
+ require 'rake/rdoctask'
306
+ Rake::RDocTask
307
+ end
308
+ df = begin; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
309
+ rdtask = rdoc_task_type.new do |rd|
310
+ rd.title = Spec.name
311
+ rd.rdoc_dir = 'rdoc'
312
+ rd.main = "README"
313
+ rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
314
+ rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
315
+ rd.template = 'darkfish' if df
316
+ end
317
+ Rake::Task[:clean].enhance [:clobber_rdoc]
318
+
319
+ desc 'Generate and open documentation'
320
+ task :docs => :rdoc do
321
+ case RUBY_PLATFORM
322
+ when /darwin/ ; sh 'open rdoc/index.html'
323
+ when /mswin|mingw/ ; sh 'start rdoc\index.html'
324
+ else
325
+ sh 'firefox rdoc/index.html'
326
+ end
327
+ end
328
+
329
+ def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
330
+ def sudo(cmd)
331
+ if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
332
+ sh cmd
333
+ else
334
+ sh "sudo #{cmd}"
335
+ end
336
+ end
337
+ def gem_cmd(action, name, *args)
338
+ rb = Gem.ruby rescue nil
339
+ rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
340
+ sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
341
+ end
342
+
343
+ begin
344
+ require 'rubygems/package_task'
345
+ Gem::PackageTask
346
+ rescue LoadError
347
+ require 'rake/gempackagetask'
348
+ Rake::GemPackageTask
349
+ end.new(Spec) do |pkg|
350
+ pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
351
+ pkg.gem_spec = Spec
352
+ end
353
+
354
+ Rake::Task[:clean].enhance [:clobber_package]
355
+
356
+ namespace :gem do
357
+ desc 'Install gem (and sudo if required)'
358
+ task :install => :package do
359
+ gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
360
+ end
361
+
362
+ desc 'Uninstall gem (and sudo if required)'
363
+ task :uninstall do
364
+ gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
365
+ end
366
+
367
+ desc "Generate new gemspec"
368
+ task :spec => :clobber do
369
+ open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
370
+ end
371
+ end
372
+
373
+ task :clobber => :clean
374
+ task :test => :build