cocoapods-xcremotecache 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/cocoapods-xcremotecache/command/hooks.rb +101 -55
- data/lib/cocoapods-xcremotecache/gem_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec0659df232b506d6211509e65fa1bcdc1c405df1392fba1d846f9d90fe816e
|
4
|
+
data.tar.gz: ee6f1445269a3c929015ef1be4666133dc8a3b87921a40961759d4ff4a20937b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2b76a94e7dbf545baeb4ac6f581e08a19488a51ed14a23d24a9429938d7052f759f0c1daada0db553691bdaa352ec8b63ace617f66abda238b031d389efae2
|
7
|
+
data.tar.gz: d5b9b7bb4bed7da81069522198ca6000754bc056b27bcd756034f67aa46c82bc231bae2ecb40820a63ce455b291973bce74ed97982cf8f92f84dc6af3ea57519
|
data/README.md
CHANGED
@@ -4,6 +4,14 @@ The CocoaPods plugin that integrates XCRemoteCache with the project.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
### Using RubyGems
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install cocoapods-xcremotecache
|
11
|
+
```
|
12
|
+
|
13
|
+
### From sources
|
14
|
+
|
7
15
|
Build & install the plugin
|
8
16
|
|
9
17
|
```bash
|
@@ -52,3 +60,7 @@ To fully uninstall the plugin, call:
|
|
52
60
|
```bash
|
53
61
|
gem uninstall cocoapods-xcremotecache
|
54
62
|
```
|
63
|
+
|
64
|
+
## Limitations
|
65
|
+
|
66
|
+
* When `generate_multiple_pod_projects` mode is enabled, only first-party targets are cached by XCRemoteCache (all dependencies are compiled locally).
|
@@ -46,17 +46,17 @@ module CocoapodsXCRemoteCacheModifier
|
|
46
46
|
@@configuration = c
|
47
47
|
end
|
48
48
|
|
49
|
-
def self.set_configuration_default_values
|
49
|
+
def self.set_configuration_default_values
|
50
50
|
default_values = {
|
51
51
|
'mode' => 'consumer',
|
52
52
|
'enabled' => true,
|
53
|
-
'xcrc_location' => "
|
53
|
+
'xcrc_location' => "XCRC",
|
54
54
|
'exclude_build_configurations' => [],
|
55
55
|
'check_build_configuration' => 'Debug',
|
56
56
|
'check_platform' => 'iphonesimulator',
|
57
57
|
'modify_lldb_init' => true,
|
58
|
-
'xccc_file' => "#{
|
59
|
-
'remote_commit_file' => "#{
|
58
|
+
'xccc_file' => "#{BIN_DIR}/xccc",
|
59
|
+
'remote_commit_file' => "#{BIN_DIR}/arc.rc",
|
60
60
|
'exclude_targets' => [],
|
61
61
|
}
|
62
62
|
@@configuration.merge! default_values.select { |k, v| !@@configuration.key?(k) }
|
@@ -89,61 +89,95 @@ module CocoapodsXCRemoteCacheModifier
|
|
89
89
|
@@configuration.select { |key, value| !CUSTOM_CONFIGURATION_KEYS.include?(key) }
|
90
90
|
end
|
91
91
|
|
92
|
-
def self.
|
93
|
-
|
94
|
-
|
95
|
-
next if exclude_build_configurations.include?(config.name)
|
96
|
-
if mode == 'consumer'
|
97
|
-
config.build_settings['CC'] = [xc_cc_path]
|
98
|
-
end
|
99
|
-
config.build_settings['SWIFT_EXEC'] = ["#{xc_location}/xcswiftc"]
|
100
|
-
config.build_settings['LIBTOOL'] = ["#{xc_location}/xclibtool"]
|
101
|
-
config.build_settings['LD'] = ["#{xc_location}/xcld"]
|
92
|
+
def self.parent_dir(path, parent_count)
|
93
|
+
"../" * parent_count + path
|
94
|
+
end
|
102
95
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
# @param target [Target] target to apply XCRemoteCache
|
97
|
+
# @param repo_distance [Integer] distance from the git repo root to the target's $SRCROOT
|
98
|
+
# @param xc_location [String] path to the dir with all XCRemoteCache binaries, relative to the repo root
|
99
|
+
# @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.)
|
101
|
+
# @param exclude_build_configurations [String[]] list of targets that should have disabled remote cache
|
102
|
+
# @param final_target [String] name of target that should trigger marking
|
103
|
+
def self.enable_xcremotecache(target, repo_distance, xc_location, xc_cc_path, mode, exclude_build_configurations, final_target)
|
104
|
+
srcroot_relative_xc_location = parent_dir(xc_location, repo_distance)
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if
|
113
|
-
|
106
|
+
target.build_configurations.each do |config|
|
107
|
+
# apply only for relevant Configurations
|
108
|
+
next if exclude_build_configurations.include?(config.name)
|
109
|
+
if mode == 'consumer'
|
110
|
+
config.build_settings['CC'] = ["$SRCROOT/#{parent_dir(xc_cc_path, repo_distance)}"]
|
114
111
|
end
|
115
|
-
|
112
|
+
config.build_settings['SWIFT_EXEC'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc"]
|
113
|
+
config.build_settings['LIBTOOL'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xclibtool"]
|
114
|
+
config.build_settings['LD'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcld"]
|
115
|
+
|
116
|
+
config.build_settings['XCREMOTE_CACHE_FAKE_SRCROOT'] = FAKE_SRCROOT
|
117
|
+
debug_prefix_map_replacement = '$(SRCROOT' + ':dir:standardizepath' * repo_distance + ')'
|
118
|
+
add_cflags!(config.build_settings, '-fdebug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
|
119
|
+
add_swiftflags!(config.build_settings, '-debug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
|
120
|
+
end
|
116
121
|
|
117
122
|
# Prebuild
|
118
123
|
if mode == 'consumer'
|
119
|
-
|
124
|
+
existing_prebuild_script = target.build_phases.detect do |phase|
|
125
|
+
if phase.respond_to?(:name)
|
126
|
+
phase.name != nil && phase.name.start_with?("[XCRC] Prebuild")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
prebuild_script = existing_prebuild_script || target.new_shell_script_build_phase("[XCRC] Prebuild")
|
120
130
|
prebuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
|
121
|
-
prebuild_script.input_paths = ["
|
131
|
+
prebuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcprebuild"]
|
122
132
|
prebuild_script.output_paths = [
|
123
|
-
"$(TARGET_TEMP_DIR)/rc.enabled",
|
133
|
+
"$(TARGET_TEMP_DIR)/rc.enabled",
|
124
134
|
"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)"
|
125
135
|
]
|
126
136
|
prebuild_script.dependency_file = "$(TARGET_TEMP_DIR)/prebuild.d"
|
127
137
|
|
128
138
|
# Move prebuild (last element) to the first position (to make it real 'prebuild')
|
129
|
-
target.build_phases.rotate!(-1)
|
139
|
+
target.build_phases.rotate!(-1) if existing_prebuild_script.nil?
|
140
|
+
elsif mode == 'producer'
|
141
|
+
# Delete existing prebuild build phase (to support switching between modes)
|
142
|
+
target.build_phases.delete_if do |phase|
|
143
|
+
if phase.respond_to?(:name)
|
144
|
+
phase.name != nil && phase.name.start_with?("[XCRC] Prebuild")
|
145
|
+
end
|
146
|
+
end
|
130
147
|
end
|
131
148
|
|
132
149
|
# Postbuild
|
133
|
-
|
150
|
+
existing_postbuild_script = target.build_phases.detect do |phase|
|
151
|
+
if phase.respond_to?(:name)
|
152
|
+
phase.name != nil && phase.name.start_with?("[XCRC] Postbuild")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
postbuild_script = existing_postbuild_script || target.new_shell_script_build_phase("[XCRC] Postbuild")
|
134
156
|
postbuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
|
135
|
-
postbuild_script.input_paths = ["
|
157
|
+
postbuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcpostbuild"]
|
136
158
|
postbuild_script.output_paths = [
|
137
|
-
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(PLATFORM_PREFERRED_ARCH).swiftmodule.md5",
|
159
|
+
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(PLATFORM_PREFERRED_ARCH).swiftmodule.md5",
|
138
160
|
"$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5"
|
139
161
|
]
|
140
162
|
postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d"
|
141
163
|
|
142
164
|
# Mark a sha as ready for a given platform and configuration when building the final_target
|
143
165
|
if mode == 'producer' && target.name == final_target
|
144
|
-
|
166
|
+
existing_mark_script = target.build_phases.detect do |phase|
|
167
|
+
if phase.respond_to?(:name)
|
168
|
+
phase.name != nil && phase.name.start_with?("[XCRC] Mark")
|
169
|
+
end
|
170
|
+
end
|
171
|
+
mark_script = existing_mark_script || target.new_shell_script_build_phase("[XCRC] Mark")
|
145
172
|
mark_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\" mark --configuration $CONFIGURATION --platform $PLATFORM_NAME"
|
146
|
-
mark_script.input_paths = ["
|
173
|
+
mark_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcprepare"]
|
174
|
+
else
|
175
|
+
# Delete existing mark build phase (to support switching between modes or changing the final target)
|
176
|
+
target.build_phases.delete_if do |phase|
|
177
|
+
if phase.respond_to?(:name)
|
178
|
+
phase.name != nil && phase.name.start_with?("[XCRC] Mark")
|
179
|
+
end
|
180
|
+
end
|
147
181
|
end
|
148
182
|
end
|
149
183
|
|
@@ -251,6 +285,7 @@ module CocoapodsXCRemoteCacheModifier
|
|
251
285
|
# Returns the content (array of lines) of the lldbinit with stripped XCRemoteCache rewrite
|
252
286
|
def self.clean_lldbinit_content(lldbinit_path)
|
253
287
|
all_lines = []
|
288
|
+
return all_lines unless File.exist?(lldbinit_path)
|
254
289
|
File.open(lldbinit_path) { |file|
|
255
290
|
while(line = file.gets) != nil
|
256
291
|
line = line.strip
|
@@ -290,7 +325,7 @@ module CocoapodsXCRemoteCacheModifier
|
|
290
325
|
|
291
326
|
begin
|
292
327
|
user_proj_directory = File.dirname(user_project.path)
|
293
|
-
set_configuration_default_values
|
328
|
+
set_configuration_default_values
|
294
329
|
|
295
330
|
unless @@configuration['enabled']
|
296
331
|
Pod::UI.puts "[XCRC] XCRemoteCache disabled"
|
@@ -310,8 +345,12 @@ module CocoapodsXCRemoteCacheModifier
|
|
310
345
|
check_build_configuration = @@configuration['check_build_configuration']
|
311
346
|
check_platform = @@configuration['check_platform']
|
312
347
|
|
348
|
+
xccc_location_absolute = "#{user_proj_directory}/#{xccc_location}"
|
349
|
+
xcrc_location_absolute = "#{user_proj_directory}/#{xcrc_location}"
|
350
|
+
remote_commit_file_absolute = "#{user_proj_directory}/#{remote_commit_file}"
|
351
|
+
|
313
352
|
# Download XCRC
|
314
|
-
download_xcrc_if_needed(
|
353
|
+
download_xcrc_if_needed(xcrc_location_absolute)
|
315
354
|
|
316
355
|
# Save .rcinfo
|
317
356
|
save_rcinfo(generate_rcinfo(), user_proj_directory)
|
@@ -320,12 +359,34 @@ module CocoapodsXCRemoteCacheModifier
|
|
320
359
|
Dir.mkdir(BIN_DIR) unless File.exist?(BIN_DIR)
|
321
360
|
|
322
361
|
# Remove previous xccc & arc.rc
|
323
|
-
File.delete(
|
324
|
-
File.delete(
|
362
|
+
File.delete(remote_commit_file_absolute) if File.exist?(remote_commit_file_absolute)
|
363
|
+
File.delete(xccc_location_absolute) if File.exist?(xccc_location_absolute)
|
325
364
|
|
326
365
|
# Prepare XCRC
|
366
|
+
|
367
|
+
# Pods projects can be generated only once (if incremental_installation is enabled)
|
368
|
+
# Always integrate XCRemoteCache to all Pods, in case it will be needed later
|
369
|
+
unless installer_context.pods_project.nil?
|
370
|
+
# Attach XCRemoteCache to Pods targets
|
371
|
+
installer_context.pods_project.targets.each do |target|
|
372
|
+
next if target.name.start_with?("Pods-")
|
373
|
+
next if target.name.end_with?("Tests")
|
374
|
+
next if exclude_targets.include?(target.name)
|
375
|
+
enable_xcremotecache(target, 1, xcrc_location, xccc_location, mode, exclude_build_configurations, final_target)
|
376
|
+
end
|
377
|
+
|
378
|
+
# Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location
|
379
|
+
pods_proj_directory = installer_context.sandbox_root
|
380
|
+
|
381
|
+
# Manual .rcinfo generation (in YAML format)
|
382
|
+
save_rcinfo({'extra_configuration_file' => "#{user_proj_directory}/.rcinfo"}, pods_proj_directory)
|
383
|
+
|
384
|
+
installer_context.pods_project.save()
|
385
|
+
end
|
386
|
+
|
387
|
+
# Enabled/disable XCRemoteCache for the main (user) project
|
327
388
|
begin
|
328
|
-
prepare_result = YAML.load`#{
|
389
|
+
prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
|
329
390
|
unless prepare_result['result'] || mode != 'consumer'
|
330
391
|
# Uninstall the XCRemoteCache for the consumer mode
|
331
392
|
disable_xcremotecache(user_project)
|
@@ -338,26 +399,11 @@ module CocoapodsXCRemoteCacheModifier
|
|
338
399
|
next
|
339
400
|
end
|
340
401
|
|
341
|
-
# Attach XCRemoteCache to Pods targets
|
342
|
-
installer_context.pods_project.targets.each do |target|
|
343
|
-
next if target.name.start_with?("Pods-")
|
344
|
-
next if target.name.end_with?("Tests")
|
345
|
-
next if exclude_targets.include?(target.name)
|
346
|
-
enable_xcremotecache(target, user_proj_directory, xcrc_location, xccc_location, mode, exclude_build_configurations, check_build_configuration, check_platform, final_target)
|
347
|
-
end
|
348
|
-
|
349
|
-
# Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location
|
350
|
-
pods_proj_directory = installer_context.sandbox_root
|
351
|
-
|
352
|
-
# Manual .rcinfo generation (in YAML format)
|
353
|
-
save_rcinfo({'extra_configuration_file' => "#{user_proj_directory}/.rcinfo"}, pods_proj_directory)
|
354
|
-
|
355
|
-
installer_context.pods_project.save()
|
356
402
|
|
357
403
|
# Attach XCRC to the app targets
|
358
404
|
user_project.targets.each do |target|
|
359
405
|
next if exclude_targets.include?(target.name)
|
360
|
-
enable_xcremotecache(target,
|
406
|
+
enable_xcremotecache(target, 0, xcrc_location, xccc_location, mode, exclude_build_configurations, final_target)
|
361
407
|
end
|
362
408
|
|
363
409
|
# Set Target sourcemap
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Polaczyk
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: CocoaPods plugin that enables XCRemoteCache with the project.
|
15
15
|
email:
|