cocoapods-xcremotecache 0.0.11 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35a580b1046422fa075fe4922b61967ceed2b26d9fbbecc799d1397956a0174b
4
- data.tar.gz: 80794d37cb6102733f0ff743167f9d7268b8bdf0f04f8be56063c4ae7f19cb47
3
+ metadata.gz: 9929e3043567b27f1a9a8dd2d475876930ed6ba35d654b463776688edcf4f0c4
4
+ data.tar.gz: f03ed16f60910db323d0ae5edf3e3d8db4f5c32b722c417990a3cae3184b9fa7
5
5
  SHA512:
6
- metadata.gz: bb1ed213b18aa38ad521abcc71174419ea83f62e10f11d2cbc2cbffc9894b2aa23dc832b91b208350dd4a9783641e1ed349ffeedbf1b2815d02758a59e5605b7
7
- data.tar.gz: 7514c19217f180da685f9083a4488d8b95451541343c0b604e2989dfe344b0dc1b241e95b116bd448433072bbdf7e38332522ec9f17be243585c8665eeee462d
6
+ metadata.gz: 14d5fba66c6ed362882a1cd6bcdf6a2e9095f81cca83ab7893020232af51839fc2154e61bdb7621f175873c460bfd5178413fc73d3c6f9c7a08c4354b3880486
7
+ data.tar.gz: 7ea3092b9c346a2d75d0df98431a721badc7065449a1f89ab19db8fa58137002907e39a755dfffa789cb2cbe1e491aa4b5ffbee31a694df9752a236981619cc8
data/README.md CHANGED
@@ -63,7 +63,3 @@ To fully uninstall the plugin, call:
63
63
  ```bash
64
64
  gem uninstall cocoapods-xcremotecache
65
65
  ```
66
-
67
- ## Limitations
68
-
69
- * When `generate_multiple_pod_projects` mode is enabled, only first-party targets are cached by XCRemoteCache (all dependencies are compiled locally).
@@ -27,8 +27,9 @@ module CocoapodsXCRemoteCacheModifier
27
27
  LLDB_INIT_COMMENT="#RemoteCacheCustomSourceMap"
28
28
  LLDB_INIT_PATH = "#{ENV['HOME']}/.lldbinit"
29
29
  FAT_ARCHIVE_NAME_INFIX = 'arm64-x86_64'
30
+ XCRC_COOCAPODS_ROOT_KEY = 'XCRC_COOCAPODS_ROOT'
30
31
 
31
- # List of plugins' user properties that should be copied to .rcinfo
32
+ # List of plugins' user properties that should not be copied to .rcinfo
32
33
  CUSTOM_CONFIGURATION_KEYS = [
33
34
  'enabled',
34
35
  'xcrc_location',
@@ -38,9 +39,7 @@ module CocoapodsXCRemoteCacheModifier
38
39
  'check_build_configuration',
39
40
  'check_platform',
40
41
  'modify_lldb_init',
41
- 'prettify_meta_files',
42
42
  'fake_src_root',
43
- 'disable_certificate_verification'
44
43
  ]
45
44
 
46
45
  class XCRemoteCache
@@ -64,9 +63,14 @@ module CocoapodsXCRemoteCacheModifier
64
63
  'exclude_targets' => [],
65
64
  'prettify_meta_files' => false,
66
65
  'fake_src_root' => "/#{'x' * 10 }",
67
- 'disable_certificate_verification' => false
66
+ 'disable_certificate_verification' => false,
67
+ 'custom_rewrite_envs' => []
68
68
  }
69
69
  @@configuration.merge! default_values.select { |k, v| !@@configuration.key?(k) }
70
+ # Always include XCRC_COOCAPODS_ROOT_KEY in custom_rewrite_envs
71
+ unless @@configuration['custom_rewrite_envs'].include?(XCRC_COOCAPODS_ROOT_KEY)
72
+ @@configuration['custom_rewrite_envs'] << XCRC_COOCAPODS_ROOT_KEY
73
+ end
70
74
  end
71
75
 
72
76
  def self.validate_configuration()
@@ -109,6 +113,8 @@ module CocoapodsXCRemoteCacheModifier
109
113
  # @param final_target [String] name of target that should trigger marking
110
114
  def self.enable_xcremotecache(target, repo_distance, xc_location, xc_cc_path, mode, exclude_build_configurations, final_target, fake_src_root)
111
115
  srcroot_relative_xc_location = parent_dir(xc_location, repo_distance)
116
+ # location of the entrite CocoaPods project, relative to SRCROOT
117
+ srcroot_relative_project_location = parent_dir('', repo_distance)
112
118
 
113
119
  target.build_configurations.each do |config|
114
120
  # apply only for relevant Configurations
