summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2022-01-04 15:03:41 +0100
committerGitHub <noreply@github.com>2022-01-04 15:03:41 +0100
commitc438e3636d578099101379de49c4afeed160e72b (patch)
tree36ca40977ea657a0dba132488d591fecf95377ce
parent517b658f5f72407e1a9e61db0344a9f85dfbc230 (diff)
parent95522535295ea6dceaafe50c4375dbf445f4945e (diff)
downloadffi-c438e3636d578099101379de49c4afeed160e72b.tar.gz
Merge pull request #929 from maierru/fix/shared_tmp_inside_docker
fix unlink error
-rw-r--r--lib/ffi/tools/const_generator.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/ffi/tools/const_generator.rb b/lib/ffi/tools/const_generator.rb
index b681e44..70ba9c2 100644
--- a/lib/ffi/tools/const_generator.rb
+++ b/lib/ffi/tools/const_generator.rb
@@ -105,9 +105,10 @@ module FFI
# @return [nil]
# @raise if a constant is missing and +:required+ was set to +true+ (see {#initialize})
def calculate(options = {})
- binary = File.join Dir.tmpdir, "rb_const_gen_bin_#{Process.pid}"
+ binary_path = nil
Tempfile.open("#{@prefix}.const_generator") do |f|
+ binary_path = f.path + ".bin"
@includes.each do |inc|
f.puts "#include <#{inc}>"
end
@@ -125,7 +126,7 @@ module FFI
f.flush
cc = ENV['CC'] || 'gcc'
- output = `#{cc} #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1`
+ output = `#{cc} #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary_path} 2>&1`
unless $?.success? then
output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
@@ -133,8 +134,8 @@ module FFI
end
end
- output = `#{binary}`
- File.unlink(binary + (FFI::Platform.windows? ? ".exe" : ""))
+ output = `#{binary_path}`
+ File.unlink(binary_path + (FFI::Platform.windows? ? ".exe" : ""))
output.each_line do |line|
line =~ /^(\S+)\s(.*)$/
const = @constants[$1]