eventmachine 0.12.2 → 0.12.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +191 -0
- data/{COPYING → docs/COPYING} +0 -0
- data/docs/ChangeLog +183 -0
- data/{DEFERRABLES → docs/DEFERRABLES} +1 -1
- data/{EPOLL → docs/EPOLL} +0 -0
- data/{GNU → docs/GNU} +0 -0
- data/docs/INSTALL +15 -0
- data/{KEYBOARD → docs/KEYBOARD} +0 -0
- data/{LEGAL → docs/LEGAL} +0 -0
- data/{LIGHTWEIGHT_CONCURRENCY → docs/LIGHTWEIGHT_CONCURRENCY} +1 -1
- data/{PURE_RUBY → docs/PURE_RUBY} +1 -1
- data/{README → docs/README} +1 -1
- data/{RELEASE_NOTES → docs/RELEASE_NOTES} +1 -1
- data/{SMTP → docs/SMTP} +1 -1
- data/{SPAWNED_PROCESSES → docs/SPAWNED_PROCESSES} +1 -1
- data/{TODO → docs/TODO} +1 -1
- data/ext/binder.cpp +1 -1
- data/ext/binder.h +1 -1
- data/ext/cmain.cpp +65 -74
- data/ext/cplusplus.cpp +1 -1
- data/ext/ed.cpp +41 -25
- data/ext/ed.h +10 -3
- data/ext/em.cpp +39 -12
- data/ext/em.h +13 -1
- data/ext/emwin.cpp +1 -1
- data/ext/emwin.h +1 -1
- data/ext/epoll.cpp +1 -1
- data/ext/epoll.h +1 -1
- data/ext/eventmachine.h +1 -1
- data/ext/eventmachine_cpp.h +1 -1
- data/ext/extconf.rb +86 -139
- data/ext/fastfilereader/extconf.rb +161 -0
- data/ext/fastfilereader/mapper.cpp +202 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/files.cpp +1 -1
- data/ext/files.h +1 -1
- data/ext/kb.cpp +1 -1
- data/ext/page.cpp +1 -1
- data/ext/page.h +1 -1
- data/ext/pipe.cpp +14 -7
- data/ext/project.h +1 -1
- data/ext/rubymain.cpp +56 -2
- data/ext/sigs.cpp +1 -1
- data/ext/sigs.h +1 -1
- data/ext/ssl.cpp +1 -1
- data/ext/ssl.h +1 -1
- data/java/src/com/rubyeventmachine/Application.java +196 -0
- data/java/src/com/rubyeventmachine/Connection.java +74 -0
- data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
- data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
- data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
- data/java/src/com/rubyeventmachine/Timer.java +54 -0
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
- data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
- data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
- data/lib/em/deferrable.rb +1 -1
- data/lib/em/eventable.rb +1 -1
- data/lib/em/future.rb +1 -1
- data/lib/em/messages.rb +1 -1
- data/lib/em/processes.rb +1 -1
- data/lib/em/spawnable.rb +1 -1
- data/lib/em/streamer.rb +1 -1
- data/lib/eventmachine.rb +138 -116
- data/lib/eventmachine_version.rb +2 -2
- data/lib/evma.rb +1 -1
- data/lib/evma/callback.rb +1 -1
- data/lib/evma/container.rb +1 -1
- data/lib/evma/factory.rb +1 -1
- data/lib/evma/protocol.rb +1 -1
- data/lib/evma/reactor.rb +1 -1
- data/lib/jeventmachine.rb +7 -2
- data/lib/pr_eventmachine.rb +2 -2
- data/lib/protocols/buftok.rb +1 -1
- data/lib/protocols/header_and_content.rb +1 -1
- data/lib/protocols/httpcli2.rb +16 -6
- data/lib/protocols/httpclient.rb +7 -1
- data/lib/protocols/line_and_text.rb +6 -2
- data/lib/protocols/linetext2.rb +12 -14
- data/lib/protocols/postgres.rb +1 -1
- data/lib/protocols/saslauth.rb +1 -1
- data/lib/protocols/smtpclient.rb +1 -1
- data/lib/protocols/smtpserver.rb +36 -23
- data/lib/protocols/stomp.rb +24 -1
- data/lib/protocols/tcptest.rb +1 -1
- data/tasks/cpp.rake +77 -0
- data/tasks/project.rake +78 -0
- data/tasks/tests.rake +192 -0
- data/tests/test_attach.rb +1 -1
- data/tests/test_basic.rb +65 -12
- data/tests/test_defer.rb +13 -29
- data/tests/test_epoll.rb +16 -21
- data/tests/test_errors.rb +1 -1
- data/tests/test_eventables.rb +4 -5
- data/tests/test_exc.rb +1 -1
- data/tests/test_futures.rb +1 -1
- data/tests/test_hc.rb +185 -236
- data/tests/test_httpclient.rb +1 -1
- data/tests/test_httpclient2.rb +28 -6
- data/tests/test_kb.rb +2 -2
- data/tests/test_ltp.rb +139 -141
- data/tests/test_ltp2.rb +1 -1
- data/tests/test_next_tick.rb +1 -1
- data/tests/test_processes.rb +1 -1
- data/tests/test_pure.rb +3 -2
- data/tests/test_running.rb +1 -1
- data/tests/test_sasl.rb +1 -1
- data/tests/test_send_file.rb +56 -51
- data/tests/test_servers.rb +26 -36
- data/tests/test_smtpclient.rb +46 -44
- data/tests/test_smtpserver.rb +1 -1
- data/tests/test_spawn.rb +1 -1
- data/tests/test_ssl_args.rb +68 -0
- data/tests/test_timers.rb +15 -9
- data/tests/test_ud.rb +1 -1
- data/tests/testem.rb +30 -4
- metadata +69 -34
data/lib/eventmachine_version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -25,7 +25,7 @@
|
|
25
25
|
|
26
26
|
module EventMachine
|
27
27
|
|
28
|
-
VERSION = "0.12.
|
28
|
+
VERSION = "0.12.4"
|
29
29
|
|
30
30
|
end
|
31
31
|
|
data/lib/evma.rb
CHANGED
data/lib/evma/callback.rb
CHANGED
data/lib/evma/container.rb
CHANGED
data/lib/evma/factory.rb
CHANGED
data/lib/evma/protocol.rb
CHANGED
data/lib/evma/reactor.rb
CHANGED
data/lib/jeventmachine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -28,7 +28,7 @@
|
|
28
28
|
# For C++ EventMachines, the analogous functionality is found in ext/rubymain.cpp,
|
29
29
|
# which is a garden-variety Ruby-extension glue module.
|
30
30
|
|
31
|
-
|
31
|
+
require 'java'
|
32
32
|
require 'em_reactor'
|
33
33
|
|
34
34
|
module EventMachine
|
@@ -49,6 +49,11 @@ module EventMachine
|
|
49
49
|
EventMachine::event_callback a1, a2, s
|
50
50
|
end
|
51
51
|
end
|
52
|
+
class Connection < com.rubyeventmachine.Connection
|
53
|
+
def associate_callback_target sig
|
54
|
+
# No-op for the time being.
|
55
|
+
end
|
56
|
+
end
|
52
57
|
def self.initialize_event_machine
|
53
58
|
@em = JEM.new
|
54
59
|
end
|
data/lib/pr_eventmachine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -578,7 +578,7 @@ module EventMachine
|
|
578
578
|
end
|
579
579
|
|
580
580
|
if w < data.length
|
581
|
-
|
581
|
+
@outbound_q.unshift data[w..-1]
|
582
582
|
break
|
583
583
|
end
|
584
584
|
rescue Errno::EAGAIN
|
data/lib/protocols/buftok.rb
CHANGED
data/lib/protocols/httpcli2.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -28,7 +28,17 @@
|
|
28
28
|
module EventMachine
|
29
29
|
module Protocols
|
30
30
|
|
31
|
-
|
31
|
+
# = Example
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# EM.run{
|
35
|
+
# include EM::Protocols
|
36
|
+
# conn = HttpClient2.connect 'google.com', 80
|
37
|
+
#
|
38
|
+
# req = conn.get('/')
|
39
|
+
# req.callback{
|
40
|
+
# p(req.content)
|
41
|
+
# }
|
32
42
|
class HttpClient2 < Connection
|
33
43
|
include LineText2
|
34
44
|
|
@@ -119,12 +129,12 @@ module Protocols
|
|
119
129
|
if chunksize > 0
|
120
130
|
@conn.set_text_mode(ln.to_i(16))
|
121
131
|
else
|
122
|
-
@content = @content.join
|
132
|
+
@content = @content ? @content.join : ''
|
123
133
|
@chunk_trailer = true
|
124
134
|
end
|
125
135
|
else
|
126
136
|
# We correctly come here after each chunk gets read.
|
127
|
-
p "Got A BLANK chunk line"
|
137
|
+
# p "Got A BLANK chunk line"
|
128
138
|
end
|
129
139
|
|
130
140
|
end
|
@@ -134,7 +144,7 @@ module Protocols
|
|
134
144
|
# We get a single chunk. Append it to the incoming content and switch back to line mode.
|
135
145
|
#
|
136
146
|
def receive_chunked_text text
|
137
|
-
p "RECEIVED #{text.length} CHUNK"
|
147
|
+
# p "RECEIVED #{text.length} CHUNK"
|
138
148
|
(@content ||= []) << text
|
139
149
|
end
|
140
150
|
|
@@ -224,7 +234,7 @@ module Protocols
|
|
224
234
|
|
225
235
|
h,prt,ssl = args[:host], Integer(args[:port]), (args[:tls] || args[:ssl])
|
226
236
|
conn = EM.connect( h, prt, self )
|
227
|
-
|
237
|
+
conn.start_tls if ssl
|
228
238
|
conn.set_default_host_header( h, prt, ssl )
|
229
239
|
conn
|
230
240
|
end
|
data/lib/protocols/httpclient.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -65,6 +65,12 @@ class HttpClient < Connection
|
|
65
65
|
# Refactor this code so that protocol errors all get handled one way (an exception?),
|
66
66
|
# instead of sprinkling set_deferred_status :failed calls everywhere.
|
67
67
|
|
68
|
+
# === Arg list
|
69
|
+
# :host => 'ip/dns', :port => fixnum, :verb => 'GET', :request => 'path',
|
70
|
+
# :basic_auth => {:username => '', :password => ''}, :content => 'content',
|
71
|
+
# :contenttype => 'text/plain', :query_string => '', :host_header => '',
|
72
|
+
# :cookie => ''
|
73
|
+
|
68
74
|
def self.request( args = {} )
|
69
75
|
args[:port] ||= 80
|
70
76
|
EventMachine.connect( args[:host], args[:port], self ) {|c|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -27,7 +27,11 @@ require File.dirname(__FILE__) + '/buftok'
|
|
27
27
|
|
28
28
|
module EventMachine
|
29
29
|
module Protocols
|
30
|
-
|
30
|
+
# A protocol that handles line-oriented data with interspersed binary text.
|
31
|
+
#
|
32
|
+
# This version is optimized for performance. See EventMachine::Protocols::LineText2
|
33
|
+
# for a version which is optimized for correctness with regard to binary text blocks
|
34
|
+
# that can switch back to line mode.
|
31
35
|
class LineAndTextProtocol < Connection
|
32
36
|
MaxLineLength = 16*1024
|
33
37
|
MaxBinaryLength = 32*1024*1024
|
data/lib/protocols/linetext2.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -24,22 +24,20 @@
|
|
24
24
|
#
|
25
25
|
#
|
26
26
|
|
27
|
-
|
28
|
-
# In the grand, time-honored tradition of re-inventing the wheel, we offer
|
29
|
-
# here YET ANOTHER protocol that handles line-oriented data with interspersed
|
30
|
-
# binary text. This one trades away some of the performance optimizations of
|
31
|
-
# EventMachine::Protocols::LineAndTextProtocol in order to get better correctness
|
32
|
-
# with regard to binary text blocks that can switch back to line mode. It also
|
33
|
-
# permits the line-delimiter to change in midstream.
|
34
|
-
# This was originally written to support Stomp.
|
35
|
-
|
36
|
-
# TODO! We're not enforcing the limits on header lengths and text-lengths.
|
37
|
-
# When we get around to that, call #receive_error if the user defined it, otherwise
|
38
|
-
# throw exceptions.
|
39
|
-
|
40
27
|
module EventMachine
|
41
28
|
module Protocols
|
29
|
+
# In the grand, time-honored tradition of re-inventing the wheel, we offer
|
30
|
+
# here YET ANOTHER protocol that handles line-oriented data with interspersed
|
31
|
+
# binary text. This one trades away some of the performance optimizations of
|
32
|
+
# EventMachine::Protocols::LineAndTextProtocol in order to get better correctness
|
33
|
+
# with regard to binary text blocks that can switch back to line mode. It also
|
34
|
+
# permits the line-delimiter to change in midstream.
|
35
|
+
# This was originally written to support Stomp.
|
42
36
|
module LineText2
|
37
|
+
# TODO! We're not enforcing the limits on header lengths and text-lengths.
|
38
|
+
# When we get around to that, call #receive_error if the user defined it, otherwise
|
39
|
+
# throw exceptions.
|
40
|
+
|
43
41
|
MaxLineLength = 16*1024
|
44
42
|
MaxBinaryLength = 32*1024*1024
|
45
43
|
|
data/lib/protocols/postgres.rb
CHANGED
data/lib/protocols/saslauth.rb
CHANGED
data/lib/protocols/smtpclient.rb
CHANGED
data/lib/protocols/smtpserver.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -119,40 +119,53 @@ module Protocols
|
|
119
119
|
|
120
120
|
def receive_line ln
|
121
121
|
@@parms[:verbose] and $>.puts ">>> #{ln}"
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
|
123
|
+
return process_data_line ln if @state.include?(:data)
|
124
|
+
|
125
|
+
case ln
|
126
|
+
when EhloRegex
|
125
127
|
process_ehlo $'.dup
|
126
|
-
|
128
|
+
when HeloRegex
|
127
129
|
process_helo $'.dup
|
128
|
-
|
130
|
+
when MailFromRegex
|
129
131
|
process_mail_from $'.dup
|
130
|
-
|
132
|
+
when RcptToRegex
|
131
133
|
process_rcpt_to $'.dup
|
132
|
-
|
134
|
+
when DataRegex
|
133
135
|
process_data
|
134
|
-
|
136
|
+
when RsetRegex
|
135
137
|
process_rset
|
136
|
-
|
138
|
+
when VrfyRegex
|
137
139
|
process_vrfy
|
138
|
-
|
140
|
+
when ExpnRegex
|
139
141
|
process_expn
|
140
|
-
|
142
|
+
when HelpRegex
|
141
143
|
process_help
|
142
|
-
|
144
|
+
when NoopRegex
|
143
145
|
process_noop
|
144
|
-
|
146
|
+
when QuitRegex
|
145
147
|
process_quit
|
146
|
-
|
148
|
+
when StarttlsRegex
|
147
149
|
process_starttls
|
148
|
-
|
150
|
+
when AuthRegex
|
149
151
|
process_auth $'.dup
|
150
152
|
else
|
151
153
|
process_unknown
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
155
|
-
|
157
|
+
# TODO - implement this properly, the implementation is a stub!
|
158
|
+
def process_vrfy
|
159
|
+
send_data "250 Ok, but unimplemented\r\n"
|
160
|
+
end
|
161
|
+
# TODO - implement this properly, the implementation is a stub!
|
162
|
+
def process_help
|
163
|
+
send_data "250 Ok, but unimplemented\r\n"
|
164
|
+
end
|
165
|
+
# TODO - implement this properly, the implementation is a stub!
|
166
|
+
def process_expn
|
167
|
+
send_data "250 Ok, but unimplemented\r\n"
|
168
|
+
end
|
156
169
|
|
157
170
|
#--
|
158
171
|
# This is called at several points to restore the protocol state
|
@@ -289,8 +302,8 @@ module Protocols
|
|
289
302
|
d = receive_data_command
|
290
303
|
|
291
304
|
if d.respond_to?(:callback)
|
292
|
-
d.callback
|
293
|
-
d.errback
|
305
|
+
d.callback(&succeeded)
|
306
|
+
d.errback(&failed)
|
294
307
|
else
|
295
308
|
(d ? succeeded : failed).call
|
296
309
|
end
|
@@ -383,8 +396,8 @@ module Protocols
|
|
383
396
|
d = receive_recipient rcpt
|
384
397
|
|
385
398
|
if d.respond_to?(:set_deferred_status)
|
386
|
-
d.callback
|
387
|
-
d.errback
|
399
|
+
d.callback(&succeeded)
|
400
|
+
d.errback(&failed)
|
388
401
|
else
|
389
402
|
(d ? succeeded : failed).call
|
390
403
|
end
|
@@ -433,8 +446,8 @@ module Protocols
|
|
433
446
|
d = receive_message
|
434
447
|
|
435
448
|
if d.respond_to?(:set_deferred_status)
|
436
|
-
d.callback
|
437
|
-
d.errback
|
449
|
+
d.callback(&succeeded)
|
450
|
+
d.errback(&failed)
|
438
451
|
else
|
439
452
|
(d ? succeeded : failed).call
|
440
453
|
end
|
data/lib/protocols/stomp.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -31,6 +31,29 @@ module EventMachine
|
|
31
31
|
|
32
32
|
# Implements Stomp (http://docs.codehaus.org/display/STOMP/Protocol).
|
33
33
|
#
|
34
|
+
# == Usage example
|
35
|
+
#
|
36
|
+
# class StompClient < EM::Connection
|
37
|
+
# include EM::Protocols::Stomp
|
38
|
+
#
|
39
|
+
# def connection_completed
|
40
|
+
# connect :login => 'guest', :passcode => 'guest'
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# def receive_msg msg
|
44
|
+
# if msg.command == "CONNECTED"
|
45
|
+
# subscribe '/some/topic'
|
46
|
+
# else
|
47
|
+
# p ['got a message', msg]
|
48
|
+
# puts msg.body
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# EM.run{
|
54
|
+
# EM.connect 'localhost', 61613, StompClient
|
55
|
+
# }
|
56
|
+
#
|
34
57
|
module Stomp
|
35
58
|
include LineText2
|
36
59
|
|
data/lib/protocols/tcptest.rb
CHANGED
data/tasks/cpp.rake
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# EventMachine C++ Rakefile Stab Case
|
2
|
+
# TODO : track header files as a build dependency...
|
3
|
+
# TODO : cross platform support
|
4
|
+
# TODO : configure style functionality
|
5
|
+
namespace :cpp do
|
6
|
+
|
7
|
+
require 'rake/clean'
|
8
|
+
|
9
|
+
# *nix only atm...
|
10
|
+
module Cpp
|
11
|
+
class <<self
|
12
|
+
def cpp; "g++"; end
|
13
|
+
def archive; "ar"; end
|
14
|
+
def compile file, output, includes=nil, flags=nil
|
15
|
+
sh %{#{cpp} #{file} #{includes} #{flags} -c -o #{output}}
|
16
|
+
end
|
17
|
+
def link file, output, libs=nil, flags=nil
|
18
|
+
sh %{#{cpp} #{file} #{libs} #{flags} -o #{output}}
|
19
|
+
end
|
20
|
+
def static output, files
|
21
|
+
sh %{#{archive} cr #{output} #{files}}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module EmConfig
|
27
|
+
Path = ENV['EVENTMACHINE_SOURCE'] || 'ext'
|
28
|
+
Sources = FileList["#{Path}/*.cpp"]
|
29
|
+
Sources.delete_if { |s| /ruby/ =~ s }
|
30
|
+
Compiled = Sources.sub(%r{^#{Path}/(.*)\.cpp}, "#{Path}/\\1.o")
|
31
|
+
|
32
|
+
Flags = "-O2 -pipe -fno-common -DOS_UNIX -DWITHOUT_SSL"
|
33
|
+
Includes = ""
|
34
|
+
Libs = ''
|
35
|
+
end
|
36
|
+
CLEAN.include(EmConfig::Compiled)
|
37
|
+
|
38
|
+
rule %r{^#{EmConfig::Path}/.*\.o$} => [proc { |targ|
|
39
|
+
targ.sub(%r{^#{EmConfig::Path}/(.*)\.o$}, "#{EmConfig::Path}/\\1.cpp")
|
40
|
+
}] do |t|
|
41
|
+
Cpp.compile t.source, t.name, EmConfig::Includes, EmConfig::Flags
|
42
|
+
end
|
43
|
+
|
44
|
+
file "#{EmConfig::Path}/libeventmachine.a" => EmConfig::Compiled do |t|
|
45
|
+
Cpp.static t.name, EmConfig::Compiled
|
46
|
+
end
|
47
|
+
CLEAN.include("#{EmConfig::Path}/libeventmachine.a")
|
48
|
+
|
49
|
+
module AppConfig
|
50
|
+
Appname = 'echo_em'
|
51
|
+
Sources = FileList['*.cpp']
|
52
|
+
Compiled = Sources.sub(%r{^(.*)\.cpp}, '\\1.o')
|
53
|
+
|
54
|
+
Flags = ["", EmConfig::Flags].join(' ')
|
55
|
+
Includes = ["-I. -I#{EmConfig::Path}", EmConfig::Includes].join(' ')
|
56
|
+
Libs = ["-L#{EmConfig::Path} -leventmachine", EmConfig::Libs].join(' ')
|
57
|
+
end
|
58
|
+
CLEAN.include(AppConfig::Compiled)
|
59
|
+
CLEAN.include(AppConfig::Appname)
|
60
|
+
|
61
|
+
rule %r{^.*\.o$} => [proc { |targ|
|
62
|
+
targ.sub(%r{^(.*)\.o$}, '\\1.cpp')
|
63
|
+
}] do |t|
|
64
|
+
Cpp.compile t.source, t.name, AppConfig::Includes, AppConfig::Flags
|
65
|
+
end
|
66
|
+
|
67
|
+
file AppConfig::Appname => ["#{EmConfig::Path}/libeventmachine.a", AppConfig::Compiled] do |t|
|
68
|
+
Cpp.link AppConfig::Compiled, t.name, AppConfig::Libs, AppConfig::Flags
|
69
|
+
end
|
70
|
+
|
71
|
+
task :build => AppConfig::Appname
|
72
|
+
|
73
|
+
task :run => AppConfig::Appname do
|
74
|
+
sh "./#{AppConfig::Appname}"
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|