xcode-archive-cache 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build/performer.rb +12 -2
- data/lib/build/product_extractor.rb +13 -11
- data/lib/build_graph/native_target_finder.rb +1 -1
- data/lib/build_settings/filter.rb +0 -1
- data/lib/injection/injector.rb +3 -3
- data/lib/injection/pods_script_fixer.rb +16 -13
- data/lib/injection/pods_xcframework_fixer.rb +1 -1
- data/lib/injection/storage.rb +7 -2
- data/lib/runner/runner.rb +2 -1
- data/lib/xcodebuild/executor.rb +32 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c30a0e4a847e52d32192c31fe3cdf3c7b0ff61cabc81e413e4fe416edbda1a8
|
4
|
+
data.tar.gz: 31925913e15ec55cf8b94dfd9940604cbc34cc98c0f1b76317cf0d05d8c202a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8fcfa4fd8a2da9cfadf202aaa3be88f4c54ddf3979aa4ac1c500e61b0a9d41f07bf43420fb0ec6332fd491b634a4d4f28ff1aebeaf273c79ded3a950a0d763
|
7
|
+
data.tar.gz: c6f6f0351aa9b02165637e93cd65b4938f2888bdb0cb7c599f8de0592a0ae4d85092508b73fb4a2b117c226287a64ccface769afd6e4c81626cd6b8d8e253297
|
data/lib/build/performer.rb
CHANGED
@@ -6,9 +6,10 @@ module XcodeArchiveCache
|
|
6
6
|
|
7
7
|
# @param [String] derived_data_path
|
8
8
|
#
|
9
|
-
def initialize(xcodebuild_executor, derived_data_path)
|
9
|
+
def initialize(xcodebuild_executor, derived_data_path, workspace_path=nil)
|
10
10
|
@xcodebuild_executor = xcodebuild_executor
|
11
11
|
@derived_data_path = derived_data_path
|
12
|
+
@workspace_path = workspace_path
|
12
13
|
end
|
13
14
|
|
14
15
|
# @param [Xcodeproj::Project::Object::PBXNativeTarget] target
|
@@ -23,7 +24,12 @@ module XcodeArchiveCache
|
|
23
24
|
.join(", ")
|
24
25
|
info("going to rebuild:\n#{rebuild_list}")
|
25
26
|
|
26
|
-
|
27
|
+
if workspace_path
|
28
|
+
build_result = xcodebuild_executor.build_from_workspace(workspace_path, target.name, derived_data_path)
|
29
|
+
else
|
30
|
+
build_result = xcodebuild_executor.build_from_project(target.project.path, target.name, derived_data_path)
|
31
|
+
end
|
32
|
+
|
27
33
|
unless build_result
|
28
34
|
raise StandardError.new, "Failed to perform rebuild"
|
29
35
|
end
|
@@ -47,6 +53,10 @@ module XcodeArchiveCache
|
|
47
53
|
# @return [XcodeArchiveCache::Xcodebuild::Executor]
|
48
54
|
#
|
49
55
|
attr_reader :xcodebuild_executor
|
56
|
+
|
57
|
+
# @return [String]
|
58
|
+
#
|
59
|
+
attr_reader :workspace_path
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
@@ -122,10 +122,12 @@ module XcodeArchiveCache
|
|
122
122
|
# @return [String]
|
123
123
|
#
|
124
124
|
def get_main_product_glob(built_node)
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
product_names = [File.basename(built_node.native_target.product_reference.path)]
|
126
|
+
if built_node.native_target.product_reference.name
|
127
|
+
product_names.push(File.basename(built_node.native_target.product_reference.name))
|
128
|
+
end
|
129
|
+
|
130
|
+
get_product_glob(product_names.select { |name| File.extname(name).length > 0 })
|
129
131
|
end
|
130
132
|
|
131
133
|
# @param [XcodeArchiveCache::BuildGraph::Node] built_node
|
@@ -133,7 +135,7 @@ module XcodeArchiveCache
|
|
133
135
|
# @return [String]
|
134
136
|
#
|
135
137
|
def get_swift_objc_interface_header_glob(built_node)
|
136
|
-
get_product_glob(File.basename(built_node.swift_objc_interface_header_file))
|
138
|
+
get_product_glob([File.basename(built_node.swift_objc_interface_header_file)])
|
137
139
|
end
|
138
140
|
|
139
141
|
# @param [XcodeArchiveCache::BuildGraph::Node] built_node
|
@@ -142,7 +144,7 @@ module XcodeArchiveCache
|
|
142
144
|
#
|
143
145
|
def get_swiftmodule_glob(built_node)
|
144
146
|
if built_node.module_name
|
145
|
-
get_product_glob(built_node.module_name + ".swiftmodule")
|
147
|
+
get_product_glob([built_node.module_name + ".swiftmodule"])
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
@@ -153,24 +155,24 @@ module XcodeArchiveCache
|
|
153
155
|
def get_modulemap_glob(built_node)
|
154
156
|
resulting_modulemap_file_name = built_node.resulting_modulemap_file_name
|
155
157
|
if resulting_modulemap_file_name
|
156
|
-
get_product_glob(resulting_modulemap_file_name)
|
158
|
+
get_product_glob([resulting_modulemap_file_name])
|
157
159
|
else
|
158
160
|
modulemap_file_path = built_node.original_modulemap_file_path
|
159
161
|
if modulemap_file_path && File.exist?(modulemap_file_path)
|
160
162
|
modulemap_file_name = File.basename(modulemap_file_path)
|
161
|
-
get_product_glob(modulemap_file_name)
|
163
|
+
get_product_glob([modulemap_file_name])
|
162
164
|
end
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
166
|
-
# @param [String]
|
168
|
+
# @param [Array<String>] file_names
|
167
169
|
#
|
168
170
|
# @return [String]
|
169
171
|
#
|
170
|
-
def get_product_glob(
|
172
|
+
def get_product_glob(file_names)
|
171
173
|
File.join(derived_data_path,
|
172
174
|
"**",
|
173
|
-
|
175
|
+
"{#{file_names.join(",")}}")
|
174
176
|
end
|
175
177
|
|
176
178
|
# @param [String] framework_path
|
@@ -123,7 +123,7 @@ module XcodeArchiveCache
|
|
123
123
|
#
|
124
124
|
def find_for_product_name(product_name)
|
125
125
|
canonical = all_targets
|
126
|
-
.select {|native_target| native_target.name == product_name || native_target.product_reference.display_name == product_name}
|
126
|
+
.select {|native_target| native_target.name == product_name || native_target.product_reference.display_name == product_name || native_target.product_reference.path == product_name }
|
127
127
|
.first
|
128
128
|
|
129
129
|
parsed = @product_name_to_target[product_name]
|
data/lib/injection/injector.rb
CHANGED
@@ -13,7 +13,7 @@ module XcodeArchiveCache
|
|
13
13
|
@headers_mover = HeadersMover.new(storage)
|
14
14
|
@dependency_remover = DependencyRemover.new
|
15
15
|
@build_flags_changer = BuildFlagsChanger.new
|
16
|
-
@pods_fixer = PodsScriptFixer.new
|
16
|
+
@pods_fixer = PodsScriptFixer.new(storage)
|
17
17
|
@modulemap_fixer = XcodeArchiveCache::Modulemap::HeaderPathFixer.new(storage)
|
18
18
|
@framework_embedder = FrameworkEmbedder.new
|
19
19
|
end
|
@@ -55,8 +55,8 @@ module XcodeArchiveCache
|
|
55
55
|
# are covered by "Embed Pods Frameworks" script
|
56
56
|
#
|
57
57
|
if graph.node_by_name(get_pods_target_name(target))
|
58
|
-
pods_fixer.fix_embed_frameworks_script(target, graph
|
59
|
-
pods_fixer.fix_copy_resources_script(target, graph
|
58
|
+
pods_fixer.fix_embed_frameworks_script(target, graph)
|
59
|
+
pods_fixer.fix_copy_resources_script(target, graph)
|
60
60
|
else
|
61
61
|
framework_nodes = graph.nodes.select { |node| node.has_framework_product? }
|
62
62
|
framework_file_paths = framework_nodes.map { |node| File.join(storage.get_storage_path(node), node.product_file_name) }
|
@@ -4,36 +4,41 @@ module XcodeArchiveCache
|
|
4
4
|
|
5
5
|
include XcodeArchiveCache::Logs
|
6
6
|
|
7
|
-
|
7
|
+
# @param [XcodeArchiveCache::Injection::Storage] storage
|
8
|
+
#
|
9
|
+
def initialize(storage)
|
10
|
+
@storage = storage
|
8
11
|
@build_settings_interpolator = XcodeArchiveCache::BuildSettings::StringInterpolator.new
|
9
12
|
end
|
10
13
|
|
11
14
|
# @param [Xcodeproj::Project::Object::PBXNativeTarget] target
|
12
15
|
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
13
|
-
# @param [String] products_dir
|
14
16
|
#
|
15
|
-
def fix_embed_frameworks_script(target, graph
|
17
|
+
def fix_embed_frameworks_script(target, graph)
|
16
18
|
build_settings = graph.dependent_build_settings
|
17
19
|
file_path = find_embed_frameworks_script(target, build_settings)
|
18
20
|
return unless file_path
|
19
21
|
|
20
|
-
fix_script(file_path, graph
|
22
|
+
fix_script(file_path, graph)
|
21
23
|
end
|
22
24
|
|
23
25
|
# @param [Xcodeproj::Project::Object::PBXNativeTarget] target
|
24
26
|
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
25
|
-
# @param [String] products_dir
|
26
27
|
#
|
27
|
-
def fix_copy_resources_script(target, graph
|
28
|
+
def fix_copy_resources_script(target, graph)
|
28
29
|
build_settings = graph.dependent_build_settings
|
29
30
|
file_path = find_copy_resources_script(target, build_settings)
|
30
31
|
return unless file_path
|
31
32
|
|
32
|
-
fix_script(file_path, graph
|
33
|
+
fix_script(file_path, graph)
|
33
34
|
end
|
34
35
|
|
35
36
|
private
|
36
37
|
|
38
|
+
# @return [XcodeArchiveCache::Injection::Storage]
|
39
|
+
#
|
40
|
+
attr_reader :storage
|
41
|
+
|
37
42
|
# @return [XcodeArchiveCache::BuildSettings::StringInterpolator]
|
38
43
|
#
|
39
44
|
attr_reader :build_settings_interpolator
|
@@ -57,16 +62,14 @@ module XcodeArchiveCache
|
|
57
62
|
end
|
58
63
|
|
59
64
|
# @param [String] file_path
|
60
|
-
# @param [XcodeArchiveCache::BuildGraph::
|
61
|
-
# @param [String] products_dir
|
65
|
+
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
62
66
|
#
|
63
|
-
def fix_script(file_path, graph
|
67
|
+
def fix_script(file_path, graph)
|
64
68
|
info("fixing #{file_path}")
|
65
69
|
script = File.read(file_path)
|
66
70
|
graph.nodes.each do |node|
|
67
|
-
|
68
|
-
|
69
|
-
script = script.gsub(Regexp.new("\"[^\"]+\/#{node.product_file_name}\""), "\"#{absolute_product_path}\"")
|
71
|
+
product_path = File.join(storage.get_storage_path(node), node.product_file_name)
|
72
|
+
script = script.gsub(Regexp.new("\"[^\"]+\/#{node.product_file_name}\""), "\"#{product_path}\"")
|
70
73
|
end
|
71
74
|
|
72
75
|
File.open(file_path, "w") {|file| file.puts(script)}
|
@@ -18,7 +18,7 @@ module XcodeArchiveCache
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# @param [Xcodeproj::Project::Object::PBXAbstractTarget] target
|
21
|
-
# @param [XcodeArchiveCache::BuildSettings::
|
21
|
+
# @param [XcodeArchiveCache::BuildSettings::Loader] build_settings_loader
|
22
22
|
#
|
23
23
|
def fix(target, build_settings_loader)
|
24
24
|
checked_targets.push(target.equatable_identifier)
|
data/lib/injection/storage.rb
CHANGED
@@ -77,7 +77,7 @@ module XcodeArchiveCache
|
|
77
77
|
def prepare_storage(node)
|
78
78
|
path = get_storage_path(node)
|
79
79
|
if File.exist?(path)
|
80
|
-
raise StandardError.new, "Injection storage path is already busy"
|
80
|
+
raise StandardError.new, "Injection storage path is already busy: #{path}"
|
81
81
|
end
|
82
82
|
|
83
83
|
FileUtils.mkdir_p(path)
|
@@ -89,7 +89,12 @@ module XcodeArchiveCache
|
|
89
89
|
# @return [String]
|
90
90
|
#
|
91
91
|
def get_storage_path(node)
|
92
|
-
File.join(container_dir_path, node.name)
|
92
|
+
path = File.join(container_dir_path, node.name)
|
93
|
+
if node.native_target
|
94
|
+
path += "-#{node.native_target.uuid}"
|
95
|
+
end
|
96
|
+
|
97
|
+
path
|
93
98
|
end
|
94
99
|
|
95
100
|
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
data/lib/runner/runner.rb
CHANGED
@@ -133,7 +133,8 @@ module XcodeArchiveCache
|
|
133
133
|
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
134
134
|
#
|
135
135
|
def rebuild_if_needed(xcodebuild_executor, root_target, graph)
|
136
|
-
|
136
|
+
workspace_path = config.is_a?(XcodeArchiveCache::Config::Workspace) ? File.absolute_path(config.file_path) : nil
|
137
|
+
rebuild_performer = XcodeArchiveCache::Build::Performer.new(xcodebuild_executor, config.settings.derived_data_path, workspace_path)
|
137
138
|
return unless rebuild_performer.should_rebuild?(graph)
|
138
139
|
|
139
140
|
@injector.perform_internal_injection(graph)
|
data/lib/xcodebuild/executor.rb
CHANGED
@@ -43,8 +43,30 @@ module XcodeArchiveCache
|
|
43
43
|
# @param [String] scheme
|
44
44
|
# @param [String] derived_data_path
|
45
45
|
#
|
46
|
-
def
|
47
|
-
|
46
|
+
def build_from_project(project_path, scheme, derived_data_path)
|
47
|
+
build(project_flag(project_path), scheme, derived_data_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
# @param [String] workspace_flag
|
51
|
+
# @param [String] scheme
|
52
|
+
# @param [String] derived_data_path
|
53
|
+
#
|
54
|
+
def build_from_workspace(workspace_path, scheme, derived_data_path)
|
55
|
+
build(workspace_flag(workspace_path), scheme, derived_data_path)
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_up_for_simulator?
|
59
|
+
destination_flag.include?("Simulator")
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# @param [String] path_flag
|
65
|
+
# @param [String] scheme
|
66
|
+
# @param [String] derived_data_path
|
67
|
+
#
|
68
|
+
def build(path_flag, scheme, derived_data_path)
|
69
|
+
flags = [path_flag,
|
48
70
|
configuration_flag,
|
49
71
|
destination_flag,
|
50
72
|
scheme_flag(scheme),
|
@@ -55,12 +77,6 @@ module XcodeArchiveCache
|
|
55
77
|
shell_executor.execute(command, true)
|
56
78
|
end
|
57
79
|
|
58
|
-
def set_up_for_simulator?
|
59
|
-
destination_flag.include?("Simulator")
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
80
|
# @return [String]
|
65
81
|
#
|
66
82
|
attr_reader :configuration
|
@@ -93,6 +109,14 @@ module XcodeArchiveCache
|
|
93
109
|
"xcodebuild #{flags.join(" ")}"
|
94
110
|
end
|
95
111
|
|
112
|
+
# @param [String] workspace_path
|
113
|
+
#
|
114
|
+
# @return [String]
|
115
|
+
#
|
116
|
+
def workspace_flag(workspace_path)
|
117
|
+
"-workspace '#{workspace_path}'"
|
118
|
+
end
|
119
|
+
|
96
120
|
# @param [String] project_path
|
97
121
|
#
|
98
122
|
# @return [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcode-archive-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Dyakonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.3.22
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Native targets cache for Xcode archive builds.
|