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