From afdd2fa7e9498eb08c276d96440595edd9273be5 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 27 Feb 2017 05:55:32 +0000 Subject: [PATCH] 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 --- lib/mkmf.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 42e39ca454..4a3a105688 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -526,6 +526,7 @@ MSG end def try_link0(src, opt="", *opts, &b) # :nodoc: + exe = CONFTEST+$EXEEXT cmd = link_command("", opt) if $universal require 'tmpdir' @@ -539,7 +540,10 @@ MSG end else 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 # 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 # [+opt+] a String which contains linker options def try_link(src, opt="", *opts, &b) - try_link0(src, opt, *opts, &b) - ensure - MakeMakefile.rm_f "#{CONFTEST}*" - MakeMakefile.rm_rf "#{CONFTEST}.dSYM" + exe = try_link0(src, opt, *opts, &b) or return false + MakeMakefile.rm_f exe + true end # 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 ensure - MakeMakefile.rm_f "#{CONFTEST}*" + MakeMakefile.rm_f "#{CONFTEST}#{$EXEEXT}" end end nil