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 +7 -0
- data/lib/cocoapods-zjbinary/Integration.rb +415 -0
- data/lib/cocoapods-zjbinary/Main.rb +262 -0
- data/lib/cocoapods-zjbinary/Prebuild.rb +308 -0
- data/lib/cocoapods-zjbinary/Reference/reference_source_code.rb +90 -0
- data/lib/cocoapods-zjbinary/command/zjbinary.rb +44 -0
- data/lib/cocoapods-zjbinary/command.rb +1 -0
- data/lib/cocoapods-zjbinary/gem_version.rb +3 -0
- data/lib/cocoapods-zjbinary/helper/feature_switches.rb +96 -0
- data/lib/cocoapods-zjbinary/helper/names.rb +78 -0
- data/lib/cocoapods-zjbinary/helper/passer.rb +45 -0
- data/lib/cocoapods-zjbinary/helper/podfile_options.rb +129 -0
- data/lib/cocoapods-zjbinary/helper/prebuild_sandbox.rb +139 -0
- data/lib/cocoapods-zjbinary/helper/target_checker.rb +49 -0
- data/lib/cocoapods-zjbinary/rome/build_framework.rb +280 -0
- data/lib/cocoapods-zjbinary/tool/tool.rb +12 -0
- data/lib/cocoapods-zjbinary.rb +1 -0
- data/lib/cocoapods_plugin.rb +4 -0
- metadata +60 -0
@@ -0,0 +1,308 @@
|
|
1
|
+
require_relative 'rome/build_framework'
|
2
|
+
require_relative 'helper/passer'
|
3
|
+
require_relative 'helper/target_checker'
|
4
|
+
require_relative 'gem_version'
|
5
|
+
|
6
|
+
# patch prebuild ability
|
7
|
+
module Pod
|
8
|
+
class Installer
|
9
|
+
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def local_manifest
|
14
|
+
if not @local_manifest_inited
|
15
|
+
@local_manifest_inited = true
|
16
|
+
raise "This method should be call before generate project" unless self.analysis_result == nil
|
17
|
+
@local_manifest = self.sandbox.manifest
|
18
|
+
end
|
19
|
+
@local_manifest
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Analyzer::SpecsState]
|
23
|
+
def prebuild_pods_changes
|
24
|
+
return nil if local_manifest.nil?
|
25
|
+
if @prebuild_pods_changes.nil?
|
26
|
+
changes = local_manifest.detect_changes_with_podfile(podfile)
|
27
|
+
@prebuild_pods_changes = Analyzer::SpecsState.new(changes)
|
28
|
+
# save the chagnes info for later stage
|
29
|
+
Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
|
30
|
+
end
|
31
|
+
@prebuild_pods_changes
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
public
|
36
|
+
|
37
|
+
# check if need to prebuild
|
38
|
+
def have_exact_prebuild_cache?
|
39
|
+
# check if need build frameworks
|
40
|
+
return false if local_manifest == nil
|
41
|
+
|
42
|
+
changes = prebuild_pods_changes
|
43
|
+
added = changes.added
|
44
|
+
changed = changes.changed
|
45
|
+
unchanged = changes.unchanged
|
46
|
+
deleted = changes.deleted
|
47
|
+
|
48
|
+
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
49
|
+
missing = unchanged.select do |pod_name|
|
50
|
+
not exsited_framework_pod_names.include?(pod_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
needed = (added + changed + deleted + missing)
|
54
|
+
return needed.empty?
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# The install method when have completed cache
|
59
|
+
def install_when_cache_hit!
|
60
|
+
# just print log
|
61
|
+
self.sandbox.exsited_framework_target_names.each do |name|
|
62
|
+
UI.puts "Using #{name}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Build the needed framework files
|
67
|
+
def prebuild_frameworks!
|
68
|
+
# build options
|
69
|
+
sandbox_path = sandbox.root
|
70
|
+
existed_framework_folder = sandbox.generate_framework_path
|
71
|
+
bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
|
72
|
+
use_static_framework = Pod::Podfile::DSL.static_binary
|
73
|
+
targets = []
|
74
|
+
|
75
|
+
if local_manifest != nil
|
76
|
+
changes = prebuild_pods_changes
|
77
|
+
added = changes.added
|
78
|
+
changed = changes.changed
|
79
|
+
unchanged = changes.unchanged
|
80
|
+
deleted = changes.deleted
|
81
|
+
|
82
|
+
existed_framework_folder.mkdir unless existed_framework_folder.exist?
|
83
|
+
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
84
|
+
|
85
|
+
# additions
|
86
|
+
missing = unchanged.select do |pod_name|
|
87
|
+
not exsited_framework_pod_names.include?(pod_name)
|
88
|
+
end
|
89
|
+
root_names_to_update = (added + changed + missing).uniq
|
90
|
+
# 生成预编译target
|
91
|
+
cache = []
|
92
|
+
targets = root_names_to_update.map do |pod_name|
|
93
|
+
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
|
94
|
+
if tars.nil?
|
95
|
+
tars = []
|
96
|
+
end
|
97
|
+
tars
|
98
|
+
end.flatten
|
99
|
+
|
100
|
+
# 添加依赖
|
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
|
105
|
+
targets = (targets + dependency_targets).uniq
|
106
|
+
else
|
107
|
+
targets = self.pod_targets
|
108
|
+
end
|
109
|
+
|
110
|
+
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
|
111
|
+
|
112
|
+
|
113
|
+
# build!
|
114
|
+
if Pod.is_use_framework
|
115
|
+
Pod::UI.puts "Prebuild frameworks (total #{targets.count}) binary_version:#{CocoapodsZjBinary::VERSION}"
|
116
|
+
else
|
117
|
+
Pod::UI.puts "Prebuild library (total #{targets.count}) binary_version:#{CocoapodsZjBinary::VERSION}"
|
118
|
+
end
|
119
|
+
|
120
|
+
Pod::Prebuild.remove_build_dir(sandbox_path)
|
121
|
+
targets.each do |target|
|
122
|
+
#linpeng edit + target.version
|
123
|
+
@sandbox_framework_folder_path_for_target_name = sandbox.framework_folder_path_for_target_name(target.name)
|
124
|
+
output_path = @sandbox_framework_folder_path_for_target_name
|
125
|
+
output_path.rmtree if output_path.exist?
|
126
|
+
if !target.should_build?
|
127
|
+
UI.puts "Prebuilding #{target.label}"
|
128
|
+
next
|
129
|
+
end
|
130
|
+
output_path.mkpath unless output_path.exist?
|
131
|
+
|
132
|
+
use_only_device_arch = Pod::Podfile::DSL.use_only_device_arch
|
133
|
+
#local cache
|
134
|
+
local_cache_path_root = Pod::Podfile::DSL.local_binary_cache_path
|
135
|
+
is_static_binary = Pod::Podfile::DSL.static_binary
|
136
|
+
type_frameworks_dir = is_static_binary ? "static" : "dynamic"
|
137
|
+
type_binary_dir = Pod.is_use_framework ? "framework" : "library"
|
138
|
+
|
139
|
+
#还未开发完
|
140
|
+
arch_path = use_only_device_arch ? "device_arch":"all_arch"
|
141
|
+
|
142
|
+
use_default_cache_path = Pod::Podfile::DSL.default_desktop_cache_path
|
143
|
+
if use_default_cache_path
|
144
|
+
path_names = output_path.to_s.split('/')
|
145
|
+
user_name = path_names[2]
|
146
|
+
local_cache_path_root = '/Users/' + user_name + '/Desktop/podCache'
|
147
|
+
end
|
148
|
+
is_has_local_cache = local_cache_path_root != nil
|
149
|
+
if not is_has_local_cache
|
150
|
+
#开始使用XcodeBuild进行编译静态库
|
151
|
+
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
|
152
|
+
else
|
153
|
+
targetFrameworkPath = local_cache_path_root + "/#{type_binary_dir}" +"/#{type_frameworks_dir}/#{target.name}/#{target.version}"
|
154
|
+
puts "[ZJBinary].本地缓存位置:#{local_cache_path_root}"
|
155
|
+
if Dir.exist?(targetFrameworkPath)
|
156
|
+
puts "[ZJBinary].本地缓存仓库获取:#{target.name}(#{target.version})#{type_frameworks_dir}-#{type_binary_dir}"
|
157
|
+
Dir.foreach(targetFrameworkPath) do |file|
|
158
|
+
if file !="." and file !=".."
|
159
|
+
f = targetFrameworkPath+"/"+file
|
160
|
+
FileUtils.cp_r(f, output_path, :remove_destination => false )
|
161
|
+
end
|
162
|
+
end
|
163
|
+
else
|
164
|
+
#开始使用XcodeBuild进行编译静态库
|
165
|
+
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
|
166
|
+
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# save the resource paths for later installing,动态库需要将frameworkwork中资源链接到pod上
|
172
|
+
# if target.static_framework? and !target.resource_paths.empty?
|
173
|
+
if !target.resource_paths.empty?
|
174
|
+
framework_path = output_path + target.framework_name
|
175
|
+
standard_sandbox_path = sandbox.standard_sanbox_path
|
176
|
+
|
177
|
+
resources = begin
|
178
|
+
if Pod::VERSION.start_with? "1.5"
|
179
|
+
target.resource_paths
|
180
|
+
else
|
181
|
+
# resource_paths is Hash{String=>Array<String>} on 1.6 and above
|
182
|
+
# (use AFNetworking to generate a demo data)
|
183
|
+
# https://github.com/leavez/cocoapods-binary/issues/50
|
184
|
+
target.resource_paths.values.flatten
|
185
|
+
end
|
186
|
+
end
|
187
|
+
raise "Wrong type: #{resources}" unless resources.kind_of? Array
|
188
|
+
path_objects = resources.map do |path|
|
189
|
+
object = Prebuild::Passer::ResourcePath.new
|
190
|
+
object.real_file_path = framework_path + File.basename(path)
|
191
|
+
# 静态库资源目录处理
|
192
|
+
if use_static_framework
|
193
|
+
object.real_file_path = path.gsub('${PODS_ROOT}', existed_framework_folder.to_s) if path.start_with? '${PODS_ROOT}'
|
194
|
+
object.real_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", existed_framework_folder.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
|
195
|
+
real_bundle_path = path.gsub('${PODS_ROOT}', sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
196
|
+
real_bundle_path = path.gsub('${PODS_CONFIGURATION_BUILD_DIR}', sandbox_path.to_s) if path.start_with? '${PODS_CONFIGURATION_BUILD_DIR}'
|
197
|
+
framework_bundle_path = real_bundle_path.gsub('_Prebuild','build/Release-iphoneos')
|
198
|
+
real_origin_path = Pathname.new(real_bundle_path)
|
199
|
+
real_file_path_obj = Pathname.new(object.real_file_path)
|
200
|
+
framework_bundle_path = Pathname.new(framework_bundle_path)
|
201
|
+
if real_origin_path.exist?
|
202
|
+
real_file_path_obj.parent.mkpath unless real_file_path_obj.parent.exist?
|
203
|
+
FileUtils.cp_r(real_origin_path, real_file_path_obj, :remove_destination => true)
|
204
|
+
else
|
205
|
+
if framework_bundle_path.exist?
|
206
|
+
real_file_path_obj.parent.mkpath unless real_file_path_obj.parent.exist?
|
207
|
+
FileUtils.cp_r(framework_bundle_path, real_file_path_obj, :remove_destination => true)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
212
|
+
object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
|
213
|
+
object
|
214
|
+
end
|
215
|
+
#save for cache
|
216
|
+
if is_has_local_cache
|
217
|
+
puts "[ZJBinary].本地缓存仓库新增:#{target.name}(#{target.version})#{type_frameworks_dir}-#{type_binary_dir}"
|
218
|
+
local_cache_path = targetFrameworkPath
|
219
|
+
FileUtils.makedirs(local_cache_path) unless File.exists?local_cache_path
|
220
|
+
c_output_path = output_path.to_s
|
221
|
+
if Dir.exist?(output_path)
|
222
|
+
Dir.foreach(output_path) do |file|
|
223
|
+
if file !="." and file !=".."
|
224
|
+
f = c_output_path+"/"+file
|
225
|
+
if !File.exist?(local_cache_path + "/" + file)
|
226
|
+
FileUtils.cp_r(f, local_cache_path, :remove_destination => false )
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
|
234
|
+
end
|
235
|
+
end
|
236
|
+
Pod::Prebuild.remove_build_dir(sandbox_path)
|
237
|
+
|
238
|
+
# copy vendored libraries and frameworks
|
239
|
+
targets.each do |target|
|
240
|
+
root_path = self.sandbox.pod_dir(target.name)
|
241
|
+
target_folder = sandbox.framework_folder_path_for_target_name(target.name)
|
242
|
+
|
243
|
+
# If target shouldn't build, we copy all the original files
|
244
|
+
# This is for target with only .a and .h files
|
245
|
+
if not target.should_build?
|
246
|
+
Prebuild::Passer.target_names_to_skip_integration_framework << target.name
|
247
|
+
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
|
248
|
+
next
|
249
|
+
end
|
250
|
+
|
251
|
+
target.spec_consumers.each do |consumer|
|
252
|
+
file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
|
253
|
+
lib_paths = file_accessor.vendored_frameworks || []
|
254
|
+
lib_paths += file_accessor.vendored_libraries
|
255
|
+
# @TODO dSYM files
|
256
|
+
lib_paths.each do |lib_path|
|
257
|
+
relative = lib_path.relative_path_from(root_path)
|
258
|
+
destination = target_folder + relative
|
259
|
+
destination.dirname.mkpath unless destination.dirname.exist?
|
260
|
+
FileUtils.cp_r(lib_path, destination, :remove_destination => true)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# save the pod_name for prebuild framwork in sandbox
|
266
|
+
targets.each do |target|
|
267
|
+
sandbox.save_pod_name_for_target target
|
268
|
+
end
|
269
|
+
|
270
|
+
# Remove useless files
|
271
|
+
# remove useless pods
|
272
|
+
all_needed_names = self.pod_targets.map(&:name).uniq
|
273
|
+
useless_target_names = sandbox.exsited_framework_target_names.reject do |name|
|
274
|
+
all_needed_names.include? name
|
275
|
+
end
|
276
|
+
useless_target_names.each do |name|
|
277
|
+
path = sandbox.framework_folder_path_for_target_name(name)
|
278
|
+
path.rmtree if path.exist?
|
279
|
+
end
|
280
|
+
|
281
|
+
if Podfile::DSL.dont_remove_source_code
|
282
|
+
# just remove the tmp files
|
283
|
+
path = sandbox.root + 'Manifest.lock.tmp'
|
284
|
+
path.rmtree if path.exist?
|
285
|
+
else
|
286
|
+
# only keep manifest.lock and framework folder in _Prebuild
|
287
|
+
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
|
288
|
+
to_delete_files = sandbox_path.children.select do |file|
|
289
|
+
filename = File.basename(file)
|
290
|
+
not to_remain_files.include?(filename)
|
291
|
+
end
|
292
|
+
to_delete_files.each do |path|
|
293
|
+
path.rmtree if path.exist?
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
# hook run_plugins_post_install_hooks 方法
|
299
|
+
install_hooks_method = instance_method(:run_plugins_post_install_hooks)
|
300
|
+
define_method(:run_plugins_post_install_hooks) do
|
301
|
+
install_hooks_method.bind(self).()
|
302
|
+
if Pod::is_prebuild_stage
|
303
|
+
#开始编译
|
304
|
+
self.prebuild_frameworks!
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
require 'xcodeproj'
|
3
|
+
require_relative '../helper/passer'
|
4
|
+
require_relative '../helper/prebuild_sandbox'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Installer
|
8
|
+
class PostInstallHooksContext
|
9
|
+
# 将源码引入主工程,方便源码调试
|
10
|
+
def refrence_source_code
|
11
|
+
sandbox_path = Pathname.new(sandbox.root)
|
12
|
+
pre_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(sandbox)
|
13
|
+
|
14
|
+
exsited_framework_pod_names = pre_sandbox.exsited_framework_pod_names || []
|
15
|
+
proj_path = sandbox_path + get_project_name("Pods")
|
16
|
+
project = Xcodeproj::Project.open(proj_path)
|
17
|
+
exsited_framework_pod_names.each do |target_name|
|
18
|
+
real_reference("_Prebuild/#{target_name}", project, target_name)
|
19
|
+
end
|
20
|
+
project.save;
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# 动态库dsym问题[CP] Copy dSYM
|
25
|
+
def adjust_dynamic_framework_dsym
|
26
|
+
sandbox_path = Pathname.new(sandbox.root).to_s
|
27
|
+
pre_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(sandbox)
|
28
|
+
exsited_framework_pod_names = pre_sandbox.exsited_framework_pod_names || []
|
29
|
+
|
30
|
+
exsited_framework_pod_names.each do |target_name|
|
31
|
+
input_xcfilelist = sandbox_path + "/Target Support Files/" + target_name + "/#{target_name}-copy-dsyms-input-files.xcfilelist"
|
32
|
+
output_xcfilelist = sandbox_path + "/Target Support Files/" + target_name + "/#{target_name}-copy-dsyms-output-files.xcfilelist"
|
33
|
+
remove_duplicated_bcsymbolmap_lines(input_xcfilelist)
|
34
|
+
remove_duplicated_bcsymbolmap_lines(output_xcfilelist)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#https://github.com/CocoaPods/CocoaPods/issues/10373
|
39
|
+
def remove_duplicated_bcsymbolmap_lines(path)
|
40
|
+
if File.exist?path
|
41
|
+
top_lines = []
|
42
|
+
bcsymbolmap_lines = []
|
43
|
+
for line in File.readlines(path).map { |line| line.strip }
|
44
|
+
if line.include? ".bcsymbolmap"
|
45
|
+
bcsymbolmap_lines.append(line)
|
46
|
+
else
|
47
|
+
#去重
|
48
|
+
if not top_lines.include?line
|
49
|
+
top_lines.append(line)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
final_lines = top_lines + bcsymbolmap_lines.uniq
|
55
|
+
File.open(path, "w+") do |f|
|
56
|
+
f.puts(final_lines)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
private
|
63
|
+
def get_project_name(tageter_name)
|
64
|
+
return "#{tageter_name}.xcodeproj"
|
65
|
+
end
|
66
|
+
|
67
|
+
def real_reference(file_path, project, target_name)
|
68
|
+
group = project.main_group.find_subpath(File.join("SourceCode", target_name), true)
|
69
|
+
group.set_source_tree('SOURCE_ROOT')
|
70
|
+
group.set_path(file_path)
|
71
|
+
add_files_to_group(group)
|
72
|
+
end
|
73
|
+
|
74
|
+
#添加文件链接
|
75
|
+
def add_files_to_group(group)
|
76
|
+
Dir.foreach(group.real_path) do |entry|
|
77
|
+
filePath = File.join(group.real_path, entry)
|
78
|
+
# 过滤目录和.DS_Store文件
|
79
|
+
if entry != ".DS_Store" && !filePath.to_s.end_with?(".meta") &&entry != "." &&entry != ".." then
|
80
|
+
# 向group中增加文件引用
|
81
|
+
group.new_reference(filePath)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pod
|
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.
|
19
|
+
#
|
20
|
+
class ZjBinary < Command
|
21
|
+
self.summary = 'Short description of cocoapods-zjbinary.'
|
22
|
+
|
23
|
+
self.description = <<-DESC
|
24
|
+
Longer description of cocoapods-zjbinary.
|
25
|
+
DESC
|
26
|
+
|
27
|
+
# self.arguments = 'NAME'
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@name = argv.shift_argument
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate!
|
35
|
+
super
|
36
|
+
help! 'A Pod name is required.' unless @name
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
UI.puts "Add your implementation for the cocoapods-zjbinary plugin in #{__FILE__}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-zjbinary/command/zjbinary'
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
require_relative 'prebuild_sandbox'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
|
6
|
+
# a flag that indicate stages
|
7
|
+
class_attr_accessor :is_prebuild_stage
|
8
|
+
|
9
|
+
class_attr_accessor :is_use_framework
|
10
|
+
# a switch for the `pod` DSL to make it only valid for ':xlbuild => true'
|
11
|
+
class Podfile
|
12
|
+
module DSL
|
13
|
+
|
14
|
+
@@enable_prebuild_patch = false
|
15
|
+
# when enable, `pod` function will skip all pods without 'prebuild => true'
|
16
|
+
def self.enable_prebuild_patch(value)
|
17
|
+
@@enable_prebuild_patch = value
|
18
|
+
end
|
19
|
+
|
20
|
+
# --- patch ---
|
21
|
+
old_method = instance_method(:pod)
|
22
|
+
|
23
|
+
define_method(:pod) do |name, *args|
|
24
|
+
if !@@enable_prebuild_patch
|
25
|
+
old_method.bind(self).(name, *args)
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
# patched content
|
30
|
+
should_prebuild = Pod::Podfile::DSL.prebuild_all
|
31
|
+
local = false
|
32
|
+
|
33
|
+
options = args.last
|
34
|
+
if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
|
35
|
+
should_prebuild = options[Pod::Prebuild.keyword]
|
36
|
+
local = (options[:path] != nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
if should_prebuild and (not local)
|
40
|
+
old_method.bind(self).(name, *args)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# a force disable option for integral
|
48
|
+
class Installer
|
49
|
+
def self.force_disable_integration(value)
|
50
|
+
@@force_disable_integration = value
|
51
|
+
end
|
52
|
+
|
53
|
+
old_method = instance_method(:integrate_user_project)
|
54
|
+
define_method(:integrate_user_project) do
|
55
|
+
if @@force_disable_integration
|
56
|
+
return
|
57
|
+
end
|
58
|
+
old_method.bind(self).()
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# a option to disable install complete message
|
63
|
+
class Installer
|
64
|
+
def self.disable_install_complete_message(value)
|
65
|
+
@@disable_install_complete_message = value
|
66
|
+
end
|
67
|
+
|
68
|
+
old_method = instance_method(:print_post_install_message)
|
69
|
+
define_method(:print_post_install_message) do
|
70
|
+
if @@disable_install_complete_message
|
71
|
+
return
|
72
|
+
end
|
73
|
+
old_method.bind(self).()
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# option to disable write lockfiles
|
78
|
+
class Config
|
79
|
+
|
80
|
+
@@force_disable_write_lockfile = false
|
81
|
+
def self.force_disable_write_lockfile(value)
|
82
|
+
@@force_disable_write_lockfile = value
|
83
|
+
end
|
84
|
+
|
85
|
+
old_method = instance_method(:lockfile_path)
|
86
|
+
define_method(:lockfile_path) do
|
87
|
+
if @@force_disable_write_lockfile
|
88
|
+
# As config is a singleton, sandbox_root refer to the standard sandbox.
|
89
|
+
return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + 'Manifest.lock.tmp'
|
90
|
+
else
|
91
|
+
return old_method.bind(self).()
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# ABOUT NAMES
|
2
|
+
#
|
3
|
+
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
|
4
|
+
# - root_spec.name (spec.root_name, targe.pod_name):
|
5
|
+
# aka "pod_name"
|
6
|
+
# the name we use in podfile. the concept.
|
7
|
+
#
|
8
|
+
# - target.name:
|
9
|
+
# aka "target_name"
|
10
|
+
# the name of the final target in xcode project. the final real thing.
|
11
|
+
#
|
12
|
+
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
|
13
|
+
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
|
14
|
+
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Tool to transform Pod_name to target efficiently
|
18
|
+
module Pod
|
19
|
+
def self.fast_get_targets_for_pod_name(pod_name, targets, cache)
|
20
|
+
pod_name_to_targets_hash = nil
|
21
|
+
if cache.empty?
|
22
|
+
pod_name_to_targets_hash = targets.reduce({}) do |sum, target|
|
23
|
+
array = sum[target.pod_name] || []
|
24
|
+
array << target
|
25
|
+
sum[target.pod_name] = array
|
26
|
+
sum
|
27
|
+
end
|
28
|
+
cache << pod_name_to_targets_hash
|
29
|
+
else
|
30
|
+
pod_name_to_targets_hash = cache.first
|
31
|
+
end
|
32
|
+
|
33
|
+
pod_name_to_targets_hash[pod_name] || []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# Target:
|
43
|
+
|
44
|
+
# def pod_name
|
45
|
+
# root_spec.name
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def name
|
49
|
+
# pod_name + #{scope_suffix}
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def product_module_name
|
53
|
+
# root_spec.module_name
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def framework_name
|
57
|
+
# "#{product_module_name}.framework"
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def product_name
|
61
|
+
# if requires_frameworks?
|
62
|
+
# framework_name
|
63
|
+
# else
|
64
|
+
# static_library_name
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
|
68
|
+
# def product_basename
|
69
|
+
# if requires_frameworks?
|
70
|
+
# product_module_name
|
71
|
+
# else
|
72
|
+
# label
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
|
76
|
+
# def framework_name
|
77
|
+
# "#{product_module_name}.framework"
|
78
|
+
# end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Prebuild
|
5
|
+
|
6
|
+
# Pass the data between the 2 steps
|
7
|
+
#
|
8
|
+
# At step 2, the normal pod install, it needs some info of the
|
9
|
+
# prebuilt step. So we store it here.
|
10
|
+
#
|
11
|
+
class Passer
|
12
|
+
|
13
|
+
# indicate the add/remove/update of prebuit pods
|
14
|
+
# @return [Analyzer::SpecsState]
|
15
|
+
#
|
16
|
+
class_attr_accessor :prebuild_pods_changes
|
17
|
+
class_attr_accessor :prebuild_pod_targets_changes
|
18
|
+
|
19
|
+
# represent the path of resurces to copy
|
20
|
+
class ResourcePath
|
21
|
+
attr_accessor :real_file_path
|
22
|
+
attr_accessor :target_file_path
|
23
|
+
end
|
24
|
+
# Save the resoures for static framework, and used when installing the prebuild framework
|
25
|
+
# static framework needs copy the resurces mannully
|
26
|
+
#
|
27
|
+
# @return [Hash<String, [Passer::ResourcePath]>]
|
28
|
+
class_attr_accessor :resources_to_copy_for_static_framework
|
29
|
+
self.resources_to_copy_for_static_framework = {}
|
30
|
+
|
31
|
+
# Some pod won't be build in prebuild stage even if it have `binary=>true`.
|
32
|
+
# The targets of this pods have `oshould_build? == true`.
|
33
|
+
# We should skip integration (patch spec) for this pods
|
34
|
+
#
|
35
|
+
# @return [Array<String>]
|
36
|
+
class_attr_accessor :target_names_to_skip_integration_framework
|
37
|
+
self.target_names_to_skip_integration_framework = []
|
38
|
+
|
39
|
+
# 编译过的framework pod 名称
|
40
|
+
class_attr_accessor :static_build_pod_names
|
41
|
+
self.static_build_pod_names = []
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|