pod-builder 1.9.4 → 2.0.0.beta.18
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 +4 -4
- data/.gitignore +9 -0
- data/Example/Frameworks/.gitignore +6 -0
- data/Example/Frameworks/.pod_builder/pod_builder +0 -0
- data/Example/Frameworks/PodBuilder.json +10 -4
- data/Example/Frameworks/Podfile +23 -0
- data/Example/Frameworks/Podfile.restore +40 -0
- data/Example/PodBuilderExample/AppDelegate.swift +4 -0
- data/Example/PodBuilderExample.xcodeproj/project.pbxproj +3 -8
- data/Example/{PodBuilderExample.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist → PodBuilderExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist} +2 -8
- data/Example/Podfile +44 -1
- data/Example/Podfile.lock +426 -7
- data/Example/Pods-acknowledgements.md +210 -0
- data/Example/Pods-acknowledgements.plist +206 -0
- data/README.md +38 -1
- data/exe/pod_builder +14 -14
- data/lib/pod_builder/analyze.rb +32 -7
- data/lib/pod_builder/analyzer.rb +16 -0
- data/lib/pod_builder/command/build.rb +110 -109
- data/lib/pod_builder/command/clean.rb +9 -11
- data/lib/pod_builder/command/clear_lldbinit.rb +1 -1
- data/lib/pod_builder/command/deintegrate.rb +2 -1
- data/lib/pod_builder/command/generate_lfs.rb +2 -2
- data/lib/pod_builder/command/install_sources.rb +1 -1
- data/lib/pod_builder/command/switch.rb +99 -99
- data/lib/pod_builder/command/sync_podfile.rb +2 -1
- data/lib/pod_builder/command/update.rb +1 -1
- data/lib/pod_builder/command/update_lldbinit.rb +2 -2
- data/lib/pod_builder/configuration.rb +61 -7
- data/lib/pod_builder/core.rb +60 -5
- data/lib/pod_builder/info.rb +24 -90
- data/lib/pod_builder/install.rb +148 -82
- data/lib/pod_builder/podfile/post_actions.rb +0 -1
- data/lib/pod_builder/podfile.rb +83 -14
- data/lib/pod_builder/podfile_item.rb +152 -74
- data/lib/pod_builder/podspec.rb +125 -133
- data/lib/pod_builder/rome/post_install.rb +248 -0
- data/lib/pod_builder/rome/pre_install.rb +6 -0
- data/lib/pod_builder/templates/build_podfile.template +1 -1
- data/lib/pod_builder/version.rb +1 -1
- data/pod-builder.gemspec +3 -3
- metadata +28 -60
- data/Example/Pods/Alamofire/LICENSE +0 -19
- data/Example/Pods/Alamofire/README.md +0 -242
- data/Example/Pods/Alamofire/Source/AFError.swift +0 -460
- data/Example/Pods/Alamofire/Source/Alamofire.swift +0 -465
- data/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +0 -37
- data/Example/Pods/Alamofire/Source/MultipartFormData.swift +0 -580
- data/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +0 -233
- data/Example/Pods/Alamofire/Source/Notifications.swift +0 -55
- data/Example/Pods/Alamofire/Source/ParameterEncoding.swift +0 -483
- data/Example/Pods/Alamofire/Source/Request.swift +0 -654
- data/Example/Pods/Alamofire/Source/Response.swift +0 -567
- data/Example/Pods/Alamofire/Source/ResponseSerialization.swift +0 -715
- data/Example/Pods/Alamofire/Source/Result.swift +0 -300
- data/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +0 -307
- data/Example/Pods/Alamofire/Source/SessionDelegate.swift +0 -725
- data/Example/Pods/Alamofire/Source/SessionManager.swift +0 -896
- data/Example/Pods/Alamofire/Source/TaskDelegate.swift +0 -466
- data/Example/Pods/Alamofire/Source/Timeline.swift +0 -136
- data/Example/Pods/Alamofire/Source/Validation.swift +0 -315
- data/Example/Pods/Manifest.lock +0 -16
- data/Example/Pods/Pods.xcodeproj/project.pbxproj +0 -673
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Alamofire.xcscheme +0 -60
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Pods-PodBuilderExample.xcscheme +0 -60
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -21
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +0 -5
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +0 -12
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +0 -16
- data/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +0 -6
- data/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +0 -9
- data/Example/Pods/Target Support Files/Alamofire/Info.plist +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Info.plist +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.markdown +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.plist +0 -58
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-dummy.m +0 -5
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-frameworks.sh +0 -153
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-resources.sh +0 -118
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-umbrella.h +0 -16
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.debug.xcconfig +0 -11
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.modulemap +0 -6
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.release.xcconfig +0 -11
- data/lib/pod_builder/cocoapods/specification.rb +0 -27
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pod_builder/cocoapods/specification'
|
2
|
-
|
3
1
|
module PodBuilder
|
4
2
|
class PodfileItem
|
5
3
|
# @return [String] The git repo
|
@@ -10,6 +8,10 @@ module PodBuilder
|
|
10
8
|
#
|
11
9
|
attr_reader :branch
|
12
10
|
|
11
|
+
# @return [String] A checksum for the spec
|
12
|
+
#
|
13
|
+
attr_reader :checksum
|
14
|
+
|
13
15
|
# @return [String] Matches @name unless for subspecs were it stores the name of the root pod
|
14
16
|
#
|
15
17
|
attr_reader :root_name
|
@@ -49,6 +51,10 @@ module PodBuilder
|
|
49
51
|
# @return [Array<String>] The pod's dependency names, if any. Use dependencies() to get the [Array<PodfileItem>]
|
50
52
|
#
|
51
53
|
attr_reader :dependency_names
|
54
|
+
|
55
|
+
# @return [Array<String>] The pod's external dependency names (excluding subspecs), if any
|
56
|
+
#
|
57
|
+
attr_reader :external_dependency_names
|
52
58
|
|
53
59
|
# @return [Bool] True if the pod is shipped as a static framework
|
54
60
|
#
|
@@ -66,9 +72,13 @@ module PodBuilder
|
|
66
72
|
#
|
67
73
|
attr_accessor :build_configuration
|
68
74
|
|
69
|
-
# @return [String] The pod's vendored
|
75
|
+
# @return [String] The pod's vendored frameworks
|
70
76
|
#
|
71
|
-
attr_accessor :
|
77
|
+
attr_accessor :vendored_frameworks
|
78
|
+
|
79
|
+
# @return [String] The pod's vendored libraries
|
80
|
+
#
|
81
|
+
attr_accessor :vendored_libraries
|
72
82
|
|
73
83
|
# @return [String] Framweworks the pod needs to link to
|
74
84
|
#
|
@@ -86,25 +96,42 @@ module PodBuilder
|
|
86
96
|
#
|
87
97
|
attr_accessor :source_files
|
88
98
|
|
99
|
+
# @return [String] license
|
100
|
+
#
|
101
|
+
attr_accessor :license
|
102
|
+
|
103
|
+
# @return [String] summary
|
104
|
+
#
|
105
|
+
attr_accessor :summary
|
106
|
+
|
107
|
+
# @return [Hash] source
|
108
|
+
#
|
109
|
+
attr_accessor :source
|
110
|
+
|
111
|
+
# @return [Hash] authors
|
112
|
+
#
|
113
|
+
attr_accessor :authors
|
114
|
+
|
115
|
+
# @return [String] homepage
|
116
|
+
#
|
117
|
+
attr_accessor :homepage
|
118
|
+
|
119
|
+
# @return [Array<String>] Default subspecs
|
120
|
+
#
|
121
|
+
attr_accessor :default_subspecs
|
122
|
+
|
89
123
|
# Initialize a new instance
|
90
124
|
#
|
91
125
|
# @param [Specification] spec
|
92
126
|
#
|
93
127
|
# @param [Hash] checkout_options
|
94
128
|
#
|
95
|
-
def initialize(spec, all_specs, checkout_options)
|
96
|
-
if overrides = Configuration.spec_overrides[spec.name]
|
97
|
-
overrides.each do |k, v|
|
98
|
-
spec.root.attributes_hash[k] = v
|
99
|
-
if checkout_options.has_key?(spec.name)
|
100
|
-
checkout_options[spec.name][k] = v
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
129
|
+
def initialize(spec, all_specs, checkout_options, supported_platforms)
|
105
130
|
@name = spec.name
|
106
131
|
@root_name = spec.name.split("/").first
|
107
132
|
|
133
|
+
@checksum = spec.checksum
|
134
|
+
|
108
135
|
checkout_options_keys = [@root_name, @name]
|
109
136
|
|
110
137
|
if opts_key = checkout_options_keys.detect { |x| checkout_options.has_key?(x) }
|
@@ -120,22 +147,22 @@ module PodBuilder
|
|
120
147
|
@commit = spec.root.source[:commit]
|
121
148
|
@is_external = false
|
122
149
|
end
|
123
|
-
|
124
|
-
@
|
150
|
+
|
151
|
+
@vendored_frameworks = extract_vendored_frameworks(spec, all_specs)
|
152
|
+
@vendored_libraries = extract_vendored_libraries(spec, all_specs)
|
125
153
|
|
126
154
|
@frameworks = []
|
127
155
|
@weak_frameworks = []
|
128
156
|
@libraries = []
|
129
|
-
spec_and_dependencies(spec, all_specs).each do |spec|
|
130
|
-
@frameworks += extract_array(spec, "framework")
|
131
|
-
@frameworks += extract_array(spec, "frameworks")
|
132
|
-
|
133
|
-
@weak_frameworks += extract_array(spec, "weak_framework")
|
134
|
-
@weak_frameworks += extract_array(spec, "weak_frameworks")
|
135
157
|
|
136
|
-
|
137
|
-
|
138
|
-
|
158
|
+
@frameworks += extract_array(spec, "framework")
|
159
|
+
@frameworks += extract_array(spec, "frameworks")
|
160
|
+
|
161
|
+
@weak_frameworks += extract_array(spec, "weak_framework")
|
162
|
+
@weak_frameworks += extract_array(spec, "weak_frameworks")
|
163
|
+
|
164
|
+
@libraries += extract_array(spec, "library")
|
165
|
+
@libraries += extract_array(spec, "libraries")
|
139
166
|
|
140
167
|
@version = spec.root.version.version
|
141
168
|
@available_versions = spec.respond_to?(:spec_source) ? spec.spec_source.versions(@root_name)&.map(&:to_s) : [@version]
|
@@ -143,7 +170,18 @@ module PodBuilder
|
|
143
170
|
@swift_version = spec.root.swift_version&.to_s
|
144
171
|
@module_name = spec.root.module_name
|
145
172
|
|
146
|
-
@
|
173
|
+
@default_subspecs = extract_array(spec, "default_subspecs")
|
174
|
+
if default_subspec = spec.attributes_hash["default_subspec"]
|
175
|
+
@default_subspecs.push(default_subspec)
|
176
|
+
end
|
177
|
+
|
178
|
+
@dependency_names = spec.attributes_hash.fetch("dependencies", {}).keys + default_subspecs.map { |t| "#{@root_name}/#{t}" }
|
179
|
+
supported_platforms.each do |platform|
|
180
|
+
@dependency_names += (spec.attributes_hash.dig(platform, "dependencies") || {}).keys
|
181
|
+
end
|
182
|
+
@dependency_names.uniq!
|
183
|
+
|
184
|
+
@external_dependency_names = @dependency_names.select { |t| !t.start_with?(root_name) }
|
147
185
|
|
148
186
|
@is_static = spec.root.attributes_hash["static_framework"] || false
|
149
187
|
@xcconfig = spec.root.attributes_hash["xcconfig"] || {}
|
@@ -152,6 +190,13 @@ module PodBuilder
|
|
152
190
|
|
153
191
|
@build_configuration = spec.root.attributes_hash.dig("pod_target_xcconfig", "prebuild_configuration") || "release"
|
154
192
|
@build_configuration.downcase!
|
193
|
+
|
194
|
+
default_license = "MIT"
|
195
|
+
@license = spec.root.attributes_hash.fetch("license", {"type"=>"#{default_license}"})["type"] || default_license
|
196
|
+
@summary = spec.root.attributes_hash.fetch("summary", "A summary for #{@name}")
|
197
|
+
@source = spec.root.attributes_hash.fetch("source", { "git"=>"https://github.com/Subito-it/PodBuilder.git" })
|
198
|
+
@authors = spec.root.attributes_hash.fetch("authors", {"PodBuilder"=>"pod@podbuilder.com"})
|
199
|
+
@homepage = spec.root.attributes_hash.fetch("homepage", "https://github.com/Subito-it/PodBuilder")
|
155
200
|
end
|
156
201
|
|
157
202
|
def pod_specification(all_poditems, parent_spec = nil)
|
@@ -204,6 +249,43 @@ module PodBuilder
|
|
204
249
|
return available_pods.select { |x| @dependency_names.include?(x.name) }
|
205
250
|
end
|
206
251
|
|
252
|
+
def recursive_dependencies(available_pods)
|
253
|
+
names = [name]
|
254
|
+
|
255
|
+
deps = []
|
256
|
+
last_count = -1
|
257
|
+
while deps.count != last_count do
|
258
|
+
last_count = deps.count
|
259
|
+
|
260
|
+
updated_names = []
|
261
|
+
names.each do |name|
|
262
|
+
if pod = available_pods.detect { |t| t.name == name }
|
263
|
+
deps.push(pod)
|
264
|
+
updated_names += pod.dependency_names
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
names = updated_names.uniq
|
269
|
+
|
270
|
+
deps.uniq!
|
271
|
+
end
|
272
|
+
|
273
|
+
root_names = deps.map(&:root_name).uniq
|
274
|
+
|
275
|
+
# We need to build all other common subspecs to properly build the framework
|
276
|
+
# Ex.
|
277
|
+
# PodA depends on DepA/subspec1
|
278
|
+
# PodB depends on DepA/subspec2
|
279
|
+
#
|
280
|
+
# When building PodA we need to build both DepA subspecs because they might
|
281
|
+
# contain different code
|
282
|
+
deps += available_pods.select { |t| root_names.include?(t.root_name) }
|
283
|
+
|
284
|
+
deps.uniq!
|
285
|
+
|
286
|
+
return deps
|
287
|
+
end
|
288
|
+
|
207
289
|
# @return [Bool] True if it's a pod that doesn't provide source code (is already shipped as a prebuilt pod)
|
208
290
|
#
|
209
291
|
def is_prebuilt
|
@@ -218,14 +300,17 @@ module PodBuilder
|
|
218
300
|
|
219
301
|
# Podspecs aren't always properly written (source_file key is often used instead of header_files)
|
220
302
|
# Therefore it can become tricky to understand which pods are already precompiled by boxing a .framework or .a
|
221
|
-
|
222
|
-
|
223
|
-
embedded_as_static_lib = vendored_items_paths.any? { |x| x.match(/#{module_name}.*\\.a/) != nil }
|
303
|
+
embedded_as_vendored = vendored_frameworks.map { |x| File.basename(x) }.include?("#{module_name}.framework")
|
304
|
+
embedded_as_static_lib = vendored_libraries.map { |x| File.basename(x) }.include?("lib#{module_name}.a")
|
224
305
|
|
225
306
|
only_headers = (source_files.count > 0 && @source_files.all? { |x| x.end_with?(".h") })
|
226
|
-
no_sources = (@source_files.count == 0 || only_headers) && @
|
307
|
+
no_sources = (@source_files.count == 0 || only_headers) && (@vendored_frameworks + @vendored_libraries).count > 0
|
227
308
|
|
228
|
-
|
309
|
+
if !no_sources && !only_headers
|
310
|
+
return false
|
311
|
+
else
|
312
|
+
return embedded_as_static_lib || embedded_as_vendored
|
313
|
+
end
|
229
314
|
end
|
230
315
|
|
231
316
|
# @return [Bool] True if it's a subspec
|
@@ -271,7 +356,7 @@ module PodBuilder
|
|
271
356
|
end
|
272
357
|
|
273
358
|
if include_pb_entry && !is_prebuilt
|
274
|
-
plists = Dir.glob(PodBuilder::
|
359
|
+
plists = Dir.glob(PodBuilder::prebuiltpath("**/#{module_name}.framework/#{Configuration::framework_plist_filename}"))
|
275
360
|
if plists.count > 0
|
276
361
|
plist = CFPropertyList::List.new(:file => plists.first)
|
277
362
|
data = CFPropertyList.native_types(plist.value)
|
@@ -302,15 +387,18 @@ module PodBuilder
|
|
302
387
|
end
|
303
388
|
end
|
304
389
|
|
305
|
-
def prebuilt_entry(include_pb_entry = true)
|
306
|
-
|
390
|
+
def prebuilt_entry(include_pb_entry = true, absolute_path = false)
|
391
|
+
if absolute_path
|
392
|
+
pod_path = PodBuilder::prebuiltpath
|
393
|
+
else
|
394
|
+
pod_path = Pathname.new(Configuration.base_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
|
395
|
+
pod_path += "/Rome"
|
396
|
+
end
|
307
397
|
|
308
398
|
if Configuration.subspecs_to_split.include?(name)
|
309
|
-
entry = "pod '
|
310
|
-
elsif override_name = Configuration.spec_overrides.dig(name, "module_name")
|
311
|
-
entry = "pod 'PodBuilder/#{override_name}', :path => '#{relative_path}'"
|
399
|
+
entry = "pod '#{podspec_name}', :path => '#{pod_path}'"
|
312
400
|
else
|
313
|
-
entry = "pod '
|
401
|
+
entry = "pod '#{name}', :path => '#{pod_path}'"
|
314
402
|
end
|
315
403
|
|
316
404
|
if include_pb_entry && !is_prebuilt
|
@@ -337,45 +425,48 @@ module PodBuilder
|
|
337
425
|
end
|
338
426
|
|
339
427
|
def vendored_framework_path
|
340
|
-
if File.exist?(PodBuilder::
|
341
|
-
return
|
342
|
-
elsif File.exist?(PodBuilder::
|
343
|
-
return
|
428
|
+
if File.exist?(PodBuilder::prebuiltpath(vendored_subspec_framework_name))
|
429
|
+
return vendored_subspec_framework_name
|
430
|
+
elsif File.exist?(PodBuilder::prebuiltpath(vendored_spec_framework_name))
|
431
|
+
return vendored_spec_framework_name
|
344
432
|
end
|
345
433
|
|
346
434
|
return nil
|
347
435
|
end
|
348
436
|
|
349
|
-
def
|
350
|
-
return "
|
437
|
+
def vendored_subspec_framework_name
|
438
|
+
return "#{prebuilt_rel_path}"
|
351
439
|
end
|
352
440
|
|
353
|
-
def
|
354
|
-
return "
|
355
|
-
end
|
356
|
-
|
357
|
-
def self.vendored_name_framework_path(name)
|
358
|
-
return "Rome/#{name}"
|
441
|
+
def vendored_spec_framework_name
|
442
|
+
return "#{module_name}.framework"
|
359
443
|
end
|
360
444
|
|
361
445
|
private
|
362
446
|
|
363
|
-
def
|
447
|
+
def extract_vendored_frameworks(spec, all_specs)
|
364
448
|
items = []
|
365
449
|
|
366
450
|
supported_platforms = spec.available_platforms.flatten.map(&:name).map(&:to_s)
|
451
|
+
items += [spec.attributes_hash["vendored_frameworks"]]
|
452
|
+
items += [spec.attributes_hash["vendored_framework"]]
|
367
453
|
|
368
|
-
|
369
|
-
|
370
|
-
items += [spec.attributes_hash["vendored_framework"]]
|
371
|
-
items += [spec.attributes_hash["vendored_libraries"]]
|
372
|
-
items += [spec.attributes_hash["vendored_library"]]
|
454
|
+
items += supported_platforms.map { |x| spec.attributes_hash.fetch(x, {})["vendored_frameworks"] }
|
455
|
+
items += supported_platforms.map { |x| spec.attributes_hash.fetch(x, {})["vendored_framework"] }
|
373
456
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
457
|
+
return items.flatten.uniq.compact
|
458
|
+
end
|
459
|
+
|
460
|
+
def extract_vendored_libraries(spec, all_specs)
|
461
|
+
items = []
|
462
|
+
|
463
|
+
supported_platforms = spec.available_platforms.flatten.map(&:name).map(&:to_s)
|
464
|
+
|
465
|
+
items += [spec.attributes_hash["vendored_libraries"]]
|
466
|
+
items += [spec.attributes_hash["vendored_library"]]
|
467
|
+
|
468
|
+
items += supported_platforms.map { |x| spec.attributes_hash.fetch(x, {})["vendored_libraries"] }
|
469
|
+
items += supported_platforms.map { |x| spec.attributes_hash.fetch(x, {})["vendored_library"] }
|
379
470
|
|
380
471
|
return items.flatten.uniq.compact
|
381
472
|
end
|
@@ -429,18 +520,5 @@ module PodBuilder
|
|
429
520
|
|
430
521
|
return source_files + root_source_files + subspec_source_files
|
431
522
|
end
|
432
|
-
|
433
|
-
def spec_and_dependencies(spec, all_specs)
|
434
|
-
specs = all_specs.select { |x| spec.dependencies.map(&:name).include?(x.name) }
|
435
|
-
specs += all_specs.select { |x| spec.default_subspecs.any? { |y| x.name == "#{spec.name}/#{y}" } }
|
436
|
-
specs += [spec, spec.root].flatten.uniq
|
437
|
-
|
438
|
-
all_remaining_specs = all_specs.reject { |x| specs.map(&:name).include?(x.name) }
|
439
|
-
if all_remaining_specs.count < all_specs.count
|
440
|
-
specs += specs.reject { |x| x == spec }.map { |x| spec_and_dependencies(x, all_remaining_specs) }
|
441
|
-
end
|
442
|
-
|
443
|
-
return specs.flatten.compact.uniq
|
444
|
-
end
|
445
523
|
end
|
446
524
|
end
|
data/lib/pod_builder/podspec.rb
CHANGED
@@ -1,38 +1,5 @@
|
|
1
1
|
module PodBuilder
|
2
2
|
class Podspec
|
3
|
-
class PodspecItem
|
4
|
-
attr_accessor :name
|
5
|
-
attr_accessor :module_name
|
6
|
-
attr_accessor :vendored_frameworks
|
7
|
-
attr_accessor :vendored_items
|
8
|
-
attr_accessor :frameworks
|
9
|
-
attr_accessor :weak_frameworks
|
10
|
-
attr_accessor :libraries
|
11
|
-
attr_accessor :resources
|
12
|
-
attr_accessor :exclude_files
|
13
|
-
attr_accessor :xcconfig
|
14
|
-
attr_accessor :dependencies
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@name = ""
|
18
|
-
@module_name = ""
|
19
|
-
@vendored_frameworks = []
|
20
|
-
@vendored_items = []
|
21
|
-
@frameworks = []
|
22
|
-
@weak_frameworks = []
|
23
|
-
@libraries = []
|
24
|
-
@resources = []
|
25
|
-
@exclude_files = []
|
26
|
-
@xcconfig = {}
|
27
|
-
@dependencies = []
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_s
|
31
|
-
@name
|
32
|
-
end
|
33
|
-
end
|
34
|
-
private_constant :PodspecItem
|
35
|
-
|
36
3
|
def self.generate(all_buildable_items, analyzer)
|
37
4
|
unless all_buildable_items.count > 0
|
38
5
|
return
|
@@ -40,142 +7,167 @@ module PodBuilder
|
|
40
7
|
|
41
8
|
puts "Generating PodBuilder's local podspec".yellow
|
42
9
|
|
43
|
-
podspec_items = podspec_items_from(all_buildable_items)
|
44
|
-
|
45
10
|
platform = analyzer.instance_variable_get("@result").targets.first.platform
|
46
|
-
generate_podspec_from(
|
11
|
+
generate_podspec_from(all_buildable_items, platform)
|
47
12
|
end
|
48
13
|
|
49
14
|
def self.include?(pod_name)
|
50
|
-
|
51
|
-
unless File.exist?(podspec_path)
|
52
|
-
return false
|
53
|
-
end
|
54
|
-
|
55
|
-
if Configuration.subspecs_to_split.include?(pod_name)
|
56
|
-
pod_name = pod_name.gsub("/", "_")
|
57
|
-
else
|
58
|
-
pod_name = pod_name.split("/").first
|
59
|
-
end
|
60
|
-
|
61
|
-
podspec_content = File.read(podspec_path)
|
62
|
-
|
63
|
-
# (_.*) will include prebuild podnames like s.subspec 'Podname_Subspec' do |p|
|
64
|
-
subspec_regex = "s.subspec '#{pod_name}(_.*)?' do |p|"
|
65
|
-
return (podspec_content.match(/#{subspec_regex}/) != nil)
|
15
|
+
return File.exist?(PodBuilder::prebuiltpath("#{pod_name}.podspec"))
|
66
16
|
end
|
67
17
|
|
68
18
|
private
|
69
19
|
|
70
|
-
def self.
|
71
|
-
|
72
|
-
|
73
|
-
vendored_frameworks = item.vendored_frameworks.map { |x| x.vendored_framework_path }.compact
|
74
|
-
vendored_frameworks += item.vendored_items.map { |x| File.basename(x) }.select { |x| File.exist?(PodBuilder::basepath(PodfileItem::vendored_name_framework_path(x))) }.map { |x| "Rome/#{x}" }
|
75
|
-
vendored_frameworks.uniq!
|
76
|
-
vendored_libraries = Dir.glob(PodBuilder::basepath("Rome/#{item.module_name}/**/*.a")).map { |x| x.to_s.gsub(PodBuilder::basepath, "")[1..-1] }
|
20
|
+
def self.generate_spec_keys_for(item, name, all_buildable_items)
|
21
|
+
podspec = ""
|
22
|
+
valid = false
|
77
23
|
|
78
|
-
|
79
|
-
|
80
|
-
|
24
|
+
slash_count = name.count("/") + 1
|
25
|
+
indentation = " " * slash_count
|
26
|
+
spec_var = "p#{slash_count}"
|
81
27
|
|
28
|
+
if item.name == name
|
29
|
+
vendored_frameworks = item.vendored_frameworks + ["#{item.module_name}.framework"]
|
30
|
+
existing_vendored_frameworks = vendored_frameworks.select { |t| File.exist?(PodBuilder::prebuiltpath(t) || "") }
|
31
|
+
existing_vendored_frameworks_basename = vendored_frameworks.map { |t| File.basename(t) }.select { |t| File.exist?(PodBuilder::prebuiltpath(t) || "") }
|
32
|
+
vendored_frameworks = (existing_vendored_frameworks + existing_vendored_frameworks_basename).uniq
|
33
|
+
|
34
|
+
vendored_libraries = item.vendored_libraries
|
35
|
+
existing_vendored_libraries = vendored_libraries.map { |t| "#{item.module_name}/#{t}" }.select { |t| File.exist?(PodBuilder::prebuiltpath(t) || "") }
|
36
|
+
existing_vendored_libraries_basename = vendored_libraries.map { |t| File.basename("#{item.module_name}/#{t}") }.select { |t| File.exist?(PodBuilder::prebuiltpath(t) || "") }
|
37
|
+
vendored_libraries = (existing_vendored_libraries + existing_vendored_libraries_basename).uniq
|
38
|
+
|
39
|
+
# .a are static libraries and should not be included again in the podspec to prevent duplicated symbols (in the app and in the prebuilt framework)
|
40
|
+
vendored_libraries.select! { |t| !t.end_with?(".a") }
|
41
|
+
|
42
|
+
frameworks = all_buildable_items.select { |t| vendored_frameworks.include?("#{t.module_name}.framework") }.uniq
|
43
|
+
static_frameworks = frameworks.select { |x| x.is_static }
|
44
|
+
|
45
|
+
resources = static_frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/*.{nib,bundle,xcasset,strings,png,jpg,tif,tiff,otf,ttf,ttc,plist,json,caf,wav,p12,momd}" }.compact.flatten.uniq
|
46
|
+
exclude_files = static_frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/Info.plist" }.compact.flatten.uniq
|
47
|
+
exclude_files += frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/#{Configuration.framework_plist_filename}" }.compact.flatten.uniq.sort
|
48
|
+
|
82
49
|
if vendored_frameworks.count > 0
|
83
|
-
podspec += "
|
84
|
-
end
|
50
|
+
podspec += "#{indentation}#{spec_var}.vendored_frameworks = '#{vendored_frameworks.uniq.sort.join("','")}'\n"
|
51
|
+
end
|
85
52
|
if vendored_libraries.count > 0
|
86
|
-
podspec += "
|
53
|
+
podspec += "#{indentation}#{spec_var}.vendored_libraries = '#{vendored_libraries.uniq.sort.join("','")}'\n"
|
87
54
|
end
|
88
55
|
if item.frameworks.count > 0
|
89
|
-
podspec += "
|
56
|
+
podspec += "#{indentation}#{spec_var}.frameworks = '#{item.frameworks.uniq.sort.join("', '")}'\n"
|
90
57
|
end
|
91
58
|
if item.libraries.count > 0
|
92
|
-
podspec += "
|
59
|
+
podspec += "#{indentation}#{spec_var}.libraries = '#{item.libraries.uniq.sort.join("', '")}'\n"
|
93
60
|
end
|
94
|
-
if
|
95
|
-
podspec += "
|
61
|
+
if resources.count > 0
|
62
|
+
podspec += "#{indentation}#{spec_var}.resources = '#{resources.uniq.sort.join("', '")}'\n"
|
96
63
|
end
|
97
|
-
if
|
98
|
-
podspec += "
|
64
|
+
if exclude_files.count > 0
|
65
|
+
podspec += "#{indentation}#{spec_var}.exclude_files = '#{exclude_files.uniq.sort.join("', '")}'\n"
|
99
66
|
end
|
100
67
|
if item.xcconfig.keys.count > 0
|
101
|
-
|
102
|
-
|
103
|
-
non_prebuilt_dependencies.each do |non_prebuilt_dependency|
|
104
|
-
podspec += " p.dependency '#{non_prebuilt_dependency.name}'\n"
|
105
|
-
end
|
106
|
-
|
107
|
-
podspec += " end"
|
108
|
-
|
109
|
-
podspecs.push(podspec)
|
110
|
-
end
|
111
|
-
|
112
|
-
cwd = File.dirname(File.expand_path(__FILE__))
|
113
|
-
podspec_file = File.read("#{cwd}/templates/build_podspec.template")
|
114
|
-
podspec_file.gsub!("%%%podspecs%%%", podspecs.join("\n\n"))
|
115
|
-
|
116
|
-
podspec_file.sub!("%%%platform_name%%%", platform.name.to_s)
|
117
|
-
podspec_file.sub!("%%%deployment_version%%%", platform.deployment_target.version)
|
118
|
-
|
119
|
-
File.write(PodBuilder::basepath("PodBuilder.podspec"), podspec_file)
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.podspec_items_from(buildable_items)
|
123
|
-
podspec_items = []
|
124
|
-
|
125
|
-
buildable_items.each do |pod|
|
126
|
-
spec_exists = File.exist?(PodBuilder::basepath(pod.vendored_spec_framework_path))
|
127
|
-
subspec_exists = File.exist?(PodBuilder::basepath(pod.vendored_subspec_framework_path))
|
128
|
-
|
129
|
-
unless spec_exists || subspec_exists
|
130
|
-
puts "Skipping `#{pod.name}`, not prebuilt".blue
|
131
|
-
next
|
132
|
-
end
|
133
|
-
|
134
|
-
pod_name = Configuration.subspecs_to_split.include?(pod.name) ? pod.name : pod.root_name
|
135
|
-
unless podspec_item = podspec_items.detect { |x| x.name == pod_name }
|
136
|
-
podspec_item = PodspecItem.new
|
137
|
-
podspec_items.push(podspec_item)
|
138
|
-
podspec_item.name = pod_name
|
139
|
-
podspec_item.module_name = pod.module_name
|
140
|
-
podspec_item.vendored_items = pod.vendored_items
|
141
|
-
end
|
142
|
-
|
143
|
-
podspec_item.vendored_frameworks += [pod] + pod.dependencies(buildable_items)
|
144
|
-
|
145
|
-
podspec_item.frameworks = podspec_item.vendored_frameworks.map { |x| x.frameworks }.flatten.uniq.sort
|
146
|
-
podspec_item.weak_frameworks = podspec_item.vendored_frameworks.map { |x| x.weak_frameworks }.flatten.uniq.sort
|
147
|
-
podspec_item.libraries = podspec_item.vendored_frameworks.map { |x| x.libraries }.flatten.uniq.sort
|
148
|
-
|
149
|
-
static_vendored_frameworks = podspec_item.vendored_frameworks.select { |x| x.is_static }
|
150
|
-
|
151
|
-
podspec_item.resources = static_vendored_frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/*.{nib,bundle,xcasset,strings,png,jpg,tif,tiff,otf,ttf,ttc,plist,json,caf,wav,p12,momd}" }.compact.flatten.uniq
|
152
|
-
podspec_item.exclude_files = static_vendored_frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/Info.plist" }.compact.flatten.uniq
|
153
|
-
podspec_item.exclude_files += podspec_item.vendored_frameworks.map { |x| x.vendored_framework_path.nil? ? nil : "#{x.vendored_framework_path}/#{Configuration.framework_plist_filename}" }.compact.flatten.uniq.sort
|
154
|
-
|
155
|
-
# Merge xcconfigs
|
156
|
-
if !pod.xcconfig.empty?
|
157
|
-
pod.xcconfig.each do |k, v|
|
68
|
+
xcconfig = Hash.new
|
69
|
+
item.xcconfig.each do |k, v|
|
158
70
|
unless v != "$(inherited)"
|
71
|
+
xcconfig[k] = item.xcconfig[k]
|
159
72
|
next
|
160
73
|
end
|
161
74
|
unless k == "OTHER_LDFLAGS"
|
162
75
|
next # For the time being limit to OTHER_LDFLAGS key
|
163
76
|
end
|
164
|
-
|
165
|
-
if podspec_values =
|
77
|
+
|
78
|
+
if podspec_values = item.xcconfig[k]
|
166
79
|
podspec_values_arr = podspec_values.split(" ")
|
167
80
|
podspec_values_arr.push(v)
|
168
81
|
v = podspec_values_arr.join(" ")
|
169
82
|
end
|
170
83
|
|
171
|
-
|
84
|
+
xcconfig[k] = item.xcconfig[k]
|
85
|
+
end
|
86
|
+
|
87
|
+
if xcconfig.keys.count > 0
|
88
|
+
podspec += "#{indentation}#{spec_var}.xcconfig = #{xcconfig.to_s}\n"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
deps = item.dependency_names.sort
|
93
|
+
if name == item.root_name
|
94
|
+
deps.reject! { |t| t.split("/").first == item.root_name }
|
95
|
+
end
|
96
|
+
|
97
|
+
if deps.count > 0
|
98
|
+
if podspec.count("\n") > 1
|
99
|
+
podspec += "\n"
|
100
|
+
end
|
101
|
+
deps.each do |dependency|
|
102
|
+
podspec += "#{indentation}#{spec_var}.dependency '#{dependency}'\n"
|
172
103
|
end
|
173
104
|
end
|
174
105
|
|
175
|
-
|
106
|
+
valid = valid || vendored_frameworks.count > 0
|
176
107
|
end
|
108
|
+
|
109
|
+
subspec_names = all_buildable_items.map(&:name).select { |t| t.start_with?("#{name}/") }
|
110
|
+
subspec_names_groups = subspec_names.group_by { |t| name + "/" + t.gsub("#{name}/", '').split("/").first }
|
111
|
+
subspec_names = subspec_names_groups.keys.uniq.sort
|
112
|
+
|
113
|
+
subspec_names.each do |subspec|
|
114
|
+
subspec_item = all_buildable_items.detect { |t| t.name == subspec } || item
|
177
115
|
|
178
|
-
|
116
|
+
if podspec.length > 0
|
117
|
+
podspec += "\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
subspec_keys, subspec_valid = generate_spec_keys_for(subspec_item, subspec, all_buildable_items)
|
121
|
+
valid = valid || subspec_valid
|
122
|
+
|
123
|
+
if subspec_keys.length > 0
|
124
|
+
podspec += "#{indentation}#{spec_var}.subspec '#{subspec.split("/").last}' do |p#{slash_count + 1}|\n"
|
125
|
+
podspec += subspec_keys
|
126
|
+
podspec += "#{indentation}end\n"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
return podspec, valid
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.generate_podspec_from(all_buildable_items, platform)
|
134
|
+
specs = Dir.glob(PodBuilder::prebuiltpath("*.podspec"))
|
135
|
+
specs.each do |s|
|
136
|
+
FileUtils.rm(s)
|
137
|
+
end
|
138
|
+
|
139
|
+
all_buildable_items.each do |item|
|
140
|
+
if item.name != item.root_name
|
141
|
+
if all_buildable_items.map(&:name).include?(item.root_name)
|
142
|
+
next # will process root spec, skip subspecs
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
podspec = "Pod::Spec.new do |p1|\n"
|
147
|
+
|
148
|
+
podspec += " p1.name = '#{item.root_name}'\n"
|
149
|
+
podspec += " p1.version = '#{item.version}'\n"
|
150
|
+
podspec += " p1.summary = '#{item.summary.gsub("'", "\\'")}'\n"
|
151
|
+
podspec += " p1.homepage = '#{item.homepage}'\n"
|
152
|
+
podspec += " p1.author = 'PodBuilder'\n"
|
153
|
+
podspec += " p1.source = { 'git' => '#{item.source['git']}'}\n"
|
154
|
+
podspec += " p1.license = { :type => '#{item.license}' }\n"
|
155
|
+
|
156
|
+
podspec += "\n"
|
157
|
+
podspec += " p1.#{platform.safe_string_name.downcase}.deployment_target = '#{platform.deployment_target.version}'\n"
|
158
|
+
podspec += "\n"
|
159
|
+
|
160
|
+
main_keys, valid = generate_spec_keys_for(item, item.root_name, all_buildable_items)
|
161
|
+
if !valid
|
162
|
+
next
|
163
|
+
end
|
164
|
+
|
165
|
+
podspec += main_keys
|
166
|
+
podspec += "end"
|
167
|
+
|
168
|
+
spec_path = PodBuilder::prebuiltpath("#{item.root_name}.podspec")
|
169
|
+
File.write(spec_path, podspec)
|
170
|
+
end
|
179
171
|
end
|
180
172
|
end
|
181
173
|
end
|