From 341265c4a27cc61f6e562a4b350428a07b4a6f18 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Tue, 17 Sep 2024 13:56:43 +0300 Subject: [PATCH 1/3] Skip building on TruffleRuby --- Rakefile | 10 +++++++--- ext/fiddle/extconf.rb | 5 +++++ lib/fiddle.rb | 9 ++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) 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..422b121c 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -1,6 +1,11 @@ # frozen_string_literal: true require 'mkmf' +if RUBY_ENGINE != 'ruby' + File.write('Makefile', dummy_makefile("").join) + return +end + # :stopdoc: def gcc? 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' From 3f6ac2b4f7a7eafad37647e69f637ebca994b98d Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Tue, 17 Sep 2024 18:36:16 +0300 Subject: [PATCH 2/3] Update CI workflow and build and install gems on TruffleRuby and JRuby --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9941930..9c6b9a17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,6 +73,31 @@ jobs: cd tmp ruby test/run.rb + # Don't run tests on TruffleRuby and JRuby because tests don't pass on them yet. + # So check only gem installing. + install: + name: >- + Install ${{ matrix.ruby }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: + - truffleruby + - jruby + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - run: rake install + + - run: ruby -e 'require "fiddle"' + docker: name: >- ${{ matrix.service }} From 58193bdf39a2186906cdd82630a1f854970a60c2 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 26 Sep 2024 14:47:34 +0200 Subject: [PATCH 3/3] Avoid adding a non-normalized path to $LOAD_PATH in tests * This is necessary to run Fiddle tests on non-CRuby. --- test/run.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run.rb b/test/run.rb index 454058f4..90992ad3 100755 --- a/test/run.rb +++ b/test/run.rb @@ -2,7 +2,7 @@ $VERBOSE = true -source_dir = "#{__dir__}/.." +source_dir = File.dirname(__dir__) $LOAD_PATH.unshift("#{source_dir}/test") $LOAD_PATH.unshift("#{source_dir}/lib")