Move management of options collection to the spec object
This commit is contained in:
parent
8039107afb
commit
efd63447d8
@ -20,17 +20,6 @@ class BuildOptions
|
|||||||
@args = other.args.dup
|
@args = other.args.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def add(name, description)
|
|
||||||
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 ""
|
|
||||||
end
|
|
||||||
|
|
||||||
@options << Option.new(name, description)
|
|
||||||
end
|
|
||||||
|
|
||||||
def empty?
|
def empty?
|
||||||
@options.empty?
|
@options.empty?
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class Formula
|
|||||||
include Utils::Inreplace
|
include Utils::Inreplace
|
||||||
extend Enumerable
|
extend Enumerable
|
||||||
|
|
||||||
attr_reader :name, :path, :homepage, :build
|
attr_reader :name, :path, :homepage
|
||||||
attr_reader :stable, :devel, :head, :active_spec
|
attr_reader :stable, :devel, :head, :active_spec
|
||||||
attr_reader :pkg_version, :revision
|
attr_reader :pkg_version, :revision
|
||||||
|
|
||||||
@ -38,9 +38,8 @@ class Formula
|
|||||||
|
|
||||||
@active_spec = determine_active_spec(spec)
|
@active_spec = determine_active_spec(spec)
|
||||||
validate_attributes :url, :name, :version
|
validate_attributes :url, :name, :version
|
||||||
@build = determine_build_options
|
active_spec.add_legacy_options(options)
|
||||||
@pkg_version = PkgVersion.new(version, revision)
|
@pkg_version = PkgVersion.new(version, revision)
|
||||||
|
|
||||||
@pin = FormulaPin.new(self)
|
@pin = FormulaPin.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,12 +64,6 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_build_options
|
|
||||||
build = active_spec.build
|
|
||||||
options.each { |opt, desc| build.add(opt, desc) }
|
|
||||||
build
|
|
||||||
end
|
|
||||||
|
|
||||||
def bottle
|
def bottle
|
||||||
Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
|
Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
|
||||||
end
|
end
|
||||||
@ -110,6 +103,10 @@ class Formula
|
|||||||
active_spec.option_defined?(name)
|
active_spec.option_defined?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build
|
||||||
|
active_spec.build
|
||||||
|
end
|
||||||
|
|
||||||
# if the dir is there, but it's empty we consider it not installed
|
# if the dir is there, but it's empty we consider it not installed
|
||||||
def installed?
|
def installed?
|
||||||
(dir = installed_prefix).directory? && dir.children.length > 0
|
(dir = installed_prefix).directory? && dir.children.length > 0
|
||||||
|
|||||||
@ -80,7 +80,15 @@ class SoftwareSpec
|
|||||||
name = name.to_s if Symbol === name
|
name = name.to_s if Symbol === name
|
||||||
raise ArgumentError, "option name is required" if name.empty?
|
raise ArgumentError, "option name is required" if name.empty?
|
||||||
raise ArgumentError, "options should not start with dashes" if name.start_with?("-")
|
raise ArgumentError, "options should not start with dashes" if name.start_with?("-")
|
||||||
build.add(name, description)
|
|
||||||
|
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 ""
|
||||||
|
end
|
||||||
|
|
||||||
|
options << Option.new(name, description)
|
||||||
end
|
end
|
||||||
|
|
||||||
def depends_on spec
|
def depends_on spec
|
||||||
@ -115,6 +123,10 @@ class SoftwareSpec
|
|||||||
options << Option.new("without-#{name}", "Build without #{name} support")
|
options << Option.new("without-#{name}", "Build without #{name} support")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_legacy_options(list)
|
||||||
|
list.each { |opt, desc| options << Option.new(opt[/^--(.+)$/, 1], desc) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class HeadSoftwareSpec < SoftwareSpec
|
class HeadSoftwareSpec < SoftwareSpec
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user