ruby-changes:33510
From: akr <ko1@a...>
Date: Tue, 15 Apr 2014 19:29:07 +0900 (JST)
Subject: [ruby-changes:33510] akr:r45591 (trunk): * ext/extmk.rb: Re-generate extmk.mk and dummy makefiles only if
akr 2014-04-15 19:29:01 +0900 (Tue, 15 Apr 2014) New Revision: 45591 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45591 Log: * ext/extmk.rb: Re-generate extmk.mk and dummy makefiles only if really required. This fixes a problem to run multiple test-all concurrently as: make test-all & make test-all & make test-all & ... Modified files: trunk/ChangeLog trunk/ext/extmk.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 45590) +++ ChangeLog (revision 45591) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Apr 15 19:26:05 2014 Tanaka Akira <akr@f...> + + * ext/extmk.rb: Re-generate extmk.mk and dummy makefiles only if + really required. + This fixes a problem to run multiple test-all concurrently as: + make test-all & make test-all & make test-all & ... + Tue Apr 15 12:49:53 2014 Sam Rawlins <sam.rawlins@g...> * enum.c (enum_each_slice, enum_each_cons): make more efficient by Index: ext/extmk.rb =================================================================== --- ext/extmk.rb (revision 45590) +++ ext/extmk.rb (revision 45591) @@ -69,6 +69,18 @@ def system(*args) https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L69 super end +def atomic_write_open(filename) + filename_new = filename + ".new.#$$" + open(filename_new, "wb") do |f| + yield f + end + if File.binread(filename_new) != (File.binread(filename) rescue nil) + File.rename(filename_new, filename) + else + File.unlink(filename_new) + end +end + def extract_makefile(makefile, keep = true) m = File.read(makefile) if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1]) @@ -229,7 +241,7 @@ def extmake(target) https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L241 f.truncate(f.pos) end unless $static else - open(makefile, "wb") do |f| + atomic_write_open(makefile) do |f| f.puts "# " + DUMMY_SIGNATURE f.print(*dummy_makefile(CONFIG["srcdir"])) end @@ -636,7 +648,7 @@ $mflags.unshift("topdir=#$topdir") https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L648 ENV.delete("RUBYOPT") if $configure_only and $command_output exts.map! {|d| "ext/#{d}/."} - open($command_output, "wb") do |mf| + atomic_write_open($command_output) do |mf| mf.puts "V = 0" mf.puts "Q1 = $(V:1=)" mf.puts "Q = $(Q1:0=@)" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/