pod-builder-y 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +13 -0
  5. data/README.md +385 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/exe/pod_builder_y +406 -0
  10. data/lib/core_ext/string.rb +5 -0
  11. data/lib/pod_builder/analyze.rb +59 -0
  12. data/lib/pod_builder/analyzer.rb +16 -0
  13. data/lib/pod_builder/command.rb +14 -0
  14. data/lib/pod_builder/command/build.rb +228 -0
  15. data/lib/pod_builder/command/build_all.rb +15 -0
  16. data/lib/pod_builder/command/clean.rb +75 -0
  17. data/lib/pod_builder/command/deintegrate.rb +101 -0
  18. data/lib/pod_builder/command/generate_lldbinit.rb +128 -0
  19. data/lib/pod_builder/command/generate_podspec.rb +22 -0
  20. data/lib/pod_builder/command/info.rb +18 -0
  21. data/lib/pod_builder/command/init.rb +148 -0
  22. data/lib/pod_builder/command/install_sources.rb +79 -0
  23. data/lib/pod_builder/command/none.rb +16 -0
  24. data/lib/pod_builder/command/restore_all.rb +33 -0
  25. data/lib/pod_builder/command/switch.rb +224 -0
  26. data/lib/pod_builder/command/sync_podfile.rb +34 -0
  27. data/lib/pod_builder/command/update.rb +43 -0
  28. data/lib/pod_builder/configuration.rb +300 -0
  29. data/lib/pod_builder/core.rb +222 -0
  30. data/lib/pod_builder/info.rb +90 -0
  31. data/lib/pod_builder/install.rb +505 -0
  32. data/lib/pod_builder/licenses.rb +73 -0
  33. data/lib/pod_builder/podfile.rb +700 -0
  34. data/lib/pod_builder/podfile/pre_actions_swizzles.rb +84 -0
  35. data/lib/pod_builder/podfile_cp.rb +99 -0
  36. data/lib/pod_builder/podfile_item.rb +530 -0
  37. data/lib/pod_builder/podspec.rb +269 -0
  38. data/lib/pod_builder/rome/post_install.rb +446 -0
  39. data/lib/pod_builder/rome/pre_install.rb +6 -0
  40. data/lib/pod_builder/templates/build_podfile.template +70 -0
  41. data/lib/pod_builder/templates/build_podspec.template +19 -0
  42. data/lib/pod_builder/version.rb +4 -0
  43. data/pod-builder.gemspec +37 -0
  44. metadata +240 -0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,406 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pod_builder/version'
