cocoapods-tt 0.0.1

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.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-tt/command/native/install.rb +56 -0
  3. data/lib/cocoapods-tt/command/native/update.rb +157 -0
  4. data/lib/cocoapods-tt/command/tt/make.rb +92 -0
  5. data/lib/cocoapods-tt/command/tt.rb +115 -0
  6. data/lib/cocoapods-tt/command.rb +1 -0
  7. data/lib/cocoapods-tt/gem_version.rb +3 -0
  8. data/lib/cocoapods-tt/native/command.rb +185 -0
  9. data/lib/cocoapods-tt/native/config.rb +366 -0
  10. data/lib/cocoapods-tt/native/core_overrides.rb +1 -0
  11. data/lib/cocoapods-tt/native/downloader/cache.rb +322 -0
  12. data/lib/cocoapods-tt/native/downloader/request.rb +86 -0
  13. data/lib/cocoapods-tt/native/downloader/response.rb +16 -0
  14. data/lib/cocoapods-tt/native/downloader.rb +192 -0
  15. data/lib/cocoapods-tt/native/executable.rb +247 -0
  16. data/lib/cocoapods-tt/native/external_sources/abstract_external_source.rb +205 -0
  17. data/lib/cocoapods-tt/native/external_sources/downloader_source.rb +30 -0
  18. data/lib/cocoapods-tt/native/external_sources/path_source.rb +55 -0
  19. data/lib/cocoapods-tt/native/external_sources/podspec_source.rb +54 -0
  20. data/lib/cocoapods-tt/native/external_sources.rb +57 -0
  21. data/lib/cocoapods-tt/native/gem_version.rb +5 -0
  22. data/lib/cocoapods-tt/native/generator/acknowledgements/markdown.rb +44 -0
  23. data/lib/cocoapods-tt/native/generator/acknowledgements/plist.rb +94 -0
  24. data/lib/cocoapods-tt/native/generator/acknowledgements.rb +107 -0
  25. data/lib/cocoapods-tt/native/generator/app_target_helper.rb +363 -0
  26. data/lib/cocoapods-tt/native/generator/bridge_support.rb +22 -0
  27. data/lib/cocoapods-tt/native/generator/constant.rb +19 -0
  28. data/lib/cocoapods-tt/native/generator/copy_dsyms_script.rb +56 -0
  29. data/lib/cocoapods-tt/native/generator/copy_resources_script.rb +223 -0
  30. data/lib/cocoapods-tt/native/generator/copy_xcframework_script.rb +227 -0
  31. data/lib/cocoapods-tt/native/generator/dummy_source.rb +31 -0
  32. data/lib/cocoapods-tt/native/generator/embed_frameworks_script.rb +196 -0
  33. data/lib/cocoapods-tt/native/generator/file_list.rb +39 -0
  34. data/lib/cocoapods-tt/native/generator/header.rb +103 -0
  35. data/lib/cocoapods-tt/native/generator/info_plist_file.rb +128 -0
  36. data/lib/cocoapods-tt/native/generator/module_map.rb +99 -0
  37. data/lib/cocoapods-tt/native/generator/prefix_header.rb +60 -0
  38. data/lib/cocoapods-tt/native/generator/script_phase_constants.rb +100 -0
  39. data/lib/cocoapods-tt/native/generator/umbrella_header.rb +46 -0
  40. data/lib/cocoapods-tt/native/hooks_manager.rb +132 -0
  41. data/lib/cocoapods-tt/native/installer/analyzer/analysis_result.rb +87 -0
  42. data/lib/cocoapods-tt/native/installer/analyzer/locking_dependency_analyzer.rb +103 -0
  43. data/lib/cocoapods-tt/native/installer/analyzer/pod_variant.rb +87 -0
  44. data/lib/cocoapods-tt/native/installer/analyzer/pod_variant_set.rb +175 -0
  45. data/lib/cocoapods-tt/native/installer/analyzer/podfile_dependency_cache.rb +55 -0
  46. data/lib/cocoapods-tt/native/installer/analyzer/sandbox_analyzer.rb +268 -0
  47. data/lib/cocoapods-tt/native/installer/analyzer/specs_state.rb +108 -0
  48. data/lib/cocoapods-tt/native/installer/analyzer/target_inspection_result.rb +58 -0
  49. data/lib/cocoapods-tt/native/installer/analyzer/target_inspector.rb +258 -0
  50. data/lib/cocoapods-tt/native/installer/analyzer.rb +1204 -0
  51. data/lib/cocoapods-tt/native/installer/base_install_hooks_context.rb +135 -0
  52. data/lib/cocoapods-tt/native/installer/installation_options.rb +195 -0
  53. data/lib/cocoapods-tt/native/installer/pod_source_installer.rb +224 -0
  54. data/lib/cocoapods-tt/native/installer/pod_source_preparer.rb +77 -0
  55. data/lib/cocoapods-tt/native/installer/podfile_validator.rb +168 -0
  56. data/lib/cocoapods-tt/native/installer/post_install_hooks_context.rb +9 -0
  57. data/lib/cocoapods-tt/native/installer/post_integrate_hooks_context.rb +9 -0
  58. data/lib/cocoapods-tt/native/installer/pre_install_hooks_context.rb +51 -0
  59. data/lib/cocoapods-tt/native/installer/pre_integrate_hooks_context.rb +9 -0
  60. data/lib/cocoapods-tt/native/installer/project_cache/project_cache.rb +11 -0
  61. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analysis_result.rb +53 -0
  62. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analyzer.rb +200 -0
  63. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_version.rb +43 -0
  64. data/lib/cocoapods-tt/native/installer/project_cache/project_installation_cache.rb +103 -0
  65. data/lib/cocoapods-tt/native/installer/project_cache/project_metadata_cache.rb +73 -0
  66. data/lib/cocoapods-tt/native/installer/project_cache/target_cache_key.rb +176 -0
  67. data/lib/cocoapods-tt/native/installer/project_cache/target_metadata.rb +74 -0
  68. data/lib/cocoapods-tt/native/installer/sandbox_dir_cleaner.rb +105 -0
  69. data/lib/cocoapods-tt/native/installer/sandbox_header_paths_installer.rb +45 -0
  70. data/lib/cocoapods-tt/native/installer/source_provider_hooks_context.rb +34 -0
  71. data/lib/cocoapods-tt/native/installer/target_uuid_generator.rb +34 -0
  72. data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +179 -0
  73. data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator.rb +815 -0
  74. data/lib/cocoapods-tt/native/installer/user_project_integrator.rb +280 -0
  75. data/lib/cocoapods-tt/native/installer/xcode/multi_pods_project_generator.rb +82 -0
  76. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +66 -0
  77. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_installer.rb +192 -0
  78. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/app_host_installer.rb +154 -0
  79. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/file_references_installer.rb +329 -0
  80. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +195 -0
  81. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_installer.rb +1239 -0
  82. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_integrator.rb +312 -0
  83. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pods_project_writer.rb +90 -0
  84. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/project_generator.rb +120 -0
  85. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installation_result.rb +140 -0
  86. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer.rb +257 -0
  87. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer_helper.rb +110 -0
  88. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator.rb +291 -0
  89. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator_result.rb +54 -0
  90. data/lib/cocoapods-tt/native/installer/xcode/single_pods_project_generator.rb +38 -0
  91. data/lib/cocoapods-tt/native/installer/xcode/target_validator.rb +170 -0
  92. data/lib/cocoapods-tt/native/installer/xcode.rb +11 -0
  93. data/lib/cocoapods-tt/native/installer.rb +1044 -0
  94. data/lib/cocoapods-tt/native/native_target_extension.rb +60 -0
  95. data/lib/cocoapods-tt/native/open-uri.rb +33 -0
  96. data/lib/cocoapods-tt/native/podfile.rb +13 -0
  97. data/lib/cocoapods-tt/native/project.rb +544 -0
  98. data/lib/cocoapods-tt/native/resolver/lazy_specification.rb +88 -0
  99. data/lib/cocoapods-tt/native/resolver/resolver_specification.rb +41 -0
  100. data/lib/cocoapods-tt/native/resolver.rb +600 -0
  101. data/lib/cocoapods-tt/native/sandbox/file_accessor.rb +532 -0
  102. data/lib/cocoapods-tt/native/sandbox/headers_store.rb +163 -0
  103. data/lib/cocoapods-tt/native/sandbox/path_list.rb +242 -0
  104. data/lib/cocoapods-tt/native/sandbox/pod_dir_cleaner.rb +71 -0
  105. data/lib/cocoapods-tt/native/sandbox/podspec_finder.rb +23 -0
  106. data/lib/cocoapods-tt/native/sandbox.rb +470 -0
  107. data/lib/cocoapods-tt/native/sources_manager.rb +221 -0
  108. data/lib/cocoapods-tt/native/target/aggregate_target.rb +558 -0
  109. data/lib/cocoapods-tt/native/target/build_settings.rb +1385 -0
  110. data/lib/cocoapods-tt/native/target/pod_target.rb +1168 -0
  111. data/lib/cocoapods-tt/native/target.rb +378 -0
  112. data/lib/cocoapods-tt/native/user_interface/error_report.rb +204 -0
  113. data/lib/cocoapods-tt/native/user_interface/inspector_reporter.rb +102 -0
  114. data/lib/cocoapods-tt/native/user_interface.rb +463 -0
  115. data/lib/cocoapods-tt/native/validator.rb +1170 -0
  116. data/lib/cocoapods-tt/native/version_metadata.rb +26 -0
  117. data/lib/cocoapods-tt/native/xcode/framework_paths.rb +54 -0
  118. data/lib/cocoapods-tt/native/xcode/linkage_analyzer.rb +22 -0
  119. data/lib/cocoapods-tt/native/xcode/xcframework/xcframework_slice.rb +138 -0
  120. data/lib/cocoapods-tt/native/xcode/xcframework.rb +99 -0
  121. data/lib/cocoapods-tt/native/xcode.rb +7 -0
  122. data/lib/cocoapods-tt.rb +1 -0
  123. data/lib/cocoapods_plugin.rb +17 -0
  124. metadata +193 -0
