Skip to content

Commit 6664aa5

Browse files
authored
Merge pull request #21181 from Homebrew/option-symbols-cleanup
Deprecate `option :cxx11` and `option :universal`
2 parents e0d83ce + a33649d commit 6664aa5

File tree

7 files changed

+13
-122
lines changed

7 files changed

+13
-122
lines changed

Library/Homebrew/formula.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4140,11 +4140,6 @@ def uses_from_macos(dep, bounds = {})
41404140
# Note that for {.depends_on} that are `:optional` or `:recommended`, options
41414141
# are generated automatically.
41424142
#
4143-
# There are also some special options:
4144-
#
4145-
# - `:universal`: build a universal binary/library (e.g. on newer Intel Macs
4146-
# this means a combined x86_64/x86 binary/library).
4147-
#
41484143
# ### Examples
41494144
#
41504145
# ```ruby
@@ -4155,14 +4150,15 @@ def uses_from_macos(dep, bounds = {})
41554150
# option "with-qt", "Text here overwrites what's autogenerated by 'depends_on "qt" => :optional'"
41564151
# ```
41574152
#
4158-
# ```ruby
4159-
# option :universal
4160-
# ```
4161-
#
41624153
# @api public
4163-
sig { params(name: String, description: String).void }
4154+
sig { params(name: T.any(String, Symbol), description: String).void }
41644155
def option(name, description = "")
4165-
specs.each { |spec| spec.option(name, description) }
4156+
case name
4157+
when Symbol
4158+
odeprecated "`option :#{name}`"
4159+
else
4160+
specs.each { |spec| spec.option(name, description) }
4161+
end
41664162
end
41674163

41684164
# Deprecated options are used to rename options and migrate users who used

Library/Homebrew/rubocops/lines.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -830,18 +830,6 @@ def audit_formula(formula_nodes)
830830
problem "Define method `#{method_name(@offensive_node)}` in the class body, not at the top-level"
831831
end
832832

833-
find_instance_method_call(body_node, :build, :universal?) do
834-
next if @formula_name == "wine"
835-
836-
problem "macOS has been 64-bit only since 10.6 so build.universal? is deprecated."
837-
end
838-
839-
find_instance_method_call(body_node, "ENV", :universal_binary) do
840-
next if @formula_name == "wine"
841-
842-
problem "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated."
843-
end
844-
845833
find_instance_method_call(body_node, "ENV", :runtime_cpu_detection) do
846834
next if tap_style_exception? :runtime_cpu_detection_allowlist
847835

Library/Homebrew/rubocops/options.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ module Cop
88
module FormulaAudit
99
# This cop audits `option`s in formulae.
1010
class Options < FormulaCop
11-
DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated."
12-
UNI_DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated."
13-
1411
DEP_OPTION = "Formulae in homebrew/core should not use `deprecated_option`."
1512
OPTION = "Formulae in homebrew/core should not use `option`."
1613

@@ -21,15 +18,10 @@ def audit_formula(formula_nodes)
2118
option_call_nodes = find_every_method_call_by_name(body_node, :option)
2219
option_call_nodes.each do |option_call|
2320
option = parameters(option_call).first
24-
problem DEPRECATION_MSG if regex_match_group(option, /32-bit/)
25-
2621
offending_node(option_call)
2722
option = string_content(option)
28-
problem UNI_DEPRECATION_MSG if option == "universal"
2923

30-
if !/with(out)?-/.match?(option) &&
31-
option != "cxx11" &&
32-
option != "universal"
24+
unless /with(out)?-/.match?(option)
3325
problem "Options should begin with `with` or `without`. " \
3426
"Migrate '--#{option}' with `deprecated_option`."
3527
end

Library/Homebrew/software_spec.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ class SoftwareSpec
2020
extend Forwardable
2121
include OnSystem::MacOSAndLinux
2222

23-
PREDEFINED_OPTIONS = T.let({
24-
universal: Option.new("universal", "Build a universal binary"),
25-
cxx11: Option.new("c++11", "Build using C++11 mode"),
26-
}.freeze, T::Hash[T.any(Symbol, String), Option])
27-
2823
sig { returns(T.nilable(String)) }
2924
attr_reader :name
3025

@@ -207,16 +202,13 @@ def option_defined?(name)
207202
options.include?(name)
208203
end
209204

