cocoapods-xcremotecache 0.0.5 → 0.0.8

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: 073bb6eb42ef3ca4b2911ecf1a22f57d3fee56b4ca151446b542c1e2a8ea95bd
4
- data.tar.gz: 3baa31150bb89f06635781eaae290b9b998776f0e0d5f099fa93197a84034de9
3
+ metadata.gz: 4eece05bcb4153a716f7646326bb8dae03fc01f22f829ed016a3bca53c2df720
4
+ data.tar.gz: de181437326d7553a3345c1811d1a16f343de388373f9c5d2747c03fd2dca212
5
5
  SHA512:
6
- metadata.gz: 3a1a857abfdd8231b6eeaaeb626bd0b446bd58176b03143e0d1c292c78b2bd56c8f1e567293708f71518c91f6869326f726b20582286172b68de6f657198bebc
7
- data.tar.gz: 987ecea74817a95bf1b1bda403e17d2494d65cc6e5c8c24666f239ae3fd83721474405e5fe3daa87112bb725346432019f6892f0a0ce327741890d449554aa58
6
+ metadata.gz: 108860776e61d492b3a530d57441cdac752c4d509bfb2260d11dae80250bd50c54cd029076993a8237da0aed67e289de7dedb790c9cc2f1fd7e4800df30df24e
7
+ data.tar.gz: 962ad32c264c26fa98d37efb335e6b6e8016e2a4432c5f9f5240041045aa9c1d66f1cb2bbc1eede2fcfbbaf8150a06217927b9805f42c3b93640f485bd84ee23
@@ -82,8 +82,8 @@ module CocoapodsXCRemoteCacheModifier
82
82
  end
83
83
 
84
84
  mode = @@configuration['mode']
85
- unless mode == 'consumer' || mode == 'producer'
86
- 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?"
87
87
  end
88
88
 
89
89
  unless mode == 'consumer' || @@configuration.key?('final_target')
@@ -103,7 +103,7 @@ module CocoapodsXCRemoteCacheModifier
103
103
  # @param repo_distance [Integer] distance from the git repo root to the target's $SRCROOT
104
104
  # @param xc_location [String] path to the dir with all XCRemoteCache binaries, relative to the repo root
105
105
  # @param xc_cc_path [String] path to the XCRemoteCache clang wrapper, relative to the repo root
106
- # @param mode [String] mode name ('consumer', 'producer' etc.)
106
+ # @param mode [String] mode name ('consumer', 'producer', 'producer-fast' etc.)
107
107
  # @param exclude_build_configurations [String[]] list of targets that should have disabled remote cache
108
108
  # @param final_target [String] name of target that should trigger marking
109
109
  def self.enable_xcremotecache(target, repo_distance, xc_location, xc_cc_path, mode, exclude_build_configurations, final_target)
@@ -114,6 +114,8 @@ module CocoapodsXCRemoteCacheModifier
114
114
  next if exclude_build_configurations.include?(config.name)
115
115
  if mode == 'consumer'
116
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')
117
119
  end
118
120
  config.build_settings['SWIFT_EXEC'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc"]
119
121
  config.build_settings['LIBTOOL'] = ["$SRCROOT/#{srcroot_relative_xc_location}/xclibtool"]
@@ -133,7 +135,8 @@ module CocoapodsXCRemoteCacheModifier
133
135
  phase.name != nil && phase.name.start_with?("[XCRC] Prebuild")
134
136
  end
135
137
  end
136
- prebuild_script = existing_prebuild_script || target.new_shell_script_build_phase("[XCRC] Prebuild")
138
+
139
+ prebuild_script = existing_prebuild_script || target.new_shell_script_build_phase("[XCRC] Prebuild #{target.name}")
137
140
  prebuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
138
141
  prebuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcprebuild"]
139
142
  prebuild_script.output_paths = [
@@ -142,9 +145,10 @@ module CocoapodsXCRemoteCacheModifier
142
145
  ]
143
146
  prebuild_script.dependency_file = "$(TARGET_TEMP_DIR)/prebuild.d"
144
147
 
145
- # Move prebuild (last element) to the first position (to make it real 'prebuild')
146
- target.build_phases.rotate!(-1) if existing_prebuild_script.nil?
147
- elsif mode == 'producer'
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'
148
152
  # Delete existing prebuild build phase (to support switching between modes)
149
153
  target.build_phases.delete_if do |phase|
150
154
  if phase.respond_to?(:name)
@@ -159,7 +163,7 @@ module CocoapodsXCRemoteCacheModifier
159
163
  phase.name != nil && phase.name.start_with?("[XCRC] Postbuild")
160
164
  end
161
165
  end
162
- 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}")
163
167
  postbuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
164
168
  postbuild_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcpostbuild"]
