mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
formula_auditor: refactor GCC dependency check into separate method
The GCC dependency check is adding a couple of minutes to our `tap_syntax` jobs. Let's fix that by moving the check into a separate method so we can exclude it from `tap_syntax`.
This commit is contained in:
parent
2415339124
commit
5f95cc388d
@ -335,13 +335,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
|
|
||||||
bad_gcc_dep = linux_only_gcc_dep?(formula) && (@strict || begin
|
|
||||||
fv = FormulaVersions.new(formula)
|
|
||||||
fv.formula_at_revision("origin/HEAD") { |prev_f| !linux_only_gcc_dep?(prev_f) }
|
|
||||||
end)
|
|
||||||
problem "Formulae in homebrew/core should not have a Linux-only dependency on GCC." if bad_gcc_dep
|
|
||||||
|
|
||||||
return if formula.tap&.audit_exception :versioned_dependencies_conflicts_allowlist, formula.name
|
return if formula.tap&.audit_exception :versioned_dependencies_conflicts_allowlist, formula.name
|
||||||
|
|
||||||
# The number of conflicts on Linux is absurd.
|
# The number of conflicts on Linux is absurd.
|
||||||
@ -415,6 +408,20 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def audit_gcc_dependency
|
||||||
|
return unless @core_tap
|
||||||
|
return unless Homebrew::SimulateSystem.simulating_or_running_on_linux?
|
||||||
|
return unless linux_only_gcc_dep?(formula)
|
||||||
|
|
||||||
|
bad_gcc_dep = @strict || begin
|
||||||
|
fv = FormulaVersions.new(formula)
|
||||||
|
fv.formula_at_revision("origin/HEAD") { |prev_f| !linux_only_gcc_dep?(prev_f) }
|
||||||
|
end
|
||||||
|
return unless bad_gcc_dep
|
||||||
|
|
||||||
|
problem "Formulae in homebrew/core should not have a Linux-only dependency on GCC."
|
||||||
|
end
|
||||||
|
|
||||||
def audit_postgresql
|
def audit_postgresql
|
||||||
return unless formula.name == "postgresql"
|
return unless formula.name == "postgresql"
|
||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
@ -865,14 +872,19 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def linux_only_gcc_dep?(formula)
|
def linux_only_gcc_dep?(formula)
|
||||||
# TODO: Make this check work when running on Linux and not simulating macOS too.
|
odie "`#linux_only_gcc_dep?` works only on Linux!" if Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
||||||
return false unless Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
|
||||||
|
|
||||||
formula_hash = formula.to_hash_with_variations
|
formula_hash = formula.to_hash_with_variations
|
||||||
deps = formula_hash["dependencies"]
|
linux_deps = formula_hash["dependencies"]
|
||||||
linux_deps = formula_hash.dig("variations", :x86_64_linux, "dependencies")
|
variations_deps = []
|
||||||
|
formula_hash["variations"].map do |variation, data|
|
||||||
|
next if variation == :x86_64_linux
|
||||||
|
|
||||||
deps.exclude?("gcc") && linux_deps&.include?("gcc")
|
variations_deps += data["dependencies"]
|
||||||
|
end
|
||||||
|
variations_deps.uniq!
|
||||||
|
|
||||||
|
linux_deps.include?("gcc") && variations_deps&.exclude?("gcc")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user