pod-builder 3.3.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0cdcd16503f8c363779e6b63a2a7c7ff66cc867a2092c65fb3a8bcb66758cfb
4
- data.tar.gz: 199fc74359e90c198cac6e8c5c1ea1e172ae93ffe584ccccf5c8d324cda0f761
3
+ metadata.gz: a78cc17a913b3034855029cd54e3b27ab7f5e4482c370e7a53c527c902bec7f1
4
+ data.tar.gz: '08abdad59a5fc4a09dd86fb3d0ca36dc93ef5f3c66a47505fc0919245f8cfd14'
5
5
  SHA512:
6
- metadata.gz: 42587bceee70997a3a91ab5428945e9e98094500ceafca8a7de957fb60784e9e2bc84d9f823fa7c00866c5910e651aa48ad7b200924163a1d9879df241fcd541
7
- data.tar.gz: 60f520d51741fbff7d7216d018266182f4786a5b77c7eec21495d5199752edd850dbafaecd9644217d5bfb7643e41cce88d94b09c271372af2602846cd19db5a
6
+ metadata.gz: 98738c77905e22cfc84ac3941347ab23b9fb1a6f5bb3e9a807b85795b8378f9e4cc2d31f75d1bc338f1ab828a6264f262ef01cd0efc0e4e075a8cfea80981c15
7
+ data.tar.gz: a2561e7991129a01f1fddc79a23e72a87af1474528d188bc686362a6040e0e798e4f66e2e882b5a273342cbf70a035554673e39cf125f0f12302f44e1625944e
data/README.md CHANGED
@@ -324,6 +324,24 @@ PodBuilder writes a plist and markdown license files of pods specified in the Po
324
324
 
325
325
  If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
326
326
 
327
+ #### `pre_actions`
328
+
329
+ Pre actions allow to execute custom scripts before a given command (`switch`, `build`) has been performed.
330
+
331
+ You need to specify a `path` to the executable script which is relative to the _PodBuilder_ folder. Optionally you can also specify whether the command should or should not print the output to stdout/stderr by passing a bool to the `quiet` key (default: false).
332
+
333
+ ```json
334
+ {
335
+ "pre_actions": {
336
+ "switch" : { "path": "pre_switch_action.rb", "quiet": true },
337
+ "build" : { "path": "pre_build_action.rb", "quiet": false }
338
+ }
339
+ }
340
+ ```
341
+
342
+ **Note:** The build action might be invoked more than once depending on the build strategy that PodBuilder needs to perform.
343
+
344
+
327
345
  #### `post_actions`
328
346
 
329
347
  Post actions allow to execute custom scripts after a given command (`switch`, `build`) has been performed.
@@ -339,11 +357,12 @@ You need to specify a `path` to the executable script which is relative to the _
339
357
  }
