mkmf.rb: clean generated files

* lib/mkmf.rb (try_link0): remove generated files other than the
  executable file.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-02-27 05:55:32 +00:00
parent e3e2a2c715
commit afdd2fa7e9

View File

@ -526,6 +526,7 @@ MSG
end end
def try_link0(src, opt="", *opts, &b) # :nodoc: def try_link0(src, opt="", *opts, &b) # :nodoc:
exe = CONFTEST+$EXEEXT
cmd = link_command("", opt) cmd = link_command("", opt)
if $universal if $universal
require 'tmpdir' require 'tmpdir'
@ -539,7 +540,10 @@ MSG
end end
else else
try_do(src, cmd, *opts, &b) try_do(src, cmd, *opts, &b)
end and File.executable?(CONFTEST+$EXEEXT) end and File.executable?(exe) or return nil
exe
ensure
MakeMakefile.rm_rf(*Dir["#{CONFTEST}*"]-[exe])
end end
# Returns whether or not the +src+ can be compiled as a C source and linked # Returns whether or not the +src+ can be compiled as a C source and linked
@ -553,10 +557,9 @@ MSG
# [+src+] a String which contains a C source # [+src+] a String which contains a C source
# [+opt+] a String which contains linker options # [+opt+] a String which contains linker options
def try_link(src, opt="", *opts, &b) def try_link(src, opt="", *opts, &b)
try_link0(src, opt, *opts, &b) exe = try_link0(src, opt, *opts, &b) or return false
ensure MakeMakefile.rm_f exe
MakeMakefile.rm_f "#{CONFTEST}*" true
MakeMakefile.rm_rf "#{CONFTEST}.dSYM"
end end
# Returns whether or not the +src+ can be compiled as a C source. +opt+ is # Returns whether or not the +src+ can be compiled as a C source. +opt+ is
@ -730,7 +733,7 @@ int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const
end end
end end
ensure ensure
MakeMakefile.rm_f "#{CONFTEST}*" MakeMakefile.rm_f "#{CONFTEST}#{$EXEEXT}"
end end
end end
nil nil