@@ -121,9 +127,12 @@ module CocoapodsXCRemoteCacheModifier
121
127
  config.build_settings['SWIFT_EXEC'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc"]
122
128
  config.build_settings['LIBTOOL'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xclibtool"]
123
129
  config.build_settings['LD'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcld"]
130
+ config.build_settings['LDPLUSPLUS'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcldplusplus"]
131
+ config.build_settings['SWIFT_USE_INTEGRATED_DRIVER'] = ['NO']
124
132
 
125
133
  config.build_settings['XCREMOTE_CACHE_FAKE_SRCROOT'] = fake_src_root
126
134
  config.build_settings['XCRC_PLATFORM_PREFERRED_ARCH'] = ["$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"]
135
+ config.build_settings[XCRC_COOCAPODS_ROOT_KEY] = ["$SRCROOT/#{srcroot_relative_project_location}"]
127
136
  debug_prefix_map_replacement = '$(SRCROOT' + ':dir:standardizepath' * repo_distance + ')'
128
137
  add_cflags!(config.build_settings, '-fdebug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
129
138
  add_swiftflags!(config.build_settings, '-debug-prefix-map', "#{debug_prefix_map_replacement}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
@@ -174,6 +183,11 @@ module CocoapodsXCRemoteCacheModifier
174
183
  "$(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"
175
184
  ]
176
185
  postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d"
186
+ # Move postbuild (last element) to the position after compile sources phase (to make it real 'postbuild')
187
+ if !existing_postbuild_script
188
+ compile_phase_index = target.build_phases.index(target.source_build_phase)
189
+ target.build_phases.insert(compile_phase_index + 1, target.build_phases.delete(postbuild_script))
190
+ end
177
191
 
178
192
  # Mark a sha as ready for a given platform and configuration when building the final_target
179
193
  if (mode == 'producer' || mode == 'producer-fast') && target.name == final_target
@@ -201,9 +215,12 @@ module CocoapodsXCRemoteCacheModifier
201
215
  config.build_settings.delete('SWIFT_EXEC') if config.build_settings.key?('SWIFT_EXEC')
202
216
  config.build_settings.delete('LIBTOOL') if config.build_settings.key?('LIBTOOL')
203
217
  config.build_settings.delete('LD') if config.build_settings.key?('LD')
218
+ config.build_settings.delete('LDPLUSPLUS') if config.build_settings.key?('LDPLUSPLUS')
219
+ config.build_settings.delete('SWIFT_USE_INTEGRATED_DRIVER') if config.build_settings.key?('SWIFT_USE_INTEGRATED_DRIVER')
204
220
  # Remove Fake src root for ObjC & Swift
205
221
  config.build_settings.delete('XCREMOTE_CACHE_FAKE_SRCROOT')
206
222
  config.build_settings.delete('XCRC_PLATFORM_PREFERRED_ARCH')
223
+ config.build_settings.delete(XCRC_COOCAPODS_ROOT_KEY)
207
224
  remove_cflags!(config.build_settings, '-fdebug-prefix-map')
208
225
  remove_swiftflags!(config.build_settings, '-debug-prefix-map')
209
226
  end
@@ -223,7 +240,7 @@ module CocoapodsXCRemoteCacheModifier
223
240
  end
224
241
 
225
242
  def self.download_xcrc_if_needed(local_location)
226
- required_binaries = ['xcld', 'xclibtool', 'xcpostbuild', 'xcprebuild', 'xcprepare', 'xcswiftc']
243
+ required_binaries = ['xcld', 'xcldplusplus', 'xclibtool', 'xcpostbuild', 'xcprebuild', 'xcprepare', 'xcswiftc']
227
244
  binaries_exist = required_binaries.reduce(true) do |exists, filename|
228
245
  file_path = File.join(local_location, filename)
229
246
  exists = exists && File.exist?(file_path)
@@ -345,12 +362,73 @@ module CocoapodsXCRemoteCacheModifier
345
362
  File.write(LLDB_INIT_PATH, lldbinit_lines.join("\n"), mode: "w")
346
363
  end
347
364
 
348
- Pod::HooksManager.register('cocoapods-xcremotecache', :post_install) do |installer_context|
365
+ Pod::HooksManager.register('cocoapods-xcremotecache', :pre_install) do |installer_context|
366
+ # The main responsibility of that hook is forcing Pods regeneration when XCRemoteCache is enabled for the first time
367
+ # In the post_install hook, this plugin adds extra build settings and steps to all Pods targets, but only when XCRemoteCache
368
+ # is enabled and all artifacts are available (i.e. xcprepare returns 0).
369
+ # If Pods projects/targets are cached from previous `pod install` action that didn't enable XCRemoteCache (e.g. artifacts
370
+ # are not available in the remote cache), these projects/targets should be invalidated to include XCRemoteCache-related
371
+ # build steps and build settings.
349
372
  if @@configuration.nil?
350
373
  Pod::UI.puts "[XCRC] Warning! XCRemoteCache not configured. Call xcremotecache({...}) in Podfile to enable XCRemoteCache"
351
374
  next
352
375
  end
353
376
 
377
+ begin
378
+ # `user_pod_directory`` and `user_proj_directory` in the 'postinstall' should be equal
379
+ user_pod_directory = File.dirname(installer_context.podfile.defined_in_file)
380
+ set_configuration_default_values
381
+
382
+ unless @@configuration['enabled']
383
+ # No need to check if enabling remote cache for the first time
384
+ next
385
+ end
386
+
387
+ validate_configuration()
388
+ mode = @@configuration['mode']
389
+ remote_commit_file = @@configuration['remote_commit_file']
390
+ xcrc_location = @@configuration['xcrc_location']
391
+ check_build_configuration = @@configuration['check_build_configuration']
392
+ check_platform = @@configuration['check_platform']
393
+
394
+ xcrc_location_absolute = "#{user_pod_directory}/#{xcrc_location}"
395
+ remote_commit_file_absolute = "#{user_pod_directory}/#{remote_commit_file}"
396
+
397
+ # Download XCRC
398
+ download_xcrc_if_needed(xcrc_location_absolute)
399
+
400
+ # Save .rcinfo
401
+ root_rcinfo = generate_rcinfo()
402
+ save_rcinfo(root_rcinfo, user_pod_directory)
403
+
404
+ # Create directory for xccc & arc.rc location
405
+ Dir.mkdir(BIN_DIR) unless File.exist?(BIN_DIR)
406
+
407
+ # Remove previous xccc & arc.rc
408
+ was_previously_enabled = File.exist?(remote_commit_file_absolute)
409
+ File.delete(remote_commit_file_absolute) if File.exist?(remote_commit_file_absolute)
410
+
411
+ prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
412
+ if !prepare_result['result'] && mode == 'consumer'
413
+ # Remote cache is still disabled - no need to force Pods projects/targets regeneration
414
+ next
415
+ end
416
+
417
+ # Force rebuilding all Pods project, because XCRC build steps and settings need to be added to Pods project/targets
418
+ # It is relevant only when 'incremental_installation' is enabled, otherwise installed_cache_path does not exist on a disk
419
+ installed_cache_path = installer_context.sandbox.project_installation_cache_path
420
+ if !was_previously_enabled && File.exist?(installed_cache_path)
421
+ Pod::UI.puts "[XCRC] Forces Pods project regenerations because XCRC is enabled for the first time."
422
+ File.delete(installed_cache_path)
423
+ end
424
+ end
425
+ end
426
+
427
+ Pod::HooksManager.register('cocoapods-xcremotecache', :post_install) do |installer_context|
428
+ if @@configuration.nil?
429
+ next
430
+ end
431
+
354
432
  user_project = installer_context.umbrella_targets[0].user_project
355
433
 
356
434
  begin
@@ -377,20 +455,12 @@ module CocoapodsXCRemoteCacheModifier
377
455
 
378
456
  xccc_location_absolute = "#{user_proj_directory}/#{xccc_location}"
379
457
  xcrc_location_absolute = "#{user_proj_directory}/#{xcrc_location}"
380
- remote_commit_file_absolute = "#{user_proj_directory}/#{remote_commit_file}"
381
-
382
- # Download XCRC
383
- download_xcrc_if_needed(xcrc_location_absolute)
384
458
 
385
459
  # Save .rcinfo
386
460
  root_rcinfo = generate_rcinfo()
387
461
  save_rcinfo(root_rcinfo, user_proj_directory)
388
462
 
389
- # Create directory for xccc & arc.rc location
390
- Dir.mkdir(BIN_DIR) unless File.exist?(BIN_DIR)
391
-
392
- # Remove previous xccc & arc.rc
393
- File.delete(remote_commit_file_absolute) if File.exist?(remote_commit_file_absolute)
463
+ # Remove previous xccc
394
464
  File.delete(xccc_location_absolute) if File.exist?(xccc_location_absolute)
395
465
 
396
466
  # Prepare XCRC
@@ -441,6 +511,7 @@ module CocoapodsXCRemoteCacheModifier
441
511
 
442
512
  # Enabled/disable XCRemoteCache for the main (user) project
443
513
  begin
514
+ # TODO: Do not compile xcc again. `xcprepare` compiles it in pre-install anyway
444
515
  prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
445
516
  unless prepare_result['result'] || mode != 'consumer'
446
517
  # Uninstall the XCRemoteCache for the consumer mode
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module CocoapodsXcremotecache
16
- VERSION = "0.0.11"
16
+ VERSION = "0.0.14"
17
17
  end
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.11
4
+ version: 0.0.14
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: 2022-05-12 00:00:00.000000000 Z
12
+ date: 2022-08-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: CocoaPods plugin that enables XCRemoteCache with the project.
15
15
  email: