Fix Keg.bottle_dependencies including unneeded build dependencies

This commit is contained in:
Bo Anderson 2022-06-30 04:11:15 +01:00
parent 2ddce84225
commit 01d1f1ecb6
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 24 additions and 16 deletions

View File

@ -87,8 +87,7 @@ class Keg
gcc = Formulary.factory(CompilerSelector.preferred_gcc) gcc = Formulary.factory(CompilerSelector.preferred_gcc)
if !Homebrew::EnvConfig.simulate_macos_on_linux? && if !Homebrew::EnvConfig.simulate_macos_on_linux? &&
DevelopmentTools.non_apple_gcc_version("gcc") < gcc.version.to_i DevelopmentTools.non_apple_gcc_version("gcc") < gcc.version.to_i
formulae += gcc.recursive_dependencies.map(&:name) formulae << gcc
formulae << gcc.name
end end
formulae formulae
end end

View File

@ -577,9 +577,8 @@ class FormulaInstaller
unsatisfied_reqs unsatisfied_reqs
end end
def expand_dependencies def expand_dependencies_for_formula(formula, inherited_options)
inherited_options = Hash.new { |hash, key| hash[key] = Options.new } any_bottle_used = false
pour_bottle = pour_bottle?
# Cache for this expansion only. FormulaInstaller has a lot of inputs which can alter expansion. # Cache for this expansion only. FormulaInstaller has a lot of inputs which can alter expansion.
cache_key = "FormulaInstaller-#{formula.full_name}-#{Time.now.to_f}" cache_key = "FormulaInstaller-#{formula.full_name}-#{Time.now.to_f}"
@ -600,24 +599,34 @@ class FormulaInstaller
elsif dep.satisfied?(inherited_options[dep.name]) elsif dep.satisfied?(inherited_options[dep.name])
Dependency.skip Dependency.skip
else else
pour_bottle ||= install_bottle_for?(dep.to_formula, build) any_bottle_used ||= install_bottle_for?(dep.to_formula, build)
end end
end end
[expanded_deps, any_bottle_used]
end
def expand_dependencies
inherited_options = Hash.new { |hash, key| hash[key] = Options.new }
any_bottle_used = pour_bottle?
expanded_deps, any_dep_bottle_used = expand_dependencies_for_formula(formula, inherited_options)
any_bottle_used ||= any_dep_bottle_used
# We require some dependencies (glibc, GCC 5, etc.) if binaries were built. # We require some dependencies (glibc, GCC 5, etc.) if binaries were built.
# Native binaries shouldn't exist in cross-platform `all` bottles. # Native binaries shouldn't exist in cross-platform `all` bottles.
if pour_bottle && !formula.bottled?(:all) && !Keg.bottle_dependencies.empty? if any_bottle_used && !formula.bottled?(:all) && !Keg.bottle_dependencies.empty?
bottle_deps = if Keg.bottle_dependencies.exclude?(formula.name) all_bottle_deps = Keg.bottle_dependencies.flat_map do |bottle_dep|
Keg.bottle_dependencies bottle_dep.recursive_dependencies.map(&:name) + [bottle_dep.name]
else
[]
end end
bottle_deps = bottle_deps.map { |formula| Dependency.new(formula) }
.reject do |dep| if all_bottle_deps.exclude?(formula.name)
inherited_options[dep.name] |= inherited_options_for(dep) bottle_deps = Keg.bottle_dependencies.flat_map do |bottle_dep|
dep.satisfied? inherited_options[dep.name] expanded_bottle_deps, = expand_dependencies_for_formula(bottle_dep, inherited_options)
expanded_bottle_deps
end
expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps)
end end
expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps)
end end
expanded_deps.map { |dep| [dep, inherited_options[dep.name]] } expanded_deps.map { |dep| [dep, inherited_options[dep.name]] }