tab: set runtime_dependencies consistently.

This commit is contained in:
Mike McQuaid 2018-06-01 19:53:26 +01:00
parent 6b817f775f
commit 42e5ef9f89
3 changed files with 16 additions and 7 deletions

View File

@ -1523,8 +1523,9 @@ class Formula
(keg = opt_or_installed_prefix_keg) && (keg = opt_or_installed_prefix_keg) &&
(tab_deps = keg.runtime_dependencies) (tab_deps = keg.runtime_dependencies)
return tab_deps.map do |d| return tab_deps.map do |d|
next unless d["full_name"] full_name = d["full_name"]
Dependency.new d["full_name"] next unless full_name
Dependency.new full_name
end.compact end.compact
end end

View File

@ -613,7 +613,7 @@ class FormulaInstaller
# Update tab with actual runtime dependencies # Update tab with actual runtime dependencies
tab = Tab.for_keg(keg) tab = Tab.for_keg(keg)
Tab.clear_cache Tab.clear_cache
tab.runtime_dependencies = tab.runtime_dependency_objects =
formula.runtime_dependencies(read_from_tab: false) formula.runtime_dependencies(read_from_tab: false)
tab.write tab.write

View File

@ -33,10 +33,7 @@ class Tab < OpenStruct
"compiler" => compiler, "compiler" => compiler,
"stdlib" => stdlib, "stdlib" => stdlib,
"aliases" => formula.aliases, "aliases" => formula.aliases,
"runtime_dependencies" => runtime_deps.map do |dep| "runtime_dependencies" => Tab.runtime_deps_hash(runtime_deps),
f = dep.to_formula
{ "full_name" => f.full_name, "version" => f.version.to_s }
end,
"source" => { "source" => {
"path" => formula.specified_path.to_s, "path" => formula.specified_path.to_s,
"tap" => formula.tap&.name, "tap" => formula.tap&.name,
@ -203,6 +200,13 @@ class Tab < OpenStruct
new(attributes) new(attributes)
end end
def self.runtime_deps_hash(deps)
deps.map do |dep|
f = dep.to_formula
{ "full_name" => f.full_name, "version" => f.version.to_s }
end
end
def with?(val) def with?(val)
option_names = val.respond_to?(:option_names) ? val.option_names : [val] option_names = val.respond_to?(:option_names) ? val.option_names : [val]
@ -262,6 +266,10 @@ class Tab < OpenStruct
super unless parsed_homebrew_version < "1.1.6" super unless parsed_homebrew_version < "1.1.6"
end end
def runtime_dependency_objects=(deps)
source["runtime_dependencies"] = Tab.runtime_deps_hash(deps)
end
def cxxstdlib def cxxstdlib
# Older tabs won't have these values, so provide sensible defaults # Older tabs won't have these values, so provide sensible defaults
lib = stdlib.to_sym if stdlib lib = stdlib.to_sym if stdlib