210-
sig { params(name: T.any(Symbol, String), description: String).void }
205+
sig { params(name: String, description: String).void }
211206
def option(name, description = "")
212-
opt = PREDEFINED_OPTIONS.fetch(name) do
213-
raise ArgumentError, "option name is required" if name.empty?
214-
raise ArgumentError, "option name must be longer than one character: #{name}" if name.length <= 1
215-
raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-")
207+
raise ArgumentError, "option name is required" if name.empty?
208+
raise ArgumentError, "option name must be longer than one character: #{name}" if name.length <= 1
209+
raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-")
216210

217-
Option.new(name, description)
218-
end
219-
options << opt
211+
options << Option.new(name, description)
220212
end
221213

222214
sig { params(hash: T::Hash[T.any(String, Symbol, T::Array[String]), T.any(String, Symbol, T::Array[String])]).void }

Library/Homebrew/test/rubocops/options_spec.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,10 @@
66
subject(:cop) { described_class.new }
77

88
context "when auditing options" do
9-
it "reports an offense when using the 32-bit option" do
10-
expect_offense(<<~RUBY)
11-
class Foo < Formula
12-
url 'https://brew.sh/foo-1.0.tgz'
13-
option "with-32-bit"
14-
^^^^^^^^^^^^^ FormulaAudit/Options: macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
15-
end
16-
RUBY
17-
end
18-
19-
it "reports an offense when using `:universal`" do
20-
expect_offense(<<~RUBY)
21-
class Foo < Formula
22-
url 'https://brew.sh/foo-1.0.tgz'
23-
option :universal
24-
^^^^^^^^^^^^^^^^^ FormulaAudit/Options: macOS has been 64-bit only since 10.6 so universal options are deprecated.
25-
end
26-
RUBY
27-
end
28-
299
it "reports an offense when using bad option names" do
3010
expect_offense(<<~RUBY)
3111
class Foo < Formula
3212
url 'https://brew.sh/foo-1.0.tgz'
33-
option :cxx11
3413
option "examples", "with-examples"
3514
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Options should begin with `with` or `without`. Migrate '--examples' with `deprecated_option`.
3615
end

Library/Homebrew/test/rubocops/text/miscellaneous_spec.rb

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -86,56 +86,6 @@ class Foo < Formula
8686
RUBY
8787
end
8888

89-
it "reports an offense when `build.universal?` is used" do
90-
expect_offense(<<~RUBY)
91-
class Foo < Formula
92-
desc "foo"
93-
url 'https://brew.sh/foo-1.0.tgz'
94-
if build.universal?
95-
^^^^^^^^^^^^^^^^ FormulaAudit/Miscellaneous: macOS has been 64-bit only since 10.6 so build.universal? is deprecated.
96-
"foo"
97-
end
98-
end
99-
RUBY
100-
end
101-
102-
it "reports no offenses when `build.universal?` is used in an exempt formula" do
103-
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/wine.rb")
104-
class Wine < Formula
105-
desc "foo"
106-
url 'https://brew.sh/foo-1.0.tgz'
107-
if build.universal?
108-
"foo"
109-
end
110-
end
111-
RUBY
112-
end
113-
114-
it "reports an offense when `ENV.universal_binary` is used" do
115-
expect_offense(<<~RUBY)
116-
class Foo < Formula
117-
desc "foo"
118-
url 'https://brew.sh/foo-1.0.tgz'
119-
if build?
120-
ENV.universal_binary
121-
^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Miscellaneous: macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated.
122-
end
123-
end
124-
RUBY
125-
end
126-
127-
it "reports no offenses when `ENV.universal_binary` is used in an exempt formula" do
128-
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/wine.rb")
129-
class Wine < Formula
130-
desc "foo"
131-
url 'https://brew.sh/foo-1.0.tgz'
132-
if build?
133-
ENV.universal_binary
134-
end
135-
end
136-
RUBY
137-
end
138-
13989
it "reports an offense when `install_name_tool` is called" do
14090
expect_offense(<<~RUBY)
14191
class Foo < Formula

Library/Homebrew/test/software_spec_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@
7777
end.to raise_error(ArgumentError)
7878
end
7979

80-
it "special cases the cxx11 option" do
81-
spec.option(:cxx11)
82-
expect(spec).to have_defined_option("c++11")
83-
expect(spec).not_to have_defined_option("cxx11")
84-
end
85-
8680
it "supports options with descriptions" do
8781
spec.option("bar", "description")
8882
expect(spec.options.first.description).to eq("description")

0 commit comments

Comments
 (0)