From f3d3bc436829b5e9212e052cec50cded80cea2df Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 23 Jan 2013 00:26:20 -0600 Subject: [PATCH] Move option comparison into BuildOptions --- Library/Homebrew/bottles.rb | 2 +- Library/Homebrew/extend/ARGV.rb | 8 -------- Library/Homebrew/formula_support.rb | 9 +++++++++ Library/Homebrew/tab.rb | 8 +++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 49d0f75396..cc239bffc9 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -15,7 +15,7 @@ def install_bottle? f and f.downloader.local_bottle_path not ARGV.build_from_source? \ and MacOS.bottles_supported? \ - and ARGV.used_options(f).empty? \ + and f.build.used_options.empty? \ and bottle_current?(f) end diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index e409199aab..5f9b992a85 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -7,14 +7,6 @@ module HomebrewArgvExtension select {|arg| arg[0..0] == '-'} 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 require 'formula' @formulae ||= downcased_unique_named.map{ |name| Formula.factory name } diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index f72358d4d3..9f30afbf7b 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -185,6 +185,7 @@ end # This class holds the build-time options defined for a Formula, # and provides named access to those options during install. class BuildOptions + attr_writer :args include Enumerable def initialize args @@ -253,4 +254,12 @@ class BuildOptions def build_32_bit? @args.include? '--32-bit' end + + def used_options + as_flags & @args.options_only + end + + def unused_options + as_flags - @args.options_only + end end diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index ab0706fdd6..7e229393f7 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -10,14 +10,16 @@ class Tab < OpenStruct FILENAME = 'INSTALL_RECEIPT.json' def self.create f, args + f.build.args = args + sha = HOMEBREW_REPOSITORY.cd do `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle end - Tab.new :used_options => args.used_options(f), - :unused_options => args.unused_options(f), + Tab.new :used_options => f.build.used_options, + :unused_options => f.build.unused_options, :tabfile => f.prefix.join(FILENAME), - :built_as_bottle => !!args.build_bottle?, + :built_as_bottle => !!ARGV.build_bottle?, :tapped_from => f.tap, :time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P :HEAD => sha