diff options
| author | Misty De Meo | 2015-04-25 02:03:00 -0700 |
|---|---|---|
| committer | Misty De Meo | 2015-04-25 12:45:31 -0700 |
| commit | f5d6d80d5bac2c83a89021481812b461c54cfba3 (patch) | |
| tree | 416baa36ba538d977fe30ef577ee9567792a9496 /Library/Homebrew/extend | |
| parent | 789390f3784707dd4f0855f5b3040e9e1fedfae6 (diff) | |
| download | brew-f5d6d80d5bac2c83a89021481812b461c54cfba3.tar.bz2 | |
ENV.deparallelize: add block form for temporary change
Closes Homebrew/homebrew#39026.
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/ENV/std.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 15 |
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 |
