formula: cache runtime_dependencies related stuff.
This commit is contained in:
parent
eeb9ac36a2
commit
ddcbdbe0c0
@ -263,6 +263,7 @@ module Homebrew
|
||||
|
||||
changed_files = keg.replace_locations_with_placeholders unless args.skip_relocation?
|
||||
|
||||
Formula.clear_cache
|
||||
Keg.clear_cache
|
||||
Tab.clear_cache
|
||||
tab = Tab.for_keg(keg)
|
||||
|
||||
@ -52,6 +52,7 @@ class Formula
|
||||
include Utils::Shell
|
||||
extend Enumerable
|
||||
extend Forwardable
|
||||
extend Cachable
|
||||
|
||||
# @!method inreplace(paths, before = nil, after = nil)
|
||||
# Actually implemented in {Utils::Inreplace.inreplace}.
|
||||
@ -1528,7 +1529,8 @@ class Formula
|
||||
# If not, return nil.
|
||||
# @private
|
||||
def opt_or_installed_prefix_keg
|
||||
if optlinked? && opt_prefix.exist?
|
||||
Formula.cache[:opt_or_installed_prefix_keg] ||= {}
|
||||
Formula.cache[:opt_or_installed_prefix_keg][name] ||= if optlinked? && opt_prefix.exist?
|
||||
Keg.new(opt_prefix)
|
||||
elsif installed_prefix.directory?
|
||||
Keg.new(installed_prefix)
|
||||
@ -1538,27 +1540,27 @@ class Formula
|
||||
# Returns a list of Dependency objects that are required at runtime.
|
||||
# @private
|
||||
def runtime_dependencies(read_from_tab: true, undeclared: true)
|
||||
if read_from_tab &&
|
||||
undeclared &&
|
||||
(keg = opt_or_installed_prefix_keg) &&
|
||||
(tab_deps = keg.runtime_dependencies)
|
||||
return tab_deps.map do |d|
|
||||
deps = if read_from_tab && undeclared &&
|
||||
(tab_deps = opt_or_installed_prefix_keg&.runtime_dependencies)
|
||||
tab_deps.map do |d|
|
||||
full_name = d["full_name"]
|
||||
next unless full_name
|
||||
|
||||
Dependency.new full_name
|
||||
end.compact
|
||||
end
|
||||
|
||||
return declared_runtime_dependencies unless undeclared
|
||||
|
||||
declared_runtime_dependencies | undeclared_runtime_dependencies
|
||||
deps ||= declared_runtime_dependencies unless undeclared
|
||||
deps ||= (declared_runtime_dependencies | undeclared_runtime_dependencies)
|
||||
deps
|
||||
end
|
||||
|
||||
# Returns a list of Formula objects that are required at runtime.
|
||||
# @private
|
||||
def runtime_formula_dependencies(read_from_tab: true, undeclared: true)
|
||||
runtime_dependencies(
|
||||
cache_key = "#{name}-#{read_from_tab}-#{undeclared}"
|
||||
|
||||
Formula.cache[:runtime_formula_dependencies] ||= {}
|
||||
Formula.cache[:runtime_formula_dependencies][cache_key] ||= runtime_dependencies(
|
||||
read_from_tab: read_from_tab,
|
||||
undeclared: undeclared,
|
||||
).map do |d|
|
||||
|
||||
@ -649,7 +649,6 @@ class FormulaInstaller
|
||||
|
||||
# Update tab with actual runtime dependencies
|
||||
tab = Tab.for_keg(keg)
|
||||
Keg.clear_cache
|
||||
Tab.clear_cache
|
||||
f_runtime_deps = formula.runtime_dependencies(read_from_tab: false)
|
||||
tab.runtime_dependencies = Tab.runtime_deps_hash(f_runtime_deps)
|
||||
@ -783,6 +782,7 @@ class FormulaInstaller
|
||||
unless link_keg
|
||||
begin
|
||||
keg.optlink
|
||||
Formula.clear_cache
|
||||
rescue Keg::LinkError => e
|
||||
onoe "Failed to create #{formula.opt_prefix}"
|
||||
puts "Things that depend on #{formula.full_name} will probably not build."
|
||||
|
||||
@ -145,6 +145,7 @@ RSpec.configure do |config|
|
||||
|
||||
begin
|
||||
Homebrew.raise_deprecation_exceptions = true
|
||||
Formula.clear_cache
|
||||
Keg.clear_cache
|
||||
Tap.clear_cache
|
||||
FormulaInstaller.clear_attempted
|
||||
@ -178,6 +179,7 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
Tab.clear_cache
|
||||
Formula.clear_cache
|
||||
Keg.clear_cache
|
||||
|
||||
FileUtils.rm_rf [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user