[前][次][番号順一覧][スレッド一覧]

ruby-changes:73905

From: Hiroshi <ko1@a...>
Date: Fri, 7 Oct 2022 15:21:02 +0900 (JST)
Subject: [ruby-changes:73905] 4f78560cf1 (master): Add --with-libffi-source-dir feature and removed --enable-bundled-libffi option. (#113)

https://git.ruby-lang.org/ruby.git/commit/?id=4f78560cf1

From 4f78560cf12ad4979a5953bbf38d05e2bf264d21 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 7 Oct 2022 15:18:00 +0900
Subject: Add --with-libffi-source-dir feature and removed
 --enable-bundled-libffi option. (#113)

https://bugs.ruby-lang.org/issues/18571

Co-authored-by: Nobuyoshi Nakada <nobu@r...>
Co-authored-by: Sutou Kouhei <kou@c...>
---
 ext/fiddle/extconf.rb       | 28 ++++++----------------------
 ext/fiddle/fiddle.gemspec   |  3 ---
 test/fiddle/test_handle.rb  |  3 +++
 test/fiddle/test_pointer.rb |  3 +++
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
index 93b4f9d4fa..d550d23f79 100644
--- a/ext/fiddle/extconf.rb
+++ b/ext/fiddle/extconf.rb
@@ -46,7 +46,7 @@ end https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L46
 
 libffi_version = nil
 have_libffi = false
-bundle = enable_config('bundled-libffi')
+bundle = with_config("libffi-source-dir")
 unless bundle
   dir_config 'libffi'
 
@@ -67,27 +67,11 @@ unless bundle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L67
 end
 
 unless have_libffi
-  # for https://github.com/ruby/fiddle
-  extlibs_rb = File.expand_path("../../bin/extlibs.rb", $srcdir)
-  if bundle && File.exist?(extlibs_rb)
-    require "fileutils"
-    require_relative "../../bin/extlibs"
-    extlibs = ExtLibs.new
-    cache_dir = File.expand_path("../../tmp/.download_cache", $srcdir)
-    ext_dir = File.expand_path("../../ext", $srcdir)
-    Dir.glob("#{$srcdir}/libffi-*/").each{|dir| FileUtils.rm_rf(dir)}
-    extlibs.run(["--cache=#{cache_dir}", ext_dir])
-  end
-  if bundle != false
-    libffi_package_name = Dir.glob("#{$srcdir}/libffi-*/")
-                            .map {|n| File.basename(n)}
-                            .max_by {|n| n.scan(/\d+/).map(&:to_i)}
-  end
-  unless libffi_package_name
-    raise "missing libffi. Please install libffi."
+  if bundle
+    libffi_srcdir = libffi_package_name = bundle
+  else
+    raise "missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location."
   end
-
-  libffi_srcdir = "#{$srcdir}/#{libffi_package_name}"
   ffi_header = 'ffi.h'
   libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
   libffi.dir = libffi_package_name
@@ -226,7 +210,7 @@ types.each do |type, signed| https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L210
 end
 
 if libffi
-  $LOCAL_LIBS.prepend("./#{libffi.a} ").strip! # to exts.mk
+  $LOCAL_LIBS.prepend("#{libffi.a} ").strip! # to exts.mk
   $INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)')
 end
 create_makefile 'fiddle' do |conf|
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
index a9c0ec4026..878109395b 100644
--- a/ext/fiddle/fiddle.gemspec
+++ b/ext/fiddle/fiddle.gemspec
@@ -20,15 +20,12 @@ Gem::Specification.new do |spec| https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.gemspec#L20
     "LICENSE.txt",
     "README.md",
     "Rakefile",
-    "bin/downloader.rb",
-    "bin/extlibs.rb",
     "ext/fiddle/closure.c",
     "ext/fiddle/closure.h",
     "ext/fiddle/conversions.c",
     "ext/fiddle/conversions.h",
     "ext/fiddle/depend",
     "ext/fiddle/extconf.rb",
-    "ext/fiddle/extlibs",
     "ext/fiddle/fiddle.c",
     "ext/fiddle/fiddle.h",
     "ext/fiddle/function.c",
diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb
index 3bb80b75e2..c19bcc6623 100644
--- a/test/fiddle/test_handle.rb
+++ b/test/fiddle/test_handle.rb
@@ -189,6 +189,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_handle.rb#L189
     end if /freebsd/=~ RUBY_PLATFORM
 
     def test_no_memory_leak
+      # https://github.com/ruby/fiddle/actions/runs/3202406059/jobs/5231356410
+      omit if RUBY_VERSION >= '3.2'
+
       if respond_to?(:assert_nothing_leaked_memory)
         n_tries = 100_000
         assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
diff --git a/test/fiddle/test_pointer.rb b/test/fiddle/test_pointer.rb
index 7d708ee417..d6cba04bbe 100644
--- a/test/fiddle/test_pointer.rb
+++ b/test/fiddle/test_pointer.rb
@@ -272,6 +272,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_pointer.rb#L272
     end
 
     def test_no_memory_leak
+      # https://github.com/ruby/fiddle/actions/runs/3202406059/jobs/5231356410
+      omit if RUBY_VERSION >= '3.2'
+
       if respond_to?(:assert_nothing_leaked_memory)
         n_tries = 100_000
         assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]