Class: XCCache::Lockfile
Defined Under Namespace
Classes: Pkg
Instance Attribute Summary
#path, #raw
Instance Method Summary
collapse
#load, #save
#[], #[]=, #initialize, #load, #merge!, #save
Instance Method Details
#deep_merge!(hash) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/xccache/core/lockfile.rb', line 40
def deep_merge!(hash)
raw.deep_merge!(
hash,
uniq_block: proc { |h| h.is_a?(Hash) ? Pkg.from_h(h).id || h : h },
sort_block: proc { |x| x.to_s.downcase },
)
(instance_variables - %i[@path @raw]).each do |ivar|
remove_instance_variable(ivar)
end
end
|
#hash_for_project(project) ⇒ Object
32
33
34
|
# File 'lib/xccache/core/lockfile.rb', line 32
def hash_for_project(project)
raw[project.display_name] ||= {}
end
|
#known_product_dependencies ⇒ Object
64
65
66
|
# File 'lib/xccache/core/lockfile.rb', line 64
def known_product_dependencies
raw.empty? ? [] : product_dependencies.reject { |d| File.dirname(d) == "__unknown__" }
end
|
#local_pkg_slugs ⇒ Object
60
61
62
|
# File 'lib/xccache/core/lockfile.rb', line 60
def local_pkg_slugs
@local_pkg_slugs ||= local_pkgs.map(&:slug).uniq
end
|
#local_pkgs ⇒ Object
56
57
58
|
# File 'lib/xccache/core/lockfile.rb', line 56
def local_pkgs
@local_pkgs ||= pkgs.select(&:local?).uniq
end
|
#pkgs ⇒ Object
52
53
54
|
# File 'lib/xccache/core/lockfile.rb', line 52
def pkgs
@pkgs ||= raw.values.flat_map { |h| h["packages"] || [] }.map { |h| Pkg.from_h(h) }
end
|
#product_dependencies ⇒ Object
68
69
70
|
# File 'lib/xccache/core/lockfile.rb', line 68
def product_dependencies
@product_dependencies ||= product_dependencies_by_targets.values.flatten.uniq
end
|
#product_dependencies_by_targets ⇒ Object
36
37
38
|
# File 'lib/xccache/core/lockfile.rb', line 36
def product_dependencies_by_targets
@product_dependencies_by_targets ||= raw.values.map { |h| h["dependencies"] }.reduce { |acc, h| acc.merge(h) }
end
|
#targets_data ⇒ Object
72
73
74
|
# File 'lib/xccache/core/lockfile.rb', line 72
def targets_data
@targets_data ||= product_dependencies_by_targets.transform_keys { |k| "#{k}.xccache" }
end
|
#verify! ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/xccache/core/lockfile.rb', line 76
def verify!
known_slugs = pkgs.map(&:slug)
unknown = product_dependencies.reject { |d| known_slugs.include?(File.dirname(d)) }
return if unknown.empty?
UI.error! <<~DESC
Unknown product dependencies at #{path}:
#{unknown.sort.map { |d| " • #{d}" }.join("\n")}
Refer to this doc for how to resolve this issue:
https://github.com/trinhngocthuyen/xccache/blob/main/docs/troubleshooting.md#unknown-product-dependencies
DESC
end
|