Skip to content

Commit

Permalink
extend/ENV/super: allow O{1,0} to accept a block
Browse files Browse the repository at this point in the history
This makes `ENV.O{1,0}` behave like `ENV.deparallelize`.

This should also allow us to build libgcrypt's jitter entropy collector,
which we currently disable because it interacts poorly with our compiler
shims. See #11201.
  • Loading branch information
carlocab committed Jul 8, 2021
1 parent 3cbf7b7 commit b0b5210
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,12 @@ def refurbish_args
end

%w[O1 O0].each do |opt|
define_method opt do
send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt)
define_method opt do |&block|
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: opt) { block.call }
else
send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt)
end
end
end
end
Expand Down

0 comments on commit b0b5210

Please sign in to comment.