eventmachine 0.12.10-x86-mswin32-60 → 1.0.0.beta.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +1 -0
  3. data/README +80 -81
  4. data/Rakefile +7 -370
  5. data/docs/COPYING +60 -60
  6. data/docs/ChangeLog +211 -211
  7. data/docs/DEFERRABLES +246 -133
  8. data/docs/EPOLL +141 -141
  9. data/docs/GNU +281 -281
  10. data/docs/INSTALL +13 -13
  11. data/docs/KEYBOARD +42 -38
  12. data/docs/LEGAL +25 -25
  13. data/docs/LIGHTWEIGHT_CONCURRENCY +130 -70
  14. data/docs/PURE_RUBY +75 -75
  15. data/docs/RELEASE_NOTES +94 -94
  16. data/docs/SMTP +4 -2
  17. data/docs/SPAWNED_PROCESSES +148 -89
  18. data/docs/TODO +8 -8
  19. data/eventmachine.gemspec +19 -26
  20. data/examples/ex_channel.rb +42 -42
  21. data/examples/ex_queue.rb +2 -2
  22. data/examples/ex_tick_loop_array.rb +15 -0
  23. data/examples/ex_tick_loop_counter.rb +32 -0
  24. data/examples/helper.rb +1 -1
  25. data/ext/binder.cpp +0 -1
  26. data/ext/cmain.cpp +36 -25
  27. data/ext/ed.cpp +104 -113
  28. data/ext/ed.h +24 -30
  29. data/ext/em.cpp +349 -283
  30. data/ext/em.h +25 -29
  31. data/ext/eventmachine.h +5 -4
  32. data/ext/extconf.rb +58 -49
  33. data/ext/fastfilereader/extconf.rb +5 -3
  34. data/ext/fastfilereader/mapper.cpp +214 -214
  35. data/ext/fastfilereader/mapper.h +59 -59
  36. data/ext/fastfilereader/rubymain.cpp +127 -127
  37. data/ext/kb.cpp +1 -3
  38. data/ext/page.cpp +107 -107
  39. data/ext/page.h +51 -51
  40. data/ext/pipe.cpp +9 -11
  41. data/ext/project.h +12 -8
  42. data/ext/rubymain.cpp +138 -104
  43. data/java/.classpath +8 -8
  44. data/java/.project +17 -17
  45. data/java/src/com/rubyeventmachine/EmReactor.java +1 -0
  46. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -40
  47. data/lib/em/buftok.rb +138 -138
  48. data/lib/em/callback.rb +25 -25
  49. data/lib/em/channel.rb +1 -1
  50. data/lib/em/connection.rb +6 -1
  51. data/lib/em/deferrable.rb +16 -2
  52. data/lib/em/file_watch.rb +53 -53
  53. data/lib/em/future.rb +61 -61
  54. data/lib/em/iterator.rb +270 -0
  55. data/lib/em/messages.rb +66 -66
  56. data/lib/em/process_watch.rb +43 -43
  57. data/lib/em/protocols.rb +1 -1
  58. data/lib/em/protocols/header_and_content.rb +138 -138
  59. data/lib/em/protocols/httpclient.rb +267 -262
  60. data/lib/em/protocols/line_protocol.rb +28 -0
  61. data/lib/em/protocols/memcache.rb +322 -322
  62. data/lib/em/protocols/postgres3.rb +247 -247
  63. data/lib/em/protocols/saslauth.rb +175 -175
  64. data/lib/em/protocols/smtpserver.rb +640 -547
  65. data/lib/em/protocols/stomp.rb +200 -200
  66. data/lib/em/protocols/tcptest.rb +52 -52
  67. data/lib/{pr_eventmachine.rb → em/pure_ruby.rb} +1013 -1022
  68. data/lib/em/queue.rb +1 -0
  69. data/lib/em/spawnable.rb +85 -85
  70. data/lib/em/streamer.rb +130 -130
  71. data/lib/em/tick_loop.rb +85 -0
  72. data/lib/em/timers.rb +2 -1
  73. data/lib/em/version.rb +1 -1
  74. data/lib/eventmachine.rb +40 -84
  75. data/lib/jeventmachine.rb +2 -1
  76. data/lib/rubyeventmachine.rb +2 -0
  77. data/setup.rb +1585 -1585
  78. data/tasks/doc.rake +30 -0
  79. data/tasks/package.rake +85 -0
  80. data/tasks/test.rake +6 -0
  81. data/tests/client.crt +31 -31
  82. data/tests/client.key +51 -51
  83. data/tests/test_attach.rb +13 -3
  84. data/tests/test_basic.rb +60 -95
  85. data/tests/test_channel.rb +3 -2
  86. data/tests/test_defer.rb +49 -47
  87. data/tests/test_deferrable.rb +35 -0
  88. data/tests/test_error_handler.rb +35 -35
  89. data/tests/test_errors.rb +82 -82
  90. data/tests/test_exc.rb +55 -55
  91. data/tests/test_file_watch.rb +49 -49
  92. data/tests/test_futures.rb +198 -198
  93. data/tests/test_handler_check.rb +36 -36
  94. data/tests/test_hc.rb +190 -218
  95. data/tests/test_httpclient.rb +227 -218
  96. data/tests/test_httpclient2.rb +3 -2
  97. data/tests/test_inactivity_timeout.rb +3 -3
  98. data/tests/test_kb.rb +60 -60
  99. data/tests/test_ltp.rb +13 -5
  100. data/tests/test_ltp2.rb +317 -317
  101. data/tests/test_next_tick.rb +1 -1
  102. data/tests/test_object_protocol.rb +36 -36
  103. data/tests/test_pending_connect_timeout.rb +2 -2
  104. data/tests/test_process_watch.rb +50 -48
  105. data/tests/test_proxy_connection.rb +52 -0
  106. data/tests/test_pure.rb +134 -125
  107. data/tests/test_queue.rb +44 -44
  108. data/tests/test_running.rb +42 -42
  109. data/tests/test_sasl.rb +72 -72
  110. data/tests/test_send_file.rb +251 -242
  111. data/tests/test_servers.rb +76 -76
  112. data/tests/test_smtpclient.rb +83 -83
  113. data/tests/test_smtpserver.rb +85 -85
  114. data/tests/test_spawn.rb +322 -322
  115. data/tests/test_ssl_methods.rb +49 -49
  116. data/tests/test_ssl_verify.rb +82 -82
  117. data/tests/test_tick_loop.rb +59 -0
  118. data/tests/test_timers.rb +13 -15
  119. data/tests/test_ud.rb +36 -36
  120. data/tests/testem.rb +31 -31
  121. metadata +66 -51
  122. data/ext/cplusplus.cpp +0 -202
  123. data/ext/emwin.cpp +0 -300
  124. data/ext/emwin.h +0 -94
  125. data/ext/epoll.cpp +0 -26
  126. data/ext/epoll.h +0 -25
  127. data/ext/eventmachine_cpp.h +0 -96
  128. data/ext/files.cpp +0 -94
  129. data/ext/files.h +0 -65
  130. data/ext/sigs.cpp +0 -89
  131. data/ext/sigs.h +0 -32
  132. data/java/src/com/rubyeventmachine/application/Application.java +0 -194
  133. data/java/src/com/rubyeventmachine/application/Connection.java +0 -74
  134. data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
  135. data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
  136. data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
  137. data/java/src/com/rubyeventmachine/application/Timer.java +0 -54
  138. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
  139. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
  140. data/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
  141. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
  142. data/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
  143. data/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
  144. data/lib/evma.rb +0 -32
  145. data/lib/evma/callback.rb +0 -32
  146. data/lib/evma/container.rb +0 -75
  147. data/lib/evma/factory.rb +0 -77
  148. data/lib/evma/protocol.rb +0 -87
  149. data/lib/evma/reactor.rb +0 -48
  150. data/web/whatis +0 -7
