cocoapods-zjbinary 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d14c1d995d7bd753cd9aee4490c199c86ff262710e3b30a76cb8845d03b6207d
4
+ data.tar.gz: d392d1633f289e8bb4c5572bc0eaee881f7135aced56d064ec3136717d7ff125
5
+ SHA512:
6
+ metadata.gz: 3997ba35810b6645907f0f5f2d19b42225d34a4d08732b7120ede6e95b2e9ba0182a10ee67a0e47f56a88921d8b2a2813fd2c15f102142976cff75b3d9a7f86b
7
+ data.tar.gz: 37737e31acd636ba8abcf982b7e71f0d4b3ed8e914691ccea44b5ed54898cf392c19933635d63803ff9f3312c83b60837965abacc52c0f52c6aa2f884d0ed0a8
@@ -0,0 +1,415 @@
1
+ require_relative 'helper/podfile_options'
2
+ require_relative 'helper/feature_switches'
3
+ require_relative 'helper/prebuild_sandbox'
4
+ require_relative 'helper/passer'
5
+ require_relative 'helper/names'
6
+ require_relative 'helper/target_checker'
7
+
8
+
9
+ # NOTE:
10
+ # This file will only be loaded on normal pod install step
11
+ # so there's no need to check is_prebuild_stage
12
+
13
+
14
+
15
+ # Provide a special "download" process for prebuilded pods.
16
+ #
17
+ # As the frameworks is already exsited in local folder. We
18
+ # just create a symlink to the original target folder.
19
+ #
20
+ module Pod
21
+ class Installer
22
+ class PodSourceInstaller
23
+
24
+ def install_for_prebuild!(standard_sanbox)
25
+ return if standard_sanbox.local? self.name
26
+
27
+ # make a symlink to target folder
28
+ prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
29
+ # if spec used in multiple platforms, it may return multiple paths
30
+ target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)
31
+
32
+ def walk(path, &action)
33
+ return unless path.exist?
34
+ path.children.each do |child|
35
+ result = action.call(child, &action)
36
+ if child.directory?
37
+ walk(child, &action) if result
38
+ end
39
+ end
40
+ end
41
+
42
+ def make_link(source, target, uselink)
43
+ source = Pathname.new(source)
44
+ target = Pathname.new(target)
45
+ target.parent.mkpath unless target.parent.exist?
46
+ relative_source = source.relative_path_from(target.parent)
47
+ if uselink
48
+ FileUtils.ln_sf(relative_source, target)
49
+ else
50
+ if File.directory?(source)
51
+ FileUtils.cp_r source, target, :remove_destination => true
52
+ else
53
+ FileUtils.cp source, target
54
+ end
55
+ if not target.exist?
56
+ raise "资源导入失败:#{target}"
57
+ end
58
+ end
59
+ end
60
+
61
+ def mirror_with_symlink(source, basefolder, target_folder, uselink)
62
+ target = target_folder + source.relative_path_from(basefolder)
63
+ make_link(source, target, uselink)
64
+ end
65
+
66
+ target_names.each do |name|
67
+ # symbol link copy all substructure
68
+ real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
69
+
70
+ # If have only one platform, just place int the root folder of this pod.
71
+ # If have multiple paths, we use a sperated folder to store different
72
+ # platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
73
+
74
+ target_folder = standard_sanbox.pod_dir(self.name)
75
+ if target_names.count > 1
76
+ target_folder += real_file_folder.basename
77
+ end
78
+ target_folder.rmtree if target_folder.exist?
79
+ target_folder.mkpath
80
+
81
+ walk(real_file_folder) do |child|
82
+ source = child
83
+
84
+ # only make symlink to file and `.framework` folder
85
+ if child.directory?
86
+ if [".framework"].include? child.extname
87
+ mirror_with_symlink(source, real_file_folder, target_folder, true)
88
+ next false # return false means don't go deeper
89
+ elsif [".dSYM"].include? child.extname
90
+ mirror_with_symlink(source, real_file_folder, target_folder, false)
91
+ next false # return false means don't go deeper
92
+ elsif [".bundle"].include? child.extname
93
+ mirror_with_symlink(source, real_file_folder, target_folder, false)
94
+ next false
95
+ else
96
+ next true
97
+ end
98
+ elsif child.file?
99
+ mirror_with_symlink(source, real_file_folder, target_folder, false)
100
+ next true
101
+ else
102
+ next true
103
+ end
104
+ end
105
+
106
+
107
+ # symbol link copy resource for static framework
108
+ hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
109
+ path_objects = hash[name]
110
+ if path_objects != nil
111
+ path_objects.each do |object|
112
+ if object.real_file_path != nil
113
+ real_path = Pathname.new(object.target_file_path)
114
+ real_path.rmtree if real_path.exist?
115
+ make_link(object.real_file_path, object.target_file_path, false)
116
+ end
117
+ end
118
+ end
119
+ end # of for each
120
+
121
+ end # of method
122
+
123
+ end
124
+ end
125
+ end
126
+
127
+
128
+ # Let cocoapods use the prebuild framework files in install process.
129
+ #
130
+ # the code only effect the second pod install process.
131
+ #
132
+ module Pod
133
+ class Installer
134
+
135
+
136
+ # Remove the old target files if prebuild frameworks changed
137
+ def remove_target_files_if_needed
138
+
139
+ changes = Pod::Prebuild::Passer.prebuild_pod_targets_changes
140
+ updated_names = []
141
+ if changes == nil
142
+ updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_pod_names
143
+ else
144
+ t_changes = Pod::Prebuild::Passer.prebuild_pods_changes
145
+ added = t_changes.added
146
+ changed = t_changes.changed
147
+ deleted = t_changes.deleted
148
+ updated_names = (added + changed + deleted).to_a
149
+
150
+ updated_names = (changes + updated_names).uniq
151
+ end
152
+
153
+ updated_names.each do |name|
154
+ root_name = Specification.root_name(name)
155
+ next if self.sandbox.local?(root_name)
156
+
157
+ # delete the cached files
158
+ target_path = self.sandbox.pod_dir(root_name)
159
+ target_path.rmtree if target_path.exist?
160
+
161
+ support_path = sandbox.target_support_files_dir(root_name)
162
+ support_path.rmtree if support_path.exist?
163
+ end
164
+
165
+ end
166
+
167
+ def save_change_targets!
168
+ sandbox_path = sandbox.root
169
+ existed_framework_folder = sandbox.generate_framework_path
170
+ if local_manifest != nil
171
+ changes = prebuild_pods_changes
172
+ added = changes.added
173
+ changed = changes.changed
174
+ unchanged = changes.unchanged
175
+ deleted = changes.deleted.to_a
176
+
177
+ existed_framework_folder.mkdir unless existed_framework_folder.exist?
178
+ exsited_framework_pod_names = sandbox.exsited_framework_pod_names
179
+
180
+ # additions
181
+ missing = unchanged.select do |pod_name|
182
+ not exsited_framework_pod_names.include?(pod_name)
183
+ end
184
+
185
+ # 保存有改变的target列表
186
+ root_names_to_update = (added + changed + missing).uniq
187
+ updates_target_names = (root_names_to_update + deleted).uniq
188
+ cache = []
189
+ updates_targets = []
190
+ updates_target_names.each do |pod_name|
191
+ tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
192
+ if tars.nil?
193
+ tars = []
194
+ end
195
+ updates_targets = (updates_targets + tars).uniq
196
+ end
197
+ updates_dependency_targets = updates_targets.map {|t|
198
+ t.recursive_dependent_targets
199
+ }.flatten.uniq || []
200
+ dependency_names = updates_dependency_targets.map { |e| e.pod_name }
201
+ if Pod::Prebuild::Passer.prebuild_pod_targets_changes.nil?
202
+ Pod::Prebuild::Passer.prebuild_pod_targets_changes = (updates_target_names + dependency_names).uniq
203
+ else
204
+ Pod::Prebuild::Passer.prebuild_pod_targets_changes = (Pod::Prebuild::Passer.prebuild_pod_targets_changes + updates_target_names + dependency_names).uniq
205
+ end
206
+ end
207
+ end
208
+
209
+ # Modify specification to use only the prebuild framework after analyzing
210
+ old_method2 = instance_method(:resolve_dependencies)
211
+ define_method(:resolve_dependencies) do
212
+ if Pod::is_prebuild_stage
213
+ # call original
214
+ old_method2.bind(self).()
215
+ self.save_change_targets!
216
+ else
217
+ # Remove the old target files, else it will not notice file changes
218
+ self.remove_target_files_if_needed
219
+ # call original
220
+ local_podspecs_path = self.sandbox.root + 'Local Podspecs'
221
+ if !File.exist?(local_podspecs_path)
222
+ FileUtils.mkdir_p(local_podspecs_path)
223
+ end
224
+ old_method2.bind(self).()
225
+ # ...
226
+ # ...
227
+ # ...
228
+ # after finishing the very complex orginal function
229
+
230
+ # check the pods
231
+ # Although we have did it in prebuild stage, it's not sufficient.
232
+ # Same pod may appear in another target in form of source code.
233
+ # Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
234
+ self.validate_every_pod_only_have_one_form
235
+
236
+
237
+ # prepare
238
+ cache = []
239
+
240
+ def add_vendered_framework(spec, platform, target, framework_file_path)
241
+ is_use_framework = Pod.is_use_framework
242
+ platform_map = spec.attributes_hash[platform]
243
+ if platform_map == nil
244
+ platform_map = {}
245
+ end
246
+ if is_use_framework
247
+ vendored_frameworks = platform_map["vendored_frameworks"] || []
248
+ vendored_frameworks = [vendored_frameworks] if vendored_frameworks.kind_of?(String)
249
+ vf = spec.attributes_hash["vendored_frameworks"] || []
250
+ vf = [vf] if vf.kind_of?(String)
251
+ vendored_frameworks += vf
252
+ vendored_frameworks += [framework_file_path]
253
+ spec.attributes_hash["vendored_frameworks"] = vendored_frameworks
254
+ if spec.attributes_hash[platform] != nil
255
+ spec.attributes_hash[platform].delete("vendored_frameworks")
256
+ end
257
+ else
258
+ vendored_libraries = platform_map["vendored_libraries"] || []
259
+ vendored_libraries = [vendored_libraries] if vendored_libraries.kind_of?(String)
260
+ vf = spec.attributes_hash["vendored_libraries"] || []
261
+ vf = [vf] if vf.kind_of?(String)
262
+ vendored_libraries += vf
263
+ library_name = "lib/lib#{target}.a"
264
+ vendored_libraries += [library_name]
265
+ spec.attributes_hash["vendored_libraries"] = vendored_libraries
266
+
267
+ if spec.attributes_hash[platform] != nil
268
+ spec.attributes_hash[platform]["vendored_libraries"] = vendored_libraries
269
+ end
270
+ end
271
+
272
+
273
+ end
274
+ def empty_source_files(spec,target)
275
+ is_use_framework = Pod.is_use_framework
276
+ if is_use_framework
277
+ spec.attributes_hash["source_files"] = []
278
+ ["ios", "watchos", "tvos", "osx"].each do |plat|
279
+ if spec.attributes_hash[plat] != nil
280
+ spec.attributes_hash[plat]["source_files"] = []
281
+ end
282
+ end
283
+ else
284
+ library_source_files = "include/*.h"
285
+ spec.attributes_hash["source_files"] = [library_source_files]
286
+ spec.attributes_hash["public_header_files"] = [library_source_files]
287
+ ["ios", "watchos", "tvos", "osx"].each do |plat|
288
+ if spec.attributes_hash[plat] != nil
289
+ spec.attributes_hash[plat]["source_files"] = [library_source_files]
290
+ spec.attributes_hash[plat]["public_header_files"] = [library_source_files]
291
+ end
292
+ end
293
+ end
294
+
295
+ end
296
+
297
+
298
+ specs = self.analysis_result.specifications
299
+ prebuilt_specs = (specs.select do |spec|
300
+ self.prebuild_pod_names.include? spec.root.name
301
+ end)
302
+
303
+ prebuilt_specs.each do |spec|
304
+
305
+ # Use the prebuild framworks as vendered frameworks
306
+ # get_corresponding_targets
307
+ targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
308
+ targets.each do |target|
309
+ # the framework_file_path rule is decided when `install_for_prebuild`,
310
+ # as to compitable with older version and be less word
311
+ framework_file_path = target.framework_name
312
+ framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
313
+ add_vendered_framework(spec, target.platform.name.to_s, target,framework_file_path)
314
+ empty_source_files(spec,target)
315
+ end
316
+ # Clean the source files
317
+ # we just add the prebuilt framework to specific platform and set no source files
318
+ # for all platform, so it doesn't support the sence that 'a pod perbuild for one
319
+ # platform and not for another platform.'
320
+
321
+
322
+ # to remove the resurce bundle target.
323
+ # When specify the "resource_bundles" in podspec, xcode will generate a bundle
324
+ # target after pod install. But the bundle have already built when the prebuit
325
+ # phase and saved in the framework folder. We will treat it as a normal resource
326
+ # file.
327
+ if spec.attributes_hash["resource_bundles"]
328
+ bundle_names = spec.attributes_hash["resource_bundles"].keys
329
+ spec.attributes_hash["resource_bundles"] = nil
330
+ spec.attributes_hash["resources"] ||= []
331
+ spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
332
+ elsif spec.attributes_hash['ios'] && spec.attributes_hash['ios']["resource_bundles"]
333
+ bundle_names = spec.attributes_hash['ios']["resource_bundles"].keys
334
+ spec.attributes_hash['ios']["resource_bundles"] = nil
335
+ spec.attributes_hash['ios']["resources"] ||= []
336
+ spec.attributes_hash['ios']["resources"] += bundle_names.map{|n| n+".bundle"}
337
+ end
338
+
339
+ # to avoid the warning of missing license
340
+ spec.attributes_hash["license"] = {}
341
+
342
+ end
343
+ end
344
+
345
+ end
346
+
347
+
348
+ # Override the download step to skip download and prepare file in target folder
349
+ # linpeng edit: hook集成安装源码的方法(源码下载完之后会将源码关联引用到Pod工程)
350
+ old_method = instance_method(:install_source_of_pod)
351
+ define_method(:install_source_of_pod) do |pod_name|
352
+ if Pod::is_prebuild_stage
353
+ tmp = old_method.bind(self).(pod_name)
354
+ else
355
+ # copy from original
356
+ pod_installer = create_pod_installer(pod_name)
357
+ # \copy from original
358
+
359
+ if self.prebuild_pod_names.include? pod_name
360
+ #linpeng edit: Pod::is_prebuild_stage 编译完成后 还会执行该步骤 该步骤会将_Prebuild/GenerateFramework/xxxx目录关联引用到Pod/xxxx目录里面 替换framework原本的源码
361
+ pod_installer.install_for_prebuild!(self.sandbox)
362
+ else
363
+ pod_installer.install!
364
+ end
365
+
366
+ # copy from original
367
+ return @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
368
+ # \copy from original
369
+ end
370
+ end
371
+
372
+ end
373
+ end
374
+
375
+ # A fix in embeded frameworks script.
376
+ #
377
+ # The framework file in pod target folder is a symblink. The EmbedFrameworksScript use `readlink`
378
+ # to read the read path. As the symlink is a relative symlink, readlink cannot handle it well. So
379
+ # we override the `readlink` to a fixed version.
380
+ #
381
+ module Pod
382
+ module Generator
383
+ class EmbedFrameworksScript
384
+ old_method = instance_method(:script)
385
+ define_method(:script) do
386
+ script = old_method.bind(self).()
387
+ if not Pod::is_prebuild_stage
388
+ patch = <<-SH.strip_heredoc
389
+ #!/bin/sh
390
+
391
+ # ---- this is added by cocoapods-xlbuild ---
392
+ # Readlink cannot handle relative symlink well, so we override it to a new one
393
+ # If the path isn't an absolute path, we add a realtive prefix.
394
+ old_read_link=`which readlink`
395
+ readlink () {
396
+ path=`$old_read_link "$1"`;
397
+ if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
398
+ echo $path;
399
+ else
400
+ echo "`dirname $1`/$path";
401
+ fi
402
+ }
403
+ # ---
404
+ SH
405
+
406
+ # patch the rsync for copy dSYM symlink
407
+ script = script.gsub "rsync --delete", "rsync --copy-links --delete"
408
+
409
+ script = patch + script
410
+ end
411
+ script
412
+ end
413
+ end
414
+ end
415
+ end
@@ -0,0 +1,262 @@
1
+ # encoding: UTF-8
2
+ require_relative 'helper/podfile_options'
3
+ require_relative 'tool/tool'
4
+
5
+ module Pod
6
+ class Podfile
7
+ module DSL
8
+ def set_local_binary_cache_path(path)
9
+ DSL.local_binary_cache_path = path
10
+ end
11
+
12
+ def set_default_desktop_cache_path!
13
+ DSL.default_desktop_cache_path = true
14
+ end
15
+
16
+ def use_only_device_arch!
17
+ DSL.use_only_device_arch = true
18
+ end
19
+
20
+ # Enable prebuiding for all pods
21
+ # it has a lower priority to other xlbuild settings
22
+ def use_dynamic_binary!
23
+ DSL.prebuild_all = true
24
+ DSL.static_binary = false
25
+ DSL.dont_remove_source_code = true
26
+ end
27
+ # 设置当前swift版本
28
+ def use_swift_version(version)
29
+ DSL.swift_version = version
30
+ end
31
+
32
+ # 设置是否使用静态库
33
+ def use_static_binary!
34
+ DSL.prebuild_all = true
35
+ DSL.static_binary = true
36
+ DSL.dont_remove_source_code = true
37
+ end
38
+
39
+ # 设置是否保存源码,默认 true
40
+ def remove_source_code_for_prebuilt_frameworks!
41
+ DSL.dont_remove_source_code = false
42
+ end
43
+
44
+ # Enable bitcode for prebuilt frameworks
45
+ def enable_bitcode_for_prebuilt_frameworks!
46
+ DSL.bitcode_enabled = true
47
+ end
48
+
49
+
50
+ # Add custom xcodebuild option to the prebuilding action
51
+ #
52
+ # You may use this for your special demands. For example: the default archs in dSYMs
53
+ # of prebuilt frameworks is 'arm64 armv7 x86_64', and no 'i386' for 32bit simulator.
54
+ # It may generate a warning when building for a 32bit simulator. You may add following
55
+ # to your podfile
56
+ #
57
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks :simulator => "ARCHS=$(ARCHS_STANDARD)" `
58
+ #
59
+ # Another example to disable the generating of dSYM file:
60
+ #
61
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks "DEBUG_INFORMATION_FORMAT=dwarf"`
62
+ #
63
+ #
64
+ # @param [String or Hash] options
65
+ #
66
+ # If is a String, it will apply for device and simulator. Use it just like in the commandline.
67
+ # If is a Hash, it should be like this: { :device => "XXXXX", :simulator => "XXXXX" }
68
+ #
69
+ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
70
+ if options.kind_of? Hash
71
+ DSL.custom_build_options = [ options[:device] ] unless options[:device].nil?
72
+ DSL.custom_build_options_simulator = [ options[:simulator] ] unless options[:simulator].nil?
73
+ elsif options.kind_of? String
74
+ DSL.custom_build_options = [options]
75
+ DSL.custom_build_options_simulator = [options]
76
+ else
77
+ raise "Wrong type."
78
+ end
79
+ end
80
+
81
+ private
82
+ class_attr_accessor :prebuild_all
83
+ prebuild_all = false
84
+
85
+ class_attr_accessor :swift_version
86
+ swift_version = "5.0" # swift版本默认5.0
87
+
88
+ class_attr_accessor :static_binary
89
+ static_binary = false
90
+
91
+ class_attr_accessor :bitcode_enabled
92
+ bitcode_enabled = false
93
+
94
+ class_attr_accessor :dont_remove_source_code
95
+ dont_remove_source_code = true
96
+
97
+ class_attr_accessor :custom_build_options
98
+ class_attr_accessor :custom_build_options_simulator
99
+
100
+ class_attr_accessor :local_binary_cache_path
101
+ class_attr_accessor :default_desktop_cache_path
102
+ class_attr_accessor :use_only_device_arch
103
+ local_binary_cache_path = nil
104
+
105
+ self.custom_build_options = []
106
+ self.custom_build_options_simulator = []
107
+ end
108
+ end
109
+
110
+ class Type
111
+ class_attr_accessor :pod_flag_file
112
+ @pod_flag_file = "build.xl"
113
+
114
+ def self.frameworks_type
115
+ is_static_binary = Pod::Podfile::DSL.static_binary
116
+ frameworks_type = is_static_binary ? "static" : "dynamic"
117
+ return frameworks_type
118
+ end
119
+
120
+ # 动静态库切换时候需要重新build(删除Pod目录重新构建)
121
+ def self.adjust_dynamic_static_change_pod(pod_root_path)
122
+ pod_type_path = pod_root_path+Pod::Type.pod_flag_file
123
+ if not File.exist?(pod_type_path)
124
+ FileUtils.remove_dir(pod_root_path)
125
+ else
126
+ frameworks_type = Pod::Type.frameworks_type
127
+ aFile = File.new(pod_type_path, "r")
128
+ if aFile
129
+ content = aFile.readlines[0]
130
+ if not frameworks_type.equal?(content)
131
+ FileUtils.remove_dir(pod_root_path)
132
+ end
133
+ end
134
+
135
+ end
136
+
137
+ end
138
+
139
+ #构建结束 标记当前打包的是动|静态库
140
+ def self.adjust_dynamic_static_change_pod_finish(pod_root_path)
141
+ # 标记状态
142
+ pod_type_path = pod_root_path+Pod::Type.pod_flag_file
143
+ if File.exist?(pod_type_path)
144
+ File.delete(pod_type_path)
145
+ end
146
+
147
+ frameworks_type = Pod::Type.frameworks_type
148
+ File.open(pod_type_path, "w+") { |f|
149
+ f.write(frameworks_type)
150
+ }
151
+ end
152
+ end
153
+ end
154
+
155
+ Pod::HooksManager.register('cocoapods-zjbinary', :pre_install) do |installer_context|
156
+ require_relative 'helper/feature_switches'
157
+ if Pod.is_prebuild_stage
158
+ next
159
+ end
160
+
161
+ # [Check Environment]
162
+ # check user_framework is on
163
+ podfile = installer_context.podfile
164
+ podfile.target_definition_list.each do |target_definition|
165
+ next if target_definition.prebuild_framework_pod_names.empty?
166
+ if target_definition.uses_frameworks?
167
+ Pod.is_use_framework = true
168
+ end
169
+ end
170
+
171
+ # -- step 1: prebuild framework ---
172
+ # Execute a sperated pod install, to generate targets for building framework,
173
+ # then compile them to framework files.
174
+ require_relative 'helper/prebuild_sandbox'
175
+
176
+ #Prebuild里面hooke了run_plugins_post_install_hooks方法
177
+ require_relative 'Prebuild'
178
+
179
+ # Pod::UI.puts "火速编译中..."
180
+
181
+ # Fetch original installer (which is running this pre-install hook) options,
182
+ # then pass them to our installer to perform update if needed
183
+ # Looks like this is the most appropriate way to figure out that something should be updated
184
+
185
+ update = nil
186
+ repo_update = nil
187
+
188
+ include ObjectSpace
189
+ ObjectSpace.each_object(Pod::Installer) { |installer|
190
+ update = installer.update
191
+ repo_update = installer.repo_update
192
+ }
193
+
194
+ # control features
195
+ Pod.is_prebuild_stage = true
196
+ Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
197
+ Pod::Installer.force_disable_integration true # don't integrate targets
198
+ Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
199
+ Pod::Installer.disable_install_complete_message true # disable install complete message
200
+
201
+ # make another custom sandbox
202
+ standard_sandbox = installer_context.sandbox
203
+ #linpeng edit: 修改Pod目录为 Pod/_Prebuild
204
+ prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
205
+
206
+ # 动|静态库(mach-o type)切换需要重新build(删除Pod目录)
207
+ pod_root_path = standard_sandbox.root
208
+ Pod::Type.adjust_dynamic_static_change_pod pod_root_path
209
+
210
+ # get the podfile for prebuild
211
+ prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
212
+
213
+ # install
214
+ lockfile = installer_context.lockfile
215
+ binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
216
+
217
+ require_relative 'Integration'
218
+ # Prebuild文件里面也扩展了 Pod::Installer类,同时新增扩展了have_exact_prebuild_cache?方法
219
+ if binary_installer.have_exact_prebuild_cache? && !update
220
+ binary_installer.install_when_cache_hit!
221
+ else
222
+ binary_installer.update = update
223
+ binary_installer.repo_update = repo_update
224
+ binary_installer.install!
225
+ end
226
+
227
+ ##备注上面的install是同步执行的,工程hook了 pod 的方法使得其会先下载源码然后进行xcodebuild编译 编译晚
228
+ #之后才会往下走
229
+
230
+ # reset the environment
231
+ Pod.is_prebuild_stage = false
232
+ Pod::Installer.force_disable_integration false
233
+ Pod::Podfile::DSL.enable_prebuild_patch false
234
+ Pod::Config.force_disable_write_lockfile false
235
+ Pod::Installer.disable_install_complete_message false
236
+ Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
237
+
238
+
239
+ # install完成标记mach-o type
240
+ Pod::Type.adjust_dynamic_static_change_pod_finish pod_root_path
241
+
242
+ # -- step 2: pod install ---
243
+ # install
244
+ Pod::UI.puts "🤖 Pod Install "
245
+ # go on the normal install step ...
246
+
247
+ end
248
+
249
+ ## pod 安装依赖的时候会执行install,install的时候会执行run_plugins_post_install_hooks(Prebuildhook了该方法)
250
+ # 只要有触发install方法就会触发如下的 ,pre hook的时候有重新创建一个Install( binary_installer.install!)因此会触发两次的post_install的hook
251
+ Pod::HooksManager.register('cocoapods-zjbinary', :post_install) do |installer_context|
252
+ if Pod::Podfile::DSL.static_binary
253
+ Pod::PrebuildSandbox.replace_tagert_copy_source_sh(installer_context)
254
+ end
255
+
256
+ if !Pod.is_prebuild_stage && Pod::Podfile::DSL.dont_remove_source_code
257
+ require_relative 'reference/reference_source_code'
258
+ installer_context.refrence_source_code
259
+ installer_context.adjust_dynamic_framework_dsym
260
+ end
261
+ end
262
+