cocoapods-xcremotecache 0.0.3 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/cocoapods-xcremotecache/command/hooks.rb +76 -25
- data/lib/cocoapods-xcremotecache/gem_version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d318ae852c59d8bff4fec2521620ebe59dd8888cc5d0d33a3a9abd8a331b4ac
|
4
|
+
data.tar.gz: 22ca6c2ee0c87ef89260efcf031dd5c9f3c9b101d483965031f079dc36af49b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4619b79b468ffac80c5ed0d7e0339b460e39817b2a763bb0e6a756d839b5baa7bf2a3673cb51b7db24b2d2790fa72cff5e05c5192102cec5231689e2e020284
|
7
|
+
data.tar.gz: 35a8375ee395f281f008ec6dd4f7f1d6943d15cd78f960875bd302e64ee6daeb4417ee7932ec8c4f23c68a6877d769a83d0b59a9fe78393a2a298d3e5af7e388
|
data/README.md
CHANGED
@@ -52,6 +52,8 @@ An object that is passed to the `xcremotecache` can contain all properties suppo
|
|
52
52
|
| `modify_lldb_init` | Controls if the pod integration should modify `~/.lldbinit` | `true` | ⬜️ |
|
53
53
|
| `xccc_file` | The path where should be placed the `xccc` binary (in the pod installation phase) | `{podfile_dir}/.rc/xccc` | ⬜️ |
|
54
54
|
| `remote_commit_file` | The path of the file with the remote commit sha (in the pod installation phase) | `{podfile_dir}/.rc/arc.rc`| ⬜️ |
|
55
|
+
| `prettify_meta_files` | A Boolean value that opts-in pretty JSON formatting for meta files | `false` | ⬜️ |
|
56
|
+
| `disable_certificate_verification` | A Boolean value that opts-in SSL certificate validation is disabled | `false` | ⬜️ |
|
55
57
|
|
56
58
|
## Uninstalling
|
57
59
|
|
@@ -17,6 +17,7 @@ require 'cocoapods/resolver'
|
|
17
17
|
require 'open-uri'
|
18
18
|
require 'yaml'
|
19
19
|
require 'json'
|
20
|
+
require 'pathname'
|
20
21
|
|
21
22
|
|
22
23
|
module CocoapodsXCRemoteCacheModifier
|
@@ -28,6 +29,7 @@ module CocoapodsXCRemoteCacheModifier
|
|
28
29
|
LLDB_INIT_PATH = "#{ENV['HOME']}/.lldbinit"
|
29
30
|
FAT_ARCHIVE_NAME_INFIX = 'arm64-x86_64'
|
30
31
|
|
32
|
+
# List of plugins' user properties that should be copied to .rcinfo
|
31
33
|
CUSTOM_CONFIGURATION_KEYS = [
|
32
34
|
'enabled',
|
33
35
|
'xcrc_location',
|
@@ -36,7 +38,9 @@ module CocoapodsXCRemoteCacheModifier
|
|
36
38
|
'final_target',
|
37
39
|
'check_build_configuration',
|
38
40
|
'check_platform',
|
39
|
-
'modify_lldb_init'
|
41
|
+
'modify_lldb_init',
|
42
|
+
'prettify_meta_files',
|
43
|
+
'disable_certificate_verification'
|
40
44
|
]
|
41
45
|
|
42
46
|
class XCRemoteCache
|
@@ -58,6 +62,8 @@ module CocoapodsXCRemoteCacheModifier
|
|
58
62
|
'xccc_file' => "#{BIN_DIR}/xccc",
|
59
63
|
'remote_commit_file' => "#{BIN_DIR}/arc.rc",
|
60
64
|
'exclude_targets' => [],
|
65
|
+
'prettify_meta_files' => false,
|
66
|
+
'disable_certificate_verification' => false
|
61
67
|
}
|
62
68
|
@@configuration.merge! default_values.select { |k, v| !@@configuration.key?(k) }
|
63
69
|
end
|
@@ -76,8 +82,8 @@ module CocoapodsXCRemoteCacheModifier
|
|
76
82
|
end
|
77
83
|
|
78
84
|
mode = @@configuration['mode']
|
79
|
-
unless mode == 'consumer' || mode == 'producer'
|
80
|
-
throw "Incorrect 'mode' value. Allowed values are ['consumer', 'producer'], but you provided '#{mode}'. A typo?"
|
85
|
+
unless mode == 'consumer' || mode == 'producer' || mode == 'producer-fast'
|
86
|
+
throw "Incorrect 'mode' value. Allowed values are ['consumer', 'producer', 'producer-fast'], but you provided '#{mode}'. A typo?"
|
81
87
|
end
|
82
88
|
|
83
89
|
unless mode == 'consumer' || @@configuration.key?('final_target')
|
@@ -97,7 +103,7 @@ module CocoapodsXCRemoteCacheModifier
|
|
97
103
|
# @param repo_distance [Integer] distance from the git repo root to the target's $SRCROOT
|
98
104
|
# @param xc_location [String] path to the dir with all XCRemoteCache binaries, relative to the repo root
|
99
105
|
# @param xc_cc_path [String] path to the XCRemoteCache clang wrapper, relative to the repo root
|
100
|
-
# @param mode [String] mode name ('consumer', 'producer' etc.)
|
106
|
+
# @param mode [String] mode name ('consumer', 'producer', 'producer-fast' etc.)
|
101
107
|
# @param exclude_build_configurations [String[]] list of targets that should have disabled remote cache
|
102
108
|
# @param final_target [String] name of target that should trigger marking
|
103
109
|
def self.enable_xcremotecache(target, repo_distance, xc_location, xc_cc_path, mode, exclude_build_configurations, final_target)
|
@@ -108,12 +114,15 @@ module CocoapodsXCRemoteCacheModifier
|
|
108
114
|
next if exclude_build_configurations.include?(config.name)
|
109
115
|
if mode == 'consumer'
|
110
116
|
config.build_settings['CC'] = ["$SRCROOT/#{parent_dir(xc_cc_path, repo_distance)}"]
|
117
|
+
elsif mode == 'producer' || mode == 'producer-fast'
|
118
|
+
config.build_settings.delete('CC') if config.build_settings.key?('CC')
|
111
119
|
end
|
112
120
|
config.build_settings['SWIFT_EXEC'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc"]
|
113
121
|
config.build_settings['LIBTOOL'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xclibtool"]
|
114
122
|
config.build_settings['LD'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcld"]
|
115
123
|
|
116
124
|
config.build_settings['XCREMOTE_CACHE_FAKE_SRCROOT'] = FAKE_SRCROOT
|
125
|
+
config.build_settings['XCRC_PLATFORM_PREFERRED_ARCH'] = ["$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"]
|
117
126
|
debug_prefix_map_replacement = '$(SRCROOT' + ':dir:standardizepath' * repo_distance + ')'
|
118
127
|
add_cflags!(config.build_settings, '-fdebug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
|
119
128
|
add_swiftflags!(config.build_settings, '-debug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
|
@@ -126,7 +135,8 @@ module CocoapodsXCRemoteCacheModifier
|
|
126
135
|
phase.name != nil && phase.name.start_with?("[XCRC] Prebuild")
|
127
136
|
end
|
128
137
|
end
|
129
|
-
|
138
|
+
|
139
|
+
prebuild_script = existing_prebuild_script || target.new_shell_script_build_phase("[XCRC] Prebuild #{target.name}")
|
130
140
|
prebuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
|
131
141
|
prebuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcprebuild"]
|
132
142
|
prebuild_script.output_paths = [
|
@@ -135,9 +145,10 @@ module CocoapodsXCRemoteCacheModifier
|
|
135
145
|
]
|
136
146
|
prebuild_script.dependency_file = "$(TARGET_TEMP_DIR)/prebuild.d"
|
137
147
|
|
138
|
-
# Move prebuild (last element) to the
|
139
|
-
target.build_phases.
|
140
|
-
|
148
|
+
# Move prebuild (last element) to the position before compile sources phase (to make it real 'prebuild')
|
149
|
+
compile_phase_index = target.build_phases.index(target.source_build_phase)
|
150
|
+
target.build_phases.insert(compile_phase_index, target.build_phases.delete(prebuild_script))
|
151
|
+
elsif mode == 'producer' || mode == 'producer-fast'
|
141
152
|
# Delete existing prebuild build phase (to support switching between modes)
|
142
153
|
target.build_phases.delete_if do |phase|
|
143
154
|
if phase.respond_to?(:name)
|
@@ -152,17 +163,17 @@ module CocoapodsXCRemoteCacheModifier
|
|
152
163
|
phase.name != nil && phase.name.start_with?("[XCRC] Postbuild")
|
153
164
|
end
|
154
165
|
end
|
155
|
-
postbuild_script = existing_postbuild_script || target.new_shell_script_build_phase("[XCRC] Postbuild")
|
166
|
+
postbuild_script = existing_postbuild_script || target.new_shell_script_build_phase("[XCRC] Postbuild #{target.name}")
|
156
167
|
postbuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
|
157
168
|
postbuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcpostbuild"]
|
158
169
|
postbuild_script.output_paths = [
|
159
|
-
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(
|
160
|
-
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(
|
170
|
+
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH).swiftmodule.md5",
|
171
|
+
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5"
|
161
172
|
]
|
162
173
|
postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d"
|
163
174
|
|
164
175
|
# Mark a sha as ready for a given platform and configuration when building the final_target
|
165
|
-
if mode == 'producer' && target.name == final_target
|
176
|
+
if (mode == 'producer' || mode == 'producer-fast') && target.name == final_target
|
166
177
|
existing_mark_script = target.build_phases.detect do |phase|
|
167
178
|
if phase.respond_to?(:name)
|
168
179
|
phase.name != nil && phase.name.start_with?("[XCRC] Mark")
|
@@ -187,8 +198,9 @@ module CocoapodsXCRemoteCacheModifier
|
|
187
198
|
config.build_settings.delete('SWIFT_EXEC') if config.build_settings.key?('SWIFT_EXEC')
|
188
199
|
config.build_settings.delete('LIBTOOL') if config.build_settings.key?('LIBTOOL')
|
189
200
|
config.build_settings.delete('LD') if config.build_settings.key?('LD')
|
190
|
-
#
|
201
|
+
# Remove Fake src root for ObjC & Swift
|
191
202
|
config.build_settings.delete('XCREMOTE_CACHE_FAKE_SRCROOT')
|
203
|
+
config.build_settings.delete('XCRC_PLATFORM_PREFERRED_ARCH')
|
192
204
|
remove_cflags!(config.build_settings, '-fdebug-prefix-map')
|
193
205
|
remove_swiftflags!(config.build_settings, '-debug-prefix-map')
|
194
206
|
end
|
@@ -250,14 +262,14 @@ module CocoapodsXCRemoteCacheModifier
|
|
250
262
|
end
|
251
263
|
|
252
264
|
def self.add_cflags!(options, key, value)
|
253
|
-
return if options.fetch('OTHER_CFLAGS',[]).include?(
|
254
|
-
options['OTHER_CFLAGS'] = remove_cflags!(options, key) << "
|
265
|
+
return if options.fetch('OTHER_CFLAGS',[]).include?(value)
|
266
|
+
options['OTHER_CFLAGS'] = remove_cflags!(options, key) << "#{key}=#{value}"
|
255
267
|
end
|
256
268
|
|
257
269
|
def self.remove_cflags!(options, key)
|
258
270
|
cflags_arr = options.fetch('OTHER_CFLAGS', ['$(inherited)'])
|
259
271
|
cflags_arr = [cflags_arr] if cflags_arr.kind_of? String
|
260
|
-
options['OTHER_CFLAGS'] = cflags_arr.delete_if {|flag| flag.
|
272
|
+
options['OTHER_CFLAGS'] = cflags_arr.delete_if {|flag| flag.include?("#{key}=") }
|
261
273
|
options['OTHER_CFLAGS']
|
262
274
|
end
|
263
275
|
|
@@ -272,12 +284,27 @@ module CocoapodsXCRemoteCacheModifier
|
|
272
284
|
end
|
273
285
|
|
274
286
|
# Uninstall the XCRemoteCache
|
275
|
-
def self.disable_xcremotecache(user_project)
|
287
|
+
def self.disable_xcremotecache(user_project, pods_project = nil)
|
276
288
|
user_project.targets.each do |target|
|
277
289
|
disable_xcremotecache_for_target(target)
|
278
290
|
end
|
279
291
|
user_project.save()
|
280
292
|
|
293
|
+
unless pods_project.nil?
|
294
|
+
pods_project.native_targets.each do |target|
|
295
|
+
disable_xcremotecache_for_target(target)
|
296
|
+
end
|
297
|
+
pods_proj_directory = pods_project.project_dir
|
298
|
+
pods_project.root_object.project_references.each do |subproj_ref|
|
299
|
+
generated_project = Xcodeproj::Project.open("#{pods_proj_directory}/#{subproj_ref[:project_ref].path}")
|
300
|
+
generated_project.native_targets.each do |target|
|
301
|
+
disable_xcremotecache_for_target(target)
|
302
|
+
end
|
303
|
+
generated_project.save()
|
304
|
+
end
|
305
|
+
pods_project.save()
|
306
|
+
end
|
307
|
+
|
281
308
|
# Remove .lldbinit rewrite
|
282
309
|
save_lldbinit_rewrite(nil) unless !@@configuration['modify_lldb_init']
|
283
310
|
end
|
@@ -334,7 +361,6 @@ module CocoapodsXCRemoteCacheModifier
|
|
334
361
|
end
|
335
362
|
|
336
363
|
validate_configuration()
|
337
|
-
|
338
364
|
mode = @@configuration['mode']
|
339
365
|
xccc_location = @@configuration['xccc_file']
|
340
366
|
remote_commit_file = @@configuration['remote_commit_file']
|
@@ -353,7 +379,8 @@ module CocoapodsXCRemoteCacheModifier
|
|
353
379
|
download_xcrc_if_needed(xcrc_location_absolute)
|
354
380
|
|
355
381
|
# Save .rcinfo
|
356
|
-
|
382
|
+
root_rcinfo = generate_rcinfo()
|
383
|
+
save_rcinfo(root_rcinfo, user_proj_directory)
|
357
384
|
|
358
385
|
# Create directory for xccc & arc.rc location
|
359
386
|
Dir.mkdir(BIN_DIR) unless File.exist?(BIN_DIR)
|
@@ -368,7 +395,9 @@ module CocoapodsXCRemoteCacheModifier
|
|
368
395
|
# Always integrate XCRemoteCache to all Pods, in case it will be needed later
|
369
396
|
unless installer_context.pods_project.nil?
|
370
397
|
# Attach XCRemoteCache to Pods targets
|
371
|
-
|
398
|
+
# Enable only for native targets which can have compilation steps
|
399
|
+
installer_context.pods_project.native_targets.each do |target|
|
400
|
+
next if target.source_build_phase.files_references.empty?
|
372
401
|
next if target.name.start_with?("Pods-")
|
373
402
|
next if target.name.end_with?("Tests")
|
374
403
|
next if exclude_targets.include?(target.name)
|
@@ -378,8 +407,30 @@ module CocoapodsXCRemoteCacheModifier
|
|
378
407
|
# Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location
|
379
408
|
pods_proj_directory = installer_context.sandbox_root
|
380
409
|
|
381
|
-
#
|
382
|
-
|
410
|
+
# Attach XCRemoteCache to Generated Pods projects
|
411
|
+
installer_context.pods_project.root_object.project_references.each do |subproj_ref|
|
412
|
+
generated_project = Xcodeproj::Project.open("#{pods_proj_directory}/#{subproj_ref[:project_ref].path}")
|
413
|
+
generated_project.native_targets.each do |target|
|
414
|
+
next if target.source_build_phase.files_references.empty?
|
415
|
+
next if target.name.end_with?("Tests")
|
416
|
+
next if exclude_targets.include?(target.name)
|
417
|
+
enable_xcremotecache(target, 1, xcrc_location, xccc_location, mode, exclude_build_configurations, final_target)
|
418
|
+
end
|
419
|
+
generated_project.save()
|
420
|
+
end
|
421
|
+
|
422
|
+
# Manual Pods/.rcinfo generation
|
423
|
+
|
424
|
+
# all paths in .rcinfo are relative to the root so paths used in Pods.xcodeproj need to be aligned
|
425
|
+
pods_path = Pathname.new(pods_proj_directory)
|
426
|
+
root_path = Pathname.new(user_proj_directory)
|
427
|
+
root_path_to_pods = root_path.relative_path_from(pods_path)
|
428
|
+
|
429
|
+
pods_rcinfo = root_rcinfo.merge({
|
430
|
+
'remote_commit_file' => "#{root_path_to_pods}/#{remote_commit_file}",
|
431
|
+
'xccc_file' => "#{root_path_to_pods}/#{xccc_location}"
|
432
|
+
})
|
433
|
+
save_rcinfo(pods_rcinfo, pods_proj_directory)
|
383
434
|
|
384
435
|
installer_context.pods_project.save()
|
385
436
|
end
|
@@ -389,12 +440,12 @@ module CocoapodsXCRemoteCacheModifier
|
|
389
440
|
prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
|
390
441
|
unless prepare_result['result'] || mode != 'consumer'
|
391
442
|
# Uninstall the XCRemoteCache for the consumer mode
|
392
|
-
disable_xcremotecache(user_project)
|
443
|
+
disable_xcremotecache(user_project, installer_context.pods_project)
|
393
444
|
Pod::UI.puts "[XCRC] XCRemoteCache disabled - no artifacts available"
|
394
445
|
next
|
395
446
|
end
|
396
447
|
rescue => error
|
397
|
-
disable_xcremotecache(user_project)
|
448
|
+
disable_xcremotecache(user_project, installer_context.pods_project)
|
398
449
|
Pod::UI.puts "[XCRC] XCRemoteCache failed with an error: #{error}."
|
399
450
|
next
|
400
451
|
end
|
@@ -419,7 +470,7 @@ module CocoapodsXCRemoteCacheModifier
|
|
419
470
|
rescue Exception => e
|
420
471
|
Pod::UI.puts "[XCRC] XCRemoteCache disabled with error: #{e}"
|
421
472
|
puts e.full_message(highlight: true, order: :top)
|
422
|
-
disable_xcremotecache(user_project)
|
473
|
+
disable_xcremotecache(user_project, installer_context.pods_project)
|
423
474
|
end
|
424
475
|
end
|
425
476
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-xcremotecache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Polaczyk
|
8
8
|
- Mark Vasiv
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: CocoaPods plugin that enables XCRemoteCache with the project.
|
15
15
|
email:
|
@@ -34,7 +34,7 @@ homepage: https://github.com/spotify/XCRemoteCache
|
|
34
34
|
licenses:
|
35
35
|
- Apache-2.0
|
36
36
|
metadata: {}
|
37
|
-
post_install_message:
|
37
|
+
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|
40
40
|
- lib
|
@@ -49,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
rubygems_version: 3.2.
|
53
|
-
signing_key:
|
52
|
+
rubygems_version: 3.2.32
|
53
|
+
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: A simple plugin that attaches to the post_install hook and modifies the generated
|
56
56
|
project to use XCRemoteCache. Supports both producing anc consuming parts.
|