aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/ENV
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/extend/ENV')
-rw-r--r--Library/Homebrew/extend/ENV/std.rb14
-rw-r--r--Library/Homebrew/extend/ENV/super.rb15
2 files changed, 28 insertions, 1 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
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index d03f10981..603e4c052 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -241,8 +241,21 @@ module Superenv
public
+ # 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
- delete('MAKEFLAGS')
+ old = delete('MAKEFLAGS')
+ if block_given?
+ begin
+ yield
+ ensure
+ self['MAKEFLAGS'] = old
+ end
+ end
+
+ old
end
alias_method :j1, :deparallelize