Pass args to FormulaInstaller instead of using global args.
This commit is contained in:
parent
919adcc216
commit
620ca4177e
@ -60,7 +60,7 @@ module Homebrew
|
|||||||
|
|
||||||
def print_formula_cache(name, args:)
|
def print_formula_cache(name, args:)
|
||||||
formula = Formulary.factory(name, force_bottle: args.force_bottle?, flags: args.flags_only)
|
formula = Formulary.factory(name, force_bottle: args.force_bottle?, flags: args.flags_only)
|
||||||
if fetch_bottle?(formula)
|
if fetch_bottle?(formula, args: args)
|
||||||
puts formula.bottle.cached_download
|
puts formula.bottle.cached_download
|
||||||
else
|
else
|
||||||
puts formula.cached_download
|
puts formula.cached_download
|
||||||
|
|||||||
@ -46,7 +46,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
fetch_args.parse
|
args = fetch_args.parse
|
||||||
|
|
||||||
if args.deps?
|
if args.deps?
|
||||||
bucket = []
|
bucket = []
|
||||||
@ -64,7 +64,7 @@ module Homebrew
|
|||||||
f.print_tap_action verb: "Fetching"
|
f.print_tap_action verb: "Fetching"
|
||||||
|
|
||||||
fetched_bottle = false
|
fetched_bottle = false
|
||||||
if fetch_bottle?(f)
|
if fetch_bottle?(f, args: args)
|
||||||
begin
|
begin
|
||||||
fetch_formula(f.bottle)
|
fetch_formula(f.bottle)
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
|
|||||||
@ -325,7 +325,7 @@ module Homebrew
|
|||||||
build_options = f.build
|
build_options = f.build
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
||||||
build_from_source: args.build_from_source?)
|
build_from_source: args.build_from_source?, args: args)
|
||||||
fi.options = build_options.used_options
|
fi.options = build_options.used_options
|
||||||
fi.env = args.env
|
fi.env = args.env
|
||||||
fi.force = args.force?
|
fi.force = args.force?
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Fetch
|
module Fetch
|
||||||
def fetch_bottle?(f)
|
def fetch_bottle?(f, args:)
|
||||||
return true if args.force_bottle? && f.bottle
|
return true if args.force_bottle? && f.bottle
|
||||||
return false unless f.bottle && f.pour_bottle?
|
return false unless f.bottle && f.pour_bottle?
|
||||||
return false if args.build_formula_from_source?(f)
|
return false if args.build_formula_from_source?(f)
|
||||||
|
|||||||
@ -39,15 +39,16 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :formula
|
attr_reader :formula
|
||||||
attr_accessor :cc, :env, :options, :build_bottle, :bottle_arch,
|
attr_accessor :cc, :env, :args, :options, :build_bottle, :bottle_arch,
|
||||||
:installed_as_dependency, :installed_on_request, :link_keg
|
:installed_as_dependency, :installed_on_request, :link_keg, :other_installers
|
||||||
|
|
||||||
mode_attr_accessor :show_summary_heading, :show_header
|
mode_attr_accessor :show_summary_heading, :show_header
|
||||||
mode_attr_accessor :build_from_source, :force_bottle, :include_test
|
mode_attr_accessor :build_from_source, :force_bottle, :include_test
|
||||||
mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git, :force, :keep_tmp
|
mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git, :force, :keep_tmp
|
||||||
mode_attr_accessor :verbose, :debug, :quiet
|
mode_attr_accessor :verbose, :debug, :quiet
|
||||||
|
|
||||||
def initialize(formula, force_bottle: false, include_test: false, build_from_source: false, cc: nil)
|
def initialize(formula, force_bottle: false, include_test: false, build_from_source: false, cc: nil, args: nil)
|
||||||
|
@args = args
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@env = nil
|
@env = nil
|
||||||
@force = false
|
@force = false
|
||||||
@ -96,10 +97,10 @@ class FormulaInstaller
|
|||||||
# it's necessary to interrupt the user before any sort of installation
|
# it's necessary to interrupt the user before any sort of installation
|
||||||
# can proceed. Only invoked when the user has no developer tools.
|
# can proceed. Only invoked when the user has no developer tools.
|
||||||
def self.prevent_build_flags
|
def self.prevent_build_flags
|
||||||
build_flags = Homebrew.args.collect_build_args
|
build_flags = args&.collect_build_args
|
||||||
return if build_flags.empty?
|
return if build_flags.blank?
|
||||||
|
|
||||||
all_bottled = Homebrew.args.formulae.all?(&:bottled?)
|
all_bottled = args.formulae.all?(&:bottled?)
|
||||||
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
def install_bottle_for?(dep, build)
|
def install_bottle_for?(dep, build)
|
||||||
return pour_bottle? if dep == formula
|
return pour_bottle? if dep == formula
|
||||||
return false if Homebrew.args.build_formula_from_source?(dep)
|
return false if args&.build_formula_from_source?(dep)
|
||||||
return false unless dep.bottle && dep.pour_bottle?
|
return false unless dep.bottle && dep.pour_bottle?
|
||||||
return false unless build.used_options.empty?
|
return false unless build.used_options.empty?
|
||||||
return false unless dep.bottle.compatible_cellar?
|
return false unless dep.bottle.compatible_cellar?
|
||||||
@ -504,7 +505,7 @@ class FormulaInstaller
|
|||||||
)
|
)
|
||||||
|
|
||||||
keep_build_test = false
|
keep_build_test = false
|
||||||
keep_build_test ||= dep.test? && include_test? && Homebrew.args.include_formula_test_deps?(dependent)
|
keep_build_test ||= dep.test? && include_test? && args&.include_formula_test_deps?(dependent)
|
||||||
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed?
|
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed?
|
||||||
|
|
||||||
if dep.prune_from_option?(build)
|
if dep.prune_from_option?(build)
|
||||||
@ -582,8 +583,9 @@ class FormulaInstaller
|
|||||||
def fetch_dependency(dep)
|
def fetch_dependency(dep)
|
||||||
df = dep.to_formula
|
df = dep.to_formula
|
||||||
fi = FormulaInstaller.new(df, force_bottle: false,
|
fi = FormulaInstaller.new(df, force_bottle: false,
|
||||||
include_test: Homebrew.args.include_formula_test_deps?(df),
|
include_test: args&.include_formula_test_deps?(df),
|
||||||
build_from_source: Homebrew.args.build_formula_from_source?(df))
|
build_from_source: args&.build_formula_from_source?(df),
|
||||||
|
args: args)
|
||||||
|
|
||||||
fi.force = force?
|
fi.force = force?
|
||||||
fi.keep_tmp = keep_tmp?
|
fi.keep_tmp = keep_tmp?
|
||||||
@ -623,8 +625,9 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(df, force_bottle: false,
|
fi = FormulaInstaller.new(df, force_bottle: false,
|
||||||
include_test: Homebrew.args.include_formula_test_deps?(df),
|
include_test: args&.include_formula_test_deps?(df),
|
||||||
build_from_source: Homebrew.args.build_formula_from_source?(df))
|
build_from_source: args&.build_formula_from_source?(df),
|
||||||
|
args: args)
|
||||||
|
|
||||||
fi.options |= tab.used_options
|
fi.options |= tab.used_options
|
||||||
fi.options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options)
|
fi.options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options)
|
||||||
@ -764,7 +767,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
formula.options.each do |opt|
|
formula.options.each do |opt|
|
||||||
name = opt.name[/^([^=]+)=$/, 1]
|
name = opt.name[/^([^=]+)=$/, 1]
|
||||||
value = Homebrew.args.value(name) if name
|
value = args&.value(name) if name
|
||||||
args << "--#{name}=#{value}" if value
|
args << "--#{name}=#{value}" if value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module Homebrew
|
|||||||
options &= f.options
|
options &= f.options
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
||||||
build_from_source: args.build_from_source?)
|
build_from_source: args.build_from_source?, args: args)
|
||||||
fi.options = options
|
fi.options = options
|
||||||
fi.force = args.force?
|
fi.force = args.force?
|
||||||
fi.keep_tmp = args.keep_tmp?
|
fi.keep_tmp = args.keep_tmp?
|
||||||
|
|||||||
@ -64,7 +64,7 @@ module Homebrew
|
|||||||
options &= f.options
|
options &= f.options
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
||||||
build_from_source: args.build_from_source?)
|
build_from_source: args.build_from_source?, args: args)
|
||||||
fi.options = options
|
fi.options = options
|
||||||
fi.force = args.force?
|
fi.force = args.force?
|
||||||
fi.keep_tmp = args.keep_tmp?
|
fi.keep_tmp = args.keep_tmp?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user