@@ -0,0 +1,73 @@
1
+ module Pod
2
+ class Installer
3
+ module ProjectCache
4
+ # Represents the metadata cache
5
+ #
6
+ class ProjectMetadataCache
7
+ require 'cocoapods/installer/project_cache/target_metadata.rb'
8
+
9
+ # @return [Sandbox] The sandbox where the Pods should be installed.
10
+ #
11
+ attr_reader :sandbox
12
+
13
+ # @return [Hash{String => TargetMetadata}]
14
+ # Hash of string by target metadata.
15
+ #
16
+ attr_reader :target_label_by_metadata
17
+
18
+ # Initialize a new instance.
19
+ #
20
+ # @param [Sandbox] sandbox see #sandbox
21
+ # @param [Hash{String => TargetMetadata}] target_label_by_metadata @see #target_label_by_metadata
22
+ #
23
+ def initialize(sandbox, target_label_by_metadata = {})
24
+ @sandbox = sandbox
25
+ @target_label_by_metadata = target_label_by_metadata
26
+ end
27
+
28
+ def to_hash
29
+ Hash[target_label_by_metadata.map do |target_label, metdata|
30
+ [target_label, metdata.to_hash]
31
+ end]
32
+ end
33
+
34
+ # Rewrites the entire cache to the given path.
35
+ #
36
+ # @param [String] path
37
+ #
38
+ # @return [void]
39
+ #
40
+ def save_as(path)
41
+ Sandbox.update_changed_file(path, YAMLHelper.convert_hash(to_hash, nil))
42
+ end
43
+
44
+ # Updates the metadata cache based on installation results.
45
+ #
46
+ # @param [Hash{String => TargetInstallationResult}] pod_target_installation_results
47
+ # The installation results for pod targets installed.
48
+ #
49
+ # @param [Hash{String => TargetInstallationResult}] aggregate_target_installation_results
50
+ # The installation results for aggregate targets installed.
51
+ #
52
+ def update_metadata!(pod_target_installation_results, aggregate_target_installation_results)
53
+ installation_results = pod_target_installation_results.values + aggregate_target_installation_results.values
54
+ installation_results.each do |installation_result|
55
+ native_target = installation_result.native_target
56
+ target_label_by_metadata[native_target.name] = TargetMetadata.from_native_target(sandbox, native_target)
57
+ # app targets need to be added to the cache because they can be used as app hosts for test targets, even if those test targets live inside a different pod (and thus project)
58
+ installation_result.app_native_targets.each_value do |app_target|
59
+ target_label_by_metadata[app_target.name] = TargetMetadata.from_native_target(sandbox, app_target)
60
+ end
61
+ end
62
+ end
63
+
64
+ def self.from_file(sandbox, path)
65
+ return ProjectMetadataCache.new(sandbox) unless File.exist?(path)
66
+ contents = YAMLHelper.load_file(path)
67
+ target_by_label_metadata = Hash[contents.map { |target_label, hash| [target_label, TargetMetadata.from_hash(hash)] }]
68
+ ProjectMetadataCache.new(sandbox, target_by_label_metadata)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,176 @@
1
+ module Pod
2
+ class Installer
3
+ module ProjectCache
4
+ # Uniquely identifies a Target.
5
+ #
6
+ class TargetCacheKey
7
+ require 'cocoapods/target/pod_target.rb'
8
+ require 'cocoapods/target/aggregate_target.rb'
9
+ require 'digest'
10
+
11
+ # @return [Sandbox] The sandbox where the Pods should be installed.
12
+ #
13
+ attr_reader :sandbox
14
+
15
+ # @return [Symbol]
16
+ # The type of target. Either aggregate or pod target.
17
+ #
18
+ attr_reader :type
19
+
20
+ # @return [Hash{String => Object}]
21
+ # The hash containing key-value pairs that identify the target.
22
+ #
23
+ attr_reader :key_hash
24
+
25
+ # Initialize a new instance.
26
+ #
27
+ # @param [Sandbox] sandbox see #sandbox
28
+ # @param [Symbol] type @see #type
29
+ # @param [Hash{String => Object}] key_hash @see #key_hash
30
+ #
31
+ def initialize(sandbox, type, key_hash)
32
+ @sandbox = sandbox
33
+ @type = type
34
+ @key_hash = key_hash
35
+ end
36
+
37
+ # Equality function used to compare TargetCacheKey objects to each other.
38
+ #
39
+ # @param [TargetCacheKey] other
40
+ # Other object to compare itself against.
41
+ #
42
+ # @return [Symbol] The difference between this and another TargetCacheKey object.
43
+ # # Symbol :none means no difference.
44
+ #
45
+ def key_difference(other)
46
+ if other.type != type
47
+ :project
48
+ else
49
+ case type
50
+ when :pod_target
51
+ return :project if (other.key_hash.keys - key_hash.keys).any?
52
+ return :project if other.key_hash['CHECKSUM'] != key_hash['CHECKSUM']
53
+ return :project if other.key_hash['SPECS'] != key_hash['SPECS']
54
+ return :project if other.key_hash['PROJECT_NAME'] != key_hash['PROJECT_NAME']
55
+ end
56
+
57
+ this_files = key_hash['FILES']
58
+ other_files = other.key_hash['FILES']
59
+ return :project if this_files != other_files
60
+
61
+ this_build_settings = key_hash['BUILD_SETTINGS_CHECKSUM']
62
+ other_build_settings = other.key_hash['BUILD_SETTINGS_CHECKSUM']
63
+ return :project if this_build_settings != other_build_settings
64
+
65
+ this_checkout_options = key_hash['CHECKOUT_OPTIONS']
66
+ other_checkout_options = other.key_hash['CHECKOUT_OPTIONS']
67
+ return :project if this_checkout_options != other_checkout_options
68
+
69
+ :none
70
+ end
71
+ end
72
+
73
+ def to_h
74
+ key_hash
75
+ end
76
+
77
+ # @return [String]
78
+ # The name of the project the target belongs to.
79
+ #
80
+ def project_name
81
+ key_hash['PROJECT_NAME']
82
+ end
83
+
84
+ # Creates a TargetCacheKey instance from the given hash.
85
+ #
86
+ # @param [Sandbox] sandbox The sandbox to use to construct a TargetCacheKey object.
87
+ #
88
+ # @param [Hash{String => Object}] key_hash
89
+ # The hash used to construct a TargetCacheKey object.
90
+ #
91
+ # @return [TargetCacheKey]
92
+ #
93
+ def self.from_cache_hash(sandbox, key_hash)
94
+ cache_hash = key_hash.dup
95
+ if files = cache_hash['FILES']
96
+ cache_hash['FILES'] = files.sort_by(&:downcase)
97
+ end
98
+ if specs = cache_hash['SPECS']
99
+ cache_hash['SPECS'] = specs.sort_by(&:downcase)
100
+ end
101
+ type = cache_hash['CHECKSUM'] ? :pod_target : :aggregate
102
+ TargetCacheKey.new(sandbox, type, cache_hash)
103
+ end
104
+
105
+ # Constructs a TargetCacheKey instance from a PodTarget.
106
+ #
107
+ # @param [Sandbox] sandbox The sandbox to use to construct a TargetCacheKey object.
108
+ #
109
+ # @param [PodTarget] pod_target
110
+ # The pod target used to construct a TargetCacheKey object.
111
+ #
112
+ # @param [Bool] is_local_pod
113
+ # Used to also include its local files in the cache key.
114
+ #
115
+ # @param [Hash] checkout_options
116
+ # The checkout options for this pod target.
117
+ #
118
+ # @return [TargetCacheKey]
119
+ #
120
+ def self.from_pod_target(sandbox, pod_target, is_local_pod: false, checkout_options: nil)
121
+ build_settings = {}
122
+ build_settings[pod_target.label.to_s] = Hash[pod_target.build_settings.map do |k, v|
123
+ [k, Digest::MD5.hexdigest(v.xcconfig.to_s)]
124
+ end]
125
+ pod_target.test_spec_build_settings_by_config.each do |name, settings_by_config|
126
+ build_settings[name] = Hash[settings_by_config.map { |k, v| [k, Digest::MD5.hexdigest(v.xcconfig.to_s)] }]
127
+ end
128
+ pod_target.app_spec_build_settings_by_config.each do |name, settings_by_config|
129
+ build_settings[name] = Hash[settings_by_config.map { |k, v| [k, Digest::MD5.hexdigest(v.xcconfig.to_s)] }]
130
+ end
131
+
132
+ contents = {
133
+ 'CHECKSUM' => pod_target.root_spec.checksum,
134
+ 'SPECS' => pod_target.specs.map(&:to_s).sort_by(&:downcase),
135
+ 'BUILD_SETTINGS_CHECKSUM' => build_settings,
136
+ 'PROJECT_NAME' => pod_target.project_name,
137
+ }
138
+ if is_local_pod
139
+ relative_file_paths = pod_target.all_files.map { |f| f.relative_path_from(sandbox.root).to_s }
140
+ contents['FILES'] = relative_file_paths.sort_by(&:downcase)
141
+ end
142
+ contents['CHECKOUT_OPTIONS'] = checkout_options if checkout_options
143
+ TargetCacheKey.new(sandbox, :pod_target, contents)
144
+ end
145
+
146
+ # Construct a TargetCacheKey instance from an AggregateTarget.
147
+ #
148
+ # @param [Sandbox] sandbox The sandbox to use to construct a TargetCacheKey object.
149
+ #
150
+ # @param [AggregateTarget] aggregate_target
151
+ # The aggregate target used to construct a TargetCacheKey object.
152
+ #
153
+ # @return [TargetCacheKey]
154
+ #
155
+ def self.from_aggregate_target(sandbox, aggregate_target)
156
+ build_settings = {}
157
+ aggregate_target.user_build_configurations.keys.each do |configuration|
158
+ build_settings[configuration] = Digest::MD5.hexdigest(aggregate_target.build_settings(configuration).xcconfig.to_s)
159
+ end
160
+
161
+ contents = {
162
+ 'BUILD_SETTINGS_CHECKSUM' => build_settings,
163
+ }
164
+ if aggregate_target.includes_resources? || aggregate_target.includes_on_demand_resources?
165
+ relative_resource_file_paths = aggregate_target.resource_paths_by_config.values.flatten.uniq
166
+ relative_on_demand_resource_file_paths = aggregate_target.on_demand_resources.map do |res|
167
+ res.relative_path_from(sandbox.project_path.dirname).to_s
168
+ end
169
+ contents['FILES'] = (relative_resource_file_paths + relative_on_demand_resource_file_paths).sort_by(&:downcase)
170
+ end
171
+ TargetCacheKey.new(sandbox, :aggregate, contents)
172
+ end
173
+ end
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,74 @@
1
+ module Pod
2
+ class Installer
3
+ module ProjectCache
4
+ # Metadata used to reconstruct a PBXTargetDependency.
5
+ #
6
+ class TargetMetadata
7
+ # @return [String]
8
+ # The label of the native target.
9
+ #
10
+ attr_reader :target_label
11
+
12
+ # @return [String]
13
+ # The UUID of the native target installed.
14
+ #
15
+ attr_reader :native_target_uuid
16
+
17
+ # @return [String]
18
+ # The path of the container project the native target was installed into.
19
+ #
20
+ attr_reader :container_project_path
21
+
22
+ # Initialize a new instance.
23
+ #
24
+ # @param [String] target_label @see #target_label
25
+ # @param [String] native_target_uuid @see #native_target_uuid
26
+ # @param [String] container_project_path @see #container_project_path
27
+ #
28
+ def initialize(target_label, native_target_uuid, container_project_path)
29
+ @target_label = target_label
30
+ @native_target_uuid = native_target_uuid
31
+ @container_project_path = container_project_path
32
+ end
33
+
34
+ def to_hash
35
+ {
36
+ 'LABEL' => target_label,
37
+ 'UUID' => native_target_uuid,
38
+ 'PROJECT_PATH' => container_project_path,
39
+ }
40
+ end
41
+
42
+ def to_s
43
+ "#{target_label} : #{native_target_uuid} : #{container_project_path}"
44
+ end
45
+
46
+ # Constructs a TargetMetadata instance from a hash.
47
+ #
48
+ # @param [Hash] hash
49
+ # The hash used to construct a new TargetMetadata instance.
50
+ #
51
+ # @return [TargetMetadata]
52
+ #
53
+ def self.from_hash(hash)
54
+ TargetMetadata.new(hash['LABEL'], hash['UUID'], hash['PROJECT_PATH'])
55
+ end
56
+
57
+ # Constructs a TargetMetadata instance from a native target.
58
+ #
59
+ # @param [Sandbox] sandbox
60
+ # The sandbox used for this installation.
61
+ #
62
+ # @param [PBXNativeTarget] native_target
63
+ # The native target used to construct a TargetMetadata instance.
64
+ #
65
+ # @return [TargetMetadata]
66
+ #
67
+ def self.from_native_target(sandbox, native_target)
68
+ TargetMetadata.new(native_target.name, native_target.uuid,
69
+ native_target.project.path.relative_path_from(sandbox.root).to_s)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,105 @@
1
+ module Pod
2
+ class Installer
3
+ # Cleans up the sandbox directory by removing stale target support files and headers.
4
+ #
5
+ class SandboxDirCleaner
6
+ # @return [Sandbox] The sandbox directory that will be cleaned.
7
+ #
8
+ attr_reader :sandbox
9
+
10
+ # @return [Array<PodTarget>]
11
+ # The list of all pod targets that will be installed into the Sandbox.
12
+ #
13
+ attr_reader :pod_targets
14
+
15
+ # @return [Array<AggregateTarget>]
16
+ # The list of all aggregate targets that will be installed into the Sandbox.
17
+ #
18
+ attr_reader :aggregate_targets
19
+
20
+ # Initialize a new instance
21
+ #
22
+ # @param [Sandbox] sandbox @see #sandbox
23
+ # @param [Array<PodTarget>] pod_targets @see #pod_targets
24
+ # @param [Array<AggregateTarget>] aggregate_targets @see #aggregate_targets
25
+ #
26
+ def initialize(sandbox, pod_targets, aggregate_targets)
27
+ @sandbox = sandbox
28
+ @pod_targets = pod_targets
29
+ @aggregate_targets = aggregate_targets
30
+ end
31
+
32
+ def clean!
33
+ UI.message('Cleaning up sandbox directory') do
34
+ # Clean up Target Support Files Directory
35
+ target_support_dirs_to_install = (pod_targets + aggregate_targets).map(&:support_files_dir)
36
+ target_support_dirs = sandbox_target_support_dirs
37
+
38
+ removed_target_support_dirs = target_support_dirs - target_support_dirs_to_install
39
+ removed_target_support_dirs.each { |dir| remove_dir(dir) }
40
+
41
+ # Clean up Sandbox Headers Directory
42
+ sandbox_private_headers_to_install = pod_targets.flat_map do |pod_target|
43
+ if pod_target.header_mappings_by_file_accessor.empty?
44
+ []
45
+ else
46
+ [pod_target.build_headers.root.join(pod_target.headers_sandbox)]
47
+ end
48
+ end
49
+ sandbox_public_headers_to_install = pod_targets.flat_map do |pod_target|
50
+ if pod_target.public_header_mappings_by_file_accessor.empty?
51
+ []
52
+ else
53
+ [
54
+ sandbox.public_headers.root.join(pod_target.headers_sandbox),
55
+ pod_target.module_map_path.dirname,
56
+ ].uniq
57
+ end
58
+ end
59
+
60
+ removed_sandbox_public_headers = sandbox_public_headers - sandbox_public_headers_to_install
61
+ removed_sandbox_public_headers.each { |path| remove_dir(path) }
62
+
63
+ removed_sandbox_private_headers = sandbox_private_headers(pod_targets) - sandbox_private_headers_to_install
64
+ removed_sandbox_private_headers.each { |path| remove_dir(path) }
65
+
66
+ project_dir_names_to_install = pod_targets.map do |pod_target|
67
+ sandbox.pod_target_project_path(pod_target.project_name)
68
+ end
69
+ project_dir_names = sandbox_project_dir_names - [sandbox.project_path]
70
+ user_project_dir_names = aggregate_targets.map(&:user_project_path).uniq
71
+
72
+ removed_project_dir_names = project_dir_names - user_project_dir_names - project_dir_names_to_install
73
+ removed_project_dir_names.each { |dir| remove_dir(dir) }
74
+ end
75
+ end
76
+
77
+ private
78
+
79
+ def sandbox_target_support_dirs
80
+ child_directories_of(sandbox.target_support_files_root)
81
+ end
82
+
83
+ def sandbox_private_headers(pod_targets)
84
+ pod_targets.flat_map { |pod_target| child_directories_of(pod_target.build_headers.root) }.uniq
85
+ end
86
+
87
+ def sandbox_project_dir_names
88
+ child_directories_of(sandbox.root).select { |d| d.extname == '.xcodeproj' }
89
+ end
90
+
91
+ def sandbox_public_headers
92
+ child_directories_of(sandbox.public_headers.root)
93
+ end
94
+
95
+ def child_directories_of(dir)
96
+ return [] unless dir.exist?
97
+ dir.children.select(&:directory?)
98
+ end
99
+
100
+ def remove_dir(path)
101
+ FileUtils.rm_rf(path)
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,45 @@
1
+ module Pod
2
+ class Installer
3
+ # Adds all the search paths into the sandbox HeaderStore and each pod target's HeaderStore.
4
+ #
5
+ class SandboxHeaderPathsInstaller
6
+ # @return [Sandbox] The sandbox to use for this analysis.
7
+ #
8
+ attr_reader :sandbox
9
+
10
+ # @return [Array<PodTarget>] The list of pod targets to analyze.
11
+ #
12
+ attr_reader :pod_targets
13
+
14
+ # Initialize a new instance
15
+ #
16
+ # @param [Sandbox] sandbox @see #sandbox
17
+ # @param [Array<PodTarget>] pod_targets @see #pod_targets
18
+ #
19
+ def initialize(sandbox, pod_targets)
20
+ @pod_targets = pod_targets
21
+ @sandbox = sandbox
22
+ end
23
+
24
+ def install!
25
+ # Link all pod target header search paths into the HeaderStore.
26
+ pod_targets.each do |pod_target|
27
+ next if pod_target.build_as_framework? && pod_target.should_build?
28
+ install_target(pod_target)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def install_target(pod_target)
35
+ pod_target_header_mappings = pod_target.header_mappings_by_file_accessor.values
36
+ public_header_mappings = pod_target.public_header_mappings_by_file_accessor.values
37
+ added_build_headers = !pod_target_header_mappings.all?(&:empty?)
38
+ added_public_headers = !public_header_mappings.all?(&:empty?)
39
+
40
+ pod_target.build_headers.add_search_path(pod_target.headers_sandbox, pod_target.platform) if added_build_headers
41
+ sandbox.public_headers.add_search_path(pod_target.headers_sandbox, pod_target.platform) if added_public_headers
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+ module Pod
2
+ class Installer
3
+ # Context object designed to be used with the HooksManager which describes
4
+ # the context of the installer before spec sources have been created
5
+ #
6
+ class SourceProviderHooksContext
7
+ # @return [Array<Source>] The source objects to send to the installer
8
+ #
9
+ attr_reader :sources
10
+
11
+ # @return [SourceProviderHooksContext] Convenience class method to generate the
12
+ # static context.
13
+ #
14
+ def self.generate
15
+ result = new
16
+ result
17
+ end
18
+
19
+ def initialize
20
+ @sources = []
21
+ end
22
+
23
+ # @param [Source] source object to be added to the installer
24
+ #
25
+ # @return [void]
26
+ #
27
+ def add_source(source)
28
+ unless source.nil?
29
+ @sources << source
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ module Pod
2
+ class Installer
3
+ # Generates stable UUIDs for Native Targets.
4
+ #
5
+ class TargetUUIDGenerator < Xcodeproj::Project::UUIDGenerator
6
+ # This method override is used to ONLY generate stable UUIDs for PBXNativeTarget instances and their sibling PBXFileReference
7
+ # product reference in the project. Stable native target UUIDs are necessary for incremental installation
8
+ # because other projects reference the target and product reference by its UUID in the remoteGlobalIDString field.
9
+ #
10
+ # @param [Array<Project>] projects
11
+ # The list of projects used to generate stabe target UUIDs.
12
+ #
13
+ def generate_all_paths_by_objects(projects)
14
+ @paths_by_object = {}
15
+ projects.each do |project|
16
+ project_basename = project.path.basename.to_s
17
+ project.objects.each do |object|
18
+ @paths_by_object[object] = object.uuid
19
+ end
20
+ project.targets.each do |target|
21
+ @paths_by_object[target] = Digest::MD5.hexdigest(project_basename + target.name).upcase
22
+ if target.is_a? Xcodeproj::Project::Object::PBXNativeTarget
23
+ @paths_by_object[target.product_reference] = Digest::MD5.hexdigest(project_basename + 'product_reference' + target.name).upcase
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def uuid_for_path(path)
30
+ path
31
+ end
32
+ end
33
+ end
34
+ end