extend/ENV/super: allow O{1,0} to accept a block

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.
This commit is contained in:
Carlo Cabrera 2021-07-05 21:45:01 +01:00
parent 3cbf7b7e9e
commit b0b521001e
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -338,8 +338,12 @@ module Superenv
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