aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/software_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/software_spec.rb')
-rw-r--r--Library/Homebrew/software_spec.rb30
1 files changed, 17 insertions, 13 deletions
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 390f31e17..867d10393 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -11,6 +11,12 @@ require 'patch'
class SoftwareSpec
extend Forwardable
+ PREDEFINED_OPTIONS = {
+ :universal => Option.new("universal", "Build a universal binary"),
+ :cxx11 => Option.new("c++11", "Build using C++11 mode"),
+ "32-bit" => Option.new("32-bit", "Build 32-bit only"),
+ }
+
attr_reader :name, :owner
attr_reader :build, :resources, :patches, :options
attr_reader :dependency_collector
@@ -75,20 +81,18 @@ class SoftwareSpec
options.include?(name)
end
- def option name, description=nil
- name = 'c++11' if name == :cxx11
- name = name.to_s if Symbol === name
- raise ArgumentError, "option name is required" if name.empty?
- raise ArgumentError, "options should not start with dashes" if name.start_with?("-")
-
- description ||= case name
- when "universal" then "Build a universal binary"
- when "32-bit" then "Build 32-bit only"
- when "c++11" then "Build using C++11 mode"
- else ""
+ def option(name, description="")
+ opt = PREDEFINED_OPTIONS.fetch(name) do
+ if Symbol === name
+ opoo "Passing arbitrary symbols to `option` is deprecated: #{name.inspect}"
+ puts "Symbols are reserved for future use, please pass a string instead"
+ name = name.to_s
end
-
- options << Option.new(name, description)
+ raise ArgumentError, "option name is required" if name.empty?
+ raise ArgumentError, "options should not start with dashes" if name.start_with?("-")
+ Option.new(name, description)
+ end
+ options << opt
end
def depends_on spec