formula: use runtime_dependencies from tab.

Don't do so in `linkage_checker` or `tab` which to avoid recursive loops
and want the actual values specified in the formula itself.
This commit is contained in:
Mike McQuaid 2018-03-25 12:48:20 +01:00
parent a7727b66b3
commit 42a39b16bf
3 changed files with 12 additions and 3 deletions

View File

@ -1486,7 +1486,14 @@ class Formula
# Returns a list of Dependency objects that are required at runtime.
# @private
def runtime_dependencies
def runtime_dependencies(read_from_tab: true)
if read_from_tab &&
installed_prefix.directory? &&
(keg = Keg.new(installed_prefix)) &&
(tab_deps = keg.runtime_dependencies)
return tab_deps.map { |d| Dependency.new d["full_name"] }.compact
end
recursive_dependencies do |_, dependency|
Dependency.prune if dependency.build?
Dependency.prune if !dependency.required? && build.without?(dependency)

View File

@ -63,7 +63,8 @@ class LinkageChecker
formula.build.without?(dep)
end
declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name)
recursive_deps = keg.to_formula.runtime_dependencies.map { |dep| dep.to_formula.name }
runtime_deps = keg.to_formula.runtime_dependencies(read_from_tab: false)
recursive_deps = runtime_deps.map { |dep| dep.to_formula.name }
declared_dep_names = declared_deps.map { |dep| dep.split("/").last }
indirect_deps = []
undeclared_deps = []

View File

@ -17,6 +17,7 @@ class Tab < OpenStruct
# Instantiates a Tab for a new installation of a formula.
def self.create(formula, compiler, stdlib)
build = formula.build
runtime_deps = formula.runtime_dependencies(read_from_tab: false)
attributes = {
"homebrew_version" => HOMEBREW_VERSION,
"used_options" => build.used_options.as_flags,
@ -32,7 +33,7 @@ class Tab < OpenStruct
"compiler" => compiler,
"stdlib" => stdlib,
"aliases" => formula.aliases,
"runtime_dependencies" => formula.runtime_dependencies.map do |dep|
"runtime_dependencies" => runtime_deps.map do |dep|
f = dep.to_formula
{ "full_name" => f.full_name, "version" => f.version.to_s }
end,