Move option comparison into BuildOptions

This commit is contained in:
Jack Nagel 2013-01-23 00:26:20 -06:00
parent d8a83073ff
commit f3d3bc4368
4 changed files with 15 additions and 12 deletions

View File

@ -15,7 +15,7 @@ def install_bottle? f
and f.downloader.local_bottle_path and f.downloader.local_bottle_path
not ARGV.build_from_source? \ not ARGV.build_from_source? \
and MacOS.bottles_supported? \ and MacOS.bottles_supported? \
and ARGV.used_options(f).empty? \ and f.build.used_options.empty? \
and bottle_current?(f) and bottle_current?(f)
end end

View File

@ -7,14 +7,6 @@ module HomebrewArgvExtension
select {|arg| arg[0..0] == '-'} select {|arg| arg[0..0] == '-'}
end end
def used_options f
f.build.as_flags & options_only
end
def unused_options f
f.build.as_flags - options_only
end
def formulae def formulae
require 'formula' require 'formula'
@formulae ||= downcased_unique_named.map{ |name| Formula.factory name } @formulae ||= downcased_unique_named.map{ |name| Formula.factory name }

View File

@ -185,6 +185,7 @@ end
# This class holds the build-time options defined for a Formula, # This class holds the build-time options defined for a Formula,
# and provides named access to those options during install. # and provides named access to those options during install.
class BuildOptions class BuildOptions
attr_writer :args
include Enumerable include Enumerable
def initialize args def initialize args
@ -253,4 +254,12 @@ class BuildOptions
def build_32_bit? def build_32_bit?
@args.include? '--32-bit' @args.include? '--32-bit'
end end
def used_options
as_flags & @args.options_only
end
def unused_options
as_flags - @args.options_only
end
end end

View File

@ -10,14 +10,16 @@ class Tab < OpenStruct
FILENAME = 'INSTALL_RECEIPT.json' FILENAME = 'INSTALL_RECEIPT.json'
def self.create f, args def self.create f, args
f.build.args = args
sha = HOMEBREW_REPOSITORY.cd do sha = HOMEBREW_REPOSITORY.cd do
`git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle
end end
Tab.new :used_options => args.used_options(f), Tab.new :used_options => f.build.used_options,
:unused_options => args.unused_options(f), :unused_options => f.build.unused_options,
:tabfile => f.prefix.join(FILENAME), :tabfile => f.prefix.join(FILENAME),
:built_as_bottle => !!args.build_bottle?, :built_as_bottle => !!ARGV.build_bottle?,
:tapped_from => f.tap, :tapped_from => f.tap,
:time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P :time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P
:HEAD => sha :HEAD => sha