pod-builder 0.1.8.beta → 0.2.0

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.
@@ -1,41 +1,70 @@
1
1
  module PodBuilder
2
2
  class Podspec
3
- def self.generate
4
- buildable_items = Podfile.podfile_items_at(PodBuilder::basepath("Podfile"))
5
- buildable_items.select! { |x| x.is_prebuilt == false }
3
+ class PodspecItem
4
+ attr_accessor :name
5
+ attr_accessor :module_name
6
+ attr_accessor :vendored_frameworks
7
+ attr_accessor :frameworks
8
+ attr_accessor :weak_frameworks
9
+ attr_accessor :libraries
10
+ attr_accessor :resources
11
+ attr_accessor :exclude_files
12
+ attr_accessor :xcconfig
6
13
 
7
- podspecs = []
8
- buildable_items.each do |pod|
9
- spec_exists = File.exist?(PodBuilder::basepath(vendored_spec_framework_path(pod)))
10
- subspec_exists = File.exist?(PodBuilder::basepath(vendored_subspec_framework_path(pod)))
11
-
12
- unless spec_exists || subspec_exists
13
- puts "Skipping #{pod.name}, not prebuilt".blue
14
- next
15
- end
14
+ def initialize
15
+ @name = ""
16
+ @module_name = ""
17
+ @vendored_frameworks = []
18
+ @frameworks = []
19
+ @weak_frameworks = []
20
+ @libraries = []
21
+ @resources = []
22
+ @exclude_files = []
23
+ @xcconfig = {}
24
+ end
25
+
26
+ def to_s
27
+ @name
28
+ end
29
+ end
30
+ private_constant :PodspecItem
31
+
32
+ def self.generate(analyzer)
33
+ puts "Generating PodBuilder's local podspec".yellow
34
+
35
+ buildable_items = Podfile.podfile_items_at(PodBuilder::basepath("Podfile")).sort_by { |x| x.name }
36
+
37
+ podspec_items = podspec_items_from(buildable_items)
16
38
 
17
- vendored_frameworks = [pod] + pod.dependencies(buildable_items)
39
+ platform = analyzer.result.targets.first.platform
40
+ generate_podspec_from(podspec_items, platform)
41
+ end
42
+
43
+ private
18
44
 
19
- static_vendored_frameworks = vendored_frameworks.select { |x| x.is_static }
20
- framework_paths = vendored_frameworks.map { |x| vendored_framework_path(x) }.compact
21
-
22
- podspec = " s.subspec '#{pod.podspec_name}' do |p|\n"
23
- podspec += " p.vendored_frameworks = '#{framework_paths.uniq.join("','")}'\n"
45
+ def self.generate_podspec_from(podspec_items, platform)
46
+ podspecs = []
47
+ podspec_items.each do |item|
48
+ vendored_frameworks = item.vendored_frameworks.map { |x| vendored_framework_path(x) }.compact.uniq
24
49
 
25
- podspec_resources = static_vendored_frameworks.map { |x| "#{vendored_framework_path(x)}/*.{nib,bundle,xcasset,strings,png,jpg,tif,tiff,otf,ttf,ttc,plist,json,caf,wav,p12,momd}" }
26
- if podspec_resources.count > 0
27
- podspec += " p.resources = '#{podspec_resources.uniq.join("','")}'\n"
50
+ podspec = " s.subspec '#{item.name.gsub("/", "_")}' do |p|\n"
51
+ podspec += " p.vendored_frameworks = '#{vendored_frameworks.join("','")}'\n"
52
+ if item.frameworks.count > 0
53
+ podspec += " p.frameworks = '#{item.frameworks.join("', '")}'\n"
28
54
  end
29
-
30
- podspec_exclude_files = static_vendored_frameworks.map { |x| "#{vendored_framework_path(x)}/Info.plist" }
31
- if podspec_exclude_files.count > 0
32
- podspec += " p.exclude_files = '#{podspec_exclude_files.uniq.join("','")}'\n"
55
+ if item.libraries.count > 0
56
+ podspec += " p.libraries = '#{item.libraries.join("', '")}'\n"
33
57
  end
34
-
35
- if pod.xcconfig.count > 0
36
- podspec += " p.xcconfig = #{pod.xcconfig.to_s.gsub("\"", "'")}\n"
58
+ if item.resources.count > 0
59
+ podspec += " p.resources = '#{item.resources.join("', '")}'\n"
37
60
  end
