parent
0df4c6a703
commit
d1d52b3467
@ -19,9 +19,9 @@ end
|
||||
module Homebrew extend self
|
||||
def options
|
||||
ff.each do |f|
|
||||
next if f.options.empty?
|
||||
next if f.build.empty?
|
||||
if ARGV.include? '--compact'
|
||||
puts f.options.collect {|o| o[0]} * " "
|
||||
puts f.build.collect {|k,v| k} * " "
|
||||
else
|
||||
puts f.name if ff.length > 1
|
||||
dump_options_for_formula f
|
||||
@ -31,9 +31,9 @@ module Homebrew extend self
|
||||
end
|
||||
|
||||
def dump_options_for_formula f
|
||||
f.options.each do |o|
|
||||
puts o[0]
|
||||
puts "\t"+o[1]
|
||||
f.options.each do |k,v|
|
||||
puts k
|
||||
puts "\t"+v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,6 +59,9 @@ class Formula
|
||||
# If we got an explicit path, use that, else determine from the name
|
||||
@path = path.nil? ? self.class.path(name) : Pathname.new(path)
|
||||
@downloader = download_strategy.new(name, @active_spec)
|
||||
|
||||
# Combine DSL `option` and `def options`
|
||||
options.each {|o| self.class.build.add(o[0], o[1]) }
|
||||
end
|
||||
|
||||
# Derive specs from class ivars
|
||||
@ -160,6 +163,10 @@ class Formula
|
||||
def plist_name; 'homebrew.mxcl.'+name end
|
||||
def plist_path; prefix+(plist_name+'.plist') end
|
||||
|
||||
def build
|
||||
self.class.build
|
||||
end
|
||||
|
||||
# Use the @active_spec to detect the download strategy.
|
||||
# Can be overriden to force a custom download strategy
|
||||
def download_strategy
|
||||
@ -579,6 +586,10 @@ private
|
||||
}
|
||||
end
|
||||
|
||||
def build
|
||||
@build ||= BuildOptions.new(ARGV)
|
||||
end
|
||||
|
||||
def url val=nil, specs=nil
|
||||
if val.nil?
|
||||
return @stable.url if @stable
|
||||
@ -630,6 +641,14 @@ private
|
||||
dependencies.add(dep)
|
||||
end
|
||||
|
||||
def option name, description=nil
|
||||
# Support symbols
|
||||
name = name.to_s
|
||||
raise "Option name is required." if name.empty?
|
||||
raise "Options should not start with dashes." if name[0, 1] == "-"
|
||||
build.add name, description
|
||||
end
|
||||
|
||||
def conflicts_with formula, opts={}
|
||||
message = <<-EOS.undent
|
||||
#{formula} cannot be installed alongside #{name.downcase}.
|
||||
|
@ -151,3 +151,80 @@ EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# This class holds the build-time options defined for a Formula,
|
||||
# and provides named access to those options during install.
|
||||
class BuildOptions
|
||||
|
||||
def initialize args
|
||||
# Take a copy of the args (any string array, actually)
|
||||
@args = Array.new(args)
|
||||
# Extend it into an ARGV extension
|
||||
@args.extend(HomebrewArgvExtension)
|
||||
@options = []
|
||||
end
|
||||
|
||||
def add name, description=nil
|
||||
if description.nil?
|
||||
case name
|
||||
when :universal, "universal"
|
||||
description = "Build a universal binary."
|
||||
when "32-bit"
|
||||
description = "Build 32-bit only."
|
||||
else
|
||||
description = ""
|
||||
end
|
||||
end
|
||||
|
||||
@options << [name, description]
|
||||
end
|
||||
|
||||
def has_option? name
|
||||
@options.any? {|o| o[0] == name}
|
||||
end
|
||||
|
||||
def empty?
|
||||
@options.empty?
|
||||
end
|
||||
|
||||
def collect
|
||||
@options.collect {|o| yield o[0], o[1]}
|
||||
end
|
||||
|
||||
def each
|
||||
@options.each {|o| yield o[0], o[1]}
|
||||
end
|
||||
|
||||
def include? name
|
||||
@args.include? '--' + name
|
||||
end
|
||||
|
||||
def using? name
|
||||
@args.include? '--' + name
|
||||
end
|
||||
|
||||
def head?
|
||||
@args.flag? '--HEAD'
|
||||
end
|
||||
|
||||
def devel?
|
||||
@args.include? '--devel'
|
||||
end
|
||||
|
||||
def stable?
|
||||
not (head? or devel?)
|
||||
end
|
||||
|
||||
# True if the user requested a universal build.
|
||||
def universal?
|
||||
@args.include? '--universal'
|
||||
end
|
||||
|
||||
# Request a 32-bit only build.
|
||||
# This is needed for some use-cases though we prefer to build Universal
|
||||
# when a 32-bit version is needed.
|
||||
def build_32_bit?
|
||||
@args.include? '--32-bit'
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user