Class: XCCache::SPM::Package::Target
Constant Summary
Constants inherited
from BaseObject
BaseObject::ATTRS
Instance Attribute Summary
#path, #raw
Instance Method Summary
collapse
Methods included from Cacheable
#__cacheable_module_name, #cacheable, included
Methods inherited from BaseObject
#cast_to, #display_name, #fetch, #full_name, #inspect, #name, #pkg_desc_of, #pkg_name, #pkg_slug, #src_dir, #to_s
#config
#load, #save
#[], #[]=, #initialize, #load, #merge!, #reload, #save
Instance Method Details
#binary? ⇒ Boolean
127
128
129
|
# File 'lib/xccache/spm/desc/target.rb', line 127
def binary?
type == :binary
end
|
#binary_path ⇒ Object
131
132
133
|
# File 'lib/xccache/spm/desc/target.rb', line 131
def binary_path
sources_path if binary?
end
|
#checksum ⇒ Object
139
140
141
|
# File 'lib/xccache/spm/desc/target.rb', line 139
def checksum
@checksum ||= root.git&.sha || sources_path.checksum
end
|
#direct_dependencies(platform: nil) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/xccache/spm/desc/target.rb', line 103
def direct_dependencies(platform: nil)
raw["dependencies"].flat_map do |hash|
dep_types = ["byName", "target", "product"]
if (dep_type = dep_types.intersection(hash.keys).first).nil?
raise GeneralError, "Unexpected dependency type. Must be one of #{dep_types}. Hash: #{hash}"
end
next [] unless match_platform?(hash[dep_type][-1], platform)
pkg_name = hash[dep_type][1] if dep_type == "product"
find_deps(hash[dep_type][0], pkg_name, dep_type)
end
end
|
#direct_dependency_targets(platform: nil) ⇒ Object
115
116
117
|
# File 'lib/xccache/spm/desc/target.rb', line 115
def direct_dependency_targets(platform: nil)
direct_dependencies(platform: platform).flat_map(&:flatten_as_targets).uniq
end
|
#downcast ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/xccache/spm/desc/target.rb', line 24
def downcast
cls = {
:binary => BinaryTarget,
:macro => MacroTarget,
}[type]
cls.nil? ? self : cast_to(cls)
end
|
#flatten_as_targets ⇒ Object
40
41
42
|
# File 'lib/xccache/spm/desc/target.rb', line 40
def flatten_as_targets
[self]
end
|
55
56
57
58
59
60
61
62
63
|
# File 'lib/xccache/spm/desc/target.rb', line 55
def (options = {})
paths = []
paths += if options.fetch(:public, true)
paths += if options.fetch(:search, false)
paths
.flat_map { |p| p.glob("**/*.h*") }
.map(&:realpath)
.uniq
end
|
69
70
71
72
73
74
75
|
# File 'lib/xccache/spm/desc/target.rb', line 69
def
@header_search_paths ||=
settings
.filter_map { |h| h.fetch("kind", {})["headerSearchPath"] }
.flat_map(&:values)
.map { |p| sources_path / p }
end
|
#local_binary_path ⇒ Object
135
136
137
|
# File 'lib/xccache/spm/desc/target.rb', line 135
def local_binary_path
binary_path if binary? && root.local?
end
|
#macro? ⇒ Boolean
123
124
125
|
# File 'lib/xccache/spm/desc/target.rb', line 123
def macro?
type == :macro
end
|
119
120
121
|
# File 'lib/xccache/spm/desc/target.rb', line 119
def match_platform?(_condition, _platform)
true end
|
#module_name ⇒ Object
32
33
34
|
# File 'lib/xccache/spm/desc/target.rb', line 32
def module_name
name.c99extidentifier
end
|
77
78
79
80
81
82
83
84
85
|
# File 'lib/xccache/spm/desc/target.rb', line 77
def
@public_header_paths ||= begin
res = []
implicit_path = sources_path / "include"
res << implicit_path unless implicit_path.glob("**/*.h*").empty?
res << (sources_path / raw["publicHeadersPath"]) if raw.key?("publicHeadersPath")
res
end
end
|
#recursive_targets(platform: nil) ⇒ Object
97
98
99
100
101
|
# File 'lib/xccache/spm/desc/target.rb', line 97
def recursive_targets(platform: nil)
children = direct_dependency_targets(platform: platform)
children += children.flat_map { |t| t.macro? ? [t] : t.recursive_targets(platform: platform) }
children.uniq
end
|
#resource_bundle_name ⇒ Object
36
37
38
|
# File 'lib/xccache/spm/desc/target.rb', line 36
def resource_bundle_name
"#{pkg_name}_#{name}.bundle"
end
|
#resource_paths ⇒ Object
87
88
89
90
91
92
93
94
95
|
# File 'lib/xccache/spm/desc/target.rb', line 87
def resource_paths
@resource_paths ||= begin
res = raw.fetch("resources", []).map { |h| sources_path / h["path"] }
implicit = sources_path.glob("*.{xcassets,xib,storyboard,xcdatamodeld,lproj}")
res + implicit
end
end
|
#settings ⇒ Object
65
66
67
|
# File 'lib/xccache/spm/desc/target.rb', line 65
def settings
raw["settings"]
end
|
#sources_path ⇒ Object
44
45
46
47
48
49
|
# File 'lib/xccache/spm/desc/target.rb', line 44
def sources_path
@sources_path ||= begin
path = raw["path"] || "Sources/#{name}"
root.src_dir / path
end
end
|
#type ⇒ Object
20
21
22
|
# File 'lib/xccache/spm/desc/target.rb', line 20
def type
@type ||= raw["type"].to_sym
end
|
#use_clang? ⇒ Boolean
51
52
53
|
# File 'lib/xccache/spm/desc/target.rb', line 51
def use_clang?
!.empty?
end
|
#xccache? ⇒ Boolean
12
13
14
|
# File 'lib/xccache/spm/desc/target.rb', line 12
def xccache?
name.end_with?(".xccache")
end
|
#xccache_id ⇒ Object
16
17
18
|
# File 'lib/xccache/spm/desc/target.rb', line 16
def xccache_id
macro? ? "#{full_name}.macro" : full_name
end
|