340
358
  ```
341
359
 
360
+ **Note:** The build action might be invoked more than once depending on the build strategy that PodBuilder needs to perform.
342
361
 
343
362
 
344
363
  # Behind the scenes
345
364
 
346
- PodBuilder leverages CocoaPods code and [cocoapods-rome plugin](https://github.com/CocoaPods/Prebuilt) to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example xcconfig settings.
365
+ PodBuilder leverages CocoaPods to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example custom xcconfig settings.
347
366
 
348
367
  # FAQ
349
368
 
@@ -2,7 +2,7 @@ require 'pod_builder/core'
2
2
  require 'json'
3
3
 
4
4
  module PodBuilder
5
- module PostActions
5
+ module Actions
6
6
  def self.load(hash)
7
7
  actions = {}
8
8
  if json = hash["switch"]
@@ -52,7 +52,10 @@ module PodBuilder
52
52
 
53
53
  supported_platforms = analyzer.instance_variable_get("@result").targets.map { |t| t.platform.safe_string_name.downcase }
54
54
 
55
- return all_specs.map { |spec| PodfileItem.new(spec, all_specs, checkout_options, supported_platforms) }.sort_by(&:name)
55
+ target_definitions = installer.podfile.target_definitions.values
56
+ items = all_specs.map { |spec| PodfileItem.new(spec, all_specs, target_definitions, checkout_options, supported_platforms) }.sort_by(&:name)
57
+
58
+ return items
56
59
  end
57
60
  end
58
61
  end
@@ -114,10 +114,19 @@ module PodBuilder
114
114
  podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
115
115
 
116
116
  podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks, build_catalyst, podfile_items.first.build_xcframework)
117
+
118
+ PodBuilder::safe_rm_rf(Configuration.build_path)
119
+ FileUtils.mkdir_p(Configuration.build_path)
120
+
121
+ init_git(Configuration.build_path) # this is needed to be able to call safe_rm_rf
122
+
123
+ Configuration.pre_actions[:build]&.execute()
117
124
 
118
125
  install_result += Install.podfile(podfile_content, podfile_items, argument_pods, podfile_items.first.build_configuration)
119
126
 
120
127
  FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
128
+
129
+ Configuration.post_actions[:build]&.execute()
121
130
  end
122
131
 
123
132
  install_result.write_prebuilt_info_files
@@ -145,9 +154,7 @@ module PodBuilder
145
154
 
146
155
  if (restore_file_error = restore_file_error) && Configuration.restore_enabled
147
156
  puts "\n\n⚠️ Podfile.restore was found invalid and was overwritten. Error:\n #{restore_file_error}".red
148
- end
149
-
150
- Configuration.post_actions[:build]&.execute()
157
+ end
151
158
 
152
159
  puts "\n\n🎉 done!\n".green
153
160
  return 0
@@ -155,6 +162,12 @@ module PodBuilder
155
162
 
156
163
  private
157
164
 
165
+ def self.init_git(path)
166
+ Dir.chdir(path) do
167
+ system("git init")
168
+ end
169
+ end
170
+
158
171
  def self.should_build_catalyst(installer)
159
172
  integrate_targets = installer.podfile.installation_options.integrate_targets
160
173
 
@@ -1,4 +1,5 @@
1
1
  require 'pod_builder/core'
2
+ require 'set'
2
3
 
3
4
  module PodBuilder
4
5
  module Command
@@ -13,6 +14,8 @@ module PodBuilder
13
14
  return -1
14
15
  end
15
16
 
17
+ Configuration.pre_actions[:switch]&.execute()
18
+
16
19
  pods_not_found = []
17
20
  pod_names_to_switch = []
18
21
  argument_pods.each do |pod|
@@ -85,6 +88,8 @@ module PodBuilder
85
88
  pod_names_to_switch = pod_names_to_switch.map { |t| t.split("/").first }.uniq
86
89
  dep_pod_names_to_switch.reject { |t| pod_names_to_switch.include?(t) }
87
90
  end
91
+
92
+ inhibit_warnings = inhibit_warnings_pods()
88
93
 
89
94
  pod_names_to_switch.each do |pod_name_to_switch|
90
95
  development_path = ""
@@ -92,7 +97,7 @@ module PodBuilder
92
97
 
93
98
  case OPTIONS[:switch_mode]
94
99
  when "development"
95
- development_path = find_podspec(pod_name_to_switch)
100
+ development_path = find_podspec(pod_name_to_switch)
96
101
  when "prebuilt"
97
102
  podfile_path = PodBuilder::basepath("Podfile.restore")
98
103
  content = File.read(podfile_path)
@@ -111,8 +116,7 @@ module PodBuilder
111
116
  next
112
117
  end
113
118
 
114
- matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
115
- if matches&.size == 2
119
+ if (matches = line.match(/^\s*pod ['|"](.*?)['|"](.*)/)) && matches.size == 3
116
120
  if matches[1].split("/").first == pod_name_to_switch
117
121
  default_entries[current_section] = line
118
122
  end
@@ -141,8 +145,7 @@ module PodBuilder
141
145
  current_section = line.split(" ")[1]
142
146
  end
143
147
 
144
- matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
145
- if matches&.size == 2
148
+ if (matches = line.match(/^\s*pod ['|"](.*?)['|"](.*)/)) && matches.size == 3
146
149
  if matches[1].split("/").first == pod_name_to_switch
147
150
  case OPTIONS[:switch_mode]
148
151
  when "prebuilt"
@@ -159,6 +162,9 @@ module PodBuilder
159
162
  indentation = line.split("pod '").first
160
163
  rel_path = Pathname.new(development_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
161
164
  development_line = "#{indentation}pod '#{matches[1]}', :path => '#{rel_path}'\n"
165
+ if inhibit_warnings.include?(matches[1])
166
+ development_line = development_line.chomp("\n") + ", :inhibit_warnings => true\n"
167
+ end
162
168
  if line.include?("# pb<") && marker = line.split("# pb<").last
163
169
  development_line = development_line.chomp("\n") + " # pb<#{marker}"
164
170
  end
@@ -167,6 +173,9 @@ module PodBuilder
167
173
  next
168
174
  when "default"
169
175
  if default_line = default_entries[current_section]
176
+ if inhibit_warnings.include?(matches[1])
177
+ default_line = default_line.chomp("\n") + ", :inhibit_warnings => true\n"
178
+ end
170
179
  if line.include?("# pb<") && marker = line.split("# pb<").last
171
180
  default_line = default_line.chomp("\n") + " # pb<#{marker}"
172
181
  end
@@ -180,8 +189,6 @@ module PodBuilder
180
189
 
181
190
  lines.append(default_line)
182
191
  next
183
- elsif
184
- raise "\n\nLine for pod '#{matches[1]}' in section '#{current_section}' not found in PodBuilder's Podfile".red
185
192
  end
186
193
  else
187
194
  raise "\n\nUnsupported mode '#{OPTIONS[:switch_mode]}'".red
@@ -208,6 +215,26 @@ module PodBuilder
208
215
  end
209
216
 
210
217
  private
218
+
219
+ def self.inhibit_warnings_pods
220
+ ret = Set.new
221
+
222
+ podfile_path = PodBuilder::basepath("Podfile")
223
+ content = File.read(podfile_path)
224
+
225
+ content.each_line do |line|
226
+ unless (name_match = line.match(/^\s*pod ['|"](.*?)['|"](.*)/)) && name_match.size == 3
227
+ next
228
+ end
229
+
230
+ if line.gsub(" ", "").include?(":inhibit_warnings=>true")
231
+ pod_name = name_match[1]
232
+ ret.add?(pod_name)
233
+ end
234
+ end
235
+
236
+ return ret
237
+ end
211
238
 
212
239
  def self.is_absolute_path(path)
213
240
  return ["~", "/"].any? { |t| path.start_with?(t) }
@@ -223,11 +250,28 @@ module PodBuilder
223
250
  if Pathname.new(path).relative?
224
251
  path = PodBuilder::basepath(path)
225
252
  end
226
- podspec = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
227
- podspec.select! { |x| !x.include?("/Local Podspecs/") }
228
- podspec.select! { |x| Dir.glob(File.join(File.dirname(x), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
229
- if podspec.count > 0
230
- podspec_path = Pathname.new(podspec.first).dirname.to_s
253
+ podspec_paths = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
254
+ podspec_paths.select! { |t| !t.include?("/Local Podspecs/") }
255
+ podspec_paths.select! { |t| Dir.glob(File.join(File.dirname(t), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
256
+ if podspec_paths.count > 1
257
+ if match_name_path = podspec_paths.find{ |t| File.basename(t, ".*") == podname }
258
+ podspec_path = Pathname.new(match_name_path).dirname.to_s
259
+ else
260
+ # Try parsing podspec
261
+ podspec_paths.each do |path|
262
+ content = File.read(path).gsub("\"", "'").gsub(" ", "")
263
+ if content.include?("name='#{podname}'")
264
+ podspec_path = path
265
+ end
266
+ unless podspec_path.nil?
267
+ break
268
+ end
269
+ end
270
+ end
271
+
272
+ break
273
+ elsif podspec_paths.count == 1
274
+ podspec_path = Pathname.new(podspec_paths.first).dirname.to_s
231
275
  break
232
276
  end
233
277
  end
@@ -75,6 +75,7 @@ module PodBuilder
75
75
  attr_accessor :build_xcframeworks_all
76
76
  attr_accessor :build_xcframeworks_include
77
77
  attr_accessor :build_xcframeworks_exclude
78
+ attr_accessor :pre_actions
78
79
  attr_accessor :post_actions
79
80
  end
80
81
 
@@ -113,6 +114,7 @@ module PodBuilder
113
114
  @build_xcframeworks_include = []
114
115
  @build_xcframeworks_exclude = []
115
116
 
117
+ @pre_actions = {}
116
118
  @post_actions = {}
117
119
 
118
120
  def self.check_inited
@@ -232,9 +234,14 @@ module PodBuilder
232
234
  Configuration.build_xcframeworks_exclude = value
233
235
  end
234
236
  end
237
+ if value = json["pre_actions"]
238
+ if value.is_a?(Hash)
239
+ Configuration.pre_actions = PodBuilder::Actions.load(value)
240
+ end
241
+ end
235
242
  if value = json["post_actions"]
236
243
  if value.is_a?(Hash)
237
- Configuration.post_actions = PodBuilder::PostActions.load(value)
244
+ Configuration.post_actions = PodBuilder::Actions.load(value)
238
245
  end
239
246
  end
240
247
 
@@ -12,7 +12,7 @@ require 'pod_builder/info'
12
12
  require 'pod_builder/configuration'
13
13
  require 'pod_builder/podspec'
14
14
  require 'pod_builder/licenses'
15
- require 'pod_builder/post_actions'
15
+ require 'pod_builder/actions'
16
16
 
17
17
  require 'core_ext/string'
18
18
 
@@ -140,12 +140,7 @@ module PodBuilder
140
140
  class Install
141
141
  # This method will generate prebuilt data by building from "/tmp/pod_builder/Podfile"
142
142
  def self.podfile(podfile_content, podfile_items, argument_pods, build_configuration)
143
- puts "Preparing build Podfile".yellow
144
-
145
- PodBuilder::safe_rm_rf(Configuration.build_path)
146
- FileUtils.mkdir_p(Configuration.build_path)
147
-
148
- init_git(Configuration.build_path) # this is needed to be able to call safe_rm_rf
143
+ puts "Preparing build Podfile".yellow
149
144
 
150
145
  podfile_content = copy_development_pods_source_code(podfile_content, podfile_items)
151
146
 
@@ -452,13 +447,7 @@ module PodBuilder
452
447
  File.write(gitattributes_path, expected_attributes, mode: 'a')
453
448
  end
454
449
  end
455
-
456
- def self.init_git(path)
457
- Dir.chdir(path) do
458
- system("git init")
459
- end
460
- end
461
-
450
+
462
451
  def self.build_folder_hash_in_prebuilt_info_file(podfile_item)
463
452
  prebuilt_info_path = PodBuilder::prebuiltpath(File.join(podfile_item.root_name, Configuration.prebuilt_info_filename))
464
453
 
@@ -591,8 +591,10 @@ module PodBuilder
591
591
  if matches&.size == 4 && !stripped_line.start_with?("#")
592
592
  path = matches[2]
593
593
 
594
+ file_exists = File.exist?(File.expand_path(path))
595
+
594
596
  is_absolute = ["~", "/"].include?(path[0])
595
- unless !is_absolute
597
+ if is_absolute || !file_exists
596
598
  podfile_lines.push(line)
597
599
  next
598
600
  end
@@ -142,6 +142,10 @@ module PodBuilder
142
142
  # @return [Bool] True if it's a pod that doesn't provide source code (is already shipped as a prebuilt pod)
143
143
  #
144
144
  attr_accessor :is_prebuilt
145
+
146
+ # @return [Bool] True if warnings should be inhibited for the pod
147
+ #
148
+ attr_accessor :inhibit_warnings
145
149
 
146
150
  # Initialize a new instance
147
151
  #
@@ -149,7 +153,7 @@ module PodBuilder
149
153
  #
150
154
  # @param [Hash] checkout_options
151
155
  #
152
- def initialize(spec, all_specs, checkout_options, supported_platforms)
156
+ def initialize(spec, all_specs, target_definitions, checkout_options, supported_platforms)
153
157
  @name = spec.name
154
158
  @root_name = spec.name.split("/").first
155
159
 
@@ -184,14 +188,26 @@ module PodBuilder
184
188
  @weak_frameworks = []
185
189
  @libraries = []
186
190
 
187
- @frameworks += extract_array(spec, "framework")
188
- @frameworks += extract_array(spec, "frameworks")
191
+ @frameworks += extract_array(spec.attributes_hash, "framework")
192
+ @frameworks += extract_array(spec.attributes_hash, "frameworks")
193
+ supported_platforms.each do |platform|
194
+ @frameworks += extract_array(spec.attributes_hash[platform], "framework")
195
+ @frameworks += extract_array(spec.attributes_hash[platform], "frameworks")
196
+ end
189
197
 
190
- @weak_frameworks += extract_array(spec, "weak_framework")
191
- @weak_frameworks += extract_array(spec, "weak_frameworks")
198
+ @weak_frameworks += extract_array(spec.attributes_hash, "weak_framework")
199
+ @weak_frameworks += extract_array(spec.attributes_hash, "weak_frameworks")
200
+ supported_platforms.each do |platform|
201
+ @weak_frameworks += extract_array(spec.attributes_hash[platform], "weak_framework")
202
+ @weak_frameworks += extract_array(spec.attributes_hash[platform], "weak_frameworks")
203
+ end
192
204
 
193
- @libraries += extract_array(spec, "library")
194
- @libraries += extract_array(spec, "libraries")
205
+ @libraries += extract_array(spec.attributes_hash, "library")
206
+ @libraries += extract_array(spec.attributes_hash, "libraries")
207
+ supported_platforms.each do |platform|
208
+ @libraries += extract_array(spec.attributes_hash[platform], "library")
209
+ @libraries += extract_array(spec.attributes_hash[platform], "libraries")
210
+ end
195
211
 
196
212
  @header_dir = spec.attributes_hash["header_dir"]
197
213
 
@@ -201,7 +217,7 @@ module PodBuilder
201
217
  @swift_version = spec.root.swift_version&.to_s
202
218
  @module_name = spec.root.module_name
203
219
 
204
- @default_subspecs = extract_array(spec, "default_subspecs")
220
+ @default_subspecs = extract_array(spec.attributes_hash, "default_subspecs")
205
221
  if default_subspec = spec.attributes_hash["default_subspec"]
206
222
  @default_subspecs.push(default_subspec)
207
223
  end
@@ -252,6 +268,7 @@ module PodBuilder
252
268
  @build_xcframework = build_as_xcframework
253
269
 
254
270
  @is_prebuilt = extract_is_prebuilt(spec, all_specs, checkout_options, supported_platforms)
271
+ @inhibit_warnings = target_definitions.any? { |t| t.inhibits_warnings_for_pod?(@name) }
255
272
  end
256
273
 
257
274
  def pod_specification(all_poditems, parent_spec = nil)
@@ -358,6 +375,10 @@ module PodBuilder
358
375
  def entry(include_version = true, include_pb_entry = true)
359
376
  e = "pod '#{@name}'"
360
377
 
378
+ if !is_prebuilt && inhibit_warnings
379
+ e += ", :inhibit_warnings => true"
380
+ end
381
+
361
382
  unless include_version
362
383
  return e
363
384
  end
@@ -466,7 +487,7 @@ module PodBuilder
466
487
  if default_subspecs != nil && default_subspecs.count > 0
467
488
  default_subspecs.each do |default_subspec_name|
468
489
  if (default_spec = all_specs.detect { |t| t.name == "#{root_name}/#{default_subspec_name}" })
469
- default_item = PodfileItem.new(default_spec, all_specs, checkout_options, supported_platforms)
490
+ default_item = PodfileItem.new(default_spec, all_specs, [], checkout_options, supported_platforms)
470
491
  if default_item.is_prebuilt
471
492
  return true
472
493
  end
@@ -516,8 +537,12 @@ module PodBuilder
516
537
  return items.flatten.uniq.compact
517
538
  end
518
539
 
519
- def extract_array(spec, key)
520
- element = spec.attributes_hash.fetch(key, [])
540
+ def extract_array(dict, key)
541
+ if dict.nil?
542
+ return []
543
+ end
544
+
545
+ element = dict.fetch(key, [])
521
546
  if element.instance_of? String
522
547
  element = [element]
523
548
  end
@@ -1,4 +1,3 @@
1
1
  module PodBuilder
2
- VERSION = "3.3.0"
2
+ VERSION = "4.1.0"
3
3
  end
4
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pod-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Camin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -181,6 +181,7 @@ files:
181
181
  - bin/setup
182
182
  - exe/pod_builder
183
183
  - lib/core_ext/string.rb
184
+ - lib/pod_builder/actions.rb
184
185
  - lib/pod_builder/analyze.rb
185
186
  - lib/pod_builder/analyzer.rb
186
187
  - lib/pod_builder/command.rb
@@ -208,7 +209,6 @@ files:
208
209
  - lib/pod_builder/podfile_cp.rb
209
210
  - lib/pod_builder/podfile_item.rb
210
211
  - lib/pod_builder/podspec.rb
211
- - lib/pod_builder/post_actions.rb
212
212
  - lib/pod_builder/rome/post_install.rb
213
213
  - lib/pod_builder/rome/pre_install.rb
214
214
  - lib/pod_builder/templates/build_podfile.template
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubygems_version: 3.0.3
237
+ rubygems_version: 3.1.2
238
238
  signing_key:
239
239
  specification_version: 4
240
240
  summary: Prebuild CocoaPods pods