From cf08b71bf8dc94eaaeb1b0cde68b97a7e02ca129 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 23 Jan 2013 00:26:28 -0600 Subject: FormulaInstaller: construct new ARGV from an Options collection The array of options that is passed to the spawned build process is a combination of the current ARGV, options passed in by a dependent formula, and an existing install receipt. The objects that are interacting here each expect the resulting collection to have certain properties, and the expectations are not consistent. Clear up this confusing mess by only dealing with Options collections. This keeps our representation of options uniform across the codebase. We can remove BuildOptions dependency on HomebrewArgvExtension, which allows us to pass any Array-like collection to Tab.create. The only other site inside of FormulaInstaller that uses the array is the #exec call, and there it is splatted and thus we can substitute our Options collection there as well. --- Library/Homebrew/build_options.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Library/Homebrew/build_options.rb') diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb index 1718bc4a0..24c49931f 100644 --- a/Library/Homebrew/build_options.rb +++ b/Library/Homebrew/build_options.rb @@ -7,7 +7,7 @@ class BuildOptions include Enumerable def initialize args - @args = Array.new(args).extend(HomebrewArgvExtension) + @args = Options.coerce(args) @options = Options.new end @@ -37,7 +37,7 @@ class BuildOptions end def include? name - @args.include? '--' + name + args.include? '--' + name end def with? name @@ -55,11 +55,11 @@ class BuildOptions end def head? - @args.flag? '--HEAD' + args.include? '--HEAD' end def devel? - @args.include? '--devel' + args.include? '--devel' end def stable? @@ -68,21 +68,21 @@ class BuildOptions # True if the user requested a universal build. def universal? - @args.include?('--universal') && has_option?('universal') + args.include?('--universal') && has_option?('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') && has_option?('32-bit') + args.include?('--32-bit') && has_option?('32-bit') end def used_options - Options.new((as_flags & @args.options_only).map { |o| Option.new(o) }) + Options.new(@options & @args) end def unused_options - Options.new((as_flags - @args.options_only).map { |o| Option.new(o) }) + Options.new(@options - @args) end end -- cgit v1.2.3