Remove FormulaInstaller.prevent_build_flags

This commit is contained in:
Bo Anderson 2021-03-22 16:11:27 +00:00
parent a235b38000
commit d14a0bb131
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
4 changed files with 18 additions and 25 deletions

View File

@ -176,7 +176,15 @@ module Homebrew
# if the user's flags will prevent bottle only-installations when no
# developer tools are available, we need to stop them early on
FormulaInstaller.prevent_build_flags(args)
unless DevelopmentTools.installed?
build_flags = []
build_flags << "--HEAD" if args.HEAD?
build_flags << "--build-bottle" if args.build_bottle?
build_flags << "--build-from-source" if args.build_from_source?
raise BuildFlagsError.new(build_flags, bottled: formulae.all?(&:bottled?)) if build_flags.present?
end
installed_formulae = []

View File

@ -81,13 +81,15 @@ module Homebrew
def reinstall
args = reinstall_args.parse
FormulaInstaller.prevent_build_flags(args)
Install.perform_preinstall_checks
formulae, casks = args.named.to_formulae_and_casks(method: :resolve)
.partition { |o| o.is_a?(Formula) }
if args.build_from_source? && !DevelopmentTools.installed?
raise BuildFlagsError.new(["--build-from-source"], bottled: formulae.all?(&:bottled?))
end
Install.perform_preinstall_checks
formulae.each do |formula|
if formula.pinned?
onoe "#{formula.full_name} is pinned. You must unpin it to reinstall."

View File

@ -115,7 +115,9 @@ module Homebrew
def upgrade_outdated_formulae(formulae, args:)
return false if args.cask?
FormulaInstaller.prevent_build_flags(args)
if args.build_from_source? && !DevelopmentTools.installed?
raise BuildFlagsError.new(["--build-from-source"], bottled: formulae.all?(&:bottled?))
end
Install.perform_preinstall_checks

View File

@ -115,25 +115,6 @@ class FormulaInstaller
@installed = Set.new
end
# When no build tools are available and build flags are passed through ARGV,
# it's necessary to interrupt the user before any sort of installation
# can proceed. Only raises when the user has no developer tools.
def self.prevent_build_flags(args)
return if DevelopmentTools.installed?
build_flags = []
build_flags << "--HEAD" if args.HEAD?
build_flags << "--universal" if args.universal?
build_flags << "--build-bottle" if args.build_bottle?
build_flags << "--build-from-source" if args.build_from_source?
return if build_flags.empty?
all_bottled = args.named.to_formulae.all?(&:bottled?)
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
end
sig { returns(T::Boolean) }
def build_from_source?
@build_from_source_formulae.include?(formula.full_name)