0
# http://rubyeventmachine.com
0
+# # The tasks and external gemspecs we used to generate binary gems are now
0
+# # obsolete. Use Patrick Hurley's gembuilder to build binary gems for any
0
+# # To build a binary gem on Win32, ensure that the include and lib paths
0
+# # both contain the proper references to OPENSSL. Use the static version
0
+# # of the libraries, not the dynamic, otherwise we expose the user to a
0
+# # runtime dependency.
0
+# # To build a binary gem for win32, first build rubyeventmachine.so
0
+# # using VC6 outside of the build tree (the normal way: ruby extconf.rb,
0
+# # and then nmake). Then copy rubyeventmachine.so into the lib directory,
0
+# # and run rake gemwin32.
0
+require 'rubygems' unless defined?(Gem)
0
+require 'rake' unless defined?(Rake)
0
require 'rake/gempackagetask'
0
- require 'archive/tar/minitar'
0
-require 'eventmachine_version'
0
-$version = EventMachine::VERSION
0
-$distdir = "eventmachine-#$version"
0
-$tardist = "#$distdir.tar.gz"
0
+Package = false # Build zips and tarballs?
0
+Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
0
+# e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults!
0
+$eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java'
0
+$eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby'
0
-# The tasks and external gemspecs we used to generate binary gems are now
0
-# obsolete. Use Patrick Hurley's gembuilder to build binary gems for any
0
-# To build a binary gem on Win32, ensure that the include and lib paths
0
-# both contain the proper references to OPENSSL. Use the static version
0
-# of the libraries, not the dynamic, otherwise we expose the user to a
0
-# To build a binary gem for win32, first build rubyeventmachine.so
0
-# using VC6 outside of the build tree (the normal way: ruby extconf.rb,
0
-# and then nmake). Then copy rubyeventmachine.so into the lib directory,
0
-# and run rake gemwin32.
0
-specwin32 = eval(File.read("eventmachine-win32.gemspec"))
0
-specwin32.version = $version
0
-desc "Build the RubyGem for EventMachine-win32"
0
-task :gemwin32 => ["pkg/eventmachine-win32-#{$version}.gem"]
0
-Rake::GemPackageTask.new(specwin32) do |g|
0
+# If running under rubygems...
0
+__DIR__ ||= File.expand_path(File.dirname(__FILE__))
0
+if Gem.path.any? {|path| %r(^#{Regexp.escape path}) =~ __DIR__}
0
+ task :default => :gem_build
0
+ task :default => [:build, :test]
0
+desc ":default build when running under rubygems."
0
+task :gem_build => :build
0
-# To build a binary gem for unix platforms, first build rubyeventmachine.so
0
-# using gcc outside of the build tree (the normal way: ruby extconf.rb,
0
-# and then make). Then copy rubyeventmachine.so into the lib directory,
0
-# and run rake gembinary.
0
-specbinary = eval(File.read("eventmachine-binary.gemspec"))
0
-specbinary.version = $version
0
-desc "Build the RubyGem for EventMachine-Binary"
0
-task :gembinary => ["pkg/eventmachine-binary-#{$version}.gem"]
0
-Rake::GemPackageTask.new(specbinary) do |g|
0
+desc "Build extension (or EVENTMACHIINE_LIBRARY) and place in lib"
0
+build_task = 'ext:build'
0
+build_task = 'java:build' if $eventmachine_library == :java
0
+build_task = :dummy_build if $eventmachine_library == :pure_ruby
0
+task :build => build_task do |t|
0
+ Dir.glob('{ext,java/src}/*.{so,bundle,dll,jar}').each do |f|
0
-spec = eval(File.read("eventmachine.gemspec"))
0
-spec = Gem::Specification.new do |s|
0
- s.name = "eventmachine"
0
- s.summary = "Ruby/EventMachine library"
0
- s.platform = Gem::Platform::RUBY
0
- s.rdoc_options = %w(--title EventMachine --main README --line-numbers)
0
- s.extra_rdoc_files = ["README",
0
- "LIGHTWEIGHT_CONCURRENCY",
0
- s.files = FileList["{bin,tests,lib,ext}/**/*"].exclude("rdoc").to_a
0
- s.require_paths = ["lib"]
0
- s.test_file = "tests/testem.rb"
0
- s.extensions = "ext/extconf.rb"
0
- s.author = "Francis Cianfrocca"
0
- s.email = "garbagecat10@gmail.com"
0
- s.rubyforge_project = %q(eventmachine)
0
- s.homepage = "http://rubyeventmachine.com"
0
- File.open("README") do |file|
0
- description << "#{line.gsub(/\[\d\]/, '')}"
0
- s.description = description[1..-1].join(" ")
0
-spec.version = $version
0
-desc "Build the EventMachine RubyGem"
0
-task :gem => ["pkg/eventmachine-#{$version}.gem"]
0
-Rake::GemPackageTask.new(spec) do |g|
0
+# Basic clean definition, this is enhanced by imports aswell.
0
+ sh 'make clean' if test ?e, 'Makefile'
0
-jspec = Gem::Specification.new do |s|
0
- s.name = "eventmachine-java"
0
- s.summary = "Ruby/EventMachine library"
0
- s.platform = Gem::Platform::RUBY
0
- s.rdoc_options = %w(--title EventMachine --main README --line-numbers)
0
- s.extra_rdoc_files = ["README", "RELEASE_NOTES", "COPYING", "GNU", "LEGAL", "TODO"]
0
- s.files = FileList["{lib}/**/*"].exclude("rdoc").to_a
0
- s.require_paths = ["lib"]
0
- s.author = "Francis Cianfrocca"
0
- s.email = "garbagecat10@gmail.com"
0
- s.rubyforge_project = %q(eventmachine)
0
- s.homepage = "http://rubyeventmachine.com"
0
- File.open("README") do |file|
0
- description << "#{line.gsub(/\[\d\]/, '')}"
0
- s.description = description[1..-1].join(" ")
0
-jspec.version = $version
0
-desc "Build the EventMachine RubyGem for JRuby"
0
-task :jgem => ["pkg/eventmachine-java-#{$version}.gem"]
0
-Rake::GemPackageTask.new(jspec) do |g|
0
- $>.puts "-----------------"
0
- $>.puts "Before executing the :jgem task, be sure to run :clean, and"
0
- $>.puts "then make sure an up-to-date em_reactor.jar is present in the"
0
- $>.puts "lib directory."
0
- $>.puts "-----------------"
0
+ Dir.glob('**/Makefile').each { |file| rm file }
0
+ Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
0
+Spec = Gem::Specification.new do |s|
0
+ s.name = "eventmachine"
0
+ s.summary = "Ruby/EventMachine library"
0
+ s.platform = Gem::Platform::RUBY
0
+ s.rdoc_options = %w(--title EventMachine --main docs/README --line-numbers)
0
+ s.extra_rdoc_files = Dir['docs/*']
0
+ s.files = %w(Rakefile) + Dir["{bin,tests,lib,ext,java,tasks}/**/*"]
0
+ s.require_path = 'lib'
0
+ s.test_file = "tests/testem.rb"
0
+ s.extensions = "Rakefile"
0
+ s.author = "Francis Cianfrocca"
0
+ s.email = "garbagecat10@gmail.com"
0
+ s.rubyforge_project = 'eventmachine'
0
+ s.homepage = "http://rubyeventmachine.com"
0
+ # Pulled in from readme, as code to pull from readme was not working!
0
+ # Might be worth removing as no one seems to use gem info anyway.
0
+ s.description = <<-EOD
0
+EventMachine implements a fast, single-threaded engine for arbitrary network
0
+communications. It's extremely easy to use in Ruby. EventMachine wraps all
0
+interactions with IP sockets, allowing programs to concentrate on the
0
+implementation of network protocols. It can be used to create both network
0
+servers and clients. To create a server or client, a Ruby program only needs
0
+to specify the IP address and port, and provide a Module that implements the
0
+communications protocol. Implementations of several standard network protocols
0
+are provided with the package, primarily to serve as examples. The real goal
0
+of EventMachine is to enable programs to easily interface with other programs
0
+using TCP/IP, especially if custom protocols are required.
0
+ require 'lib/eventmachine_version'
0
+ s.version = EventMachine::VERSION
0
+ desc "Build C++ extension"
0
+ task :build => [:clean, :make]
0
+ task :make => [:makefile] do
0
-desc "Clean extension and JAR builds out of the lib directory"
0
- files = %W(lib/*.so lib/*.jar)
0
- files = FileList[files.map { |file| File.join(".", file) }].to_a
0
- $>.puts "unlinking file: #{f}"
0
- desc "Build #$name .tar.gz distribution."
0
- task :tar => [ $tardist ]
0
- file $tardist => [ ] do |t|
0
- current = File.basename(Dir.pwd)
0
- files = %W(ext/**/*.rb ext/**/*.cpp ext/**/*.h bin/**/* lib/**/* tests/**/* README COPYING
0
- GNU LEGAL RELEASE_NOTES INSTALL EPOLL TODO KEYBOARD
0
- LIGHTWEIGHT_CONCURRENCY PURE_RUBY SMTP SPAWNED_PROCESSES DEFERRABLES setup.rb )
0
- files = FileList[files.map { |file| File.join(current, file) }].to_a
0
- files = files.select {|f| f !~ /lib\/.*[\.](so|jar)\Z/i } # remove any so or jar files in the lib directory
0
- ddnew = dd.gsub(/^#{current}/, $distdir)
0
- mtime = $release_date || File.stat(dd).mtime
0
- if File.directory?(dd)
0
- { :name => ddnew, :mode => 0755, :dir => true, :mtime => mtime }
0
- data = File.open(dd, "rb") { |ff| ff.read }
0
- { :name => ddnew, :mode => mode, :data => data, :size =>
0
- data.size, :mtime => mtime }
0
- ff = File.open(t.name.gsub(%r{^\.\./}o, ''), "wb")
0
- gz = Zlib::GzipWriter.new(ff)
0
- tw = Archive::Tar::Minitar::Writer.new(gz)
0
- tw.mkdir(entry[:name], entry)
0
- tw.add_file_simple(entry[:name], entry) { |os| os.write(entry[:data]) }
0
+ desc 'Compile the makefile'
0
-# This is used by several rake tasks, that parameterize the
0
-# behavior so we can use the same tests to test both the
0
-# extension and non-extension versions.
0
-def run_tests t, libr, test_filename_filter="test_*.rb"
0
- require 'test/unit/testsuite'
0
- require 'test/unit/ui/console/testrunner'
0
- runner = Test::Unit::UI::Console::TestRunner
0
- $eventmachine_library = ((RUBY_PLATFORM =~ /java/) ? :java : libr)
0
- $LOAD_PATH.unshift('tests')
0
- $stderr.puts "Checking for test cases:" #if t.verbose
0
- if test_filename_filter.is_a?(Array)
0
- test_filename_filter.each {|testcase|
0
- $stderr.puts "\t#{testcase}"
0
- load "tests/#{testcase}"
0
- Dir["tests/#{test_filename_filter}"].each do |testcase|
0
- $stderr.puts "\t#{testcase}" #if t.verbose
0
+ # This task creates the JRuby JAR file and leaves it in the lib directory.
0
+ # This step is required before executing the jgem task.
0
+ desc "Build java extension"
0
+ task :build => [:jar] do |t|
0
+ mv 'em_reactor.jar', '../../lib/em_reactor.jar'
0
- suite = Test::Unit::TestSuite.new($name)
0
- ObjectSpace.each_object(Class) do |testcase|
0
- suite << testcase.suite if testcase < Test::Unit::TestCase
0
+ desc "compile .java to .class"
0
+ sh 'javac com/rubyeventmachine/*.java'
0
+ desc "compile .classes to .jar"
0
+ task :jar => [:compile] do
0
+ sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class"
0
-desc "Run tests for #$name."
0
-desc "Run tests for #$name."
0
-task :test_partial do |t|
0
- run_tests t, :extension, [
0
- "test_httpclient2.rb",
0
-desc "Run pure-ruby tests for #$name."
0
- run_tests t, :pure_ruby
0
-desc "Run extension tests for #$name."
0
- run_tests t, :extension
0
-desc "PROVISIONAL: run tests for user-defined events"
0
- run_tests t, :extension, "test_ud.rb"
0
-desc "PROVISIONAL: run tests for line/text protocol handler"
0
- run_tests t, :extension, "test_ltp*.rb"
0
-desc "PROVISIONAL: run tests for header/content protocol handler"
0
- run_tests t, :extension, "test_hc.rb"
0
-desc "PROVISIONAL: run tests for exceptions"
0
- run_tests t, :extension, "test_exc.rb"
0
-desc "Test protocol handlers"
0
-task :test_protocols => [ :test_hc, :test_ltp ]
0
-desc "Test HTTP client"
0
-task :test_httpclient do |t|
0
- run_tests t, :extension, "test_httpclient.rb"
0
-desc "Test HTTP client2"
0
-task :test_httpclient2 do |t|
0
- run_tests t, :extension, "test_httpclient2.rb"
0
-task :test_futures do |t|
0
- run_tests t, :extension, "test_future*.rb"
0
-task :test_timers do |t|
0
- run_tests t, :extension, "test_timer*.rb"
0
-task :test_next_tick do |t|
0
- run_tests t, :extension, "test_next_tick*.rb"
0
-task :test_epoll do |t|
0
- run_tests t, :extension, "test_epoll*.rb"
0
-task :test_servers do |t|
0
- run_tests t, :extension, "test_servers*.rb"
0
-task :test_basic do |t|
0
- run_tests t, :extension, "test_basic*.rb"
0
-task :test_send_file do |t|
0
- run_tests t, :extension, "test_send_file*.rb"
0
-task :test_running do |t|
0
- run_tests t, :extension, "test_running*.rb"
0
-desc "Test Keyboard Events"
0
-task :test_keyboard do |t|
0
- run_tests t, :extension, "test_kb*.rb"
0
-task :test_spawn do |t|
0
- run_tests t, :spawn, "test_spawn*.rb"
0
- run_tests t, :extension, "test_smtp*.rb"
0
-task :test_errors do |t|
0
- run_tests t, :extension, "test_errors*.rb"
0
- run_tests t, :extension, "test_pure*.rb"
0
-task :test_processes do |t|
0
- run_tests t, :extension, "test_process*.rb"
0
- run_tests t, :extension, "test_sasl*.rb"
0
-task :test_attach do |t|
0
- run_tests t, :extension, "test_attach*.rb"
0
-desc "Build everything"
0
-task :default => [ :gem ]
0
-# This task is useful for development.
0
-desc "Compile the extension."
0
- Dir.mkdir "nonversioned" unless File.directory?("nonversioned")
0
- Dir.chdir "nonversioned"
0
- system "ruby ../ext/extconf.rb"
0
- system "cp *.so ../lib" or system "copy *.so ../lib"
0
-# This task creates the JRuby JAR file and leaves it in the lib directory.
0
-# This step is required before executing the jgem task.