aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-15 10:29:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-15 10:29:01 +0000
commit07b12e1ee2a59156d970864af0e3bd82f18e97b5 (patch)
tree270bc7e52eb02b46f96a3081da7367d94448d8d8
parentd9a177521f82ac439aa0333672a6da11570db80b (diff)
downloadruby-07b12e1ee2a59156d970864af0e3bd82f18e97b5.tar.gz
* 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 & ... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rwxr-xr-xext/extmk.rb16
2 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a6ea1e48e..f1eed88bc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Apr 15 19:26:05 2014 Tanaka Akira <akr@fsij.org>
+
+ * 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@gmail.com>
* enum.c (enum_each_slice, enum_each_cons): make more efficient by
diff --git a/ext/extmk.rb b/ext/extmk.rb
index ef9afa0676..97819ff4a5 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -69,6 +69,18 @@ def system(*args)
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)
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")
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=@)"