165
169
  postbuild_script.output_paths = [
@@ -169,14 +173,14 @@ module CocoapodsXCRemoteCacheModifier
169
173
  postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d"
170
174
 
171
175
  # Mark a sha as ready for a given platform and configuration when building the final_target
172
- if mode == 'producer' && target.name == final_target
176
+ if (mode == 'producer' || mode == 'producer-fast') && target.name == final_target
173
177
  existing_mark_script = target.build_phases.detect do |phase|
174
178
  if phase.respond_to?(:name)
175
179
  phase.name != nil && phase.name.start_with?("[XCRC] Mark")
176
180
  end
177
181
  end
178
182
  mark_script = existing_mark_script || target.new_shell_script_build_phase("[XCRC] Mark")
179
- mark_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\" mark --configuration $CONFIGURATION --platform $PLATFORM_NAME"
183
+ mark_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\" mark --configuration \"$CONFIGURATION\" --platform $PLATFORM_NAME"
180
184
  mark_script.input_paths = ["$SRCROOT/#{srcroot_relative_xc_location}/xcprepare"]
181
185
  else
182
186
  # Delete existing mark build phase (to support switching between modes or changing the final target)
@@ -194,8 +198,9 @@ module CocoapodsXCRemoteCacheModifier
194
198
  config.build_settings.delete('SWIFT_EXEC') if config.build_settings.key?('SWIFT_EXEC')
195
199
  config.build_settings.delete('LIBTOOL') if config.build_settings.key?('LIBTOOL')
196
200
  config.build_settings.delete('LD') if config.build_settings.key?('LD')
197
- # Add Fake src root for ObjC & Swift
201
+ # Remove Fake src root for ObjC & Swift
198
202
  config.build_settings.delete('XCREMOTE_CACHE_FAKE_SRCROOT')
203
+ config.build_settings.delete('XCRC_PLATFORM_PREFERRED_ARCH')
199
204
  remove_cflags!(config.build_settings, '-fdebug-prefix-map')
200
205
  remove_swiftflags!(config.build_settings, '-debug-prefix-map')
201
206
  end
@@ -257,14 +262,14 @@ module CocoapodsXCRemoteCacheModifier
257
262
  end
258
263
 
259
264
  def self.add_cflags!(options, key, value)
260
- return if options.fetch('OTHER_CFLAGS',[]).include?(' ' + value)
261
- options['OTHER_CFLAGS'] = remove_cflags!(options, key) << " #{key}=#{value}"
265
+ return if options.fetch('OTHER_CFLAGS',[]).include?(value)
266
+ options['OTHER_CFLAGS'] = remove_cflags!(options, key) << "#{key}=#{value}"
262
267
  end
263
268
 
264
269
  def self.remove_cflags!(options, key)
265
270
  cflags_arr = options.fetch('OTHER_CFLAGS', ['$(inherited)'])
266
271
  cflags_arr = [cflags_arr] if cflags_arr.kind_of? String
267
- options['OTHER_CFLAGS'] = cflags_arr.delete_if {|flag| flag.start_with?(" #{key}=") }
272
+ options['OTHER_CFLAGS'] = cflags_arr.delete_if {|flag| flag.include?("#{key}=") }
268
273
  options['OTHER_CFLAGS']
269
274
  end
270
275
 
@@ -279,12 +284,27 @@ module CocoapodsXCRemoteCacheModifier
279
284
  end
280
285
 
281
286
  # Uninstall the XCRemoteCache
282
- def self.disable_xcremotecache(user_project)
287
+ def self.disable_xcremotecache(user_project, pods_project = nil)
283
288
  user_project.targets.each do |target|
284
289
  disable_xcremotecache_for_target(target)
285
290
  end
286
291
  user_project.save()
287
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
+
288
308
  # Remove .lldbinit rewrite
289
309
  save_lldbinit_rewrite(nil) unless !@@configuration['modify_lldb_init']
290
310
  end
@@ -375,7 +395,9 @@ module CocoapodsXCRemoteCacheModifier
375
395
  # Always integrate XCRemoteCache to all Pods, in case it will be needed later
376
396
  unless installer_context.pods_project.nil?
377
397
  # Attach XCRemoteCache to Pods targets
378
- installer_context.pods_project.targets.each do |target|
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?
379
401
  next if target.name.start_with?("Pods-")
380
402
  next if target.name.end_with?("Tests")
381
403
  next if exclude_targets.include?(target.name)
@@ -385,6 +407,18 @@ module CocoapodsXCRemoteCacheModifier
385
407
  # Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location
386
408
  pods_proj_directory = installer_context.sandbox_root
387
409
 
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
+
388
422
  # Manual Pods/.rcinfo generation
389
423
 
390
424
  # all paths in .rcinfo are relative to the root so paths used in Pods.xcodeproj need to be aligned
@@ -406,12 +440,12 @@ module CocoapodsXCRemoteCacheModifier
406
440
  prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
407
441
  unless prepare_result['result'] || mode != 'consumer'
408
442
  # Uninstall the XCRemoteCache for the consumer mode
409
- disable_xcremotecache(user_project)
443
+ disable_xcremotecache(user_project, installer_context.pods_project)
410
444
  Pod::UI.puts "[XCRC] XCRemoteCache disabled - no artifacts available"
411
445
  next
412
446
  end
413
447
  rescue => error
414
- disable_xcremotecache(user_project)
448
+ disable_xcremotecache(user_project, installer_context.pods_project)
415
449
  Pod::UI.puts "[XCRC] XCRemoteCache failed with an error: #{error}."
416
450
  next
417
451
  end
@@ -436,7 +470,7 @@ module CocoapodsXCRemoteCacheModifier
436
470
  rescue Exception => e
437
471
  Pod::UI.puts "[XCRC] XCRemoteCache disabled with error: #{e}"
438
472
  puts e.full_message(highlight: true, order: :top)
439
- disable_xcremotecache(user_project)
473
+ disable_xcremotecache(user_project, installer_context.pods_project)
440
474
  end
441
475
  end
442
476
  end
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module CocoapodsXcremotecache
16
- VERSION = "0.0.5"
16
+ VERSION = "0.0.8"
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.5
4
+ version: 0.0.8
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-01-19 00:00:00.000000000 Z
12
+ date: 2022-04-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: CocoaPods plugin that enables XCRemoteCache with the project.
15
15
  email: