ext/fiddle/extconf.rb in fiddle-1.0.0.beta1 vs ext/fiddle/extconf.rb in fiddle-1.0.0.beta2
- old
+ new
@@ -1,6 +1,6 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'mkmf'
# :stopdoc:
bundle = enable_config('bundled-libffi')
@@ -16,10 +16,19 @@
$defs.push(format('-DUSE_HEADER_HACKS'))
true
end and (have_library('ffi') || have_library('libffi'))
end or
begin
+ if bundle
+ 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
ver = bundle != false &&
Dir.glob("#{$srcdir}/libffi-*/")
.map {|n| File.basename(n)}
.max_by {|n| n.scan(/\d+/).map(&:to_i)}
unless ver
@@ -39,16 +48,16 @@
end
libffi.include = "#{libffi.builddir}/include"
libffi.lib = "#{libffi.builddir}/.libs"
libffi.a = "#{libffi.lib}/libffi_convenience.#{$LIBEXT}"
nowarn = CONFIG.merge("warnflags"=>"")
- libffi.cflags = RbConfig.expand("$(CFLAGS)", nowarn)
+ libffi.cflags = RbConfig.expand("$(CFLAGS)".dup, nowarn)
ver = ver[/libffi-(.*)/, 1]
FileUtils.mkdir_p(libffi.dir)
libffi.opt = CONFIG['configure_args'][/'(-C)'/, 1]
- libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}")
+ libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}".dup)
libffi.arch = RbConfig::CONFIG['host']
if $mswin
unless find_executable(as = /x64/ =~ libffi.arch ? "ml64" : "ml")
raise "missing #{as} command."
end
@@ -75,10 +84,10 @@
]
args << ($enable_shared || !$static ? '--enable-shared' : '--enable-static')
args << libffi.opt if libffi.opt
args.concat %W[
CC=#{cc} CFLAGS=#{libffi.cflags}
- CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)", nowarn)}
+ CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)".dup, nowarn)}
LD=#{ld} LDFLAGS=#{libffi.ldflags}
]
FileUtils.rm_f("#{libffi.include}/ffitarget.h")
Logging::open do