From b0b521001e1b93646a32a5705b05fe53ed0cdae7 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 5 Jul 2021 21:45:01 +0100 Subject: [PATCH] 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. --- Library/Homebrew/extend/ENV/super.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index e2ce2e6262..03af1e7b6a 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -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