Skip to content

Commit

Permalink
Merge pull request #11666 from carlocab/optim-block
Browse files Browse the repository at this point in the history
extend/ENV/super: allow `O{1,0}` to accept a block
  • Loading branch information
carlocab committed Jul 8, 2021
2 parents f860734 + 2599ccc commit 805f0ba
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,26 @@ def refurbish_args
append_to_cccfg "O"
end

%w[O1 O0].each do |opt|
define_method opt do
send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt)
# rubocop: disable Naming/MethodName
# Fixes style error `Naming/MethodName: Use snake_case for method names.`
sig { params(block: T.nilable(T.proc.void)).void }
def O0(&block)
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O0", &block)
else
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O0"
end
end

sig { params(block: T.nilable(T.proc.void)).void }
def O1(&block)
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O1", &block)
else
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O1"
end
end
# rubocop: enable Naming/MethodName
end

require "extend/os/extend/ENV/super"

0 comments on commit 805f0ba

Please sign in to comment.