cocoapods-ppbuild 0.0.3 → 1.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.
- checksums.yaml +4 -4
- data/lib/cocoapods-ppbuild/Integration.rb +167 -111
- data/lib/cocoapods-ppbuild/Main.rb +8 -3
- data/lib/cocoapods-ppbuild/Prebuild.rb +15 -17
- data/lib/cocoapods-ppbuild/command/ppbuild.rb +25 -197
- data/lib/cocoapods-ppbuild/gem_version.rb +1 -1
- data/lib/cocoapods-ppbuild/helper/passer.rb +1 -1
- data/lib/cocoapods-ppbuild/helper/podfile_options.rb +4 -3
- data/lib/cocoapods-ppbuild/helper/prebuild_sandbox.rb +28 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4d8400efa95565f34739f086c1c7a65b260f5b34df388e03633d8f5a2216c63
|
4
|
+
data.tar.gz: 740423aaa87dee1df082830b910469fb77b2af8b8ff1f294a6c2ff52559b0375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e16e6f0a08d29705ff44917b46d449199f7a8cb0dcbfe2fc660019828e9cad7bc3981a9dd6513e18f016b195f4c49f8a417d55ebac99c0ff6d369abef10cf7e
|
7
|
+
data.tar.gz: 4109f534f1848b4147e94aa03406f5e9a8e1ec2395c8210cbcd2f62a1b3c42c0da9d5dca047a7b097057f97451bd8a8424ec65204e6d54c64ed0bec5c0a43731
|
@@ -61,7 +61,6 @@ module Pod
|
|
61
61
|
end
|
62
62
|
|
63
63
|
target_names.each do |name|
|
64
|
-
|
65
64
|
# symbol link copy all substructure
|
66
65
|
real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
|
67
66
|
|
@@ -79,6 +78,7 @@ module Pod
|
|
79
78
|
|
80
79
|
walk(real_file_folder) do |child|
|
81
80
|
source = child
|
81
|
+
|
82
82
|
# only make symlink to file and `.framework` folder
|
83
83
|
if child.directory?
|
84
84
|
if [".framework"].include? child.extname
|
@@ -87,6 +87,9 @@ module Pod
|
|
87
87
|
elsif [".dSYM"].include? child.extname
|
88
88
|
mirror_with_symlink(source, real_file_folder, target_folder, false)
|
89
89
|
next false # return false means don't go deeper
|
90
|
+
elsif [".bundle"].include? child.extname
|
91
|
+
mirror_with_symlink(source, real_file_folder, target_folder, false)
|
92
|
+
next false
|
90
93
|
else
|
91
94
|
next true
|
92
95
|
end
|
@@ -105,6 +108,8 @@ module Pod
|
|
105
108
|
if path_objects != nil
|
106
109
|
path_objects.each do |object|
|
107
110
|
if object.real_file_path != nil
|
111
|
+
real_path = Pathname.new(object.target_file_path)
|
112
|
+
real_path.rmtree if real_path.exist?
|
108
113
|
make_link(object.real_file_path, object.target_file_path, false)
|
109
114
|
end
|
110
115
|
end
|
@@ -129,15 +134,18 @@ module Pod
|
|
129
134
|
# Remove the old target files if prebuild frameworks changed
|
130
135
|
def remove_target_files_if_needed
|
131
136
|
|
132
|
-
changes = Pod::Prebuild::Passer.
|
137
|
+
changes = Pod::Prebuild::Passer.prebuild_pod_targets_changes
|
133
138
|
updated_names = []
|
134
139
|
if changes == nil
|
135
140
|
updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_pod_names
|
136
141
|
else
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
142
|
+
t_changes = Pod::Prebuild::Passer.prebuild_pods_changes
|
143
|
+
added = t_changes.added
|
144
|
+
changed = t_changes.changed
|
145
|
+
deleted = t_changes.deleted
|
146
|
+
updated_names = (added + changed + deleted).to_a
|
147
|
+
|
148
|
+
updated_names = (changes + updated_names).uniq
|
141
149
|
end
|
142
150
|
|
143
151
|
updated_names.each do |name|
|
@@ -154,88 +162,133 @@ module Pod
|
|
154
162
|
|
155
163
|
end
|
156
164
|
|
165
|
+
def save_change_targets!
|
166
|
+
sandbox_path = sandbox.root
|
167
|
+
existed_framework_folder = sandbox.generate_framework_path
|
168
|
+
if local_manifest != nil
|
169
|
+
changes = prebuild_pods_changes
|
170
|
+
added = changes.added
|
171
|
+
changed = changes.changed
|
172
|
+
unchanged = changes.unchanged
|
173
|
+
deleted = changes.deleted.to_a
|
174
|
+
|
175
|
+
existed_framework_folder.mkdir unless existed_framework_folder.exist?
|
176
|
+
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
177
|
+
|
178
|
+
# additions
|
179
|
+
missing = unchanged.select do |pod_name|
|
180
|
+
not exsited_framework_pod_names.include?(pod_name)
|
181
|
+
end
|
182
|
+
|
183
|
+
# 保存有改变的target列表
|
184
|
+
root_names_to_update = (added + changed + missing).uniq
|
185
|
+
updates_target_names = (root_names_to_update + deleted).uniq
|
186
|
+
cache = []
|
187
|
+
updates_targets = []
|
188
|
+
updates_target_names.each do |pod_name|
|
189
|
+
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
|
190
|
+
if tars.nil?
|
191
|
+
tars = []
|
192
|
+
end
|
193
|
+
updates_targets = (updates_targets + tars).uniq
|
194
|
+
end
|
195
|
+
updates_dependency_targets = updates_targets.map {|t|
|
196
|
+
t.recursive_dependent_targets
|
197
|
+
}.flatten.uniq || []
|
198
|
+
dependency_names = updates_dependency_targets.map { |e| e.pod_name }
|
199
|
+
if Pod::Prebuild::Passer.prebuild_pod_targets_changes.nil?
|
200
|
+
Pod::Prebuild::Passer.prebuild_pod_targets_changes = (updates_target_names + dependency_names).uniq
|
201
|
+
else
|
202
|
+
Pod::Prebuild::Passer.prebuild_pod_targets_changes = (Pod::Prebuild::Passer.prebuild_pod_targets_changes + updates_target_names + dependency_names).uniq
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
157
206
|
|
158
207
|
# Modify specification to use only the prebuild framework after analyzing
|
159
208
|
old_method2 = instance_method(:resolve_dependencies)
|
160
209
|
define_method(:resolve_dependencies) do
|
210
|
+
if Pod::is_prebuild_stage
|
211
|
+
# call original
|
212
|
+
old_method2.bind(self).()
|
213
|
+
self.save_change_targets!
|
214
|
+
else
|
215
|
+
# Remove the old target files, else it will not notice file changes
|
216
|
+
self.remove_target_files_if_needed
|
217
|
+
# call original
|
218
|
+
old_method2.bind(self).()
|
219
|
+
# ...
|
220
|
+
# ...
|
221
|
+
# ...
|
222
|
+
# after finishing the very complex orginal function
|
223
|
+
|
224
|
+
# check the pods
|
225
|
+
# Although we have did it in prebuild stage, it's not sufficient.
|
226
|
+
# Same pod may appear in another target in form of source code.
|
227
|
+
# Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
|
228
|
+
self.validate_every_pod_only_have_one_form
|
161
229
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
# Same pod may appear in another target in form of source code.
|
175
|
-
# Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
|
176
|
-
self.validate_every_pod_only_have_one_form
|
177
|
-
|
178
|
-
|
179
|
-
# prepare
|
180
|
-
cache = []
|
181
|
-
|
182
|
-
def add_vendered_framework(spec, platform, added_framework_file_path)
|
183
|
-
if spec.attributes_hash[platform] == nil
|
184
|
-
spec.attributes_hash[platform] = {}
|
230
|
+
|
231
|
+
# prepare
|
232
|
+
cache = []
|
233
|
+
|
234
|
+
def add_vendered_framework(spec, platform, added_framework_file_path)
|
235
|
+
if spec.attributes_hash[platform] == nil
|
236
|
+
spec.attributes_hash[platform] = {}
|
237
|
+
end
|
238
|
+
vendored_frameworks = spec.attributes_hash[platform]["vendored_frameworks"] || []
|
239
|
+
vendored_frameworks = [vendored_frameworks] if vendored_frameworks.kind_of?(String)
|
240
|
+
vendored_frameworks += [added_framework_file_path]
|
241
|
+
spec.attributes_hash[platform]["vendored_frameworks"] = vendored_frameworks
|
185
242
|
end
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
spec.attributes_hash["source_files"] = []
|
193
|
-
["ios", "watchos", "tvos", "osx"].each do |plat|
|
194
|
-
if spec.attributes_hash[plat] != nil
|
195
|
-
spec.attributes_hash[plat]["source_files"] = []
|
243
|
+
def empty_source_files(spec)
|
244
|
+
spec.attributes_hash["source_files"] = []
|
245
|
+
["ios", "watchos", "tvos", "osx"].each do |plat|
|
246
|
+
if spec.attributes_hash[plat] != nil
|
247
|
+
spec.attributes_hash[plat]["source_files"] = []
|
248
|
+
end
|
196
249
|
end
|
197
250
|
end
|
198
|
-
end
|
199
251
|
|
200
252
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
253
|
+
specs = self.analysis_result.specifications
|
254
|
+
prebuilt_specs = (specs.select do |spec|
|
255
|
+
self.prebuild_pod_names.include? spec.root.name
|
256
|
+
end)
|
205
257
|
|
206
|
-
|
258
|
+
prebuilt_specs.each do |spec|
|
207
259
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
260
|
+
# Use the prebuild framworks as vendered frameworks
|
261
|
+
# get_corresponding_targets
|
262
|
+
targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
|
263
|
+
targets.each do |target|
|
264
|
+
# the framework_file_path rule is decided when `install_for_prebuild`,
|
265
|
+
# as to compitable with older version and be less wordy.
|
266
|
+
framework_file_path = target.framework_name
|
267
|
+
framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
|
268
|
+
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
|
269
|
+
end
|
270
|
+
# Clean the source files
|
271
|
+
# we just add the prebuilt framework to specific platform and set no source files
|
272
|
+
# for all platform, so it doesn't support the sence that 'a pod perbuild for one
|
273
|
+
# platform and not for another platform.'
|
274
|
+
empty_source_files(spec)
|
275
|
+
|
276
|
+
# to remove the resurce bundle target.
|
277
|
+
# When specify the "resource_bundles" in podspec, xcode will generate a bundle
|
278
|
+
# target after pod install. But the bundle have already built when the prebuit
|
279
|
+
# phase and saved in the framework folder. We will treat it as a normal resource
|
280
|
+
# file.
|
281
|
+
if spec.attributes_hash["resource_bundles"]
|
282
|
+
bundle_names = spec.attributes_hash["resource_bundles"].keys
|
283
|
+
spec.attributes_hash["resource_bundles"] = nil
|
284
|
+
spec.attributes_hash["resources"] ||= []
|
285
|
+
spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
|
286
|
+
end
|
235
287
|
|
236
|
-
|
237
|
-
|
288
|
+
# to avoid the warning of missing license
|
289
|
+
spec.attributes_hash["license"] = {}
|
238
290
|
|
291
|
+
end
|
239
292
|
end
|
240
293
|
|
241
294
|
end
|
@@ -244,23 +297,25 @@ module Pod
|
|
244
297
|
# Override the download step to skip download and prepare file in target folder
|
245
298
|
old_method = instance_method(:install_source_of_pod)
|
246
299
|
define_method(:install_source_of_pod) do |pod_name|
|
247
|
-
|
248
|
-
|
249
|
-
pod_installer = create_pod_installer(pod_name)
|
250
|
-
# \copy from original
|
251
|
-
|
252
|
-
if self.prebuild_pod_names.include? pod_name
|
253
|
-
pod_installer.install_for_prebuild!(self.sandbox)
|
300
|
+
if Pod::is_prebuild_stage
|
301
|
+
tmp = old_method.bind(self).(pod_name)
|
254
302
|
else
|
255
|
-
|
256
|
-
|
303
|
+
# copy from original
|
304
|
+
pod_installer = create_pod_installer(pod_name)
|
305
|
+
# \copy from original
|
306
|
+
|
307
|
+
if self.prebuild_pod_names.include? pod_name
|
308
|
+
pod_installer.install_for_prebuild!(self.sandbox)
|
309
|
+
else
|
310
|
+
pod_installer.install!
|
311
|
+
end
|
257
312
|
|
258
|
-
|
259
|
-
|
260
|
-
|
313
|
+
# copy from original
|
314
|
+
return @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
|
315
|
+
# \copy from original
|
316
|
+
end
|
261
317
|
end
|
262
318
|
|
263
|
-
|
264
319
|
end
|
265
320
|
end
|
266
321
|
|
@@ -273,33 +328,34 @@ end
|
|
273
328
|
module Pod
|
274
329
|
module Generator
|
275
330
|
class EmbedFrameworksScript
|
276
|
-
|
277
331
|
old_method = instance_method(:script)
|
278
332
|
define_method(:script) do
|
279
|
-
|
280
333
|
script = old_method.bind(self).()
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
echo $path;
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
334
|
+
if not Pod::is_prebuild_stage
|
335
|
+
patch = <<-SH.strip_heredoc
|
336
|
+
#!/bin/sh
|
337
|
+
|
338
|
+
# ---- this is added by cocoapods-ppbuild ---
|
339
|
+
# Readlink cannot handle relative symlink well, so we override it to a new one
|
340
|
+
# If the path isn't an absolute path, we add a realtive prefix.
|
341
|
+
old_read_link=`which readlink`
|
342
|
+
readlink () {
|
343
|
+
path=`$old_read_link "$1"`;
|
344
|
+
if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
|
345
|
+
echo $path;
|
346
|
+
else
|
347
|
+
echo "`dirname $1`/$path";
|
348
|
+
fi
|
349
|
+
}
|
350
|
+
# ---
|
351
|
+
SH
|
352
|
+
|
353
|
+
# patch the rsync for copy dSYM symlink
|
354
|
+
script = script.gsub "rsync --delete", "rsync --copy-links --delete"
|
355
|
+
|
356
|
+
script = patch + script
|
357
|
+
end
|
358
|
+
script
|
303
359
|
end
|
304
360
|
end
|
305
361
|
end
|
@@ -25,6 +25,11 @@ module Pod
|
|
25
25
|
DSL.dont_remove_source_code = true
|
26
26
|
end
|
27
27
|
|
28
|
+
# 设置是否保存源码,默认 true
|
29
|
+
def remove_source_code_for_prebuilt_frameworks!
|
30
|
+
DSL.dont_remove_source_code = false
|
31
|
+
end
|
32
|
+
|
28
33
|
# Enable bitcode for prebuilt frameworks
|
29
34
|
def enable_bitcode_for_prebuilt_frameworks!
|
30
35
|
DSL.bitcode_enabled = true
|
@@ -111,7 +116,7 @@ Pod::HooksManager.register('cocoapods-ppbuild', :pre_install) do |installer_cont
|
|
111
116
|
require_relative 'helper/prebuild_sandbox'
|
112
117
|
require_relative 'Prebuild'
|
113
118
|
|
114
|
-
Pod::UI.puts "火速编译中..."
|
119
|
+
# Pod::UI.puts "火速编译中..."
|
115
120
|
|
116
121
|
# Fetch original installer (which is running this pre-install hook) options,
|
117
122
|
# then pass them to our installer to perform update if needed
|
@@ -143,7 +148,8 @@ Pod::HooksManager.register('cocoapods-ppbuild', :pre_install) do |installer_cont
|
|
143
148
|
# install
|
144
149
|
lockfile = installer_context.lockfile
|
145
150
|
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
|
146
|
-
|
151
|
+
|
152
|
+
require_relative 'Integration'
|
147
153
|
if binary_installer.have_exact_prebuild_cache? && !update
|
148
154
|
binary_installer.install_when_cache_hit!
|
149
155
|
else
|
@@ -165,7 +171,6 @@ Pod::HooksManager.register('cocoapods-ppbuild', :pre_install) do |installer_cont
|
|
165
171
|
# install
|
166
172
|
Pod::UI.puts "\n"
|
167
173
|
Pod::UI.puts "🤖 Pod Install"
|
168
|
-
require_relative 'Integration'
|
169
174
|
# go on the normal install step ...
|
170
175
|
end
|
171
176
|
|
@@ -62,7 +62,6 @@ module Pod
|
|
62
62
|
UI.puts "Using #{name}"
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
65
|
|
67
66
|
# Build the needed framework files
|
68
67
|
def prebuild_frameworks!
|
@@ -87,22 +86,22 @@ module Pod
|
|
87
86
|
missing = unchanged.select do |pod_name|
|
88
87
|
not exsited_framework_pod_names.include?(pod_name)
|
89
88
|
end
|
90
|
-
|
91
|
-
|
92
|
-
root_names_to_update = (added + changed + missing)
|
93
|
-
|
94
|
-
# transform names to targets
|
89
|
+
root_names_to_update = (added + changed + missing).uniq
|
90
|
+
# 生成预编译target
|
95
91
|
cache = []
|
96
92
|
targets = root_names_to_update.map do |pod_name|
|
97
93
|
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
|
98
|
-
if tars.nil?
|
99
|
-
|
94
|
+
if tars.nil?
|
95
|
+
tars = []
|
100
96
|
end
|
101
97
|
tars
|
102
98
|
end.flatten
|
103
99
|
|
104
|
-
#
|
100
|
+
# 添加依赖
|
105
101
|
dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
|
102
|
+
dependency_targets = dependency_targets.select do |tar|
|
103
|
+
sandbox.existed_target_version_for_pod_name(tar.pod_name) != tar.version
|
104
|
+
end
|
106
105
|
targets = (targets + dependency_targets).uniq
|
107
106
|
else
|
108
107
|
targets = self.pod_targets
|
@@ -121,6 +120,7 @@ module Pod
|
|
121
120
|
end
|
122
121
|
|
123
122
|
output_path = sandbox.framework_folder_path_for_target_name(target.name)
|
123
|
+
output_path.rmtree if output_path.exist?
|
124
124
|
output_path.mkpath unless output_path.exist?
|
125
125
|
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
|
126
126
|
|
@@ -150,10 +150,10 @@ module Pod
|
|
150
150
|
real_bundle_path = path.gsub('${PODS_ROOT}', sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
151
151
|
real_bundle_path = path.gsub('${PODS_CONFIGURATION_BUILD_DIR}', sandbox_path.to_s) if path.start_with? '${PODS_CONFIGURATION_BUILD_DIR}'
|
152
152
|
real_origin_path = Pathname.new(real_bundle_path)
|
153
|
+
real_file_path_obj = Pathname.new(object.real_file_path)
|
153
154
|
if real_origin_path.exist?
|
154
|
-
|
155
|
-
|
156
|
-
FileUtils.cp_r(real_origin_path, temp_path, :remove_destination => true)
|
155
|
+
real_file_path_obj.parent.mkpath unless real_file_path_obj.parent.exist?
|
156
|
+
FileUtils.cp_r(real_origin_path, real_file_path_obj, :remove_destination => true)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
@@ -225,15 +225,13 @@ module Pod
|
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
|
-
#
|
229
|
-
|
228
|
+
# hook run_plugins_post_install_hooks 方法
|
229
|
+
install_hooks_method = instance_method(:run_plugins_post_install_hooks)
|
230
230
|
define_method(:run_plugins_post_install_hooks) do
|
231
|
-
|
231
|
+
install_hooks_method.bind(self).()
|
232
232
|
if Pod::is_prebuild_stage
|
233
233
|
self.prebuild_frameworks!
|
234
234
|
end
|
235
235
|
end
|
236
|
-
|
237
|
-
|
238
236
|
end
|
239
237
|
end
|
@@ -1,215 +1,43 @@
|
|
1
1
|
module Pod
|
2
2
|
class Command
|
3
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
4
|
+
# to the 'pod' command.
|
5
|
+
#
|
6
|
+
# You can also create subcommands of existing or new commands. Say you
|
7
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
8
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
9
|
+
# to change.
|
10
|
+
#
|
11
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
12
|
+
# the class to exist in the the Pod::Command::List namespace
|
13
|
+
# - change this class to extend from `List` instead of `Command`. This
|
14
|
+
# tells the plugin system that it is a subcommand of `list`.
|
15
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
16
|
+
#
|
17
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
18
|
+
# in the `plugins.json` file, once your plugin is released.
|
3
19
|
#
|
4
20
|
class Ppbuild < Command
|
5
|
-
self.summary = '
|
21
|
+
self.summary = 'Short description of cocoapods-Ppbuild.'
|
6
22
|
|
7
23
|
self.description = <<-DESC
|
8
|
-
|
9
|
-
在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
|
24
|
+
Longer description of cocoapods-Ppbuild.
|
10
25
|
DESC
|
11
26
|
|
12
|
-
self.arguments =
|
13
|
-
CLAide::Argument.new('NAME', false)
|
14
|
-
]
|
15
|
-
def self.options
|
16
|
-
[
|
17
|
-
['--all-clean', '删除所有已经下载的源码'],
|
18
|
-
['--clean', '删除所有指定下载的源码'],
|
19
|
-
['--list', '展示所有一级下载的源码以及其大小'],
|
20
|
-
['--source', '源码路径,本地路径,会去自动链接本地源码']
|
21
|
-
]
|
22
|
-
end
|
27
|
+
# self.arguments = 'NAME'
|
23
28
|
|
24
29
|
def initialize(argv)
|
25
|
-
@
|
26
|
-
@names = argv.arguments! unless argv.arguments.empty?
|
27
|
-
@list = argv.flag?('list', false )
|
28
|
-
@all_clean = argv.flag?('all-clean', false )
|
29
|
-
@clean = argv.flag?('clean', false )
|
30
|
-
@config = Pod::Config.instance
|
31
|
-
@analyzer = nil
|
32
|
-
@podfile_dependency_cache = Pod::Installer::Analyzer::PodfileDependencyCache.from_podfile(@config.podfile)
|
30
|
+
@name = argv.shift_argument
|
33
31
|
super
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
raise "podfile.lock,不存在,请先pod install/update" unless File.exist?(podfile_lock)
|
40
|
-
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock) )
|
41
|
-
|
42
|
-
if @list
|
43
|
-
list
|
44
|
-
elsif @clean
|
45
|
-
clean
|
46
|
-
elsif @all_clean
|
47
|
-
all_clean
|
48
|
-
elsif @names
|
49
|
-
add
|
50
|
-
end
|
51
|
-
|
52
|
-
if @list && @clean && @names
|
53
|
-
raise "请选择您要执行的命令。"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
#==========================begin add ==============
|
58
|
-
|
59
|
-
def add
|
60
|
-
if @names == nil
|
61
|
-
raise "请输入要调试组件名,多个组件名称用空格分隔"
|
62
|
-
end
|
63
|
-
@names.each do |name|
|
64
|
-
lib_file = get_lib_path(name)
|
65
|
-
unless File.exist?(lib_file)
|
66
|
-
raise "找不到 #{lib_file}"
|
67
|
-
end
|
68
|
-
UI.puts "#{lib_file}"
|
69
|
-
|
70
|
-
target_path = @codeSource || download_source(name)
|
71
|
-
|
72
|
-
link(lib_file,target_path,name)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
#下载源码到本地
|
77
|
-
def download_source(name)
|
78
|
-
target_path = File.join(source_root, name)
|
79
|
-
UI.puts target_path
|
80
|
-
FileUtils.rm_rf(target_path)
|
81
|
-
find_dependency = find_dependency(name)
|
82
|
-
spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
|
83
|
-
|
84
|
-
download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
|
85
|
-
Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
|
86
|
-
|
87
|
-
target_path
|
88
|
-
end
|
89
|
-
|
90
|
-
#找出依赖
|
91
|
-
def find_dependency (name)
|
92
|
-
find_dependency = nil
|
93
|
-
|
94
|
-
@config.podfile.dependencies.each do |dependency|
|
95
|
-
if dependency.root_name.downcase == name.downcase
|
96
|
-
find_dependency = dependency
|
97
|
-
break
|
98
|
-
end
|
99
|
-
end
|
100
|
-
if find_dependency.external_source.nil?
|
101
|
-
|
102
|
-
end
|
103
|
-
find_dependency
|
104
|
-
end
|
105
|
-
|
106
|
-
# 获取external_source 下的仓库
|
107
|
-
# @return spec
|
108
|
-
def fetch_external_source(dependency ,podfile , lockfile, sandbox,use_lockfile_options)
|
109
|
-
checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name)
|
110
|
-
source = if use_lockfile_options && lockfile && checkout_options
|
111
|
-
ExternalSources.from_params(checkout_options, dependency, podfile.defined_in_file, podfile.installation_options.clean?)
|
112
|
-
else
|
113
|
-
ExternalSources.from_dependency(dependency, podfile.defined_in_file, podfile.installation_options.clean?)
|
114
|
-
end
|
115
|
-
source.fetch(sandbox)
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
#==========================link begin ==============
|
120
|
-
|
121
|
-
#链接,.a文件位置, 源码目录
|
122
|
-
def link(lib_file,target_path,basename)
|
123
|
-
check(lib_file,dir,basename)
|
124
|
-
end
|
125
|
-
|
126
|
-
def check(lib_file,dir,basename)
|
127
|
-
file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
|
128
|
-
if File.exist?(file)
|
129
|
-
raise "#{file} 不存在 请检测代码源是否正确~"
|
130
|
-
end
|
131
|
-
UI.puts "link successfully!"
|
132
|
-
UI.puts "view linked source at path: #{dir}"
|
133
|
-
end
|
134
|
-
|
135
|
-
def get_lib_path(name)
|
136
|
-
dir = Pathname.new(File.join(Pathname.pwd,"Pods",name))
|
137
|
-
dir = get_framework_path(dir, name)
|
138
|
-
if !Dir.exist?(dir)
|
139
|
-
raise "找不到组件:#{name}, 请输入正确名称!! 者将组件名在git上提issues"
|
140
|
-
end
|
141
|
-
lib_path = File.join(dir, name)
|
142
|
-
lib_path
|
143
|
-
end
|
144
|
-
|
145
|
-
def get_framework_path(basepath, name)
|
146
|
-
dir = Pathname.new(File.join(basepath, "#{name}.framework"))
|
147
|
-
if !Dir.exist?(dir)
|
148
|
-
dir = dir.children.first
|
149
|
-
if Dir.exist?(dir)
|
150
|
-
return get_framework_path(dir, name)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
return dir
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
#源码地址
|
158
|
-
# def get_gitlib_iOS_path(name)
|
159
|
-
# "git@gitlab.xxx.com:iOS/#{name}.git"
|
160
|
-
# end
|
161
|
-
#要转换的地址,Github-iOS默认都是静态库
|
162
|
-
# def git_gitlib_iOS_path
|
163
|
-
# 'git@gitlab.xxx.com:Github-iOS/'
|
164
|
-
# end
|
165
|
-
|
166
|
-
|
167
|
-
#要转换的地址,Github-iOS默认都是静态库
|
168
|
-
# def http_gitlib_GitHub_iOS_path
|
169
|
-
# 'https://gitlab.xxx.com/Github-iOS/'
|
170
|
-
# end
|
171
|
-
|
172
|
-
#要转换的地址,iOS默认都是静态库
|
173
|
-
# def http_gitlib_iOS_path
|
174
|
-
# 'https://gitlab.xxx.com/iOS/'
|
175
|
-
# end
|
176
|
-
|
177
|
-
#==========================list begin ==============
|
178
|
-
|
179
|
-
def list
|
180
|
-
Dir.entries(source_root).each do |sub|
|
181
|
-
UI.puts "- #{sub}" unless sub.include?('.')
|
182
|
-
end
|
183
|
-
UI.puts "加载完成"
|
184
|
-
end
|
185
|
-
|
186
|
-
|
187
|
-
#==========================clean begin ==============
|
188
|
-
def all_clean
|
189
|
-
FileUtils.rm_rf(source_root) if File.directory?(source_root)
|
190
|
-
UI.puts "清理完成 #{source_root}"
|
191
|
-
end
|
192
|
-
|
193
|
-
def clean
|
194
|
-
raise "请输入要删除的组件库" if @names.nil?
|
195
|
-
@names.each do |name|
|
196
|
-
full_path = File.join(source_root,name)
|
197
|
-
if File.directory?(full_path)
|
198
|
-
FileUtils.rm_rf(full_path)
|
199
|
-
else
|
200
|
-
UI.puts "找不到 #{full_path}".yellow
|
201
|
-
end
|
202
|
-
end
|
203
|
-
UI.puts "清理完成 #{@names.to_s}"
|
34
|
+
def validate!
|
35
|
+
super
|
36
|
+
help! 'A Pod name is required.' unless @name
|
204
37
|
end
|
205
38
|
|
206
|
-
|
207
|
-
|
208
|
-
def source_root
|
209
|
-
dir = File.join(@config.cache_root,"Source")
|
210
|
-
FileUtils.mkdir_p(dir) unless File.exist? dir
|
211
|
-
UI.puts "缓存目录 #{dir}"
|
212
|
-
dir
|
39
|
+
def run
|
40
|
+
UI.puts "Add your implementation for the cocoapods-Ppbuild plugin in #{__FILE__}"
|
213
41
|
end
|
214
42
|
end
|
215
43
|
end
|
@@ -77,9 +77,10 @@ module Pod
|
|
77
77
|
|
78
78
|
# filter prebuild
|
79
79
|
prebuild_names = target_definition.prebuild_framework_pod_names
|
80
|
-
if not Podfile::DSL.prebuild_all
|
81
|
-
|
82
|
-
end
|
80
|
+
# if not Podfile::DSL.prebuild_all
|
81
|
+
# targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
|
82
|
+
# end
|
83
|
+
targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
|
83
84
|
dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
|
84
85
|
targets = (targets + dependency_targets).uniq
|
85
86
|
|
@@ -67,13 +67,20 @@ module Pod
|
|
67
67
|
exsited_framework_name_pairs.select {|pair| pair[1] == pod_name }.map { |pair| pair[0]}
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
def existed_target_version_for_pod_name(pod_name)
|
71
|
+
folder = framework_folder_path_for_target_name(pod_name)
|
72
|
+
return "" unless folder.exist?
|
73
|
+
flag_file_path = folder + "#{pod_name}.pod_name"
|
74
|
+
return "" unless flag_file_path.exist?
|
75
|
+
version = File.read(flag_file_path)
|
76
|
+
version
|
77
|
+
end
|
71
78
|
|
72
79
|
def save_pod_name_for_target(target)
|
73
80
|
folder = framework_folder_path_for_target_name(target.name)
|
74
81
|
return unless folder.exist?
|
75
82
|
flag_file_path = folder + "#{target.pod_name}.pod_name"
|
76
|
-
File.write(flag_file_path.to_s, "")
|
83
|
+
File.write(flag_file_path.to_s, "#{target.version}")
|
77
84
|
end
|
78
85
|
|
79
86
|
def real_bundle_path_for_pod(path)
|
@@ -107,3 +114,22 @@ module Pod
|
|
107
114
|
end
|
108
115
|
end
|
109
116
|
end
|
117
|
+
|
118
|
+
module Pod
|
119
|
+
class Sandbox
|
120
|
+
# hook 清除pod方法,得到删除的pod,通知主pod更新
|
121
|
+
clean_method = instance_method(:clean_pod)
|
122
|
+
define_method(:clean_pod) do |pod_name|
|
123
|
+
if Pod::is_prebuild_stage
|
124
|
+
if Pod::Prebuild::Passer.prebuild_pod_targets_changes.nil?
|
125
|
+
Pod::Prebuild::Passer.prebuild_pod_targets_changes = [pod_name]
|
126
|
+
else
|
127
|
+
Pod::Prebuild::Passer.prebuild_pod_targets_changes = (Pod::Prebuild::Passer.prebuild_pod_targets_changes + [pod_name]).uniq
|
128
|
+
end
|
129
|
+
end
|
130
|
+
clean_method.bind(self).(pod_name)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-ppbuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 彭懂
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
- lib/cocoapods-ppbuild/rome/build_framework.rb
|
62
62
|
- lib/cocoapods-ppbuild/tool/tool.rb
|
63
63
|
- lib/cocoapods_plugin.rb
|
64
|
-
homepage: https://github.com/
|
64
|
+
homepage: https://github.com/pdcodeunder/cocoapods-ppbuild.git
|
65
65
|
licenses:
|
66
66
|
- MIT
|
67
67
|
metadata: {}
|