diff options
| author | Jack Nagel | 2013-01-23 00:26:28 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-26 12:14:47 -0600 |
| commit | cf08b71bf8dc94eaaeb1b0cde68b97a7e02ca129 (patch) | |
| tree | def0a5578f371e60cf1d340637f9b9f33d97d2f1 /Library/Homebrew/formula_installer.rb | |
| parent | 046d802d0994be84802c6c50b6336b27b6d8ddd5 (diff) | |
| download | brew-cf08b71bf8dc94eaaeb1b0cde68b97a7e02ca129.tar.bz2 | |
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.
Diffstat (limited to 'Library/Homebrew/formula_installer.rb')
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 1e44b18e4..7e4418241 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -17,7 +17,7 @@ class FormulaInstaller @f = ff @show_header = false @ignore_deps = ARGV.ignore_deps? || ARGV.interactive? - @options = [] + @options = Options.new @@attempted ||= Set.new @@ -247,6 +247,17 @@ class FormulaInstaller @build_time ||= Time.now - @start_time unless pour_bottle? or ARGV.interactive? or @start_time.nil? end + def build_argv + @build_argv ||= begin + opts = Options.coerce(ARGV.options_only) + unless opts.include? '--fresh' + opts.concat(options) # from a dependent formula + opts.concat((tab.used_options rescue [])) # from a previous install + end + opts << '--build-from-source' # don't download bottle + end + end + def build FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{f}/*"] @@ -261,16 +272,6 @@ class FormulaInstaller # I'm guessing this is not a good way to do this, but I'm no UNIX guru ENV['HOMEBREW_ERROR_PIPE'] = write.to_i.to_s - args = ARGV.clone - args.concat(tab.used_options.as_flags) unless tab.nil? or args.include? '--fresh' - # FIXME: enforce the download of the non-bottled package - # in the spawned Ruby process. - args << '--build-from-source' - # Add any options that were passed into this FormulaInstaller instance. - # Usually this represents options being passed by a dependent formula. - args.concat options - args.uniq! - fork do begin read.close @@ -281,7 +282,7 @@ class FormulaInstaller '-rbuild', '--', f.path, - *args.options_only + *build_argv rescue Exception => e Marshal.dump(e, write) write.close @@ -300,7 +301,7 @@ class FormulaInstaller raise "Empty installation" if Dir["#{f.prefix}/*"].empty? - Tab.create(f, args).write # INSTALL_RECEIPT.json + Tab.create(f, build_argv).write # INSTALL_RECEIPT.json rescue Exception => e ignore_interrupts do |
