diff --git a/Rakefile b/Rakefile index aefc9ed5..fb3e8bd4 100644 --- a/Rakefile +++ b/Rakefile @@ -17,8 +17,12 @@ namespace :version do end end -require 'rake/extensiontask' -Rake::ExtensionTask.new("fiddle") -Rake::ExtensionTask.new("-test-/memory_view") +if RUBY_ENGINE == 'ruby' + require 'rake/extensiontask' + Rake::ExtensionTask.new("fiddle") + Rake::ExtensionTask.new("-test-/memory_view") +else + task :compile +end task :default => [:compile, :test] diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 2d85b3ee..f681d9ee 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -1,4 +1,10 @@ # frozen_string_literal: true + +if RUBY_ENGINE != 'ruby' + File.write('Makefile', dummy_makefile("").join) + return +end + require 'mkmf' # :stopdoc: diff --git a/lib/fiddle.rb b/lib/fiddle.rb index 6137c487..cd559dc8 100644 --- a/lib/fiddle.rb +++ b/lib/fiddle.rb @@ -1,6 +1,13 @@ # frozen_string_literal: true -require 'fiddle.so' +if RUBY_ENGINE == "ruby" + require 'fiddle.so' +else + $LOAD_PATH.delete(__dir__) + require 'fiddle' # load from stdlib + return +end + require 'fiddle/closure' require 'fiddle/function' require 'fiddle/version' diff --git a/test/run.rb b/test/run.rb index 454058f4..333531da 100755 --- a/test/run.rb +++ b/test/run.rb @@ -3,8 +3,8 @@ $VERBOSE = true source_dir = "#{__dir__}/.." -$LOAD_PATH.unshift("#{source_dir}/test") -$LOAD_PATH.unshift("#{source_dir}/lib") +$LOAD_PATH.unshift(File.expand_path("#{source_dir}/test")) +$LOAD_PATH.unshift(File.expand_path("#{source_dir}/lib")) build_dir = Dir.pwd if File.exist?("#{build_dir}/fiddle.so")