From b622c36be6c0220c852417f7b6e9a147a2dfe220 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 14 Sep 2021 09:48:17 +0100 Subject: [PATCH] Add, use uses_from_macos_names. This strips e.g. `:build` tags. --- Library/Homebrew/formula.rb | 3 +++ Library/Homebrew/formula_auditor.rb | 2 +- Library/Homebrew/language/perl.rb | 2 +- Library/Homebrew/software_spec.rb | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index cea4bed176..e4d3929b99 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -487,6 +487,9 @@ class Formula # Dependencies provided by macOS for the currently active {SoftwareSpec}. delegate uses_from_macos_elements: :active_spec + # Dependency names provided by macOS for the currently active {SoftwareSpec}. + delegate uses_from_macos_names: :active_spec + # The {Requirement}s for the currently active {SoftwareSpec}. delegate requirements: :active_spec diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index c46a8cc94e..43e7eb1679 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -264,7 +264,7 @@ module Homebrew next unless @core_tap # we want to allow uses_from_macos for aliases but not bare dependencies - if self.class.aliases.include?(dep.name) && spec.uses_from_macos_elements.exclude?(dep.name) + if self.class.aliases.include?(dep.name) && spec.uses_from_macos_names.exclude?(dep.name) problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'." end diff --git a/Library/Homebrew/language/perl.rb b/Library/Homebrew/language/perl.rb index f65e9c1685..f4822239ad 100644 --- a/Library/Homebrew/language/perl.rb +++ b/Library/Homebrew/language/perl.rb @@ -13,7 +13,7 @@ module Language def detected_perl_shebang(formula = self) perl_path = if formula.deps.map(&:name).include? "perl" Formula["perl"].opt_bin/"perl" - elsif formula.uses_from_macos_elements.include? "perl" + elsif formula.uses_from_macos_names.include? "perl" "/usr/bin/perl#{MacOS.preferred_perl_version}" else raise ShebangDetectionError.new("Perl", "formula does not depend on Perl") diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 5f774a65ac..e796653be6 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -186,6 +186,10 @@ class SoftwareSpec depends_on(spec) end + def uses_from_macos_names + uses_from_macos_elements.flat_map { |e| e.is_a?(Hash) ? e.keys : e } + end + def deps dependency_collector.deps end