cocoapods-meitu-bin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +56 -0
- data/lib/cocoapods-meitu-bin/command/bin/archive.rb +206 -0
- data/lib/cocoapods-meitu-bin/command/bin/auto.rb +212 -0
- data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +345 -0
- data/lib/cocoapods-meitu-bin/command/bin/header_files_specifications.rb +262 -0
- data/lib/cocoapods-meitu-bin/command/bin/init.rb +72 -0
- data/lib/cocoapods-meitu-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-meitu-bin/command/bin/lib/lint.rb +67 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/dependency.rb +89 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/spec_repo.rb +105 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/version.rb +68 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock.rb +36 -0
- data/lib/cocoapods-meitu-bin/command/bin/output_source.rb +146 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo/push.rb +88 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo/update.rb +42 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo.rb +14 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/add.rb +148 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/delete.rb +59 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/list.rb +46 -0
- data/lib/cocoapods-meitu-bin/command/bin/source.rb +30 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec/lint.rb +109 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec.rb +13 -0
- data/lib/cocoapods-meitu-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-meitu-bin/command/bin/upload.rb +175 -0
- data/lib/cocoapods-meitu-bin/command/bin.rb +69 -0
- data/lib/cocoapods-meitu-bin/command.rb +1 -0
- data/lib/cocoapods-meitu-bin/config/config.rb +149 -0
- data/lib/cocoapods-meitu-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-meitu-bin/config/config_builder.rb +216 -0
- data/lib/cocoapods-meitu-bin/gem_version.rb +9 -0
- data/lib/cocoapods-meitu-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/bin_helper.rb +97 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +434 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +140 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/zip_file_helper.rb +87 -0
- data/lib/cocoapods-meitu-bin/helpers/build_helper.rb +167 -0
- data/lib/cocoapods-meitu-bin/helpers/build_utils.rb +64 -0
- data/lib/cocoapods-meitu-bin/helpers/framework.rb +86 -0
- data/lib/cocoapods-meitu-bin/helpers/framework_builder.rb +551 -0
- data/lib/cocoapods-meitu-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-meitu-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +54 -0
- data/lib/cocoapods-meitu-bin/helpers/sources_helper.rb +35 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_files_helper.rb +80 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_source_creator.rb +304 -0
- data/lib/cocoapods-meitu-bin/helpers/upload_helper.rb +104 -0
- data/lib/cocoapods-meitu-bin/helpers.rb +5 -0
- data/lib/cocoapods-meitu-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-meitu-bin/native/analyzer.rb +109 -0
- data/lib/cocoapods-meitu-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-meitu-bin/native/gen.rb +79 -0
- data/lib/cocoapods-meitu-bin/native/installation_options.rb +28 -0
- data/lib/cocoapods-meitu-bin/native/installer.rb +259 -0
- data/lib/cocoapods-meitu-bin/native/linter.rb +26 -0
- data/lib/cocoapods-meitu-bin/native/lockfile.rb +85 -0
- data/lib/cocoapods-meitu-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-meitu-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-meitu-bin/native/pod_target_installer.rb +87 -0
- data/lib/cocoapods-meitu-bin/native/podfile.rb +99 -0
- data/lib/cocoapods-meitu-bin/native/podfile_env.rb +38 -0
- data/lib/cocoapods-meitu-bin/native/podfile_generator.rb +201 -0
- data/lib/cocoapods-meitu-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-meitu-bin/native/resolver.rb +299 -0
- data/lib/cocoapods-meitu-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-meitu-bin/native/source.rb +35 -0
- data/lib/cocoapods-meitu-bin/native/sources_manager.rb +21 -0
- data/lib/cocoapods-meitu-bin/native/specification.rb +31 -0
- data/lib/cocoapods-meitu-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-meitu-bin/native/validator.rb +40 -0
- data/lib/cocoapods-meitu-bin/native.rb +26 -0
- data/lib/cocoapods-meitu-bin/source_provider_hook.rb +68 -0
- data/lib/cocoapods-meitu-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +11 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +201 -0
@@ -0,0 +1,299 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'parallel'
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'cocoapods-meitu-bin/native/podfile'
|
6
|
+
require 'cocoapods-meitu-bin/native/sources_manager'
|
7
|
+
require 'cocoapods-meitu-bin/native/installation_options'
|
8
|
+
require 'cocoapods-meitu-bin/gem_version'
|
9
|
+
# require 'cocoapods-meitu-bin/command/bin/archive'
|
10
|
+
require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
|
11
|
+
require 'cocoapods-meitu-bin/config/config'
|
12
|
+
|
13
|
+
module Pod
|
14
|
+
class Resolver
|
15
|
+
if Pod.match_version?('~> 1.6')
|
16
|
+
# 其实不用到 resolver_specs_by_target 再改 spec
|
17
|
+
# 在这个方法里面,通过修改 dependency 的 source 应该也可以
|
18
|
+
# 就是有一点,如果改了之后,对应的 source 没有符合 dependency 的版本
|
19
|
+
# 分析依赖阶段就会报错了,没法像 resolver_specs_by_target 一样
|
20
|
+
# 没有对应的二进制版本时还可以转到源码源码
|
21
|
+
#
|
22
|
+
def aggregate_for_dependency(dependency)
|
23
|
+
sources_manager = Config.instance.sources_manager
|
24
|
+
if dependency&.podspec_repo
|
25
|
+
sources_manager.aggregate_for_dependency(dependency)
|
26
|
+
# 采用 lock 中的 source ,会导致插件对 source 的先后调整失效
|
27
|
+
# elsif (locked_vertex = @locked_dependencies.vertex_named(dependency.name)) && (locked_dependency = locked_vertex.payload) && locked_dependency.podspec_repo
|
28
|
+
# sources_manager.aggregate_for_dependency(locked_dependency)
|
29
|
+
else
|
30
|
+
@aggregate ||= Source::Aggregate.new(sources)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if Pod.match_version?('~> 1.4')
|
36
|
+
def specifications_for_dependency(dependency, additional_requirements_frozen = [])
|
37
|
+
additional_requirements = additional_requirements_frozen.dup.compact
|
38
|
+
requirement = Requirement.new(dependency.requirement.as_list + additional_requirements.flat_map(&:as_list))
|
39
|
+
if podfile.allow_prerelease? && !requirement.prerelease?
|
40
|
+
requirement = Requirement.new(dependency.requirement.as_list.map { |r| r + '.a' } + additional_requirements.flat_map(&:as_list))
|
41
|
+
end
|
42
|
+
|
43
|
+
options = if Pod.match_version?('~> 1.7')
|
44
|
+
podfile.installation_options
|
45
|
+
else
|
46
|
+
installation_options
|
47
|
+
end
|
48
|
+
|
49
|
+
if Pod.match_version?('~> 1.8')
|
50
|
+
specifications = find_cached_set(dependency)
|
51
|
+
.all_specifications(options.warn_for_multiple_pod_sources, requirement)
|
52
|
+
else
|
53
|
+
specifications = find_cached_set(dependency)
|
54
|
+
.all_specifications(options.warn_for_multiple_pod_sources)
|
55
|
+
.select { |s| requirement.satisfied_by? s.version }
|
56
|
+
end
|
57
|
+
|
58
|
+
specifications
|
59
|
+
.map { |s| s.subspec_by_name(dependency.name, false, true) }
|
60
|
+
.compact
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if Pod.match_version?('~> 1.6')
|
65
|
+
alias old_valid_possibility_version_for_root_name? valid_possibility_version_for_root_name?
|
66
|
+
|
67
|
+
def valid_possibility_version_for_root_name?(requirement, activated, spec)
|
68
|
+
return true if podfile.allow_prerelease?
|
69
|
+
|
70
|
+
old_valid_possibility_version_for_root_name?(requirement, activated, spec)
|
71
|
+
end
|
72
|
+
elsif Pod.match_version?('~> 1.4')
|
73
|
+
def requirement_satisfied_by?(requirement, activated, spec)
|
74
|
+
version = spec.version
|
75
|
+
return false unless requirement.requirement.satisfied_by?(version)
|
76
|
+
|
77
|
+
shared_possibility_versions, prerelease_requirement = possibility_versions_for_root_name(requirement, activated)
|
78
|
+
if !shared_possibility_versions.empty? && !shared_possibility_versions.include?(version)
|
79
|
+
return false
|
80
|
+
end
|
81
|
+
if !podfile.allow_prerelease? && version.prerelease? && !prerelease_requirement
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
unless spec_is_platform_compatible?(activated, requirement, spec)
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# 读取黑名单
|
93
|
+
def read_black_list
|
94
|
+
config_file = File.join(Pod::Config.instance.project_root, 'BinConfig.yaml')
|
95
|
+
return nil unless File.exist?(config_file)
|
96
|
+
config = YAML.load(File.open(config_file))
|
97
|
+
return nil if config.nil?
|
98
|
+
install_config = config['install_config']
|
99
|
+
return nil if install_config.nil?
|
100
|
+
install_config['black_list']
|
101
|
+
end
|
102
|
+
|
103
|
+
# >= 1.4.0 才有 resolver_specs_by_target 以及 ResolverSpecification
|
104
|
+
# >= 1.5.0 ResolverSpecification 才有 source,供 install 或者其他操作时,输入 source 变更
|
105
|
+
#
|
106
|
+
if Pod.match_version?('~> 1.4')
|
107
|
+
old_resolve = instance_method(:resolve)
|
108
|
+
define_method(:resolve) do
|
109
|
+
dependencies = @podfile_dependency_cache.target_definition_list.flat_map do |target|
|
110
|
+
@podfile_dependency_cache.target_definition_dependencies(target).each do |dep|
|
111
|
+
next unless target.platform
|
112
|
+
@platforms_by_dependency[dep].push(target.platform)
|
113
|
+
end
|
114
|
+
end.uniq
|
115
|
+
@platforms_by_dependency.each_value(&:uniq!)
|
116
|
+
|
117
|
+
# 遍历locked_dependencies,将二进制版本号的最后一位删掉
|
118
|
+
locked_dependencies.each do |value|
|
119
|
+
next if value.nil?
|
120
|
+
# 获取 Pod::Dependency
|
121
|
+
dep = value.payload
|
122
|
+
next if dep.external_source
|
123
|
+
# 修改版本号限制
|
124
|
+
requirements = dep.requirement.as_list.map do |req|
|
125
|
+
req_arr = req.split('.').delete_if { |r| r.include?('bin') }
|
126
|
+
req_arr.join('.')
|
127
|
+
end
|
128
|
+
# 重新生成 Pod::Dependency
|
129
|
+
dep = Dependency.new(dep.name, requirements, {:source => dep.podspec_repo, :external_source => dep.external_source})
|
130
|
+
value.payload = dep
|
131
|
+
end
|
132
|
+
|
133
|
+
start_time = Time.now
|
134
|
+
@activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
|
135
|
+
UI.puts "Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
|
136
|
+
resolver_specs_by_target
|
137
|
+
rescue Molinillo::ResolverError => e
|
138
|
+
handle_resolver_error(e)
|
139
|
+
end
|
140
|
+
|
141
|
+
old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
|
142
|
+
define_method(:resolver_specs_by_target) do
|
143
|
+
specs_by_target = old_resolver_specs_by_target.bind(self).call
|
144
|
+
|
145
|
+
sources_manager = Config.instance.sources_manager
|
146
|
+
use_source_pods = podfile.use_source_pods
|
147
|
+
|
148
|
+
# 从BinConfig读取black_list
|
149
|
+
black_list = read_black_list
|
150
|
+
use_source_pods.concat(black_list).uniq! unless black_list.nil?
|
151
|
+
|
152
|
+
specifications = specs_by_target.values.flatten.map(&:spec).uniq
|
153
|
+
|
154
|
+
missing_binary_specs = []
|
155
|
+
specs_by_target.each do |target, rspecs|
|
156
|
+
# use_binaries 并且 use_source_pods 不包含 本地可过滤
|
157
|
+
use_binary_rspecs = if podfile.use_binaries? || podfile.use_binaries_selector
|
158
|
+
rspecs.select do |rspec|
|
159
|
+
([rspec.name, rspec.root.name] & use_source_pods).empty? &&
|
160
|
+
(podfile.use_binaries_selector.nil? || podfile.use_binaries_selector.call(rspec.spec))
|
161
|
+
end
|
162
|
+
else
|
163
|
+
[]
|
164
|
+
end
|
165
|
+
|
166
|
+
# Parallel.map(rspecs, in_threads: 8) do |rspec|
|
167
|
+
specs_by_target[target] = rspecs.map do |rspec|
|
168
|
+
# 含有 subspecs 的组件暂不处理
|
169
|
+
# next rspec if rspec.spec.subspec? || rspec.spec.subspecs.any?
|
170
|
+
|
171
|
+
# developments 组件采用默认输入的 spec (development pods 的 source 为 nil)
|
172
|
+
# 可以使 :podspec => "htts://IMYFoundation.podspec"可以走下去,by slj
|
173
|
+
unless rspec.spec.respond_to?(:spec_source) && rspec.spec.spec_source
|
174
|
+
next rspec
|
175
|
+
end
|
176
|
+
|
177
|
+
# 采用二进制依赖并且不为开发组件
|
178
|
+
use_binary = use_binary_rspecs.include?(rspec)
|
179
|
+
if use_binary
|
180
|
+
source = sources_manager.binary_source
|
181
|
+
configuration = ENV['configuration'] || podfile.configuration
|
182
|
+
spec_version = version_helper.version(rspec.root.name, rspec.spec.version, specifications, configuration)
|
183
|
+
else
|
184
|
+
# 获取podfile中的source
|
185
|
+
podfile_sources = podfile.sources.uniq.map { |source| sources_manager.source_with_name_or_url(source) }
|
186
|
+
source = (sources_manager.code_source_list + podfile_sources).uniq.select do |s|
|
187
|
+
s.search(rspec.root.name)
|
188
|
+
end.first
|
189
|
+
spec_version = rspec.spec.version
|
190
|
+
end
|
191
|
+
|
192
|
+
raise Informative, "#{rspec.root.name}(#{spec_version})的podspec未找到,请执行 pod repo update 或添加相应的source源" unless source
|
193
|
+
|
194
|
+
# UI.message "------------------- 分界线 -----------------------"
|
195
|
+
# UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件(#{use_binary ? '二进制' : '源码'})."
|
196
|
+
|
197
|
+
begin
|
198
|
+
# 从新 source 中获取 spec,在bin archive中会异常,因为找不到
|
199
|
+
specification = source.specification(rspec.root.name, spec_version)
|
200
|
+
|
201
|
+
raise Informative, "Specification of #{rspec.root.name}(#{spec_version}) is nil" unless specification
|
202
|
+
|
203
|
+
UI.message "specification = #{specification}"
|
204
|
+
# 组件是 subspec
|
205
|
+
if rspec.spec.subspec?
|
206
|
+
specification = specification.subspec_by_name(rspec.name, false, true)
|
207
|
+
end
|
208
|
+
|
209
|
+
# 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
|
210
|
+
# 造成 subspec_by_name 返回 nil,这个是正常现象
|
211
|
+
next unless specification
|
212
|
+
|
213
|
+
used_by_only = if Pod.match_version?('~> 1.7')
|
214
|
+
rspec.used_by_non_library_targets_only
|
215
|
+
else
|
216
|
+
rspec.used_by_tests_only
|
217
|
+
end
|
218
|
+
# 组装新的 rspec ,替换原 rspec
|
219
|
+
rspec = if Pod.match_version?('~> 1.4.0')
|
220
|
+
ResolverSpecification.new(specification, used_by_only)
|
221
|
+
else
|
222
|
+
ResolverSpecification.new(specification, used_by_only, source)
|
223
|
+
end
|
224
|
+
# UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} (#{spec_version}) specification = #{specification} #{rspec} "
|
225
|
+
rescue Pod::StandardError => e
|
226
|
+
# 没有从新的 source 找到对应版本组件,直接返回原 rspec
|
227
|
+
missing_binary_specs << rspec.spec if use_binary
|
228
|
+
# UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
|
229
|
+
rspec
|
230
|
+
end
|
231
|
+
rspec
|
232
|
+
end.compact
|
233
|
+
end
|
234
|
+
|
235
|
+
# if missing_binary_specs.any?
|
236
|
+
# missing_binary_specs.uniq.each do |spec|
|
237
|
+
# # UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
|
238
|
+
# end
|
239
|
+
# # 下面的代码为了实现 auto 命令的 --all-make
|
240
|
+
# Pod::Command::Bin::Archive.missing_binary_specs(missing_binary_specs)
|
241
|
+
# #缓存没有二进制组件到spec文件,local_psec_dir 目录
|
242
|
+
# sources_sepc = []
|
243
|
+
# des_dir = CBin::Config::Builder.instance.local_psec_dir
|
244
|
+
# FileUtils.rm_f(des_dir) if File.exist?des_dir
|
245
|
+
# Dir.mkdir des_dir unless File.exist?des_dir
|
246
|
+
# missing_binary_specs.uniq.each do |spec|
|
247
|
+
# # 排除subspec
|
248
|
+
# next if spec.name.include?('/')
|
249
|
+
#
|
250
|
+
# spec_git_res = false
|
251
|
+
# CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
252
|
+
# spec_git_res = spec.source[:git] && spec.source[:git].include?(ignore_git)
|
253
|
+
# break if spec_git_res
|
254
|
+
# end
|
255
|
+
# next if spec_git_res
|
256
|
+
#
|
257
|
+
# #获取没有制作二进制版本的spec集合
|
258
|
+
# sources_sepc << spec
|
259
|
+
# unless spec.defined_in_file.nil?
|
260
|
+
# FileUtils.cp("#{spec.defined_in_file}", "#{des_dir}")
|
261
|
+
# end
|
262
|
+
# end
|
263
|
+
# end
|
264
|
+
|
265
|
+
specs_by_target
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def version_helper
|
270
|
+
@version_helper ||= begin
|
271
|
+
CBin::BuildAll::BinHelper.new
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
if Pod.match_version?('~> 1.4.0')
|
277
|
+
# 1.4.0 没有 spec_source
|
278
|
+
class Specification
|
279
|
+
class Set
|
280
|
+
class LazySpecification < BasicObject
|
281
|
+
attr_reader :spec_source
|
282
|
+
|
283
|
+
old_initialize = instance_method(:initialize)
|
284
|
+
define_method(:initialize) do |name, version, source|
|
285
|
+
old_initialize.bind(self).call(name, version, source)
|
286
|
+
|
287
|
+
@spec_source = source
|
288
|
+
end
|
289
|
+
|
290
|
+
def respond_to?(method, include_all = false)
|
291
|
+
return super unless method == :spec_source
|
292
|
+
|
293
|
+
true
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Installer
|
5
|
+
class Analyzer
|
6
|
+
class SandboxAnalyzer
|
7
|
+
# def pod_changed?(pod)
|
8
|
+
# spec = root_spec(pod)
|
9
|
+
# 有 subspec 的情况下,root spec 对应的 used_files 可能始终为空
|
10
|
+
# 要添加为空 && 没有 subspec 的情况
|
11
|
+
# file_accessors = spec.available_platforms.map { |platform| Sandbox::FileAccessor.new(sandbox.pod_dir(pod), spec.consumer(platform)) }
|
12
|
+
# files = [
|
13
|
+
# file_accessors.map(&:vendored_frameworks),
|
14
|
+
# file_accessors.map(&:vendored_libraries),
|
15
|
+
# file_accessors.map(&:resource_bundle_files),
|
16
|
+
# file_accessors.map(&:prefix_header),
|
17
|
+
# file_accessors.map(&:resources),
|
18
|
+
# file_accessors.map(&:source_files),
|
19
|
+
# file_accessors.map(&:module_map),
|
20
|
+
# ]
|
21
|
+
# used_files = files.flatten.compact.map(&:to_s).uniq
|
22
|
+
# p pod if used_files.empty?
|
23
|
+
|
24
|
+
# return true if spec.version != sandbox_version(pod)
|
25
|
+
# return true if spec.checksum != sandbox_checksum(pod)
|
26
|
+
# return true if resolved_spec_names(pod) != sandbox_spec_names(pod)
|
27
|
+
# return true if sandbox.predownloaded?(pod)
|
28
|
+
# return true if folder_empty?(pod)
|
29
|
+
# false
|
30
|
+
# end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Source
|
7
|
+
# Returns the path of the specification with the given name and version.
|
8
|
+
#
|
9
|
+
# @param [String] name
|
10
|
+
# the name of the Pod.
|
11
|
+
#
|
12
|
+
# @param [Version,String] version
|
13
|
+
# the version for the specification.
|
14
|
+
#
|
15
|
+
# @return [Pathname] The path of the specification.
|
16
|
+
#
|
17
|
+
def specification_path(name, version)
|
18
|
+
raise ArgumentError, 'No name' unless name
|
19
|
+
raise ArgumentError, 'No version' unless version
|
20
|
+
|
21
|
+
path = pod_path(name) + version.to_s
|
22
|
+
|
23
|
+
specification_path = Specification::VALID_EXTNAME
|
24
|
+
.map { |extname| "#{name}#{extname}" }
|
25
|
+
.map { |file| path + file }
|
26
|
+
.find(&:exist?)
|
27
|
+
|
28
|
+
unless specification_path
|
29
|
+
raise StandardError, "Unable to find the specification #{name} " \
|
30
|
+
"(#{version}) in the #{self.name} source."
|
31
|
+
end
|
32
|
+
specification_path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-meitu-bin/config/config'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Source
|
8
|
+
class Manager
|
9
|
+
# 源码 source list
|
10
|
+
def code_source_list
|
11
|
+
[]
|
12
|
+
# CBin.config.code_repo_url_list.split(";").map { |source| source_with_name_or_url(source)}
|
13
|
+
end
|
14
|
+
# 二进制 source
|
15
|
+
def binary_source
|
16
|
+
source_with_name_or_url(CBin.config.binary_repo_url)
|
17
|
+
# source_with_name_or_url('git@github.com:Zhangyanshen/example-private-spec-bin.git')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-meitu-bin/native/sources_manager'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Specification
|
7
|
+
VALID_EXTNAME = %w[.binary.podspec.json .binary.podspec .podspec.json .podspec].freeze
|
8
|
+
DEFAULT_TEMPLATE_EXTNAME = %w[.binary-template.podspec .binary-template.podspec.json].freeze
|
9
|
+
|
10
|
+
# TODO
|
11
|
+
# 可以在这里根据组件依赖二进制或源码调整 sources 的先后顺序
|
12
|
+
# 如果是源码,则调整 code_source 到最前面
|
13
|
+
# 如果是二进制,则调整 binary_source 到最前面
|
14
|
+
# 这样 CocoaPods 分析时,就会优先获取到对应源的 podspec
|
15
|
+
#
|
16
|
+
# 先要把 Podfile 里面的配置数据保存到单例中,再在这里判断,就不需要 resolver 了
|
17
|
+
# 但是现在这个插件依旧可用,重构需要时间 = = ,没什么动力去重构了呀。。。
|
18
|
+
#
|
19
|
+
# class Set
|
20
|
+
# old_initialize = instance_method(:initialize)
|
21
|
+
# define_method(:initialize) do |name, sources|
|
22
|
+
# if name == 'TDFAdaptationKit'
|
23
|
+
# sources_manager = Pod::Config.instance.sources_manager
|
24
|
+
# # sources = [sources_manager.binary_source, *sources].uniq
|
25
|
+
# sources = [sources_manager.code_source, *sources].uniq
|
26
|
+
# end
|
27
|
+
# old_initialize.bind(self).call(name, sources)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
class Xcode
|
4
|
+
# The {Xcode::TargetValidator} ensures that the pod and aggregate target
|
5
|
+
# configuration is valid for installation.
|
6
|
+
#
|
7
|
+
class TargetValidator
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def verify_swift_pods_have_module_dependencies
|
12
|
+
error_messages = []
|
13
|
+
pod_targets.each do |pod_target|
|
14
|
+
next unless pod_target.uses_swift?
|
15
|
+
|
16
|
+
non_module_dependencies = []
|
17
|
+
pod_target.dependent_targets.each do |dependent_target|
|
18
|
+
next if !dependent_target.should_build? || dependent_target.defines_module?
|
19
|
+
non_module_dependencies << dependent_target.name
|
20
|
+
end
|
21
|
+
|
22
|
+
next if non_module_dependencies.empty?
|
23
|
+
|
24
|
+
error_messages << "The Swift pod `#{pod_target.name}` depends upon #{non_module_dependencies.map { |d| "`#{d}`" }.to_sentence}, " \
|
25
|
+
"which #{non_module_dependencies.count == 1 ? 'does' : 'do'} not define modules. " \
|
26
|
+
'To opt into those targets generating module maps '\
|
27
|
+
'(which is necessary to import them from Swift when building as static libraries), ' \
|
28
|
+
'you may set `use_modular_headers!` globally in your Podfile, '\
|
29
|
+
'or specify `:modular_headers => true` for particular dependencies.'
|
30
|
+
end
|
31
|
+
return false
|
32
|
+
|
33
|
+
# raise Informative, 'The following Swift pods cannot yet be integrated '\
|
34
|
+
# "as static libraries:\n\n#{error_messages.join("\n\n")}"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Validator
|
5
|
+
# def validate_source_url(spec)
|
6
|
+
# return if spec.source.nil? || spec.source[:http].nil?
|
7
|
+
# url = URI(spec.source[:http])
|
8
|
+
# return if url.scheme == 'https' || url.scheme == 'file'
|
9
|
+
# warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \
|
10
|
+
# 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
|
11
|
+
# 'This will be an error in future releases. Please update the URL to use https.')
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# Perform analysis for a given spec (or subspec)
|
15
|
+
#
|
16
|
+
def perform_extensive_analysis(spec)
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
|
20
|
+
#覆盖
|
21
|
+
def check_file_patterns
|
22
|
+
FILE_PATTERNS.each do |attr_name|
|
23
|
+
next if %i(source_files resources).include? attr_name
|
24
|
+
if respond_to?("_validate_#{attr_name}", true)
|
25
|
+
send("_validate_#{attr_name}")
|
26
|
+
else
|
27
|
+
validate_nonempty_patterns(attr_name, :error)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
_validate_header_mappings_dir
|
32
|
+
if consumer.spec.root?
|
33
|
+
_validate_license
|
34
|
+
_validate_module_map
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_source_url(spec); end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-meitu-bin/gem_version'
|
3
|
+
|
4
|
+
if Pod.match_version?('~> 1.4')
|
5
|
+
require 'cocoapods-meitu-bin/native/podfile'
|
6
|
+
require 'cocoapods-meitu-bin/native/installation_options'
|
7
|
+
require 'cocoapods-meitu-bin/native/specification'
|
8
|
+
require 'cocoapods-meitu-bin/native/path_source'
|
9
|
+
require 'cocoapods-meitu-bin/native/analyzer'
|
10
|
+
require 'cocoapods-meitu-bin/native/installer'
|
11
|
+
require 'cocoapods-meitu-bin/native/podfile_generator'
|
12
|
+
require 'cocoapods-meitu-bin/native/pod_source_installer'
|
13
|
+
require 'cocoapods-meitu-bin/native/linter'
|
14
|
+
require 'cocoapods-meitu-bin/native/resolver'
|
15
|
+
require 'cocoapods-meitu-bin/native/source'
|
16
|
+
require 'cocoapods-meitu-bin/native/validator'
|
17
|
+
require 'cocoapods-meitu-bin/native/acknowledgements'
|
18
|
+
require 'cocoapods-meitu-bin/native/sandbox_analyzer'
|
19
|
+
require 'cocoapods-meitu-bin/native/podspec_finder'
|
20
|
+
require 'cocoapods-meitu-bin/native/file_accessor'
|
21
|
+
require 'cocoapods-meitu-bin/native/pod_target_installer'
|
22
|
+
require 'cocoapods-meitu-bin/native/target_validator'
|
23
|
+
require 'cocoapods-meitu-bin/native/gen'
|
24
|
+
require 'cocoapods-meitu-bin/native/lockfile'
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'cocoapods-meitu-bin/native/sources_manager'
|
2
|
+
require 'cocoapods-meitu-bin/command/bin/repo/update'
|
3
|
+
require 'cocoapods-meitu-bin/config/config'
|
4
|
+
require 'cocoapods/user_interface'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
|
8
|
+
require 'cocoapods-meitu-bin/native'
|
9
|
+
require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
|
10
|
+
|
11
|
+
Pod::UI.puts "当前configuration: `#{ENV['configuration'] || Pod::Config.instance.podfile.configuration}`".green
|
12
|
+
|
13
|
+
# pod bin repo update 更新二进制私有源
|
14
|
+
Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new($ARGV)).run
|
15
|
+
|
16
|
+
# 有插件/本地库 且是dev环境下,默认进入源码白名单 过滤 archive命令
|
17
|
+
if _context.podfile.plugins.keys.include?('cocoapods-meitu-bin') && _context.podfile.configuration_env == 'dev'
|
18
|
+
dependencies = _context.podfile.dependencies
|
19
|
+
dependencies.each do |d|
|
20
|
+
next unless d.respond_to?(:external_source) &&
|
21
|
+
d.external_source.is_a?(Hash) &&
|
22
|
+
!d.external_source[:path].nil? &&
|
23
|
+
$ARGV[1] != 'archive'
|
24
|
+
_context.podfile.set_use_source_pods d.name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# 同步 BinPodfile 文件
|
29
|
+
project_root = Pod::Config.instance.project_root
|
30
|
+
path = File.join(project_root.to_s, 'BinPodfile')
|
31
|
+
|
32
|
+
next unless File.exist?(path)
|
33
|
+
|
34
|
+
contents = File.open(path, 'r:utf-8', &:read)
|
35
|
+
podfile = Pod::Config.instance.podfile
|
36
|
+
podfile.instance_eval do
|
37
|
+
begin
|
38
|
+
eval(contents, nil, path)
|
39
|
+
rescue Exception => e
|
40
|
+
message = "Invalid `#{path}` file: #{e.message}"
|
41
|
+
raise Pod::DSLError.new(message, path, e, contents)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Pod::HooksManager.register('cocoapods-meitu-bin', :source_provider) do |context, _|
|
47
|
+
sources_manager = Pod::Config.instance.sources_manager
|
48
|
+
podfile = Pod::Config.instance.podfile
|
49
|
+
if podfile
|
50
|
+
# 读取配置文件
|
51
|
+
config_file = File.join(Pod::Config.instance.project_root, 'BinConfig.yaml')
|
52
|
+
if File.exist?(config_file)
|
53
|
+
config = YAML.load(File.open(config_file))
|
54
|
+
unless config.nil?
|
55
|
+
build_config = config['install_config'] || {}
|
56
|
+
use_binary = build_config['use_binary'] || false
|
57
|
+
podfile.use_binaries!(use_binary) if use_binary
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# 添加源码私有源 && 二进制私有源
|
61
|
+
added_sources = sources_manager.code_source_list
|
62
|
+
# if podfile.use_binaries? || podfile.use_binaries_selector
|
63
|
+
# added_sources << sources_manager.binary_source
|
64
|
+
# added_sources.reverse!
|
65
|
+
# end
|
66
|
+
added_sources.each { |source| context.add_source(source)}
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'cocoapods-meitu-bin/command'
|
2
|
+
require 'cocoapods-meitu-bin/source_provider_hook'
|
3
|
+
# require 'cocoapods-meitu-bin/gem_version'
|
4
|
+
#
|
5
|
+
# msg = <<-MSG
|
6
|
+
# ————————————————————————————————
|
7
|
+
# |#{'cocoapods-meitu-bin'.center(30)}|
|
8
|
+
# |#{CBin::VERSION.center(30)}|
|
9
|
+
# ————————————————————————————————
|
10
|
+
# MSG
|
11
|
+
# Pod::UI.puts msg.red
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|