cocoapods-mtxx-bin 0.0.6 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-mtxx-bin/command/bin/buildAll.rb +46 -41
- data/lib/cocoapods-mtxx-bin/command/bin/outputSource.rb +141 -0
- data/lib/cocoapods-mtxx-bin/command/bin/upload.rb +173 -0
- data/lib/cocoapods-mtxx-bin/command/bin.rb +3 -1
- data/lib/cocoapods-mtxx-bin/gem_version.rb +1 -1
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/bin_helper.rb +2 -0
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb +7 -3
- data/lib/cocoapods-mtxx-bin/native/analyzer.rb +26 -6
- data/lib/cocoapods-mtxx-bin/native/installation_options.rb +4 -1
- data/lib/cocoapods-mtxx-bin/native/installer.rb +22 -52
- data/lib/cocoapods-mtxx-bin/native/pod_target_installer.rb +0 -7
- data/lib/cocoapods-mtxx-bin/native/resolver.rb +5 -5
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c59fa44939d32b5a5422f0646ea4729c41891e6acf7915cae4d944285c4d897
|
4
|
+
data.tar.gz: e76cb2fbf759274440591980a15935bb450992b0ab62b931413fabb937c1876b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f522fc8a561fe0cd06b287b30c456579fe20eb7ad576a91a1abb5a727a96ad44a994cfcab3330771c15c88eef6a1be554edae02b288f03aeee9136ae711dea
|
7
|
+
data.tar.gz: 15a88b10bb581930ce29bd61a2a49b75fcda4e8f9e6e76eec0a715618e1c53ed461b0dbb92efae72cfd5867801ba87b58a0779ce89ba9e2adb372e38113bc925
|
@@ -19,7 +19,7 @@ module Pod
|
|
19
19
|
|
20
20
|
self.summary = '根据壳工程打包所有依赖组件为静态库(static framework)'
|
21
21
|
self.description = <<-DESC
|
22
|
-
#{
|
22
|
+
#{summary}
|
23
23
|
DESC
|
24
24
|
|
25
25
|
def self.options
|
@@ -31,9 +31,9 @@ module Pod
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def initialize(argv)
|
34
|
-
@clean = argv.flag?('clean', false
|
35
|
-
@repo_update = argv.flag?('repo-update', false
|
36
|
-
@full_build = argv.flag?('full-build', false
|
34
|
+
@clean = argv.flag?('clean', false)
|
35
|
+
@repo_update = argv.flag?('repo-update', false)
|
36
|
+
@full_build = argv.flag?('full-build', false)
|
37
37
|
@base_dir = "#{Pathname.pwd}/build_pods"
|
38
38
|
super
|
39
39
|
end
|
@@ -71,10 +71,10 @@ module Pod
|
|
71
71
|
|
72
72
|
# 读取配置文件
|
73
73
|
def read_config
|
74
|
-
UI.title
|
74
|
+
UI.title 'Read config from file `BinConfig.yaml`'.green do
|
75
75
|
config_file = File.join(CBin.config.binary_dir, 'BinConfig.yaml')
|
76
76
|
return unless File.exist?(config_file)
|
77
|
-
config = YAML.
|
77
|
+
config = YAML.safe_load(File.open(config_file))
|
78
78
|
return if config.nil?
|
79
79
|
build_config = config['build_config']
|
80
80
|
return if build_config.nil?
|
@@ -87,38 +87,44 @@ module Pod
|
|
87
87
|
|
88
88
|
# 更新repo仓库
|
89
89
|
def repo_update
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
90
|
+
if @repo_update
|
91
|
+
UI.title 'Repo update'.green do
|
92
|
+
return if podfile.nil?
|
93
|
+
sources_manager = Pod::Config.instance.sources_manager
|
94
|
+
podfile.sources.uniq.map do |src|
|
95
|
+
# next if src.include?(CDN) || src.include?(MASTER_HTTP) || src.include?(MASTER_SSH)
|
96
|
+
next unless src.include?(MT_REPO)
|
97
|
+
UI.message "Update repo: #{src}"
|
98
|
+
source = sources_manager.source_with_name_or_url(src)
|
99
|
+
source.update(false)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
101
103
|
end
|
102
104
|
|
103
105
|
# 执行pre build
|
104
106
|
def pre_build
|
105
|
-
|
106
|
-
|
107
|
-
|
107
|
+
if @pre_build
|
108
|
+
UI.title 'Execute the command of pre build'.green do
|
109
|
+
system(@pre_build)
|
110
|
+
end
|
111
|
+
end
|
108
112
|
end
|
109
113
|
|
110
114
|
# 执行post build
|
111
|
-
def post_build(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
+
def post_build(_results)
|
116
|
+
if @post_build
|
117
|
+
UI.title 'Execute the command of post build'.green do
|
118
|
+
system(@post_build)
|
119
|
+
end
|
120
|
+
end
|
115
121
|
end
|
116
122
|
|
117
123
|
# 获取 podfile
|
118
124
|
def podfile
|
119
125
|
@podfile ||= begin
|
120
|
-
podfile_path = File.join(Pathname.pwd,
|
121
|
-
raise
|
126
|
+
podfile_path = File.join(Pathname.pwd, 'Podfile')
|
127
|
+
raise 'Podfile不存在' unless File.exist?(podfile_path)
|
122
128
|
sources_manager = Pod::Config.instance.sources_manager
|
123
129
|
podfile = Podfile.from_file(Pathname.new(podfile_path))
|
124
130
|
podfile_hash = podfile.to_hash
|
@@ -132,8 +138,8 @@ module Pod
|
|
132
138
|
# 获取 podfile.lock
|
133
139
|
def lockfile
|
134
140
|
@lockfile ||= begin
|
135
|
-
lock_path = File.join(Pathname.pwd,
|
136
|
-
raise
|
141
|
+
lock_path = File.join(Pathname.pwd, 'Podfile.lock')
|
142
|
+
raise 'Podfile.lock不存在,请执行pod install' unless File.exist?(lock_path)
|
137
143
|
Lockfile.from_file(Pathname.new(lock_path))
|
138
144
|
end
|
139
145
|
end
|
@@ -141,30 +147,30 @@ module Pod
|
|
141
147
|
# 获取 sandbox
|
142
148
|
def sandbox
|
143
149
|
@sandbox ||= begin
|
144
|
-
sandbox_path = File.join(Pathname.pwd,
|
145
|
-
raise
|
150
|
+
sandbox_path = File.join(Pathname.pwd, 'Pods')
|
151
|
+
raise 'Pods文件夹不存在,请执行pod install' unless File.exist?(sandbox_path)
|
146
152
|
Pod::Sandbox.new(sandbox_path)
|
147
153
|
end
|
148
154
|
end
|
149
155
|
|
150
156
|
# 根据podfile和podfile.lock分析依赖
|
151
157
|
def analyse
|
152
|
-
UI.title
|
158
|
+
UI.title 'Analyze dependencies'.green do
|
153
159
|
analyzer = Pod::Installer::Analyzer.new(
|
154
160
|
sandbox,
|
155
161
|
podfile,
|
156
162
|
lockfile
|
157
163
|
)
|
158
|
-
analyzer.analyze(true
|
164
|
+
analyzer.analyze(true)
|
159
165
|
end
|
160
166
|
end
|
161
167
|
|
162
168
|
# 删除编译产物
|
163
169
|
def clean_build_pods
|
164
|
-
UI.title
|
165
|
-
build_path = Dir.pwd +
|
170
|
+
UI.title 'Clean build pods'.green do
|
171
|
+
build_path = Dir.pwd + '/build'
|
166
172
|
FileUtils.rm_rf(build_path) if File.exist?(build_path)
|
167
|
-
build_pods_path = Dir.pwd +
|
173
|
+
build_pods_path = Dir.pwd + '/build_pods'
|
168
174
|
FileUtils.rm_rf(build_pods_path) if File.exist?(build_pods_path)
|
169
175
|
end
|
170
176
|
end
|
@@ -269,14 +275,14 @@ module Pod
|
|
269
275
|
|
270
276
|
# 展示结果
|
271
277
|
def show_results(results)
|
272
|
-
UI.title
|
273
|
-
UI.info
|
274
|
-
UI.info "|#{
|
275
|
-
UI.info
|
278
|
+
UI.title '打包结果:'.green do
|
279
|
+
UI.info '——————————————————————————————————'.green
|
280
|
+
UI.info "|#{'Type'.center(20)}|#{'Count'.center(11)}|".green
|
281
|
+
UI.info '——————————————————————————————————'.green
|
276
282
|
results.each do |key, value|
|
277
283
|
UI.info "|#{key.center(20)}|#{value.size.to_s.center(11)}|".green
|
278
284
|
end
|
279
|
-
UI.info
|
285
|
+
UI.info '——————————————————————————————————'.green
|
280
286
|
|
281
287
|
# 打印出失败的 target
|
282
288
|
unless results['Fail'].empty?
|
@@ -304,7 +310,6 @@ module Pod
|
|
304
310
|
end
|
305
311
|
result
|
306
312
|
end
|
307
|
-
|
308
313
|
end
|
309
314
|
end
|
310
315
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'cocoapods-mtxx-bin/helpers/buildAll/builder'
|
2
|
+
require 'cocoapods-mtxx-bin/helpers/buildAll/podspec_util'
|
3
|
+
require 'cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper'
|
4
|
+
require 'cocoapods-mtxx-bin/helpers/buildAll/bin_helper'
|
5
|
+
require 'cocoapods-mtxx-bin/config/config'
|
6
|
+
require 'yaml'
|
7
|
+
require 'digest'
|
8
|
+
|
9
|
+
module Pod
|
10
|
+
class Command
|
11
|
+
class Bin < Command
|
12
|
+
class OutputSource < Bin
|
13
|
+
self.summary = '输出各个组件的source源,默认输出全部组件的source'
|
14
|
+
self.description = <<-DESC
|
15
|
+
#{summary}
|
16
|
+
DESC
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
%w[--error-source 过滤异常的source,比如http的,CI打包只支持SSH认证]
|
21
|
+
].concat(super).uniq
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@error_source = argv.flag?('error-source', false)
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
# 开始时间
|
31
|
+
@start_time = Time.now.to_i
|
32
|
+
# 更新repo仓库
|
33
|
+
repo_update
|
34
|
+
# 分析依赖
|
35
|
+
@analyze_result = analyse
|
36
|
+
# 打印source
|
37
|
+
show_cost_source
|
38
|
+
# 计算耗时
|
39
|
+
show_cost_time
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# 打印source
|
45
|
+
def show_cost_source
|
46
|
+
all_source_list = []
|
47
|
+
error_source_list = []
|
48
|
+
@analyze_result.specifications.each do |specification|
|
49
|
+
next if specification.subspec?
|
50
|
+
all_source_list << specification.source
|
51
|
+
if @error_source && verified_git_address(specification)
|
52
|
+
error_source_list << specification.name + ' ' + specification.source[:git] + + ' ' + specification.source[:tag]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
if @error_source
|
56
|
+
UI.info '问题组件,source 为http CI打包不支持http认证,应修改为ssh'.red
|
57
|
+
UI.info error_source_list.to_s.red
|
58
|
+
else
|
59
|
+
UI.info '输出所有pod组件source'.green
|
60
|
+
UI.info error_source_list.to_s.green
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# git clone 地址 是否非法
|
65
|
+
def verified_git_address(specification)
|
66
|
+
return false if specification.source[:git].nil?
|
67
|
+
git = specification.source[:git]
|
68
|
+
git.include?('http://techgit.meitu.com') || git.include?('https://techgit.meitu.com')
|
69
|
+
end
|
70
|
+
|
71
|
+
# 打印耗时
|
72
|
+
def show_cost_time
|
73
|
+
return if @start_time.nil?
|
74
|
+
UI.info "总耗时:#{Time.now.to_i - @start_time}s".green
|
75
|
+
end
|
76
|
+
|
77
|
+
# 更新repo仓库
|
78
|
+
def repo_update
|
79
|
+
if @repo_update
|
80
|
+
UI.title 'Repo update'.green do
|
81
|
+
return if podfile.nil?
|
82
|
+
sources_manager = Pod::Config.instance.sources_manager
|
83
|
+
podfile.sources.uniq.map do |src|
|
84
|
+
# next if src.include?(CDN) || src.include?(MASTER_HTTP) || src.include?(MASTER_SSH)
|
85
|
+
next unless src.include?(MT_REPO)
|
86
|
+
UI.message "Update repo: #{src}"
|
87
|
+
source = sources_manager.source_with_name_or_url(src)
|
88
|
+
source.update(false)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# 获取 podfile
|
95
|
+
def podfile
|
96
|
+
@podfile ||= begin
|
97
|
+
podfile_path = File.join(Pathname.pwd, 'Podfile')
|
98
|
+
raise 'Podfile不存在' unless File.exist?(podfile_path)
|
99
|
+
sources_manager = Pod::Config.instance.sources_manager
|
100
|
+
podfile = Podfile.from_file(Pathname.new(podfile_path))
|
101
|
+
podfile_hash = podfile.to_hash
|
102
|
+
podfile_hash['sources'] = (podfile_hash['sources'] || []).concat(sources_manager.code_source_list.map(&:url))
|
103
|
+
podfile_hash['sources'] << sources_manager.binary_source.url
|
104
|
+
podfile_hash['sources'].uniq!
|
105
|
+
Podfile.from_hash(podfile_hash)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# 获取 podfile.lock
|
110
|
+
def lockfile
|
111
|
+
@lockfile ||= begin
|
112
|
+
lock_path = File.join(Pathname.pwd, 'Podfile.lock')
|
113
|
+
raise 'Podfile.lock不存在,请执行pod install' unless File.exist?(lock_path)
|
114
|
+
Lockfile.from_file(Pathname.new(lock_path))
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# 获取 sandbox
|
119
|
+
def sandbox
|
120
|
+
@sandbox ||= begin
|
121
|
+
sandbox_path = File.join(Pathname.pwd, 'Pods')
|
122
|
+
raise 'Pods文件夹不存在,请执行pod install' unless File.exist?(sandbox_path)
|
123
|
+
Pod::Sandbox.new(sandbox_path)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# 根据podfile和podfile.lock分析依赖
|
128
|
+
def analyse
|
129
|
+
UI.title 'Analyze dependencies'.green do
|
130
|
+
analyzer = Pod::Installer::Analyzer.new(
|
131
|
+
sandbox,
|
132
|
+
podfile,
|
133
|
+
lockfile
|
134
|
+
)
|
135
|
+
analyzer.analyze(true)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Upload < Bin
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
self.summary = "上传二进制文件及podspec"
|
10
|
+
self.description = <<-DESC
|
11
|
+
#{self.summary}
|
12
|
+
|
13
|
+
`NAME`: 库名【必填】\n
|
14
|
+
`VERSION`: 版本号【必填】\n
|
15
|
+
`FILE`: 需要压缩的二进制文件或目录【必填】\n
|
16
|
+
`REPO`: 上传podspec的仓库,可以通过`pod repo list`查看【必填】\n
|
17
|
+
|
18
|
+
e.g.:\n
|
19
|
+
pod bin upload Pod1 1.0.0 Pod1.framework mtxxspecs --spec=Pod1.podspec
|
20
|
+
DESC
|
21
|
+
|
22
|
+
self.arguments = [
|
23
|
+
CLAide::Argument.new('NAME', true ),
|
24
|
+
CLAide::Argument.new('VERSION', true),
|
25
|
+
CLAide::Argument.new('FILE', true),
|
26
|
+
CLAide::Argument.new('REPO', true)
|
27
|
+
]
|
28
|
+
|
29
|
+
def self.options
|
30
|
+
[
|
31
|
+
%w[--spec=SPEC 指定podspec文件路径,如果不指定,将在当前目录下查找]
|
32
|
+
].concat(super)
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(argv)
|
36
|
+
@name = argv.shift_argument
|
37
|
+
@version = argv.shift_argument
|
38
|
+
@file = argv.shift_argument
|
39
|
+
@repo = argv.shift_argument
|
40
|
+
@spec = argv.option('spec', nil)
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
# 参数检查
|
46
|
+
argvsCheck
|
47
|
+
# 压缩文件
|
48
|
+
zip_file
|
49
|
+
# 上传文件
|
50
|
+
upload_zip_file
|
51
|
+
# 修改podspec
|
52
|
+
modify_spec
|
53
|
+
# 上传podspec
|
54
|
+
upload_spec
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# 参数检查
|
60
|
+
def argvsCheck
|
61
|
+
raise Informative, "name不能为空" if @name.nil?
|
62
|
+
raise Informative, "version不能为空" if @version.nil?
|
63
|
+
raise Informative, "repo不能为空" if @repo.nil?
|
64
|
+
raise Informative, "未找到需要压缩的二进制文件" if @file.nil?
|
65
|
+
raise Informative, "未找到podspec文件" unless File.exist?(podspec)
|
66
|
+
end
|
67
|
+
|
68
|
+
# 压缩文件
|
69
|
+
def zip_file
|
70
|
+
UI.title "压缩二进制文件`#{zip_file_name}`".yellow do
|
71
|
+
output_zip_file = File.join(Dir.pwd, zip_file_name)
|
72
|
+
FileUtils.rm_f(output_zip_file) if File.exist?(output_zip_file)
|
73
|
+
command = "zip --symlinks -r #{zip_file_name} #{@file}"
|
74
|
+
UI.info "#{command}"
|
75
|
+
`#{command}`
|
76
|
+
raise Informative, "压缩二进制文件失败" unless File.exist?(output_zip_file)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# 压缩后的zip包名
|
81
|
+
def zip_file_name
|
82
|
+
@zip_file_name ||= begin
|
83
|
+
"#{@name}_#{@version}.zip"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# 上传文件
|
88
|
+
def upload_zip_file
|
89
|
+
UI.title "上传二进制文件`#{zip_file_name}`".yellow do
|
90
|
+
zip_file = File.join(Dir.pwd, zip_file_name)
|
91
|
+
raise Informative, "`#{@zip_file_name}`不存在" unless File.exist?(zip_file)
|
92
|
+
upload_url = CBin.config.binary_upload_url_str
|
93
|
+
command = "curl -F \"name=#{@name}\" -F \"version=#{@version}\" -F \"file=@#{zip_file}\" #{upload_url}"
|
94
|
+
UI.info "#{command}"
|
95
|
+
json = `#{command}`
|
96
|
+
UI.info json
|
97
|
+
begin
|
98
|
+
error_code = JSON.parse(json)["error_code"]
|
99
|
+
raise Informative, "`#{zip_file_name}`上传失败" unless error_code == 0
|
100
|
+
UI.info "`#{zip_file_name}`上传成功".green
|
101
|
+
rescue JSON::ParserError => e
|
102
|
+
raise Informative, "`#{zip_file_name}`上传失败\n#{e.to_s}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# 修改podspec
|
108
|
+
def modify_spec
|
109
|
+
UI.title "修改podspec:`#{podspec}`".yellow do
|
110
|
+
spec = Specification.from_file(podspec)
|
111
|
+
spec_hash = spec.to_hash
|
112
|
+
spec_hash['version'] = @version
|
113
|
+
spec_hash['source'] = source
|
114
|
+
spec = Specification.from_hash(spec_hash)
|
115
|
+
write_podspec_json(spec)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# 写入podspec
|
120
|
+
def write_podspec_json(spec)
|
121
|
+
FileUtils.rm_f(podspec_json_file) if File.exist?(podspec_json_file)
|
122
|
+
File.open(podspec_json_file, "w+") do |f|
|
123
|
+
f.write(spec.to_pretty_json)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def source
|
128
|
+
url = "#{CBin.config.binary_download_url_str}/#{@name}/#{@version}/#{zip_file_name}"
|
129
|
+
{ http: url, type: 'zip' }
|
130
|
+
end
|
131
|
+
|
132
|
+
# 上传podspec
|
133
|
+
def upload_spec
|
134
|
+
UI.title "推送podspec:`#{podspec_json_file_name}`".yellow do
|
135
|
+
raise Informative, "`#{podspec_json_file_name}`不存在" unless File.exist?(podspec_json_file)
|
136
|
+
argvs = %W[#{@repo} #{podspec_json_file} --skip-import-validation --use-libraries --allow-warnings --verbose]
|
137
|
+
|
138
|
+
begin
|
139
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
140
|
+
push.validate!
|
141
|
+
push.run
|
142
|
+
rescue Pod::StandardError => e
|
143
|
+
raise Informative, "推送podspec:`#{podspec_json_file_name}失败\n#{e.to_s}"
|
144
|
+
end
|
145
|
+
# 上传完成后,清理工作目录
|
146
|
+
FileUtils.rm_f(podspec_json_file) if File.exist?(podspec_json_file)
|
147
|
+
FileUtils.rm_r('binary') if File.exist?('binary')
|
148
|
+
FileUtils.rm_f(zip_file_name) if File.exist?(zip_file_name)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def binary_dir
|
153
|
+
File.join(Dir.pwd, 'binary')
|
154
|
+
end
|
155
|
+
|
156
|
+
def podspec_json_file_name
|
157
|
+
"#{@name}.podspec.json"
|
158
|
+
end
|
159
|
+
|
160
|
+
def podspec_json_file
|
161
|
+
File.join(Dir.pwd, podspec_json_file_name)
|
162
|
+
end
|
163
|
+
|
164
|
+
def podspec
|
165
|
+
@spec ||= begin
|
166
|
+
"#{@name}.podspec"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -9,6 +9,8 @@ require 'cocoapods-mtxx-bin/command/bin/install'
|
|
9
9
|
require 'cocoapods-mtxx-bin/command/bin/repo'
|
10
10
|
require 'cocoapods-mtxx-bin/command/bin/spec'
|
11
11
|
require 'cocoapods-mtxx-bin/command/bin/buildAll'
|
12
|
+
require 'cocoapods-mtxx-bin/command/bin/outputSource'
|
13
|
+
require 'cocoapods-mtxx-bin/command/bin/upload'
|
12
14
|
require 'cocoapods-mtxx-bin/helpers'
|
13
15
|
# require 'cocoapods-mtxx-bin/native'
|
14
16
|
|
@@ -41,7 +43,7 @@ module Pod
|
|
41
43
|
self.summary = '组件二进制化插件'
|
42
44
|
self.description = <<-DESC.strip_heredoc
|
43
45
|
组件二进制化插件
|
44
|
-
|
46
|
+
|
45
47
|
利用源码私有源与二进制私有源实现对组件依赖类型的切换
|
46
48
|
DESC
|
47
49
|
|
@@ -10,6 +10,8 @@ module CBin
|
|
10
10
|
specs = specifications.map(&:name).select { |spec|
|
11
11
|
spec.include?(pod_name) && !spec.include?('/Binary')
|
12
12
|
}.sort!
|
13
|
+
xcode_version = `xcodebuild -version`.split(' ').join('')
|
14
|
+
specs << xcode_version
|
13
15
|
specs_str = specs.join('')
|
14
16
|
"#{original_version}.bin#{Digest::MD5.hexdigest(specs_str)[0,6]}"
|
15
17
|
end
|
@@ -94,12 +94,16 @@ module CBin
|
|
94
94
|
"#{@base_dir}/#{@pod_target}/Temp"
|
95
95
|
end
|
96
96
|
|
97
|
+
def configuration
|
98
|
+
"Debug"
|
99
|
+
end
|
100
|
+
|
97
101
|
def iphoneos
|
98
|
-
"
|
102
|
+
"#{configuration}-iphoneos"
|
99
103
|
end
|
100
104
|
|
101
105
|
def iphonesimulator
|
102
|
-
"
|
106
|
+
"#{configuration}-iphonesimulator"
|
103
107
|
end
|
104
108
|
|
105
109
|
# 需要排除的资源文件后缀
|
@@ -130,7 +134,7 @@ CONFIGURATION_TEMP_DIR=#{temp_dir} \
|
|
130
134
|
BUILD_ROOT=#{product_dir} \
|
131
135
|
BUILD_DIR=#{product_dir} \
|
132
136
|
clean build \
|
133
|
-
-configuration
|
137
|
+
-configuration #{configuration} \
|
134
138
|
-target #{@pod_target} \
|
135
139
|
-project #{project}
|
136
140
|
BUILD
|
@@ -1,11 +1,30 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
require 'parallel'
|
4
3
|
require 'cocoapods'
|
5
4
|
|
6
5
|
module Pod
|
7
6
|
class Installer
|
8
7
|
class Analyzer
|
8
|
+
alias old_fetch_external_sources fetch_external_sources
|
9
|
+
def fetch_external_sources(podfile_state)
|
10
|
+
verify_no_pods_with_different_sources!
|
11
|
+
deps = dependencies_to_fetch(podfile_state)
|
12
|
+
pods = pods_to_fetch(podfile_state)
|
13
|
+
return if deps.empty?
|
14
|
+
UI.section 'Fetching external sources' do
|
15
|
+
if installation_options.install_with_multi_threads
|
16
|
+
thread_count = installation_options.multi_threads_count
|
17
|
+
Parallel.each(deps.sort, in_threads: thread_count) do |dependency|
|
18
|
+
fetch_external_source(dependency, !pods.include?(dependency.root_name))
|
19
|
+
end
|
20
|
+
else
|
21
|
+
deps.sort.each do |dependency|
|
22
|
+
fetch_external_source(dependency, !pods.include?(dependency.root_name))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
9
28
|
# > 1.6.0
|
10
29
|
# all_specs[dep.name] 为 nil 会崩溃
|
11
30
|
# 主要原因是 all_specs 分析错误
|
@@ -32,15 +51,16 @@ module Pod
|
|
32
51
|
#
|
33
52
|
alias old_update_repositories update_repositories
|
34
53
|
def update_repositories
|
35
|
-
if installation_options.
|
54
|
+
if installation_options.update_source_with_multi_threads
|
36
55
|
# 并发更新私有源
|
37
56
|
# 这里多线程会导致 pod update 额外输出 --verbose 的内容
|
38
57
|
# 不知道为什么?
|
39
|
-
|
40
|
-
|
41
|
-
|
58
|
+
thread_count = installation_options.multi_threads_count
|
59
|
+
Parallel.each(sources.uniq(&:url), in_threads: thread_count) do |source|
|
60
|
+
if source.updateable?
|
61
|
+
sources_manager.update(source.name, true)
|
42
62
|
else
|
43
|
-
UI.message "Skipping `#{source.name}` update because the repository is not
|
63
|
+
UI.message "Skipping `#{source.name}` update because the repository is not an updateable repository."
|
44
64
|
end
|
45
65
|
end
|
46
66
|
@specs_updated = true
|
@@ -19,7 +19,10 @@ module Pod
|
|
19
19
|
env_option :install_with_multi_threads, false
|
20
20
|
|
21
21
|
# 是否多进程执行 update_repositories
|
22
|
-
env_option :
|
22
|
+
env_option :update_source_with_multi_threads, false
|
23
|
+
|
24
|
+
# 并发执行个数
|
25
|
+
option :multi_threads_count, 4
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -16,70 +16,32 @@ module Pod
|
|
16
16
|
alias old_install_pod_sources install_pod_sources
|
17
17
|
def install_pod_sources
|
18
18
|
if installation_options.install_with_multi_threads
|
19
|
-
|
20
|
-
install_pod_sources_for_version_in_1_4_0
|
21
|
-
elsif Pod.match_version?('~> 1.5')
|
22
|
-
install_pod_sources_for_version_above_1_5_0
|
23
|
-
else
|
24
|
-
old_install_pod_sources
|
25
|
-
end
|
19
|
+
install_pod_sources_with_multiple_threads
|
26
20
|
else
|
27
21
|
old_install_pod_sources
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
31
|
-
#
|
32
|
-
def
|
33
|
-
@installed_specs = []
|
34
|
-
pods_to_install = sandbox_state.added | sandbox_state.changed
|
35
|
-
title_options = { verbose_prefix: '-> '.green }
|
36
|
-
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
37
|
-
if pods_to_install.include?(spec.name)
|
38
|
-
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
39
|
-
previous = sandbox.manifest.version(spec.name)
|
40
|
-
title = "Installing #{spec.name} #{spec.version} (was #{previous})"
|
41
|
-
else
|
42
|
-
title = "Installing #{spec}"
|
43
|
-
end
|
44
|
-
UI.titled_section(title.green, title_options) do
|
45
|
-
install_source_of_pod(spec.name)
|
46
|
-
end
|
47
|
-
else
|
48
|
-
UI.titled_section("Using #{spec}", title_options) do
|
49
|
-
create_pod_installer(spec.name)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def install_pod_sources_for_version_above_1_5_0
|
25
|
+
# 多线程下载
|
26
|
+
def install_pod_sources_with_multiple_threads
|
56
27
|
@installed_specs = []
|
57
28
|
pods_to_install = sandbox_state.added | sandbox_state.changed
|
58
|
-
title_options = { verbose_prefix
|
59
|
-
|
60
|
-
|
61
|
-
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
29
|
+
title_options = { :verbose_prefix => '-> '.green }
|
30
|
+
thread_count = installation_options.multi_threads_count
|
31
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: thread_count) do |spec|
|
62
32
|
if pods_to_install.include?(spec.name)
|
63
33
|
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
64
34
|
current_version = spec.version
|
65
35
|
previous_version = sandbox.manifest.version(spec.name)
|
66
36
|
has_changed_version = current_version != previous_version
|
67
|
-
current_repo = analysis_result.specs_by_source.detect
|
68
|
-
|
69
|
-
end
|
70
|
-
current_repo &&= current_repo.url || current_repo.name
|
37
|
+
current_repo = analysis_result.specs_by_source.detect { |key, values| break key if values.map(&:name).include?(spec.name) }
|
38
|
+
current_repo &&= (Pod::TrunkSource::TRUNK_REPO_NAME if current_repo.name == Pod::TrunkSource::TRUNK_REPO_NAME) || current_repo.url || current_repo.name
|
71
39
|
previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
|
72
|
-
has_changed_repo = !previous_spec_repo.nil? && current_repo && (
|
40
|
+
has_changed_repo = !previous_spec_repo.nil? && current_repo && !current_repo.casecmp(previous_spec_repo).zero?
|
73
41
|
title = "Installing #{spec.name} #{spec.version}"
|
74
|
-
if has_changed_version && has_changed_repo
|
75
|
-
|
76
|
-
|
77
|
-
if has_changed_version && !has_changed_repo
|
78
|
-
title += " (was #{previous_version})"
|
79
|
-
end
|
80
|
-
if !has_changed_version && has_changed_repo
|
81
|
-
title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
|
82
|
-
end
|
42
|
+
title << " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if has_changed_version && has_changed_repo
|
43
|
+
title << " (was #{previous_version})" if has_changed_version && !has_changed_repo
|
44
|
+
title << " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if !has_changed_version && has_changed_repo
|
83
45
|
else
|
84
46
|
title = "Installing #{spec}"
|
85
47
|
end
|
@@ -87,7 +49,7 @@ module Pod
|
|
87
49
|
install_source_of_pod(spec.name)
|
88
50
|
end
|
89
51
|
else
|
90
|
-
UI.
|
52
|
+
UI.section("Using #{spec}", title_options[:verbose_prefix]) do
|
91
53
|
create_pod_installer(spec.name)
|
92
54
|
end
|
93
55
|
end
|
@@ -128,7 +90,15 @@ module Pod
|
|
128
90
|
# old_ensure_matching_version 会移除不是同一个 CocoaPods 版本的组件缓存
|
129
91
|
alias old_ensure_matching_version ensure_matching_version
|
130
92
|
def ensure_matching_version
|
131
|
-
@@lock.synchronize
|
93
|
+
@@lock.synchronize do
|
94
|
+
version_file = root + 'VERSION'
|
95
|
+
# version = version_file.read.strip if version_file.file?
|
96
|
+
|
97
|
+
# root.rmtree if version != Pod::VERSION && root.exist?
|
98
|
+
root.mkpath
|
99
|
+
|
100
|
+
version_file.open('w') { |f| f << Pod::VERSION }
|
101
|
+
end
|
132
102
|
end
|
133
103
|
end
|
134
104
|
end
|
@@ -22,10 +22,7 @@ module Pod
|
|
22
22
|
alias old_add_swift_library_compatibility_header_phase add_swift_library_compatibility_header_phase
|
23
23
|
|
24
24
|
def add_swift_library_compatibility_header_phase(native_target)
|
25
|
-
UI.puts "====== swift add_swift_library_compatibility_header_phase ======".yellow
|
26
25
|
if $ARGV[1] == "auto"
|
27
|
-
UI.puts "====== auto swift add_swift_library_compatibility_header_phase ======".yellow
|
28
|
-
|
29
26
|
if custom_module_map
|
30
27
|
raise Informative, 'Using Swift static libraries with custom module maps is currently not supported. ' \
|
31
28
|
"Please build `#{target.label}` as a framework or remove the custom module map."
|
@@ -80,13 +77,9 @@ module Pod
|
|
80
77
|
${BUILT_PRODUCTS_DIR}/Swift\ Compatibility\ Header/${PRODUCT_MODULE_NAME}-Swift.h
|
81
78
|
)
|
82
79
|
else
|
83
|
-
UI.puts "====== null swift add_swift_library_compatibility_header_phase ======".yellow
|
84
80
|
old_add_swift_library_compatibility_header_phase(native_target)
|
85
81
|
end
|
86
|
-
|
87
82
|
end
|
88
|
-
|
89
|
-
#-----------------------------------------------------------------------#
|
90
83
|
end
|
91
84
|
end
|
92
85
|
end
|
@@ -189,8 +189,8 @@ module Pod
|
|
189
189
|
|
190
190
|
raise Informative, "#{rspec.root.name}(#{spec_version})的podspec未找到,请执行 pod repo update 或添加相应的source源" unless source
|
191
191
|
|
192
|
-
UI.message "------------------- 分界线 -----------------------"
|
193
|
-
UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件(#{use_binary ? '二进制' : '源码'})."
|
192
|
+
# UI.message "------------------- 分界线 -----------------------"
|
193
|
+
# UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件(#{use_binary ? '二进制' : '源码'})."
|
194
194
|
|
195
195
|
begin
|
196
196
|
# 从新 source 中获取 spec,在bin archive中会异常,因为找不到
|
@@ -219,11 +219,11 @@ module Pod
|
|
219
219
|
else
|
220
220
|
ResolverSpecification.new(specification, used_by_only, source)
|
221
221
|
end
|
222
|
-
UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} (#{spec_version}) specification = #{specification} #{rspec} "
|
222
|
+
# UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} (#{spec_version}) specification = #{specification} #{rspec} "
|
223
223
|
rescue Pod::StandardError => e
|
224
224
|
# 没有从新的 source 找到对应版本组件,直接返回原 rspec
|
225
225
|
missing_binary_specs << rspec.spec if use_binary
|
226
|
-
UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
|
226
|
+
# UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
|
227
227
|
rspec
|
228
228
|
end
|
229
229
|
rspec
|
@@ -232,7 +232,7 @@ module Pod
|
|
232
232
|
|
233
233
|
if missing_binary_specs.any?
|
234
234
|
missing_binary_specs.uniq.each do |spec|
|
235
|
-
UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
|
235
|
+
# UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
|
236
236
|
end
|
237
237
|
# 下面的代码为了实现 auto 命令的 --all-make
|
238
238
|
Pod::Command::Bin::Archive.missing_binary_specs(missing_binary_specs)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-mtxx-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: cocoapods
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.10.2
|
34
|
+
- - "<="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.11.2
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- -
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 1.10.2
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.11.2
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: cocoapods-generate
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +108,7 @@ files:
|
|
102
108
|
- lib/cocoapods-mtxx-bin/command/bin/initHotKey.rb
|
103
109
|
- lib/cocoapods-mtxx-bin/command/bin/install.rb
|
104
110
|
- lib/cocoapods-mtxx-bin/command/bin/lib/lint.rb
|
111
|
+
- lib/cocoapods-mtxx-bin/command/bin/outputSource.rb
|
105
112
|
- lib/cocoapods-mtxx-bin/command/bin/repo.rb
|
106
113
|
- lib/cocoapods-mtxx-bin/command/bin/repo/push.rb
|
107
114
|
- lib/cocoapods-mtxx-bin/command/bin/repo/update.rb
|
@@ -109,6 +116,7 @@ files:
|
|
109
116
|
- lib/cocoapods-mtxx-bin/command/bin/spec/create.rb
|
110
117
|
- lib/cocoapods-mtxx-bin/command/bin/spec/lint.rb
|
111
118
|
- lib/cocoapods-mtxx-bin/command/bin/update.rb
|
119
|
+
- lib/cocoapods-mtxx-bin/command/bin/upload.rb
|
112
120
|
- lib/cocoapods-mtxx-bin/config/config.rb
|
113
121
|
- lib/cocoapods-mtxx-bin/config/config_asker.rb
|
114
122
|
- lib/cocoapods-mtxx-bin/config/config_builder.rb
|