38
-
61
+ if item.resources.count > 0
62
+ podspec += " p.exclude_files = '#{item.exclude_files.join("', '")}'\n"
63
+ end
64
+ if item.xcconfig.keys.count > 0
65
+ podspec += " p.xcconfig = #{item.xcconfig.to_s}\n"
66
+ end
67
+
39
68
  podspec += " end"
40
69
 
41
70
  podspecs.push(podspec)
@@ -44,26 +73,82 @@ module PodBuilder
44
73
  cwd = File.dirname(File.expand_path(__FILE__))
45
74
  podspec_file = File.read("#{cwd}/templates/build_podspec.template")
46
75
  podspec_file.gsub!("%%%podspecs%%%", podspecs.join("\n\n"))
76
+
77
+ podspec_file.sub!("%%%platform_name%%%", platform.name.to_s)
78
+ podspec_file.sub!("%%%deployment_version%%%", platform.deployment_target.version)
47
79
 
48
80
  File.write(PodBuilder::basepath("PodBuilder.podspec"), podspec_file)
49
81
  end
50
-
51
- private
52
82
 
83
+ def self.podspec_items_from(buildable_items)
84
+ podspec_items = []
85
+
86
+ buildable_items.each do |pod|
87
+ spec_exists = File.exist?(PodBuilder::basepath(vendored_spec_framework_path(pod)))
88
+ subspec_exists = File.exist?(PodBuilder::basepath(vendored_subspec_framework_path(pod)))
89
+
90
+ unless spec_exists || subspec_exists
91
+ puts "Skipping #{pod.name}, not prebuilt".blue
92
+ next
93
+ end
94
+
95
+ pod_name = Configuration.subspecs_to_split.include?(pod.name) ? pod.name : pod.root_name
96
+ unless podspec_item = podspec_items.detect { |x| x.name == pod_name }
97
+ podspec_item = PodspecItem.new
98
+ podspec_items.push(podspec_item)
99
+ podspec_item.name = pod_name
100
+ podspec_item.module_name = pod.module_name
101
+ end
102
+
103
+ podspec_item.vendored_frameworks += [pod] + pod.dependencies(buildable_items)
104
+
105
+ podspec_item.frameworks = podspec_item.vendored_frameworks.map { |x| x.frameworks }.flatten.uniq.sort
106
+ podspec_item.weak_frameworks = podspec_item.vendored_frameworks.map { |x| x.weak_frameworks }.flatten.uniq.sort
107
+ podspec_item.libraries = podspec_item.vendored_frameworks.map { |x| x.libraries }.flatten.uniq.sort
108
+
109
+ static_vendored_frameworks = podspec_item.vendored_frameworks.select { |x| x.is_static }
110
+
111
+ podspec_item.resources = static_vendored_frameworks.map { |x| "#{vendored_framework_path(x)}/*.{nib,bundle,xcasset,strings,png,jpg,tif,tiff,otf,ttf,ttc,plist,json,caf,wav,p12,momd}" }.flatten.uniq
112
+ podspec_item.exclude_files = static_vendored_frameworks.map { |x| "#{vendored_framework_path(x)}/Info.plist" }.flatten.uniq
113
+
114
+ # Merge xcconfigs
115
+ if !pod.xcconfig.empty?
116
+ pod.xcconfig.each do |k, v|
117
+ unless v != "$(inherited)"
118
+ next
119
+ end
120
+ unless k == "OTHER_LDFLAGS"
121
+ next # For the time being limit to OTHER_LDFLAGS key
122
+ end
123
+
124
+ if podspec_values = podspec_item.xcconfig[k]
125
+ podspec_values_arr = podspec_values.split(" ")
126
+ podspec_values_arr.push(v)
127
+ v = podspec_values_arr.join(" ")
128
+ end
129
+
130
+ podspec_item.xcconfig[k] = v
131
+ end
132
+ end
133
+ end
134
+
135
+ return podspec_items
136
+ end
137
+
53
138
  def self.vendored_framework_path(pod)
54
139
  if File.exist?(PodBuilder::basepath(vendored_subspec_framework_path(pod)))
55
140
  return vendored_subspec_framework_path(pod)
