Merge pull request #12055 from Bo98/uses_from_macos_elements
Set uses_from_macos_elements in all cases
This commit is contained in:
commit
102be3e2b2
@ -7,19 +7,21 @@ class SoftwareSpec
|
||||
undef uses_from_macos
|
||||
|
||||
def uses_from_macos(deps, bounds = {})
|
||||
@uses_from_macos_elements ||= []
|
||||
|
||||
if deps.is_a?(Hash)
|
||||
bounds = deps.dup
|
||||
deps = bounds.shift
|
||||
deps = [bounds.shift].to_h
|
||||
end
|
||||
|
||||
@uses_from_macos_elements << deps
|
||||
|
||||
bounds = bounds.transform_values { |v| MacOS::Version.from_symbol(v) }
|
||||
if MacOS.version >= bounds[:since] ||
|
||||
(Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since))
|
||||
@uses_from_macos_elements << deps
|
||||
else
|
||||
depends_on deps
|
||||
end
|
||||
|
||||
# Linux simulating macOS. Assume oldest macOS version.
|
||||
return if Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since)
|
||||
|
||||
# macOS new enough for dependency to not be required.
|
||||
return if MacOS.version >= bounds[:since]
|
||||
|
||||
depends_on deps
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
||||
@ -1903,7 +1906,6 @@ class Formula
|
||||
# @private
|
||||
def to_hash
|
||||
dependencies = deps
|
||||
uses_from_macos = uses_from_macos_elements || []
|
||||
|
||||
hsh = {
|
||||
"name" => name,
|
||||
@ -1941,7 +1943,7 @@ class Formula
|
||||
"optional_dependencies" => dependencies.select(&:optional?)
|
||||
.map(&:name)
|
||||
.uniq,
|
||||
"uses_from_macos" => uses_from_macos.uniq,
|
||||
"uses_from_macos" => uses_from_macos_elements.uniq,
|
||||
"requirements" => [],
|
||||
"conflicts_with" => conflicts.map(&:name),
|
||||
"caveats" => caveats&.gsub(HOMEBREW_PREFIX, "$(brew --prefix)"),
|
||||
|
@ -264,8 +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.blank? || 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
|
||||
|
||||
|
@ -11,10 +11,10 @@ module Language
|
||||
module_function
|
||||
|
||||
def detected_perl_shebang(formula = self)
|
||||
perl_path = if formula.uses_from_macos_elements&.include? "perl"
|
||||
"/usr/bin/perl#{MacOS.preferred_perl_version}"
|
||||
elsif formula.deps.map(&:name).include? "perl"
|
||||
perl_path = if formula.deps.map(&:name).include? "perl"
|
||||
Formula["perl"].opt_bin/"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")
|
||||
end
|
||||
|
@ -47,6 +47,7 @@ class SoftwareSpec
|
||||
@deprecated_options = []
|
||||
@build = BuildOptions.new(Options.create(@flags), options)
|
||||
@compiler_failures = []
|
||||
@uses_from_macos_elements = []
|
||||
@bottle_disable_reason = nil
|
||||
end
|
||||
|
||||
@ -178,10 +179,17 @@ class SoftwareSpec
|
||||
end
|
||||
|
||||
def uses_from_macos(spec, _bounds = {})
|
||||
spec = spec.dup.shift if spec.is_a?(Hash)
|
||||
spec = [spec.dup.shift].to_h if spec.is_a?(Hash)
|
||||
|
||||
@uses_from_macos_elements << spec
|
||||
|
||||
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
|
||||
|
@ -33,8 +33,8 @@ describe Formula do
|
||||
|
||||
expect(f.class.stable.deps.first.name).to eq("foo")
|
||||
expect(f.class.head.deps.first.name).to eq("foo")
|
||||
expect(f.class.stable.uses_from_macos_elements).to be_empty
|
||||
expect(f.class.head.uses_from_macos_elements).to be_empty
|
||||
expect(f.class.stable.uses_from_macos_elements).to eq(["foo"])
|
||||
expect(f.class.head.uses_from_macos_elements).to eq(["foo"])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe SoftwareSpec do
|
||||
spec.uses_from_macos("foo", since: :high_sierra)
|
||||
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.uses_from_macos_elements).to be_empty
|
||||
expect(spec.uses_from_macos_elements).to eq(["foo"])
|
||||
end
|
||||
|
||||
it "works with tags" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user