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,532 @@
1
+ require 'cocoapods/xcode/linkage_analyzer'
2
+
3
+ module Pod
4
+ class Sandbox
5
+ # Resolves the file patterns of a specification against its root directory,
6
+ # taking into account any exclude pattern and the default extensions to use
7
+ # for directories.
8
+ #
9
+ # @note The FileAccessor always returns absolute paths.
10
+ #
11
+ class FileAccessor
12
+ HEADER_EXTENSIONS = Xcodeproj::Constants::HEADER_FILES_EXTENSIONS
13
+ SOURCE_FILE_EXTENSIONS = (%w(.m .mm .i .c .cc .cxx .cpp .c++ .swift) + HEADER_EXTENSIONS).uniq.freeze
14
+
15
+ GLOB_PATTERNS = {
16
+ :readme => 'readme{*,.*}'.freeze,
17
+ :license => 'licen{c,s}e{*,.*}'.freeze,
18
+ :source_files => "*{#{SOURCE_FILE_EXTENSIONS.join(',')}}".freeze,
19
+ :public_header_files => "*{#{HEADER_EXTENSIONS.join(',')}}".freeze,
20
+ :podspecs => '*.{podspec,podspec.json}'.freeze,
21
+ :docs => 'doc{s}{*,.*}/**/*'.freeze,
22
+ }.freeze
23
+
24
+ # @return [Sandbox::PathList] the directory where the source of the Pod
25
+ # is located.
26
+ #
27
+ attr_reader :path_list
28
+
29
+ # @return [Specification::Consumer] the consumer of the specification for
30
+ # which the file patterns should be resolved.
31
+ #
32
+ attr_reader :spec_consumer
33
+
34
+ # Initialize a new instance
35
+ #
36
+ # @param [Sandbox::PathList, Pathname] path_list @see #path_list
37
+ # @param [Specification::Consumer] spec_consumer @see #spec_consumer
38
+ #
39
+ def initialize(path_list, spec_consumer)
40
+ if path_list.is_a?(PathList)
41
+ @path_list = path_list
42
+ else
43
+ @path_list = PathList.new(path_list)
44
+ end
45
+ @spec_consumer = spec_consumer
46
+
47
+ unless @spec_consumer
48
+ raise Informative, 'Attempt to initialize File Accessor without a specification consumer.'
49
+ end
50
+ end
51
+
52
+ # @return [Pathname] the directory which contains the files of the Pod.
53
+ #
54
+ def root
55
+ path_list.root if path_list
56
+ end
57
+
58
+ # @return [Specification] the specification.
59
+ #
60
+ def spec
61
+ spec_consumer.spec
62
+ end
63
+
64
+ # @return [Specification] the platform used to consume the specification.
65
+ #
66
+ def platform_name
67
+ spec_consumer.platform_name
68
+ end
69
+
70
+ # @return [String] A string suitable for debugging.
71
+ #
72
+ def inspect
73
+ "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>"
74
+ end
75
+
76
+ #-----------------------------------------------------------------------#
77
+
78
+ public
79
+
80
+ # @!group Paths
81
+
82
+ # @return [Array<Pathname>] the source files of the specification.
83
+ #
84
+ def source_files
85
+ paths_for_attribute(:source_files)
86
+ end
87
+
88
+ # @return [Array<Pathname>] the source files of the specification that
89
+ # use ARC.
90
+ #
91
+ def arc_source_files
92
+ case spec_consumer.requires_arc
93
+ when TrueClass
94
+ source_files
95
+ when FalseClass
96
+ []
97
+ else
98
+ paths_for_attribute(:requires_arc) & source_files
99
+ end
100
+ end
101
+
102
+ # @return [Array<Pathname>] the source files of the specification that
103
+ # do not use ARC.
104
+ #
105
+ def non_arc_source_files
106
+ source_files - arc_source_files
107
+ end
108
+
109
+ # @return [Array<Pathname] the source files that do not match any of the
110
+ # recognized file extensions
111
+ def other_source_files
112
+ extensions = SOURCE_FILE_EXTENSIONS
113
+ source_files.reject { |f| extensions.include?(f.extname) }
114
+ end
115
+
116
+ # @return [Array<Pathname>] the headers of the specification.
117
+ #
118
+ def headers
119
+ extensions = HEADER_EXTENSIONS
120
+ source_files.select { |f| extensions.include?(f.extname) }
121
+ end
122
+
123
+ # @param [Boolean] include_frameworks
124
+ # Whether or not to include the headers of the vendored frameworks.
125
+ # Defaults to not include them.
126
+ #
127
+ # @return [Array<Pathname>] the public headers of the specification.
128
+ #
129
+ def public_headers(include_frameworks = false)
130
+ public_headers = public_header_files
131
+ project_headers = project_header_files
132
+ private_headers = private_header_files
133
+ if public_headers.nil? || public_headers.empty?
134
+ header_files = headers
135
+ else
136
+ header_files = public_headers
137
+ end
138
+ header_files += vendored_frameworks_headers if include_frameworks
139
+ header_files - project_headers - private_headers
140
+ end
141
+
142
+ # @return [Array<Pathname>] The project headers of the specification.
143
+ #
144
+ def project_headers
145
+ project_header_files
146
+ end
147
+
148
+ # @return [Array<Pathname>] The private headers of the specification.
149
+ #
150
+ def private_headers
151
+ private_header_files
152
+ end
153
+
154
+ # @return [Array<Pathname>] the resources of the specification.
155
+ #
156
+ def resources
157
+ paths_for_attribute(:resources, true)
158
+ end
159
+
160
+ # @return [Array<Pathname>] the files of the specification to preserve.
161
+ #
162
+ def preserve_paths
163
+ paths_for_attribute(:preserve_paths, true)
164
+ end
165
+
166
+ # @return [Array<Pathname>] The paths of the framework bundles that come
167
+ # shipped with the Pod.
168
+ #
169
+ def vendored_frameworks
170
+ paths_for_attribute(:vendored_frameworks, true)
171
+ end
172
+
173
+ # @return [Array<Pathname>] The paths of the dynamic framework bundles
174
+ # that come shipped with the Pod.
175
+ #
176
+ def vendored_dynamic_frameworks
177
+ (vendored_frameworks - vendored_xcframeworks).select do |framework|
178
+ Xcode::LinkageAnalyzer.dynamic_binary?(framework + framework.basename('.*'))
179
+ end
180
+ end
181
+
182
+ # @return [Array<Pathname>] The paths of the static xcframework bundles
183
+ # that come shipped with the Pod.
184
+ #
185
+ def vendored_static_xcframeworks
186
+ vendored_xcframeworks.select do |path|
187
+ Xcode::XCFramework.new(spec.name, path).build_type == BuildType.static_framework
188
+ end
189
+ end
190
+
191
+ # @return [Array<Pathname>] The paths of the dynamic xcframework bundles
192
+ # that come shipped with the Pod.
193
+ #
194
+ def vendored_dynamic_xcframeworks
195
+ vendored_xcframeworks.select do |path|
196
+ Xcode::XCFramework.new(spec.name, path).build_type == BuildType.dynamic_framework
197
+ end
198
+ end
199
+
200
+ # @return [Array<Pathname>] The paths of the static (fake) framework
201
+ # bundles that come shipped with the Pod.
202
+ #
203
+ def vendored_static_frameworks
204
+ vendored_frameworks - vendored_dynamic_frameworks - vendored_xcframeworks
205
+ end
206
+
207
+ # @return [Array<Pathname>] The paths of vendored .xcframework bundles
208
+ # that come shipped with the Pod.
209
+ #
210
+ def vendored_xcframeworks
211
+ vendored_frameworks.select do |framework|
212
+ File.extname(framework) == '.xcframework'
213
+ end
214
+ end
215
+
216
+ # @param [Array<FileAccessor>] file_accessors
217
+ # The list of all file accessors to compute.
218
+ #
219
+ # @return [Array<Pathname>] The list of all file accessors that a target will integrate into the project.
220
+ #
221
+ def self.all_files(file_accessors)
222
+ files = [
223
+ file_accessors.map(&:vendored_frameworks),
224
+ file_accessors.map(&:vendored_libraries),
225
+ file_accessors.map(&:resource_bundle_files),
226
+ file_accessors.map(&:license),
227
+ file_accessors.map(&:prefix_header),
228
+ file_accessors.map(&:preserve_paths),
229
+ file_accessors.map(&:readme),
230
+ file_accessors.map(&:resources),
231
+ file_accessors.map(&:on_demand_resources_files),
232
+ file_accessors.map(&:source_files),
233
+ file_accessors.map(&:module_map),
234
+ ]
235
+ files.flatten.compact.uniq
236
+ end
237
+
238
+ # @param [Pathname] framework
239
+ # The vendored framework to search into.
240
+ # @return [Pathname] The path of the header directory of the
241
+ # vendored framework.
242
+ #
243
+ def self.vendored_frameworks_headers_dir(framework)
244
+ dir = framework + 'Headers'
245
+ dir.directory? ? dir.realpath : dir
246
+ end
247
+
248
+ # @param [Pathname] framework
249
+ # The vendored framework to search into.
250
+ # @return [Array<Pathname>] The paths of the headers included in the
251
+ # vendored framework.
252
+ #
253
+ def self.vendored_frameworks_headers(framework)
254
+ headers_dir = vendored_frameworks_headers_dir(framework)
255
+ Pathname.glob(headers_dir + '**/' + GLOB_PATTERNS[:public_header_files])
256
+ end
257
+
258
+ # @param [String] target_name
259
+ # The target name this .xcframework belongs to
260
+ #
261
+ # @param [Pathname] framework_path
262
+ # The path to the .xcframework
263
+ #
264
+ # @return [Array<Pathname>] The paths to all the headers included in the
265
+ # vendored xcframework
266
+ #
267
+ def self.vendored_xcframework_headers(target_name, framework_path)
268
+ xcframework = Xcode::XCFramework.new(target_name, framework_path)
269
+ xcframework.slices.flat_map do |slice|
270
+ vendored_frameworks_headers(slice.path)
271
+ end
272
+ end
273
+
274
+ # @return [Array<Pathname>] The paths of the framework headers that come
275
+ # shipped with the Pod.
276
+ #
277
+ def vendored_frameworks_headers
278
+ paths = (vendored_frameworks - vendored_xcframeworks).flat_map do |framework|
279
+ self.class.vendored_frameworks_headers(framework)
280
+ end.uniq
281
+ paths.concat Array.new(vendored_xcframeworks.flat_map do |framework|
282
+ self.class.vendored_xcframework_headers(spec.name, framework)
283
+ end)
284
+ paths
285
+ end
286
+
287
+ # @return [Array<Pathname>] The paths of the library bundles that come
288
+ # shipped with the Pod.
289
+ #
290
+ def vendored_libraries
291
+ paths_for_attribute(:vendored_libraries)
292
+ end
293
+
294
+ # @return [Array<Pathname>] The paths of the dynamic libraries
295
+ # that come shipped with the Pod.
296
+ #
297
+ def vendored_dynamic_libraries
298
+ vendored_libraries.select do |library|
299
+ Xcode::LinkageAnalyzer.dynamic_binary?(library)
300
+ end
301
+ end
302
+
303
+ # @return [Array<Pathname>] The paths of the static libraries
304
+ # that come shipped with the Pod.
305
+ #
306
+ def vendored_static_libraries
307
+ vendored_libraries - vendored_dynamic_libraries
308
+ end
309
+
310
+ # @return [Array<Pathname>] The paths of the dynamic binary artifacts
311
+ # that come shipped with the Pod.
312
+ #
313
+ def vendored_dynamic_artifacts
314
+ vendored_dynamic_libraries + vendored_dynamic_frameworks
315
+ end
316
+
317
+ # @return [Array<Pathname>] The paths of the static binary artifacts
318
+ # that come shipped with the Pod.
319
+ #
320
+ def vendored_static_artifacts
321
+ vendored_static_libraries + vendored_static_frameworks + vendored_static_xcframeworks
322
+ end
323
+
324
+ # @return [Hash{String => Array<Pathname>}] A hash that describes the
325
+ # resource bundles of the Pod. The keys represent the name of
326
+ # the bundle while the values the path of the resources.
327
+ #
328
+ def resource_bundles
329
+ result = {}
330
+ spec_consumer.resource_bundles.each do |name, file_patterns|
331
+ paths = expanded_paths(file_patterns,
332
+ :exclude_patterns => spec_consumer.exclude_files,
333
+ :include_dirs => true)
334
+ result[name] = paths
335
+ end
336
+ result
337
+ end
338
+
339
+ # @return [Array<Pathname>] The paths of the files which should be
340
+ # included in resources bundles by the Pod.
341
+ #
342
+ def resource_bundle_files
343
+ resource_bundles.values.flatten
344
+ end
345
+
346
+ # @return [Hash{String => Hash] The expanded paths of the on demand resources specified
347
+ # keyed by their tag including their category.
348
+ #
349
+ def on_demand_resources
350
+ result = {}
351
+ spec_consumer.on_demand_resources.each do |tag_name, file_patterns|
352
+ paths = expanded_paths(file_patterns[:paths],
353
+ :exclude_patterns => spec_consumer.exclude_files,
354
+ :include_dirs => true)
355
+ result[tag_name] = { :paths => paths, :category => file_patterns[:category] }
356
+ end
357
+ result
358
+ end
359
+
360
+ # @return [Array<Pathname>] The expanded paths of the on demand resources.
361
+ #
362
+ def on_demand_resources_files
363
+ on_demand_resources.values.flat_map { |v| v[:paths] }
364
+ end
365
+
366
+ # @return [Pathname] The of the prefix header file of the specification.
367
+ #
368
+ def prefix_header
369
+ if file = spec_consumer.prefix_header_file
370
+ path_list.root + file
371
+ end
372
+ end
373
+
374
+ # @return [Pathname, nil] The path of the auto-detected README file.
375
+ #
376
+ def readme
377
+ path_list.glob([GLOB_PATTERNS[:readme]]).first
378
+ end
379
+
380
+ # @return [Pathname] The path of the license file as indicated in the
381
+ # specification or auto-detected.
382
+ #
383
+ def license
384
+ spec_license || path_list.glob([GLOB_PATTERNS[:license]]).first
385
+ end
386
+
387
+ # @return [Pathname, Nil] The path of the custom module map file of the
388
+ # specification, if specified.
389
+ def module_map
390
+ if module_map = spec_consumer.module_map
391
+ path_list.root + module_map
392
+ end
393
+ end
394
+
395
+ # @return [Array<Pathname>] The paths of auto-detected podspecs
396
+ #
397
+ def specs
398
+ path_list.glob([GLOB_PATTERNS[:podspecs]])
399
+ end
400
+
401
+ # @return [Array<Pathname>] The paths of auto-detected docs
402
+ #
403
+ def docs
404
+ path_list.glob([GLOB_PATTERNS[:docs]])
405
+ end
406
+
407
+ # @return [Pathname] The path of the license file specified in the
408
+ # specification, if it exists
409
+ #
410
+ def spec_license
411
+ if file = spec_consumer.license[:file]
412
+ absolute_path = root + file
413
+ absolute_path if File.exist?(absolute_path)
414
+ end
415
+ end
416
+
417
+ # @return [Array<Pathname>] Paths to include for local pods to assist in development
418
+ #
419
+ def developer_files
420
+ podspecs = specs
421
+ result = [module_map, prefix_header]
422
+
423
+ if license_path = spec_consumer.license[:file]
424
+ license_path = root + license_path
425
+ unless File.exist?(license_path)
426
+ UI.warn "A license was specified in podspec `#{spec.name}` but the file does not exist - #{license_path}"
427
+ end
428
+ end
429
+
430
+ if podspecs.size <= 1
431
+ result += [license, readme, podspecs, docs]
432
+ else
433
+ # Manually add non-globbing files since there are multiple podspecs in the same folder
434
+ result << podspec_file
435
+ if license_file = spec_license
436
+ absolute_path = root + license_file
437
+ result << absolute_path if File.exist?(absolute_path)
438
+ end
439
+ end
440
+ result.compact.flatten.sort
441
+ end
442
+
443
+ #-----------------------------------------------------------------------#
444
+
445
+ private
446
+
447
+ # @!group Private paths
448
+
449
+ # @return [Array<Pathname>] The paths of the user-specified public header
450
+ # files.
451
+ #
452
+ def public_header_files
453
+ paths_for_attribute(:public_header_files)
454
+ end
455
+
456
+ # @return [Array<Pathname>] The paths of the user-specified project header
457
+ # files.
458
+ #
459
+ def project_header_files
460
+ paths_for_attribute(:project_header_files)
461
+ end
462
+
463
+ # @return [Array<Pathname>] The paths of the user-specified private header
464
+ # files.
465
+ #
466
+ def private_header_files
467
+ paths_for_attribute(:private_header_files)
468
+ end
469
+
470
+ # @return [Pathname] The path of the podspec matching @spec
471
+ #
472
+ def podspec_file
473
+ specs.lazy.select { |p| File.basename(p.to_s, '.*') == spec.name }.first
474
+ end
475
+
476
+ #-----------------------------------------------------------------------#
477
+
478
+ private
479
+
480
+ # @!group Private helpers
481
+
482
+ # Returns the list of the paths founds in the file system for the
483
+ # attribute with given name. It takes into account any dir pattern and
484
+ # any file excluded in the specification.
485
+ #
486
+ # @param [Symbol] attribute
487
+ # the name of the attribute.
488
+ #
489
+ # @return [Array<Pathname>] the paths.
490
+ #
491
+ def paths_for_attribute(attribute, include_dirs = false)
492
+ file_patterns = spec_consumer.send(attribute)
493
+ options = {
494
+ :exclude_patterns => spec_consumer.exclude_files,
495
+ :dir_pattern => GLOB_PATTERNS[attribute],
496
+ :include_dirs => include_dirs,
497
+ }
498
+ expanded_paths(file_patterns, options)
499
+ end
500
+
501
+ # Matches the given patterns to the file present in the root of the path
502
+ # list.
503
+ #
504
+ # @param [Array<String>] patterns
505
+ # The patterns to expand.
506
+ #
507
+ # @param [Hash] options
508
+ # The options to use to expand the patterns to file paths.
509
+ #
510
+ # @option options [String] :dir_pattern
511
+ # The pattern to add to directories.
512
+ #
513
+ # @option options [Array<String>] :exclude_patterns
514
+ # The exclude patterns to pass to the PathList.
515
+ #
516
+ # @option options [Bool] :include_dirs
517
+ # Whether directories should be also included or just plain
518
+ # files.
519
+ #
520
+ # @raise [Informative] If the pod does not exists.
521
+ #
522
+ # @return [Array<Pathname>] A list of the paths.
523
+ #
524
+ def expanded_paths(patterns, options = {})
525
+ return [] if patterns.empty?
526
+ path_list.glob(patterns, options).flatten.compact.uniq
527
+ end
528
+
529
+ #-----------------------------------------------------------------------#
530
+ end
531
+ end
532
+ end
@@ -0,0 +1,163 @@
1
+ module Pod
2
+ class Sandbox
3
+ # Provides support for managing a header directory. It also keeps track of
4
+ # the header search paths.
5
+ #
6
+ class HeadersStore
7
+ SEARCH_PATHS_KEY = Struct.new(:platform_name, :target_name, :use_modular_headers)
8
+
9
+ # @return [Pathname] the absolute path of this header directory.
10
+ #
11
+ def root
12
+ sandbox.headers_root + @relative_path
13
+ end
14
+
15
+ # @return [Sandbox] the sandbox where this header directory is stored.
16
+ #
17
+ attr_reader :sandbox
18
+
19
+ # @param [Sandbox] @see #sandbox
20
+ #
21
+ # @param [String] relative_path
22
+ # the relative path to the sandbox root and hence to the Pods
23
+ # project.
24
+ #
25
+ # @param [Symbol] visibility_scope
26
+ # the header visibility scope to use in this store. Can be `:private` or `:public`.
27
+ #
28
+ def initialize(sandbox, relative_path, visibility_scope)
29
+ @sandbox = sandbox
30
+ @relative_path = relative_path
31
+ @search_paths = []
32
+ @search_paths_cache = {}
33
+ @visibility_scope = visibility_scope
34
+ end
35
+
36
+ # @param [Platform] platform
37
+ # the platform for which the header search paths should be
38
+ # returned.
39
+ #
40
+ # @param [String] target_name
41
+ # the target for which the header search paths should be
42
+ # returned. Can be `nil` in which case all headers that match the platform
43
+ # will be returned.
44
+ #
45
+ # @param [Boolean] use_modular_headers
46
+ # whether the search paths generated should use modular (stricter) style.
47
+ #
48
+ # @return [Array<String>] All the search paths of the header directory in
49
+ # xcconfig format. The paths are specified relative to the pods
50
+ # root with the `${PODS_ROOT}` variable.
51
+ #
52
+ def search_paths(platform, target_name = nil, use_modular_headers = false)
53
+ key = SEARCH_PATHS_KEY.new(platform.name, target_name, use_modular_headers)
54
+ if (cached = @search_paths_cache[key])
55
+ return cached
56
+ end
57
+ search_paths = @search_paths.select do |entry|
58
+ matches_platform = entry[:platform] == platform.name
59
+ matches_target = target_name.nil? || (File.basename(entry[:path]) == target_name)
60
+ matches_platform && matches_target
61
+ end
62
+ headers_dir = root.relative_path_from(sandbox.root).dirname
63
+ @search_paths_cache[key] = search_paths.flat_map do |entry|
64
+ paths = []
65
+ paths << "${PODS_ROOT}/#{headers_dir}/#{@relative_path}" if !use_modular_headers || @visibility_scope == :public
66
+ paths << "${PODS_ROOT}/#{headers_dir}/#{entry[:path]}" if !use_modular_headers || @visibility_scope == :private
67
+ paths
68
+ end.tap(&:uniq!).freeze
69
+ end
70
+
71
+ # Removes the entire root directory.
72
+ #
73
+ # @return [void]
74
+ #
75
+ def implode!
76
+ root.rmtree if root.exist?
77
+ end
78
+
79
+ # Removes the directory at the given path relative to the root.
80
+ #
81
+ # @param [Pathname] path
82
+ # The path used to join with #root and remove.
83
+ #
84
+ # @return [void]
85
+ #
86
+ def implode_path!(path)
87
+ path = root.join(path)
88
+ path.rmtree if path.exist?
89
+ end
90
+
91
+ #-----------------------------------------------------------------------#
92
+
93
+ public
94
+
95
+ # @!group Adding headers
96
+
97
+ # Adds headers to the directory.
98
+ #
99
+ # @param [Pathname] namespace
100
+ # the path where the header file should be stored relative to the
101
+ # headers directory.
102
+ #
103
+ # @param [Array<Pathname>] relative_header_paths
104
+ # the path of the header file relative to the Pods project
105
+ # (`PODS_ROOT` variable of the xcconfigs).
106
+ #
107
+ # @note This method does _not_ add the files to the search paths.
108
+ #
109
+ # @return [Array<Pathname>]
110
+ #
111
+ def add_files(namespace, relative_header_paths)
112
+ root.join(namespace).mkpath unless relative_header_paths.empty?
113
+ relative_header_paths.map do |relative_header_path|
114
+ add_file(namespace, relative_header_path, :mkdir => false)
115
+ end
116
+ end
117
+
118
+ # Adds a header to the directory.
119
+ #
120
+ # @param [Pathname] namespace
121
+ # the path where the header file should be stored relative to the
122
+ # headers directory.
123
+ #
124
+ # @param [Pathname] relative_header_path
125
+ # the path of the header file relative to the Pods project
126
+ # (`PODS_ROOT` variable of the xcconfigs).
127
+ #
128
+ # @note This method does _not_ add the file to the search paths.
129
+ #
130
+ # @return [Pathname]
131
+ #
132
+ def add_file(namespace, relative_header_path, mkdir: true)
133
+ namespaced_path = root + namespace
134
+ namespaced_path.mkpath if mkdir
135
+
136
+ absolute_source = (sandbox.root + relative_header_path)
137
+ source = absolute_source.relative_path_from(namespaced_path)
138
+ if Gem.win_platform?
139
+ FileUtils.ln(absolute_source, namespaced_path, :force => true)
140
+ else
141
+ FileUtils.ln_sf(source, namespaced_path)
142
+ end
143
+ namespaced_path + relative_header_path.basename
144
+ end
145
+
146
+ # Adds an header search path to the sandbox.
147
+ #
148
+ # @param [Pathname] path
149
+ # the path to add.
150
+ #
151
+ # @param [String] platform
152
+ # the platform the search path applies to
153
+ #
154
+ # @return [void]
155
+ #
156
+ def add_search_path(path, platform)
157
+ @search_paths << { :platform => platform.name, :path => File.join(@relative_path, path) }
158
+ end
159
+
160
+ #-----------------------------------------------------------------------#
161
+ end
162
+ end
163
+ end