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>
This commit is contained in:
parent
92f0c53934
commit
4f78560cf1
@ -46,7 +46,7 @@ end
|
|||||||
|
|
||||||
libffi_version = nil
|
libffi_version = nil
|
||||||
have_libffi = false
|
have_libffi = false
|
||||||
bundle = enable_config('bundled-libffi')
|
bundle = with_config("libffi-source-dir")
|
||||||
unless bundle
|
unless bundle
|
||||||
dir_config 'libffi'
|
dir_config 'libffi'
|
||||||
|
|
||||||
@ -67,27 +67,11 @@ unless bundle
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless have_libffi
|
unless have_libffi
|
||||||
# for https://github.com/ruby/fiddle
|
if bundle
|
||||||
extlibs_rb = File.expand_path("../../bin/extlibs.rb", $srcdir)
|
libffi_srcdir = libffi_package_name = bundle
|
||||||
if bundle && File.exist?(extlibs_rb)
|
else
|
||||||
require "fileutils"
|
raise "missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location."
|
||||||
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
|
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."
|
|
||||||
end
|
|
||||||
|
|
||||||
libffi_srcdir = "#{$srcdir}/#{libffi_package_name}"
|
|
||||||
ffi_header = 'ffi.h'
|
ffi_header = 'ffi.h'
|
||||||
libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
|
libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
|
||||||
libffi.dir = libffi_package_name
|
libffi.dir = libffi_package_name
|
||||||
@ -226,7 +210,7 @@ types.each do |type, signed|
|
|||||||
end
|
end
|
||||||
|
|
||||||
if libffi
|
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)')
|
$INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)')
|
||||||
end
|
end
|
||||||
create_makefile 'fiddle' do |conf|
|
create_makefile 'fiddle' do |conf|
|
||||||
|
@ -20,15 +20,12 @@ Gem::Specification.new do |spec|
|
|||||||
"LICENSE.txt",
|
"LICENSE.txt",
|
||||||
"README.md",
|
"README.md",
|
||||||
"Rakefile",
|
"Rakefile",
|
||||||
"bin/downloader.rb",
|
|
||||||
"bin/extlibs.rb",
|
|
||||||
"ext/fiddle/closure.c",
|
"ext/fiddle/closure.c",
|
||||||
"ext/fiddle/closure.h",
|
"ext/fiddle/closure.h",
|
||||||
"ext/fiddle/conversions.c",
|
"ext/fiddle/conversions.c",
|
||||||
"ext/fiddle/conversions.h",
|
"ext/fiddle/conversions.h",
|
||||||
"ext/fiddle/depend",
|
"ext/fiddle/depend",
|
||||||
"ext/fiddle/extconf.rb",
|
"ext/fiddle/extconf.rb",
|
||||||
"ext/fiddle/extlibs",
|
|
||||||
"ext/fiddle/fiddle.c",
|
"ext/fiddle/fiddle.c",
|
||||||
"ext/fiddle/fiddle.h",
|
"ext/fiddle/fiddle.h",
|
||||||
"ext/fiddle/function.c",
|
"ext/fiddle/function.c",
|
||||||
|
@ -189,6 +189,9 @@ module Fiddle
|
|||||||
end if /freebsd/=~ RUBY_PLATFORM
|
end if /freebsd/=~ RUBY_PLATFORM
|
||||||
|
|
||||||
def test_no_memory_leak
|
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)
|
if respond_to?(:assert_nothing_leaked_memory)
|
||||||
n_tries = 100_000
|
n_tries = 100_000
|
||||||
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
|
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
|
||||||
|
@ -272,6 +272,9 @@ module Fiddle
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_no_memory_leak
|
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)
|
if respond_to?(:assert_nothing_leaked_memory)
|
||||||
n_tries = 100_000
|
n_tries = 100_000
|
||||||
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
|
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user