root/trunk/tasks/cpp.rake

Revision 788, 2.2 kB (checked in by raggi, 8 months ago)

Merge of branches/raggi
Most notable work and patches by Aman Gupta, Roger Pack, and James Tucker.
Patches / Tickets also submitted by: Jeremy Evans, aanand, darix, mmmurf,
danielaquino, macournoyer.

  • Moved docs into docs/ dir
  • Major refactor of rakefile, added generic rakefile helpers in tasks
  • Added example CPP build rakefile in tasks/cpp.rake
  • Moved rake tests out to tasks/tests.rake
  • Added svn ignores where appropriate
  • Fixed jruby build on older java platforms
  • Gem now builds from Rakefile rather than directly via extconf
  • Gem unified for jruby, C++ and pure ruby.
  • Correction for pure C++ build, removing ruby dependency
  • Fix for CYGWIN builds on ipv6
  • Major refactor for extconf.rb
  • Working mingw builds
  • extconf optionally uses pkg_config over manual configuration
  • extconf builds for 1.9 on any system that has 1.9
  • extconf no longer links pthread explicitly
  • looks for kqueue on all *nix systems
  • better error output on std::runtime_error, now says where it came from
  • Fixed some tests on jruby
  • Added test for general send_data flaw, required for a bugfix in jruby build
  • Added timeout to epoll tests
  • Added fixes for java reactor ruby api
  • Small addition of some docs in httpclient.rb and httpcli2.rb
  • Some refactor and fixes in smtpserver.rb
  • Added parenthesis where possible to avoid excess ruby warnings
  • Refactor of $eventmachine_library logic for accuracy and maintenance, jruby
  • EM::start_server now supports unix sockets
  • EM::connect now supports unix sockets
  • EM::defer @threadqueue now handled more gracefully
  • Added better messages on exceptions raised
  • Fix edge case in timer fires
  • Explicitly require buftok.rb
  • Add protocols to autoload, rather than require them all immediately
  • Fix a bug in pr_eventmachine for outbound_q
  • Refactors to take some of the use of defer out of tests.
  • Fixes in EM.defer under start/stop conditions. Reduced scope of threads.
Line 
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
Note: See TracBrowser for help on using the browser.