4
+
5
+ show_version = ARGV.include?("version") && ARGV.count == 1
6
+ if show_version
7
+ puts PodBuilder::VERSION
8
+ exit(0)
9
+ end
10
+
11
+ if ENV["DEBUGGING"]
12
+ puts "Running in debug, injecting $LOAD_PATH"
13
+ libdir = File.expand_path("#{File.dirname(__FILE__)}/../lib")
14
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
15
+ end
16
+
17
+ require 'optparse'
18
+ require 'pod_builder/core'
19
+ require 'pod_builder/command'
20
+
21
+ OPTIONS = {}
22
+
23
+ def parse_commandline()
24
+ subcommands = {
25
+ "none" => {
26
+ :opts => OptionParser.new do |opts|
27
+ opts.banner = "
28
+ Usage:
29
+
30
+ $ pod_builder COMMAND [OPTIONS]
31
+
32
+ Prebuild CocoaPods pods
33
+
34
+ Command:
35
+ + init Initialize prebuild folders
36
+ + deintegrate Deintegrate prebuild folders
37
+ + build Build a specific pod declared in the PodBuilder-Podfile
38
+ + build_all Build all pods declared in the PodBuilder-Podfile
39
+ + update Rebuild items that are outdated
40
+ + restore_all Rebuild all pods declared in the Restore-Podfile
41
+ + install_sources Install sources of pods to debug into prebuilt items
42
+ + generate_lldbinit Generate an lldbinit file with setting target.source-map to debug prebuilt items
43
+ + switch Switch between prebuilt/development/standard pod in the Application-Podfile
44
+ + clean Remove prebuild items, dSYMs and source files added by `install_sources` command that are no longer in the PodBuilder-Podfile
45
+ + sync_podfile Update your Application-Podfile with all pods declared in the PodBuilder-Podfile
46
+ + info Print json-formatted informations about prebuilt items
47
+
48
+ Options:
49
+ "
50
+ opts.on("-v", "--version", "Show the version of the tool") do |o|
51
+ OPTIONS[:version] = o
52
+ end
53
+ end,
54
+ :call => [
55
+ PodBuilder::Command::None
56
+ ]
57
+ },
58
+
59
+ "build" => {
60
+ :opts => OptionParser.new do |opts|
61
+ opts.banner = "
62
+ Usage:
63
+
64
+ $ pod_builder build [OPTIONS] <PODNAME...>
65
+
66
+ Prebuild the specified CocoaPods pods.
67
+
68
+ Options:
69
+ "
70
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
71
+ OPTIONS[:update_repos] = false
72
+ end
73
+ opts.on("-f", "--force", "Rebuild items even when no code change is detected") do |o|
74
+ OPTIONS[:force_rebuild] = true
75
+ end
76
+ opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
77
+ OPTIONS[:allow_warnings] = o
78
+ end
79
+ opts.on("-r", "--parent-deps", "Include all pods that depend on the specified <PODNAME...>") do |o|
80
+ OPTIONS[:resolve_parent_dependencies] = true
81
+ end
82
+ opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
83
+ OPTIONS[:no_stdin_available] = o
84
+ end
85
+ opts.on("-d", "--debug", "Don't clean build folder") do |o|
86
+ OPTIONS[:debug] = o
87
+ end
88
+ end,
89
+ :call => [
90
+ PodBuilder::Command::Build
91
+ ]
92
+ },
93
+
94
+ "build_all" => {
95
+ :opts => OptionParser.new do |opts|
96
+ opts.banner = "
97
+ Usage:
98
+
99
+ $ pod_builder build_all [OPTIONS]
100
+
101
+ Prebuild all pods specified in the PodBuilder-Podfile.
102
+
103
+ Options:
104
+ "
105
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
106
+ OPTIONS[:update_repos] = false
107
+ end
108
+ opts.on("-f", "--force", "Rebuild items even when no code change is detected") do |o|
109
+ OPTIONS[:force_rebuild] = false
110
+ end
111
+ opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
112
+ OPTIONS[:allow_warnings] = o
113
+ end
114
+ opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
115
+ OPTIONS[:no_stdin_available] = o
116
+ end
117
+ opts.on("-d", "--debug", "Don't clean build folder") do |o|
118
+ OPTIONS[:debug] = o
119
+ end
120
+ end,
121
+ :call => [
122
+ PodBuilder::Command::BuildAll
123
+ ]
124
+ },
125
+
126
+ "update" => {
127
+ :opts => OptionParser.new do |opts|
128
+ opts.banner = "
129
+ Usage:
130
+
131
+ $ pod_builder update [OPTIONS]
132
+
133
+ Rebuild items that are outdated
134
+
135
+ Options:
136
+ "
137
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
138
+ OPTIONS[:update_repos] = false
139
+ end
140
+ opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
141
+ OPTIONS[:allow_warnings] = o
142
+ end
143
+ opts.on("-r", "--dry", "Determine which items need to be updated") do |o|
144
+ OPTIONS[:dry_run] = o
145
+ end
146
+ opts.on("-d", "--debug", "Don't clean build folder") do |o|
147
+ OPTIONS[:debug] = o
148
+ end
149
+ end,
150
+ :call => [
151
+ PodBuilder::Command::Update
152
+ ]
153
+ },
154
+
155
+ "restore_all" => {
156
+ :opts => OptionParser.new do |opts|
157
+ opts.banner = "
158
+ Usage:
159
+
160
+ $ pod_builder restore_all [OPTIONS]
161
+
162
+ Rebuilds all pods to the version specified in the Restore-Podfile.
163
+
164
+ Options:
165
+ "
166
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
167
+ OPTIONS[:update_repos] = false
168
+ end
169
+ opts.on("-d", "--debug", "Don't clean build folder") do |o|
170
+ OPTIONS[:debug] = o
171
+ end
172
+ end,
173
+ :call => [
174
+ PodBuilder::Command::RestoreAll
175
+ ]
176
+ },
177
+
178
+ "init" => {
179
+ :opts => OptionParser.new do |opts|
180
+ opts.banner = "
181
+ Usage:
182
+
183
+ $ pod_builder init [OPTIONS]
184
+
185
+ Initializes PodBuilder.
186
+
187
+ Options:
188
+ "
189
+ opts.on("-d", "--destination path", "Prebuilt destination path (default: #{PodBuilder::Configuration.base_path})") do |o|
190
+ OPTIONS[:prebuild_path] = o
191
+ end
192
+ end,
193
+ :call => [
194
+ PodBuilder::Command::Init
195
+ ]
196
+ },
197
+
198
+ "generate_podspec" => {
199
+ :opts => OptionParser.new do |opts|
200
+ end,
201
+ :call => [
202
+ PodBuilder::Command::GeneratePodspec
203
+ ]
204
+ },
205
+
206
+ "deintegrate" => {
207
+ :opts => OptionParser.new do |opts|
208
+ opts.banner = "
209
+ Usage:
210
+
211
+ $ pod_builder deintegrate
212
+
213
+ Remove PodBuilder from your project.
214
+
215
+ Options:
216
+ "
217
+ end,
218
+ :call => [
219
+ PodBuilder::Command::Deintegrate
220
+ ]
221
+ },
222
+
223
+ "clean" => {
224
+ :opts => OptionParser.new do |opts|
225
+ opts.banner = "
226
+ Usage:
227
+
228
+ $ pod_builder clean
229
+
230
+ Remove unused prebuild data, dSYM and source folders.
231
+
232
+ Options:
233
+ "
234
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
235
+ OPTIONS[:update_repos] = false
236
+ end
237
+ end,
238
+ :call => [
239
+ PodBuilder::Command::Clean
240
+ ]
241
+ },
242
+
243
+ "install_sources" => {
244
+ :opts => OptionParser.new do |opts|
245
+ opts.banner = "
246
+ Usage:
247
+
248
+ $ pod_builder install_sources
249
+
250
+ Install source of prebuilt pods to be able to step into and debug prebuilt's code.
251
+
252
+ "
253
+ end,
254
+ :call => [
255
+ PodBuilder::Command::InstallSources
256
+ ]
257
+ },
258
+
259
+ "generate_lldbinit" => {
260
+ :opts => OptionParser.new do |opts|
261
+ opts.banner = "
262
+ Usage:
263
+
264
+ $ pod_builder generate_lldbinit [PATH]
265
+
266
+ Update PodBuilder's custom lldbinit by setting the target.source-map which allows to
267
+ step into and debug prebuilt prebuilt's code. To allow this to work it is required
268
+ to specify a path containing the source code that generated the prebuilt item.
269
+
270
+ You can pass a [PATH] which PodBuilder will use to look for dependencies's source code.
271
+ If omitted it will be implied that the project is organized as a monorepo expecting
272
+ source code dependencies to live in the project repo.
273
+ "
274
+ end,
275
+ :call => [
276
+ PodBuilder::Command::UpdateLldbInit
277
+ ]
278
+ },
279
+
280
+ "switch" => {
281
+ :opts => OptionParser.new do |opts|
282
+ opts.banner = "
283
+ Usage:
284
+
285
+ $ pod_builder switch [OPTIONS] <PODNAME...>
286
+
287
+ Switch integration between prebuilt/development/default pod version. Multiple space separated pods can be passed
288
+
289
+ Options:
290
+ "
291
+ opts.on("-p", "--prebuilt", "Use prebuilt") do |o|
292
+ OPTIONS[:switch_mode] = "prebuilt"
293
+ end
294
+ opts.on("-d", "--development", "Development pod") do |o|
295
+ OPTIONS[:switch_mode] = "development"
296
+ end
297
+ opts.on("-s", "--default", "Default version specified in PodBuilder-Podfile") do |o|
298
+ OPTIONS[:switch_mode] = "default"
299
+ end
300
+ opts.on("-c", "--child-deps", "Include dependencies of the specified <PODNAME...>") do |o|
301
+ OPTIONS[:resolve_child_dependencies] = true
302
+ end
303
+ opts.on("-r", "--parent-deps", "Include all pods that depend on the specified <PODNAME...>") do |o|
304
+ OPTIONS[:resolve_parent_dependencies] = true
305
+ end
306
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update (only when passing --parent-deps") do |o|
307
+ OPTIONS[:update_repos] = false
308
+ end
309
+ end,
310
+ :call => [
311
+ PodBuilder::Command::Switch
312
+ ]
313
+ },
314
+
315
+ "sync_podfile" => {
316
+ :opts => OptionParser.new do |opts|
317
+ opts.banner = "
318
+ Usage:
319
+
320
+ $ pod_builder sync_podfile
321
+
322
+ Rewrite the Application-Podfile based on the PodBuilder-Podfile.
323
+ You may want to run this command when you add a new pod to the PodBuilder-Podfile
324
+ and you want to integrate it in the project without rebuilding it.
325
+
326
+ Options:
327
+ "
328
+ opts.on("-u", "--skip-repo-update", "Skip CocoaPods repo update") do |o|
329
+ OPTIONS[:update_repos] = false
330
+ end
331
+ end,
332
+ :call => [
333
+ PodBuilder::Command::SyncPodfile
334
+ ]
335
+ },
336
+
337
+ "info" => {
338
+ :opts => OptionParser.new do |opts|
339
+ opts.banner = "
340
+ Usage:
341
+
342
+ $ pod_builder info
343
+
344
+ Output dependencies and prebuilt informations
345
+
346
+ " end,
347
+ :call => [
348
+ PodBuilder::Command::Info
349
+ ]
350
+ }
351
+ }
352
+
353
+ argv = ARGV.dup
354
+ if subcommand = subcommands[argv.first]
355
+ ARGV.shift
356
+ else
357
+ subcommand = subcommands["none"]
358
+ end
359
+
360
+ ret = -1
361
+ show_help = argv.include?("--help") || argv.include?("-h") || argv.count == 0
362
+ if show_help
363
+ puts subcommand[:opts].help
364
+ else
365
+ PodBuilder::Configuration.load
366
+
367
+ PodBuilder::add_lockfile
368
+
369
+ subcommand[:opts].order!
370
+ subcommand[:call].each do |k|
371
+ if (ret = k.call) && ret == -1
372
+ puts subcommand[:opts].help
373
+ end
374
+ end
375
+ end
376
+
377
+ return ret
378
+ end
379
+
380
+ command_ret = -1
381
+ begin
382
+ unless ENV["USER"] != "root"
383
+ raise "\n\nFor safety do not run this as root\n".red
384
+ end
385
+
386
+ command_ret = parse_commandline
387
+ rescue Exception => e
388
+ error = e.to_s
389
+
390
+ if error.length < 1000 || !File.directory?(PodBuilder::Configuration.build_path)
391
+ puts "#{error.red}\n"
392
+ puts e.backtrace.join("\n\t").red
393
+ puts "\n\nCommand failed!".red
394
+ else
395
+ error_log = File.join(PodBuilder::Configuration.build_path, "pod_builder.err")
396
+ puts "\n\nCommand failed, check #{error_log}!".red
397
+ File.write(error_log, error)
398
+ end
399
+ ensure
400
+ if command_ret == 0
401
+ PodBuilder::clean_basepath
402
+ end
403
+ PodBuilder::remove_lockfile
404
+
405
+ exit(command_ret)
406
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def detect_indentation
3
+ return self[/\A\s*/]
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ require 'rubygems/specification'
2
+ require 'pod_builder/rome/pre_install.rb'
3
+ require 'pod_builder/rome/post_install.rb'
4
+
5
+ module PodBuilder
6
+ class Analyze
7
+ # @return [Pod::Installer] The Pod::Installer instance created by processing the Podfile
8
+ #
9
+ def self.installer_at(path, repo_update = false)
10
+ CLAide::Command::PluginManager.load_plugins("cocoapods")
11
+
12
+ # Manually load inline podbuilder-rome plugin
13
+ pluginspec = Gem::Specification.new("podbuilder-rome", PodBuilder::VERSION)
14
+ pluginspec.activate
15
+
16
+ if !CLAide::Command::PluginManager.loaded_plugins["cocoapods"].map(&:name).include?(pluginspec.name)
17
+ CLAide::Command::PluginManager.loaded_plugins["cocoapods"].push(pluginspec)
18
+ end
19
+
20
+ current_dir = Dir.pwd
21
+ Dir.chdir(path)
22
+
23
+ config = Pod::Config.new()
24
+ installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
25
+ installer.repo_update = repo_update
26
+ installer.update = false
27
+
28
+ installer.prepare
29
+
30
+ analyzer = installer.resolve_dependencies
31
+
32
+ Dir.chdir(current_dir)
33
+
34
+ return installer, analyzer
35
+ end
36
+
37
+ # @return [Array<PodfileItem>] The PodfileItem in the Podfile (including subspecs) and dependencies
38
+ #
39
+ def self.podfile_items(installer, analyzer)
40
+ sandbox = installer.sandbox
41
+ analysis_result = installer.analysis_result
42
+
43
+ all_podfile_pods = analysis_result.podfile_dependency_cache.podfile_dependencies
44
+
45
+ external_source_pods = all_podfile_pods.select(&:external_source)
46
+ checkout_options = external_source_pods.map { |x| [x.name.split("/").first, x.external_source] }.to_h
47
+
48
+ # this adds the :commit which might be missing in checkout_options
49
+ # will also overwrite :branch with :commit which is desired
50
+ checkout_options.merge!(analyzer.sandbox.checkout_sources)
51
+
52
+ all_specs = analysis_result.specifications
53
+
54
+ supported_platforms = analyzer.instance_variable_get("@result").targets.map { |t| t.platform.safe_string_name.downcase }
55
+
56
+ return all_specs.map { |spec| PodfileItem.new(spec, all_specs, checkout_options, supported_platforms) }.sort_by(&:name)
57
+ end
58
+ end
59
+ end