aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/ENV/std.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/extend/ENV/std.rb')
-rw-r--r--Library/Homebrew/extend/ENV/std.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index bea13c173..4f3c9887d 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -78,8 +78,22 @@ module Stdenv
paths.select { |d| File.directory? d }.join(File::PATH_SEPARATOR)
end
+ # Removes the MAKEFLAGS environment variable, causing make to use a single job.
+ # This is useful for makefiles with race conditions.
+ # When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
+ # Returns the value of MAKEFLAGS.
def deparallelize
+ old = self['MAKEFLAGS']
remove 'MAKEFLAGS', /-j\d+/
+ if block_given?
+ begin
+ yield
+ ensure
+ self['MAKEFLAGS'] = old
+ end
+ end
+
+ old
end
alias_method :j1, :deparallelize