eventmachine 1.2.0.dev.2-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +105 -0
- data/GNU +281 -0
- data/LICENSE +60 -0
- data/README.md +108 -0
- data/docs/DocumentationGuidesIndex.md +27 -0
- data/docs/GettingStarted.md +521 -0
- data/docs/old/ChangeLog +211 -0
- data/docs/old/DEFERRABLES +246 -0
- data/docs/old/EPOLL +141 -0
- data/docs/old/INSTALL +13 -0
- data/docs/old/KEYBOARD +42 -0
- data/docs/old/LEGAL +25 -0
- data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
- data/docs/old/PURE_RUBY +75 -0
- data/docs/old/RELEASE_NOTES +94 -0
- data/docs/old/SMTP +4 -0
- data/docs/old/SPAWNED_PROCESSES +148 -0
- data/docs/old/TODO +8 -0
- data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
- data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
- data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
- data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
- data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
- data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
- data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
- data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
- data/examples/old/ex_channel.rb +43 -0
- data/examples/old/ex_queue.rb +2 -0
- data/examples/old/ex_tick_loop_array.rb +15 -0
- data/examples/old/ex_tick_loop_counter.rb +32 -0
- data/examples/old/helper.rb +2 -0
- data/ext/binder.cpp +124 -0
- data/ext/binder.h +46 -0
- data/ext/cmain.cpp +988 -0
- data/ext/ed.cpp +2111 -0
- data/ext/ed.h +442 -0
- data/ext/em.cpp +2379 -0
- data/ext/em.h +308 -0
- data/ext/eventmachine.h +143 -0
- data/ext/extconf.rb +270 -0
- data/ext/fastfilereader/extconf.rb +110 -0
- data/ext/fastfilereader/mapper.cpp +216 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +354 -0
- data/ext/project.h +176 -0
- data/ext/rubymain.cpp +1504 -0
- data/ext/ssl.cpp +615 -0
- data/ext/ssl.h +103 -0
- data/java/.classpath +8 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +591 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +72 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +201 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +415 -0
- data/lib/2.0/fastfilereaderext.so +0 -0
- data/lib/2.0/rubyeventmachine.so +0 -0
- data/lib/2.1/fastfilereaderext.so +0 -0
- data/lib/2.1/rubyeventmachine.so +0 -0
- data/lib/2.2/fastfilereaderext.so +0 -0
- data/lib/2.2/rubyeventmachine.so +0 -0
- data/lib/2.3/fastfilereaderext.so +0 -0
- data/lib/2.3/rubyeventmachine.so +0 -0
- data/lib/em/buftok.rb +59 -0
- data/lib/em/callback.rb +58 -0
- data/lib/em/channel.rb +69 -0
- data/lib/em/completion.rb +304 -0
- data/lib/em/connection.rb +770 -0
- data/lib/em/deferrable.rb +210 -0
- data/lib/em/deferrable/pool.rb +2 -0
- data/lib/em/file_watch.rb +73 -0
- data/lib/em/future.rb +61 -0
- data/lib/em/iterator.rb +252 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/pool.rb +151 -0
- data/lib/em/process_watch.rb +45 -0
- data/lib/em/processes.rb +123 -0
- data/lib/em/protocols.rb +37 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +299 -0
- data/lib/em/protocols/httpclient2.rb +600 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +29 -0
- data/lib/em/protocols/linetext2.rb +166 -0
- data/lib/em/protocols/memcache.rb +331 -0
- data/lib/em/protocols/object_protocol.rb +46 -0
- data/lib/em/protocols/postgres3.rb +246 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +394 -0
- data/lib/em/protocols/smtpserver.rb +666 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +205 -0
- data/lib/em/protocols/tcptest.rb +54 -0
- data/lib/em/pure_ruby.rb +1022 -0
- data/lib/em/queue.rb +80 -0
- data/lib/em/resolver.rb +232 -0
- data/lib/em/spawnable.rb +84 -0
- data/lib/em/streamer.rb +118 -0
- data/lib/em/threaded_resource.rb +90 -0
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +61 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1584 -0
- data/lib/fastfilereaderext.rb +2 -0
- data/lib/jeventmachine.rb +301 -0
- data/lib/rubyeventmachine.rb +2 -0
- data/rakelib/package.rake +120 -0
- data/rakelib/test.rake +8 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/dhparam.pem +13 -0
- data/tests/em_test_helper.rb +151 -0
- data/tests/test_attach.rb +151 -0
- data/tests/test_basic.rb +283 -0
- data/tests/test_channel.rb +75 -0
- data/tests/test_completion.rb +178 -0
- data/tests/test_connection_count.rb +54 -0
- data/tests/test_connection_write.rb +35 -0
- data/tests/test_defer.rb +35 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +142 -0
- data/tests/test_error_handler.rb +38 -0
- data/tests/test_exc.rb +28 -0
- data/tests/test_file_watch.rb +66 -0
- data/tests/test_fork.rb +75 -0
- data/tests/test_futures.rb +170 -0
- data/tests/test_get_sock_opt.rb +37 -0
- data/tests/test_handler_check.rb +35 -0
- data/tests/test_hc.rb +155 -0
- data/tests/test_httpclient.rb +233 -0
- data/tests/test_httpclient2.rb +128 -0
- data/tests/test_idle_connection.rb +25 -0
- data/tests/test_inactivity_timeout.rb +54 -0
- data/tests/test_ipv4.rb +125 -0
- data/tests/test_ipv6.rb +131 -0
- data/tests/test_iterator.rb +115 -0
- data/tests/test_kb.rb +28 -0
- data/tests/test_line_protocol.rb +33 -0
- data/tests/test_ltp.rb +138 -0
- data/tests/test_ltp2.rb +308 -0
- data/tests/test_many_fds.rb +22 -0
- data/tests/test_next_tick.rb +104 -0
- data/tests/test_object_protocol.rb +36 -0
- data/tests/test_pause.rb +107 -0
- data/tests/test_pending_connect_timeout.rb +52 -0
- data/tests/test_pool.rb +196 -0
- data/tests/test_process_watch.rb +50 -0
- data/tests/test_processes.rb +128 -0
- data/tests/test_proxy_connection.rb +180 -0
- data/tests/test_pure.rb +88 -0
- data/tests/test_queue.rb +64 -0
- data/tests/test_resolver.rb +104 -0
- data/tests/test_running.rb +14 -0
- data/tests/test_sasl.rb +47 -0
- data/tests/test_send_file.rb +217 -0
- data/tests/test_servers.rb +33 -0
- data/tests/test_set_sock_opt.rb +39 -0
- data/tests/test_shutdown_hooks.rb +23 -0
- data/tests/test_smtpclient.rb +75 -0
- data/tests/test_smtpserver.rb +57 -0
- data/tests/test_spawn.rb +293 -0
- data/tests/test_ssl_args.rb +78 -0
- data/tests/test_ssl_dhparam.rb +83 -0
- data/tests/test_ssl_ecdh_curve.rb +79 -0
- data/tests/test_ssl_extensions.rb +49 -0
- data/tests/test_ssl_methods.rb +65 -0
- data/tests/test_ssl_protocols.rb +246 -0
- data/tests/test_ssl_verify.rb +126 -0
- data/tests/test_stomp.rb +37 -0
- data/tests/test_system.rb +46 -0
- data/tests/test_threaded_resource.rb +61 -0
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +123 -0
- data/tests/test_ud.rb +8 -0
- data/tests/test_unbind_reason.rb +52 -0
- metadata +381 -0
@@ -0,0 +1,301 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
+
# Homepage:: http://rubyeventmachine.com
|
5
|
+
# Date:: 8 Apr 2006
|
6
|
+
#
|
7
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
+
# usage examples.
|
9
|
+
#
|
10
|
+
#----------------------------------------------------------------------------
|
11
|
+
#
|
12
|
+
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
+
# Gmail: blackhedd
|
14
|
+
#
|
15
|
+
# This program is free software; you can redistribute it and/or modify
|
16
|
+
# it under the terms of either: 1) the GNU General Public License
|
17
|
+
# as published by the Free Software Foundation; either version 2 of the
|
18
|
+
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
+
#
|
20
|
+
# See the file COPYING for complete licensing information.
|
21
|
+
#
|
22
|
+
#---------------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
# This module provides "glue" for the Java version of the EventMachine reactor core.
|
27
|
+
# For C++ EventMachines, the analogous functionality is found in ext/rubymain.cpp,
|
28
|
+
# which is a garden-variety Ruby-extension glue module.
|
29
|
+
|
30
|
+
require 'java'
|
31
|
+
require 'rubyeventmachine'
|
32
|
+
require 'socket'
|
33
|
+
|
34
|
+
java_import java.io.FileDescriptor
|
35
|
+
java_import java.nio.channels.SocketChannel
|
36
|
+
java_import java.lang.reflect.Field
|
37
|
+
|
38
|
+
module JavaFields
|
39
|
+
def set_field(key, value)
|
40
|
+
field = getClass.getDeclaredField(key)
|
41
|
+
field.setAccessible(true)
|
42
|
+
if field.getType.toString == 'int'
|
43
|
+
field.setInt(self, value)
|
44
|
+
else
|
45
|
+
field.set(self, value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_field(key)
|
50
|
+
field = getClass.getDeclaredField(key)
|
51
|
+
field.setAccessible(true)
|
52
|
+
field.get(self)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
FileDescriptor.send :include, JavaFields
|
57
|
+
SocketChannel.send :include, JavaFields
|
58
|
+
|
59
|
+
module EventMachine
|
60
|
+
# TODO: These event numbers are defined in way too many places.
|
61
|
+
# DRY them up.
|
62
|
+
# @private
|
63
|
+
TimerFired = 100
|
64
|
+
# @private
|
65
|
+
ConnectionData = 101
|
66
|
+
# @private
|
67
|
+
ConnectionUnbound = 102
|
68
|
+
# @private
|
69
|
+
ConnectionAccepted = 103
|
70
|
+
# @private
|
71
|
+
ConnectionCompleted = 104
|
72
|
+
# @private
|
73
|
+
LoopbreakSignalled = 105
|
74
|
+
# @private
|
75
|
+
ConnectionNotifyReadable = 106
|
76
|
+
# @private
|
77
|
+
ConnectionNotifyWritable = 107
|
78
|
+
# @private
|
79
|
+
SslHandshakeCompleted = 108
|
80
|
+
|
81
|
+
# Exceptions that are defined in rubymain.cpp
|
82
|
+
class ConnectionError < RuntimeError; end
|
83
|
+
class ConnectionNotBound < RuntimeError; end
|
84
|
+
class UnknownTimerFired < RuntimeError; end
|
85
|
+
class Unsupported < RuntimeError; end
|
86
|
+
|
87
|
+
# This thunk class used to be called EM, but that caused conflicts with
|
88
|
+
# the alias "EM" for module EventMachine. (FC, 20Jun08)
|
89
|
+
class JEM < com.rubyeventmachine.EmReactor
|
90
|
+
def eventCallback a1, a2, a3, a4
|
91
|
+
s = String.from_java_bytes(a3.array[a3.position...a3.limit]) if a3
|
92
|
+
EventMachine::event_callback a1, a2, s || a4
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
# class Connection < com.rubyeventmachine.Connection
|
97
|
+
# def associate_callback_target sig
|
98
|
+
# # No-op for the time being.
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
def self.initialize_event_machine
|
102
|
+
@em = JEM.new
|
103
|
+
end
|
104
|
+
def self.release_machine
|
105
|
+
@em = nil
|
106
|
+
end
|
107
|
+
def self.add_oneshot_timer interval
|
108
|
+
@em.installOneshotTimer interval
|
109
|
+
end
|
110
|
+
def self.run_machine
|
111
|
+
@em.run
|
112
|
+
end
|
113
|
+
def self.stop
|
114
|
+
@em.stop
|
115
|
+
end
|
116
|
+
def self.start_tcp_server server, port
|
117
|
+
@em.startTcpServer server, port
|
118
|
+
end
|
119
|
+
def self.stop_tcp_server sig
|
120
|
+
@em.stopTcpServer sig
|
121
|
+
end
|
122
|
+
def self.start_unix_server filename
|
123
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
124
|
+
raise "unsupported on this platform"
|
125
|
+
end
|
126
|
+
def self.send_data sig, data, length
|
127
|
+
@em.sendData sig, data.to_java_bytes
|
128
|
+
end
|
129
|
+
def self.send_datagram sig, data, length, address, port
|
130
|
+
@em.sendDatagram sig, data.to_java_bytes, length, address, port
|
131
|
+
end
|
132
|
+
def self.connect_server server, port
|
133
|
+
bind_connect_server nil, nil, server, port
|
134
|
+
end
|
135
|
+
def self.bind_connect_server bind_addr, bind_port, server, port
|
136
|
+
@em.connectTcpServer bind_addr, bind_port.to_i, server, port
|
137
|
+
end
|
138
|
+
def self.close_connection sig, after_writing
|
139
|
+
@em.closeConnection sig, after_writing
|
140
|
+
end
|
141
|
+
def self.set_comm_inactivity_timeout sig, interval
|
142
|
+
@em.setCommInactivityTimeout sig, interval
|
143
|
+
end
|
144
|
+
def self.set_pending_connect_timeout sig, val
|
145
|
+
end
|
146
|
+
def self.set_heartbeat_interval val
|
147
|
+
end
|
148
|
+
def self.start_tls sig
|
149
|
+
@em.startTls sig
|
150
|
+
end
|
151
|
+
def self.ssl?
|
152
|
+
false
|
153
|
+
end
|
154
|
+
def self.signal_loopbreak
|
155
|
+
@em.signalLoopbreak
|
156
|
+
end
|
157
|
+
def self.set_timer_quantum q
|
158
|
+
@em.setTimerQuantum q
|
159
|
+
end
|
160
|
+
def self.epoll
|
161
|
+
# Epoll is a no-op for Java.
|
162
|
+
# The latest Java versions run epoll when possible in NIO.
|
163
|
+
end
|
164
|
+
def self.epoll= val
|
165
|
+
end
|
166
|
+
def self.kqueue
|
167
|
+
end
|
168
|
+
def self.kqueue= val
|
169
|
+
end
|
170
|
+
def self.epoll?
|
171
|
+
false
|
172
|
+
end
|
173
|
+
def self.kqueue?
|
174
|
+
false
|
175
|
+
end
|
176
|
+
def self.set_rlimit_nofile n_descriptors
|
177
|
+
# Currently a no-op for Java.
|
178
|
+
end
|
179
|
+
def self.open_udp_socket server, port
|
180
|
+
@em.openUdpSocket server, port
|
181
|
+
end
|
182
|
+
def self.invoke_popen cmd
|
183
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
184
|
+
raise "unsupported on this platform"
|
185
|
+
end
|
186
|
+
def self.read_keyboard
|
187
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
188
|
+
raise "temporarily unsupported on this platform"
|
189
|
+
end
|
190
|
+
def self.set_max_timer_count num
|
191
|
+
# harmless no-op in Java. There's no built-in timer limit.
|
192
|
+
@max_timer_count = num
|
193
|
+
end
|
194
|
+
def self.get_max_timer_count
|
195
|
+
# harmless no-op in Java. There's no built-in timer limit.
|
196
|
+
@max_timer_count || 100_000
|
197
|
+
end
|
198
|
+
def self.library_type
|
199
|
+
:java
|
200
|
+
end
|
201
|
+
def self.get_peername sig
|
202
|
+
if peer = @em.getPeerName(sig)
|
203
|
+
Socket.pack_sockaddr_in(*peer)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
def self.get_sockname sig
|
207
|
+
if sockName = @em.getSockName(sig)
|
208
|
+
Socket.pack_sockaddr_in(*sockName)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
# @private
|
212
|
+
def self.attach_fd fileno, watch_mode
|
213
|
+
# 3Aug09: We could pass in the actual SocketChannel, but then it would be modified (set as non-blocking), and
|
214
|
+
# we would need some logic to make sure detach_fd below didn't clobber it. For now, we just always make a new
|
215
|
+
# SocketChannel for the underlying file descriptor
|
216
|
+
# if fileno.java_kind_of? SocketChannel
|
217
|
+
# ch = fileno
|
218
|
+
# ch.configureBlocking(false)
|
219
|
+
# fileno = nil
|
220
|
+
# elsif fileno.java_kind_of? java.nio.channels.Channel
|
221
|
+
|
222
|
+
if fileno.java_kind_of? java.nio.channels.Channel
|
223
|
+
field = fileno.getClass.getDeclaredField('fdVal')
|
224
|
+
field.setAccessible(true)
|
225
|
+
fileno = field.get(fileno)
|
226
|
+
else
|
227
|
+
raise ArgumentError, 'attach_fd requires Java Channel or POSIX fileno' unless fileno.is_a? Fixnum
|
228
|
+
end
|
229
|
+
|
230
|
+
if fileno == 0
|
231
|
+
raise "can't open STDIN as selectable in Java =("
|
232
|
+
elsif fileno.is_a? Fixnum
|
233
|
+
# 8Aug09: The following code is specific to the sun jvm's SocketChannelImpl. Is there a cross-platform
|
234
|
+
# way of implementing this? If so, also remember to update EventableSocketChannel#close and #cleanup
|
235
|
+
fd = FileDescriptor.new
|
236
|
+
fd.set_field 'fd', fileno
|
237
|
+
|
238
|
+
ch = SocketChannel.open
|
239
|
+
ch.configureBlocking(false)
|
240
|
+
ch.kill
|
241
|
+
ch.set_field 'fd', fd
|
242
|
+
ch.set_field 'fdVal', fileno
|
243
|
+
ch.set_field 'state', ch.get_field('ST_CONNECTED')
|
244
|
+
end
|
245
|
+
|
246
|
+
@em.attachChannel(ch,watch_mode)
|
247
|
+
end
|
248
|
+
def self.detach_fd sig
|
249
|
+
if ch = @em.detachChannel(sig)
|
250
|
+
ch.get_field 'fdVal'
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def self.set_notify_readable sig, mode
|
255
|
+
@em.setNotifyReadable(sig, mode)
|
256
|
+
end
|
257
|
+
def self.set_notify_writable sig, mode
|
258
|
+
@em.setNotifyWritable(sig, mode)
|
259
|
+
end
|
260
|
+
|
261
|
+
def self.is_notify_readable sig
|
262
|
+
@em.isNotifyReadable(sig)
|
263
|
+
end
|
264
|
+
def self.is_notify_writable sig
|
265
|
+
@em.isNotifyWritable(sig)
|
266
|
+
end
|
267
|
+
def self.get_connection_count
|
268
|
+
@em.getConnectionCount
|
269
|
+
end
|
270
|
+
|
271
|
+
def self.pause_connection(sig)
|
272
|
+
@em.pauseConnection(sig)
|
273
|
+
end
|
274
|
+
def self.resume_connection(sig)
|
275
|
+
@em.resumeConnection(sig)
|
276
|
+
end
|
277
|
+
def self.connection_paused?(sig)
|
278
|
+
@em.isConnectionPaused(sig)
|
279
|
+
end
|
280
|
+
def self._get_outbound_data_size(sig)
|
281
|
+
@em.getOutboundDataSize(sig)
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
def self.set_tls_parms(sig, params)
|
286
|
+
end
|
287
|
+
def self.start_tls(sig)
|
288
|
+
end
|
289
|
+
def self.send_file_data(sig, filename)
|
290
|
+
end
|
291
|
+
|
292
|
+
class Connection
|
293
|
+
def associate_callback_target sig
|
294
|
+
# No-op for the time being
|
295
|
+
end
|
296
|
+
def get_outbound_data_size
|
297
|
+
EM._get_outbound_data_size @signature
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/package_task'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rake/extensiontask'
|
6
|
+
require 'rake/javaextensiontask'
|
7
|
+
rescue LoadError => e
|
8
|
+
puts <<-MSG
|
9
|
+
rake-compiler gem seems to be missing. Please install it with
|
10
|
+
|
11
|
+
gem install rake-compiler
|
12
|
+
|
13
|
+
(add sudo if necessary).
|
14
|
+
MSG
|
15
|
+
end
|
16
|
+
|
17
|
+
Gem::PackageTask.new(GEMSPEC) do |pkg|
|
18
|
+
end
|
19
|
+
|
20
|
+
if RUBY_PLATFORM =~ /java/
|
21
|
+
Rake::JavaExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
|
22
|
+
ext.ext_dir = 'java/src'
|
23
|
+
end
|
24
|
+
else
|
25
|
+
def setup_cross_compilation(ext)
|
26
|
+
unless RUBY_PLATFORM =~ /mswin|mingw/
|
27
|
+
ext.cross_compile = true
|
28
|
+
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def hack_cross_compilation(ext)
|
32
|
+
# inject 1.8/1.9 pure-ruby entry point
|
33
|
+
# HACK: add these dependencies to the task instead of using cross_compiling
|
34
|
+
if ext.cross_platform.is_a?(Array)
|
35
|
+
ext.cross_platform.each do |platform|
|
36
|
+
task = "native:#{GEMSPEC.name}:#{platform}"
|
37
|
+
if Rake::Task.task_defined?(task)
|
38
|
+
Rake::Task[task].prerequisites.unshift "lib/#{ext.name}.rb"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
em = Rake::ExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
|
45
|
+
ext.ext_dir = 'ext'
|
46
|
+
ext.source_pattern = '*.{h,c,cpp}'
|
47
|
+
setup_cross_compilation(ext)
|
48
|
+
end
|
49
|
+
hack_cross_compilation em
|
50
|
+
|
51
|
+
ff = Rake::ExtensionTask.new("fastfilereaderext", GEMSPEC) do |ext|
|
52
|
+
ext.ext_dir = 'ext/fastfilereader'
|
53
|
+
ext.source_pattern = '*.{h,c,cpp}'
|
54
|
+
setup_cross_compilation(ext)
|
55
|
+
end
|
56
|
+
hack_cross_compilation ff
|
57
|
+
end
|
58
|
+
|
59
|
+
# Setup shim files that require 1.8 vs 1.9 extensions in win32 bin gems
|
60
|
+
%w[ rubyeventmachine fastfilereaderext ].each do |filename|
|
61
|
+
file("lib/#{filename}.rb") do |t|
|
62
|
+
File.open(t.name, 'wb') do |f|
|
63
|
+
f.write <<-eoruby
|
64
|
+
RUBY_VERSION =~ /(\\d+.\\d+)/
|
65
|
+
require "\#{$1}/#{File.basename(t.name, '.rb')}"
|
66
|
+
eoruby
|
67
|
+
end
|
68
|
+
at_exit{ FileUtils.rm t.name if File.exist?(t.name) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
task :cross_cxx do
|
73
|
+
ENV['CROSS_COMPILING'] = 'yes'
|
74
|
+
require 'rake/extensioncompiler'
|
75
|
+
ENV['CXX'] = "#{Rake::ExtensionCompiler.mingw_host}-g++"
|
76
|
+
end
|
77
|
+
|
78
|
+
if Rake::Task.task_defined?(:cross)
|
79
|
+
task :cross => 'lib/rubyeventmachine.rb'
|
80
|
+
task :cross => 'lib/fastfilereaderext.rb'
|
81
|
+
task :cross => :cross_cxx
|
82
|
+
end
|
83
|
+
|
84
|
+
def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
|
85
|
+
def sudo(cmd)
|
86
|
+
if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
|
87
|
+
sh cmd
|
88
|
+
else
|
89
|
+
sh "sudo #{cmd}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
def gem_cmd(action, name, *args)
|
93
|
+
rb = Gem.ruby rescue nil
|
94
|
+
rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
|
95
|
+
sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
|
96
|
+
end
|
97
|
+
|
98
|
+
Rake::Task[:clean].enhance [:clobber_package]
|
99
|
+
|
100
|
+
# DevKit task following the example of Luis Lavena's test-ruby-c-extension
|
101
|
+
task :devkit do
|
102
|
+
begin
|
103
|
+
require "devkit"
|
104
|
+
rescue LoadError => e
|
105
|
+
abort "Failed to activate RubyInstaller's DevKit required for compilation."
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
110
|
+
Rake::Task['compile'].prerequisites.unshift 'devkit'
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Build binary gems for Windows with rake-compiler-dock"
|
114
|
+
task 'gem:windows' do
|
115
|
+
require 'rake_compiler_dock'
|
116
|
+
RakeCompilerDock.sh <<-EOT
|
117
|
+
RUBY_CC_VERSION="${RUBY_CC_VERSION//1.8.7/}"
|
118
|
+
bundle && rake cross native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