8000 Add --with-libffi-source-dir feature and removed --enable-bundled-lib… · ruby/ruby@4f78560 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f78560

Browse files
hsbtnobukou
committed
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@ruby-lang.org> Co-authored-by: Sutou Kouhei <kou@clear-code.com>
1 parent 92f0c53 commit 4f78560

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

ext/fiddle/extconf.rb

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def enable_debug_build_flag(flags)
4646

4747
libffi_version = nil
4848
have_libffi = false
49-
bundle = enable_config('bundled-libffi')
49+
bundle = with_config("libffi-source-dir")
5050
unless bundle
5151
dir_config 'libffi'
5252

@@ -67,27 +67,11 @@ def enable_debug_build_flag(flags)
6767
end
6868

6969
unless have_libffi
70-
# for https://github.com/ruby/fiddle
71-
extlibs_rb = File.expand_path("../../bin/extlibs.rb", $srcdir)
72-
if bundle && File.exist?(extlibs_rb)
73-
require "fileutils"
74-
require_relative "../../bin/extlibs"
75-
extlibs = ExtLibs.new
76-
cache_dir = File.expand_path("../../tmp/.download_cache", $srcdir)
77-
ext_dir = File.expand_path("../../ext", $srcdir)
78-
Dir.glob("#{$srcdir}/libffi-*/").each{|dir| FileUtils.rm_rf(dir)}
79-
extlibs.run(["--cache=#{cache_dir}"< 8000 /span>, ext_dir])
80-
end
81-
if bundle != false
82-
libffi_package_name = Dir.glob("#{$srcdir}/libffi-*/")
83-
.map {|n| File.basename(n)}
84-
.max_by {|n| n.scan(/\d+/).map(&:to_i)}
85-
end
86-
unless libffi_package_name
87-
raise "missing libffi. Please install libffi."
70+
if bundle
71+
libffi_srcdir = libffi_package_name = bundle
72+
else
73+
raise "missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location."
8874
end
89-
90-
libffi_srcdir = "#{$srcdir}/#{libffi_package_name}"
9175
ffi_header = 'ffi.h'
9276
libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
9377
libffi.dir = libffi_package_name
@@ -226,7 +210,7 @@ def enable_debug_build_flag(flags)
226210
end
227211

228212
if libffi
229-
$LOCAL_LIBS.prepend("./#{libffi.a} ").strip! # to exts.mk
213+
$LOCAL_LIBS.prepend("#{libffi.a} ").strip! # to exts.mk
230214
$INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)')
231215
end
232216
create_makefile 'fiddle' do |conf|

ext/fiddle/fiddle.gemspec

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@ Gem::Specification.new do |spec|
2020
"LICENSE.txt",
2121
"README.md",
2222
"Rakefile",
23-
"bin/downloader.rb",
24-
"bin/extlibs.rb",
2523
"ext/fiddle/closure.c",
2624
"ext/fiddle/closure.h",
2725
"ext/fiddle/conversions.c",
2826
"ext/fiddle/conversions.h",
2927
"ext/fiddle/depend",
3028
"ext/fiddle/extconf.rb",
31-
"ext/fiddle/extlibs",
3229
"ext/fiddle/fiddle.c",
3330
"ext/fiddle/fiddle.h",
3431
"ext/fiddle/function.c",

test/fiddle/test_handle.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ def test_dlerror
189189
end if /freebsd/=~ RUBY_PLATFORM
190190

191191
def test_no_memory_leak
192+
# https://github.com/ruby/fiddle/actions/runs/3202406059/jobs/5231356410
193+
omit if RUBY_VERSION >= '3.2'
194+
192195
if respond_to?(:assert_nothing_leaked_memory)
193196
n_tries = 100_000
194197
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do

test/fiddle/test_pointer.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ def test_null_pointer
272272
end
273273

274274
def test_no_memory_leak
275+
# https://github.com/ruby/fiddle/actions/runs/3202406059/jobs/5231356410
276+
omit if RUBY_VERSION >= '3.2'
277+
275278
if respond_to?(:assert_nothing_leaked_memory)
276279
n_tries = 100_000
277280
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do

0 commit comments

Comments
 (0)
0