56
141
  elsif File.exist?(PodBuilder::basepath(vendored_spec_framework_path(pod)))
57
142
  return vendored_spec_framework_path(pod)
58
143
  end
59
-
144
+
60
145
  return nil
61
146
  end
62
147
 
63
148
  def self.vendored_subspec_framework_path(pod)
64
149
  return "Rome/#{pod.prebuilt_rel_path}"
65
150
  end
66
-
151
+
67
152
  def self.vendored_spec_framework_path(pod)
68
153
  return "Rome/#{pod.module_name}.framework"
69
154
  end
@@ -48,7 +48,7 @@ plugin 'cocoapods-rome', { dsym: false, configuration: '%%%build_configuration%
48
48
  installer.pods_project.save
49
49
  }}
50
50
 
51
- platform :ios, '9.0'
51
+ platform :%%%platform_name%%%, '%%%deployment_version%%%'
52
52
 
53
53
  # Targets
54
54
 
@@ -57,7 +57,7 @@ target 'DummyTarget' do
57
57
  end
58
58
 
59
59
  pre_install do |installer|
60
- raise "\n🚨 Do not launch 'pod install' manually, use `pod_builder` instead!\n" if !File.exist?('pod_builder.lock')
60
+ raise "\n\n🚨 Do not launch 'pod install' manually, use `pod_builder` instead!\n" if !File.exist?('pod_builder.lock')
61
61
 
62
62
  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
63
63
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.author = { "Tomas Camin" => "tomas.camin@schibsted.com" }
13
13
  s.source = { :git => "https://www.subito.it", :tag => s.version.to_s }
14
14
 
15
- s.platform = :ios, '9.0'
15
+ s.platform = :%%%platform_name%%%, '%%%deployment_version%%%'
16
16
  s.requires_arc = true
17
17
 
18
18
  %%%podspecs%%%
@@ -1,4 +1,4 @@
1
1
  module PodBuilder
2
- VERSION = "0.1.8.beta"
2
+ VERSION = "0.2.0"
3
3
  end
4
4
 
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_runtime_dependency 'xcodeproj'
30
30
  spec.add_runtime_dependency 'colored'
31
+ spec.add_runtime_dependency 'highline'
31
32
  spec.add_runtime_dependency 'cocoapods', '~> 1.0'
32
33
  spec.add_runtime_dependency 'cocoapods-core', '~> 1.0'
33
34
  spec.add_runtime_dependency 'cocoapods-rome', '~> 1.0'
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: 0.1.8.beta
4
+ version: 0.2.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: 2018-08-27 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: highline
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: cocoapods
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +237,7 @@ files:
223
237
  - bin/console
224
238
  - bin/setup
225
239
  - exe/pod_builder
240
+ - lib/core_ext/string.rb
226
241
  - lib/pod_builder/analyze.rb
227
242
  - lib/pod_builder/cocoapods/analyzer.rb
228
243
  - lib/pod_builder/cocoapods/specification.rb
@@ -231,11 +246,14 @@ files:
231
246
  - lib/pod_builder/command/build_all.rb
232
247
  - lib/pod_builder/command/clean.rb
233
248
  - lib/pod_builder/command/deintegrate.rb
249
+ - lib/pod_builder/command/generate_lfs.rb
234
250
  - lib/pod_builder/command/generate_podspec.rb
235
251
  - lib/pod_builder/command/init.rb
236
252
  - lib/pod_builder/command/install_sources.rb
237
253
  - lib/pod_builder/command/none.rb
238
254
  - lib/pod_builder/command/restore_all.rb
255
+ - lib/pod_builder/command/switch.rb
256
+ - lib/pod_builder/command/synch_podfile.rb
239
257
  - lib/pod_builder/configuration.rb
240
258
  - lib/pod_builder/core.rb
241
259
  - lib/pod_builder/install.rb
@@ -262,9 +280,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
280
  version: '0'
263
281
  required_rubygems_version: !ruby/object:Gem::Requirement
264
282
  requirements:
265
- - - ">"
283
+ - - ">="
266
284
  - !ruby/object:Gem::Version
267
- version: 1.3.1
285
+ version: '0'
268
286
  requirements: []
269
287
  rubyforge_project:
270
288
  rubygems_version: 2.7.3