data/.gitignore CHANGED
@@ -11,4 +11,6 @@ Makefile
11
11
  *.log
12
12
  *.def
13
13
  *.pdb
14
+ *.dSYM
14
15
  java/src/.project
16
+ *.rbc
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
data/README CHANGED
@@ -1,82 +1,81 @@
1
- = RUBY/EventMachine
2
-
3
- Homepage:: http://rubyeventmachine.com
4
- Rubyforge Page:: http://rubyforge.org/projects/eventmachine
5
- Google Group:: http://groups.google.com/group/eventmachine
6
- Mailing List:: http://rubyforge.org/pipermail/eventmachine-talk
7
- RDoc:: http://eventmachine.rubyforge.org
8
- IRC:: ##eventmachine on irc.freenode.net
9
- Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
10
- Email:: gmail address: garbagecat10
11
-
12
- EventMachine is copyrighted free software made available under the terms
13
- of either the GPL or Ruby's License. See the file COPYING for full licensing
14
- information.
15
- See EventMachine and EventMachine::Connection for documentation and
16
- usage examples.
17
-
18
- EventMachine implements a fast, single-threaded engine for arbitrary network
19
- communications. It's extremely easy to use in Ruby. EventMachine wraps all
20
- interactions with IP sockets, allowing programs to concentrate on the
21
- implementation of network protocols. It can be used to create both network
22
- servers and clients. To create a server or client, a Ruby program only needs
23
- to specify the IP address and port, and provide a Module that implements the
24
- communications protocol. Implementations of several standard network protocols
25
- are provided with the package, primarily to serve as examples. The real goal
26
- of EventMachine is to enable programs to easily interface with other programs
27
- using TCP/IP, especially if custom protocols are required.
28
-
29
- A Ruby program uses EventMachine by registering the addresses and ports of
30
- network servers and clients, and then entering an event-handling loop.
31
- EventMachine contains glue code in Ruby which will execute callbacks to
32
- user-supplied code for all significant events occurring in the clients
33
- and servers. These events include connection acceptance, startup, data-receipt,
34
- shutdown, and timer events. Arbitrary processing can be performed by user code
35
- during event callbacks, including sending data to one or more remote network
36
- peers, startup and shutdown of network connections, and installation of new
37
- event handlers.
38
-
39
- The EventMachine implements a very familiar model for network programming.
40
- It emphasizes: 1) the maximum possible isolation of user code from network
41
- objects like sockets; 2) maximum performance and scalability; and 3) extreme
42
- ease-of-use for user code. It attempts to provide a higher-level interface
43
- than similar projects which expose a variety of low-level event-handling
44
- and networking objects to Ruby programs.
45
-
46
- The design and implementation of EventMachine grows out of nearly ten years
47
- of experience writing high-performance, high-scaling network server applications.
48
- We have taken particular account of the challenges and lessons described as
49
- the "C10K problem" by Dan Kegel and others.
50
-
51
- EventMachine consists of an extension library written in C++ (which can be
52
- accessed from languages other than Ruby), and a Ruby module which can be dropped
53
- into user programs. On most platforms, EventMachine uses the
54
- <tt>select(2)</tt> system call,
55
- so it will run on a large range of Unix-like systems and on Microsoft
56
- Windows with good performance and scalability. On Linux 2.6 kernels, EventMachine
57
- automatically configures itself to use <tt>epoll(4)</tt> instead of
58
- <tt>select(2),</tt> so scalability on that platform can be significantly
59
- improved.
60
-
61
- Here's a fully-functional echo server written with EventMachine:
62
-
63
- require 'eventmachine'
64
-
65
- module EchoServer
66
- def post_init
67
- puts "-- someone connected to the echo server!"
68
- end
69
-
70
- def receive_data data
71
- send_data ">>>you sent: #{data}"
72
- close_connection if data =~ /quit/i
73
- end
74
-
75
- def unbind
76
- puts "-- someone disconnected from the echo server!"
77
- end
78
- end
79
-
80
- EventMachine::run {
81
- EventMachine::start_server "127.0.0.1", 8081, EchoServer
1
+ = RUBY/EventMachine
2
+
3
+ Homepage:: http://rubyeventmachine.com
4
+ Rubyforge Page:: http://rubyforge.org/projects/eventmachine
5
+ Google Group:: http://groups.google.com/group/eventmachine
6
+ RDoc:: http://eventmachine.rubyforge.org
7
+ IRC:: #eventmachine on irc.freenode.net
8
+ Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Email:: gmail address: garbagecat10
10
+
11
+ EventMachine is copyrighted free software made available under the terms
12
+ of either the GPL or Ruby's License. See the file COPYING for full licensing
13
+ information.
14
+ See EventMachine and EventMachine::Connection for documentation and
15
+ usage examples.
16
+
17
+ EventMachine implements a fast, single-threaded engine for arbitrary network
18
+ communications. It's extremely easy to use in Ruby. EventMachine wraps all
19
+ interactions with IP sockets, allowing programs to concentrate on the
20
+ implementation of network protocols. It can be used to create both network
21
+ servers and clients. To create a server or client, a Ruby program only needs
22
+ to specify the IP address and port, and provide a Module that implements the
23
+ communications protocol. Implementations of several standard network protocols
24
+ are provided with the package, primarily to serve as examples. The real goal
25
+ of EventMachine is to enable programs to easily interface with other programs
26
+ using TCP/IP, especially if custom protocols are required.
27
+
28
+ A Ruby program uses EventMachine by registering the addresses and ports of
29
+ network servers and clients, and then entering an event-handling loop.
30
+ EventMachine contains glue code in Ruby which will execute callbacks to
31
+ user-supplied code for all significant events occurring in the clients
32
+ and servers. These events include connection acceptance, startup, data-receipt,
33
+ shutdown, and timer events. Arbitrary processing can be performed by user code
34
+ during event callbacks, including sending data to one or more remote network
35
+ peers, startup and shutdown of network connections, and installation of new
36
+ event handlers.
37
+
38
+ The EventMachine implements a very familiar model for network programming.
39
+ It emphasizes: 1) the maximum possible isolation of user code from network
40
+ objects like sockets; 2) maximum performance and scalability; and 3) extreme
41
+ ease-of-use for user code. It attempts to provide a higher-level interface
42
+ than similar projects which expose a variety of low-level event-handling
43
+ and networking objects to Ruby programs.
44
+
45
+ The design and implementation of EventMachine grows out of nearly ten years
46
+ of experience writing high-performance, high-scaling network server applications.
47
+ We have taken particular account of the challenges and lessons described as
48
+ the "C10K problem" by Dan Kegel and others.
49
+
50
+ EventMachine consists of an extension library written in C++ (which can be
51
+ accessed from languages other than Ruby), and a Ruby module which can be dropped
52
+ into user programs. On most platforms, EventMachine uses the
53
+ <tt>select(2)</tt> system call,
54
+ so it will run on a large range of Unix-like systems and on Microsoft
55
+ Windows with good performance and scalability. On Linux 2.6 kernels, EventMachine
56
+ automatically configures itself to use <tt>epoll(4)</tt> instead of
57
+ <tt>select(2),</tt> so scalability on that platform can be significantly
58
+ improved.
59
+
60
+ Here's a fully-functional echo server written with EventMachine:
61
+
62
+ require 'eventmachine'
63
+
64
+ module EchoServer
65
+ def post_init
66
+ puts "-- someone connected to the echo server!"
67
+ end
68
+
69
+ def receive_data data
70
+ send_data ">>>you sent: #{data}"
71
+ close_connection if data =~ /quit/i
72
+ end
73
+
74
+ def unbind
75
+ puts "-- someone disconnected from the echo server!"
76
+ end
77
+ end
78
+
79
+ EventMachine::run {
80
+ EventMachine::start_server "127.0.0.1", 8081, EchoServer
82
81
  }
data/Rakefile CHANGED
@@ -1,374 +1,11 @@
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
- #++
1
+ require 'rubygems' unless defined?(Gem)
2
+ require 'rake' unless defined?(Rake)
3
+ import *Dir['tasks/*.rake']
14
4
 
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
5
+ GEMSPEC = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
298
6
 
299
7
  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
8
  task :clobber => :clean
374
- task :test => :build
9
+
10
+ desc "Build eventmachine, then run tests."
11
+ task :default => [:compile, :test]