diff --git a/Rakefile b/Rakefile index 004afe5f0..9634f9fb1 100644 --- a/Rakefile +++ b/Rakefile @@ -33,10 +33,6 @@ require 'rake' unless defined?(Rake) Package = false # Build zips and tarballs? Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r } -# e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults! -$eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java' -$eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby' - MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make. 'nmake' else @@ -48,8 +44,7 @@ task :default => [:build, :test] desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib" build_task = 'ext:build' -build_task = 'java:build' if $eventmachine_library == :java -build_task = :dummy_build if $eventmachine_library == :pure_ruby +build_task = 'java:build' if RUBY_PLATFORM =~ /java/ task :build => build_task do |t| Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f| mv f, "lib" diff --git a/lib/pr_eventmachine.rb b/lib/em/pure_ruby.rb similarity index 99% rename from lib/pr_eventmachine.rb rename to lib/em/pure_ruby.rb index 11cd72ac7..9dd14165f 100644 --- a/lib/pr_eventmachine.rb +++ b/lib/em/pure_ruby.rb @@ -34,10 +34,7 @@ require 'fcntl' require 'set' - module EventMachine - - class << self # This is mostly useful for automated tests. # Return a distinctive symbol so the caller knows whether he's dealing diff --git a/lib/eventmachine.rb b/lib/eventmachine.rb index d19f543b0..f7f943283 100644 --- a/lib/eventmachine.rb +++ b/lib/eventmachine.rb @@ -1,75 +1,12 @@ -#-- -# -# Author:: Francis Cianfrocca (gmail: blackhedd) -# Homepage:: http://rubyeventmachine.com -# Date:: 8 Apr 2006 -# -# See EventMachine and EventMachine::Connection for documentation and -# usage examples. -# -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. -# Gmail: blackhedd -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of either: 1) the GNU General Public License -# as published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version; or 2) Ruby's License. -# -# See the file COPYING for complete licensing information. -# -#--------------------------------------------------------------------------- -# -# - - -#-- Select in a library based on a global variable. -# PROVISIONALLY commented out this whole mechanism which selects -# a pure-Ruby EM implementation if the extension is not available. -# I expect this will cause a lot of people's code to break, as it -# exposes misconfigurations and path problems that were masked up -# till now. The reason I'm disabling it is because the pure-Ruby -# code will have problems of its own, and it's not nearly as fast -# anyway. Suggested by a problem report from Moshe Litvin. 05Jun07. -# -# 05Dec07: Re-enabled the pure-ruby mechanism, but without the automatic -# fallback feature that tripped up Moshe Litvin. We shouldn't fail over to -# the pure Ruby version because it's possible that the user intended to -# run the extension but failed to do so because of a compilation or -# similar error. So we require either a global variable or an environment -# string be set in order to select the pure-Ruby version. -# - - -unless defined?($eventmachine_library) - $eventmachine_library = ENV['EVENTMACHINE_LIBRARY'] || :cascade -end -$eventmachine_library = $eventmachine_library.to_sym - -case $eventmachine_library -when :pure_ruby - require 'pr_eventmachine' -when :extension - require 'rubyeventmachine' -when :java +if RUBY_PLATFORM =~ /java/ + require 'java' require 'jeventmachine' -else # :cascade - # This is the case that most user code will take. - # Prefer the extension if available. +else begin - if RUBY_PLATFORM =~ /java/ - require 'java' - require 'jeventmachine' - $eventmachine_library = :java - else - require 'rubyeventmachine' - $eventmachine_library = :extension - end + require 'rubyeventmachine' rescue LoadError - warn "# EventMachine fell back to pure ruby mode" if $DEBUG - require 'pr_eventmachine' - $eventmachine_library = :pure_ruby + warn "Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'" + raise end end diff --git a/tests/test_basic.rb b/tests/test_basic.rb index 16083e8b5..388d465ec 100644 --- a/tests/test_basic.rb +++ b/tests/test_basic.rb @@ -43,35 +43,6 @@ def test_connection_class_cache assert_kind_of EM::Connection, a end - def test_libtype - lt = EventMachine.library_type - em_lib = (ENV["EVENTMACHINE_LIBRARY"] || $eventmachine_library || :xxx).to_sym - - # Running from test runner, under jruby. - if RUBY_PLATFORM == 'java' - unless em_lib == :pure_ruby - assert_equal( :java, lt ) - return - end - end - - case em_lib - when :pure_ruby - assert_equal( :pure_ruby, lt ) - when :extension - assert_equal( :extension, lt ) - when :java - assert_equal( :java, lt ) - else - # Running from jruby as a standalone test. - if RUBY_PLATFORM == 'java' - assert_equal( :java, lt ) - else - assert_equal( :extension, lt ) - end - end - end - #-------------------------------------