Module: Pod::PodGenerate::Patches::UserIntegratorPatch::ParallelIntegration
- Defined in:
- lib/cocoapods-podgenerate/patches/user_integrator_patch.rb
Instance Method Summary collapse
-
#integrate_user_targets ⇒ Object
── Optimization 1: Parallel integrate_user_targets ──.
-
#save_projects(projects) ⇒ Object
── Optimization 2: Parallel save_projects ──.
-
#warn_about_xcconfig_overrides ⇒ Object
── Optimization 3: Parallel warn_about_xcconfig_overrides ── Overrides the original method by prepend — called automatically from integrate!.
Instance Method Details
#integrate_user_targets ⇒ Object
── Optimization 1: Parallel integrate_user_targets ──
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cocoapods-podgenerate/patches/user_integrator_patch.rb', line 34 def integrate_user_targets target_integrators = targets_to_integrate.sort_by(&:name).map do |target| Pod::Installer::UserProjectIntegrator::TargetIntegrator.new(target, :use_input_output_paths => use_input_output_paths?) end if target_integrators.size <= 1 target_integrators.each(&:integrate!) return end Pod::UI. "- Integrating #{target_integrators.size} targets in parallel" threads = target_integrators.map do |integrator| Thread.new do begin integrator.integrate! rescue StandardError => e Pod::UI.warn "[cocoapods-podgenerate] Target integration error: #{e.}" end end end threads.each(&:join) end |
#save_projects(projects) ⇒ Object
── Optimization 2: Parallel save_projects ──
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods-podgenerate/patches/user_integrator_patch.rb', line 58 def save_projects(projects) projects = projects.uniq if projects.size <= 1 projects.each do |project| if project.dirty? project.save else FileUtils.touch(project.path + 'project.pbxproj') end end return end Pod::UI. "- Saving #{projects.size} user projects in parallel" mutex = Mutex.new threads = projects.map do |project| Thread.new do begin if project.dirty? project.save else mutex.synchronize do FileUtils.touch(project.path + 'project.pbxproj') end end rescue StandardError => e Pod::UI.warn "[cocoapods-podgenerate] Project save error: #{e.}" end end end threads.each(&:join) end |
#warn_about_xcconfig_overrides ⇒ Object
── Optimization 3: Parallel warn_about_xcconfig_overrides ──Overrides the original method by prepend — called automatically from integrate!
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/cocoapods-podgenerate/patches/user_integrator_patch.rb', line 94 def warn_about_xcconfig_overrides targets = targets_to_integrate return if targets.empty? if targets.size <= 1 warn_single_target(targets.first) return end pool_size = compute_pool_size Pod::UI. "- Checking xcconfig overrides for #{targets.size} targets (pool: #{pool_size})" pool = Concurrent::FixedThreadPool.new(pool_size) targets.each do |aggregate_target| pool.post do warn_single_target(aggregate_target) rescue StandardError => e Pod::UI.warn "[cocoapods-podgenerate] Xcconfig warning error: #{e.}" end end pool.shutdown pool.wait_for_termination rescue NameError targets.each { |t| warn_single_target(t) } end |