Skip to content
Snippets Groups Projects
Commit efd63447 authored by Jack Nagel's avatar Jack Nagel
Browse files

Move management of options collection to the spec object

parent 8039107a
No related branches found
No related tags found
No related merge requests found
......@@ -20,17 +20,6 @@ class BuildOptions
@args = other.args.dup
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?
@options.empty?
end
......
......@@ -16,7 +16,7 @@ class Formula
include Utils::Inreplace
extend Enumerable
attr_reader :name, :path, :homepage, :build
attr_reader :name, :path, :homepage
attr_reader :stable, :devel, :head, :active_spec
attr_reader :pkg_version, :revision
......@@ -38,9 +38,8 @@ class Formula
@active_spec = determine_active_spec(spec)
validate_attributes :url, :name, :version
@build = determine_build_options
active_spec.add_legacy_options(options)
@pkg_version = PkgVersion.new(version, revision)
@pin = FormulaPin.new(self)
end
......@@ -65,12 +64,6 @@ class Formula
end
end
def determine_build_options
build = active_spec.build
options.each { |opt, desc| build.add(opt, desc) }
build
end
def bottle
Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
end
......@@ -110,6 +103,10 @@ class Formula
active_spec.option_defined?(name)
end
def build
active_spec.build
end
# if the dir is there, but it's empty we consider it not installed
def installed?
(dir = installed_prefix).directory? && dir.children.length > 0
......
......@@ -80,7 +80,15 @@ class SoftwareSpec
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?("-")
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
def depends_on spec
......@@ -115,6 +123,10 @@ class SoftwareSpec
options << Option.new("without-#{name}", "Build without #{name} support")
end
end
def add_legacy_options(list)
list.each { |opt, desc| options << Option.new(opt[/^--(.+)$/, 1], desc) }
end
end
class HeadSoftwareSpec < SoftwareSpec
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment