cocoapods-meitu-bin 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +9 -9
- data/lib/cocoapods-meitu-bin/command/bin/get_checksum.rb +16 -1
- data/lib/cocoapods-meitu-bin/config/config.rb +23 -0
- data/lib/cocoapods-meitu-bin/gem_version.rb +1 -1
- data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +2 -2
- data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +1 -1
- data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +4 -0
- data/lib/cocoapods-meitu-bin/native/installer.rb +75 -14
- data/lib/cocoapods-meitu-bin/source_provider_hook.rb +39 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 159c257b8856aad76bd63ed408f8693d644a4798f040b68471e0591bbeb5d80b
|
4
|
+
data.tar.gz: 999806ccf28ed97b0e2e9180a372e668a026657e4e59c8ba89bad59e97b468cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd23b947bb5f41b041d867727fe88c519b8fd4b8b6b996fa5acce3a0daff88d527b30010159d3b622786c3e0f18d4dd639c01dbcdbd4f838c049d6f6b01cb25
|
7
|
+
data.tar.gz: 3780e408c04ef40e5f7dd4f46bd1bff10b2ffa5c47354b7a763229eb5aed4d15536cf5c4025dd1dc03b87ca2aec890a4b77a3968bb7d5087c69e9e6508a4fd4b
|
@@ -250,25 +250,25 @@ module Pod
|
|
250
250
|
end
|
251
251
|
# 构建产物
|
252
252
|
builder = Builder.new(pod_target, @sandbox.checkout_sources, @skip_simulator, @configuration)
|
253
|
-
result = builder.build
|
254
|
-
fail_pods << pod_target.pod_name unless result
|
255
|
-
next unless result
|
253
|
+
# result = builder.build
|
254
|
+
# fail_pods << pod_target.pod_name unless result
|
255
|
+
# next unless result
|
256
256
|
builder.create_binary
|
257
257
|
# 压缩并上传zip
|
258
258
|
zip_helper = ZipFileHelper.new(pod_target, version, builder.product_dir, builder.build_as_framework?, @configuration)
|
259
259
|
result = zip_helper.zip_lib
|
260
260
|
fail_pods << pod_target.pod_name unless result
|
261
261
|
next unless result
|
262
|
-
result = zip_helper.upload_zip_lib
|
263
|
-
fail_pods << pod_target.pod_name unless result
|
264
|
-
next unless result
|
262
|
+
# result = zip_helper.upload_zip_lib
|
263
|
+
# fail_pods << pod_target.pod_name unless result
|
264
|
+
# next unless result
|
265
265
|
# 生成二进制podspec并上传
|
266
266
|
podspec_creator = PodspecUtil.new(pod_target, version, builder.build_as_framework?, @configuration)
|
267
267
|
bin_spec = podspec_creator.create_binary_podspec
|
268
268
|
bin_spec_file = podspec_creator.write_binary_podspec(bin_spec)
|
269
|
-
result = podspec_creator.push_binary_podspec(bin_spec_file)
|
270
|
-
fail_pods << pod_target.pod_name unless result
|
271
|
-
success_pods << pod_target.pod_name if result
|
269
|
+
# result = podspec_creator.push_binary_podspec(bin_spec_file)
|
270
|
+
# fail_pods << pod_target.pod_name unless result
|
271
|
+
# success_pods << pod_target.pod_name if result
|
272
272
|
rescue Pod::StandardError => e
|
273
273
|
UI.info "`#{pod_target}`编译失败,原因:#{e}".red
|
274
274
|
fail_pods << pod_target.pod_name
|
@@ -25,7 +25,22 @@ module Pod
|
|
25
25
|
# 计算checksum值
|
26
26
|
def calculate_checksum(file_path)
|
27
27
|
return "" unless File.exist?(file_path)
|
28
|
-
content =
|
28
|
+
content = ""
|
29
|
+
lines = []
|
30
|
+
#过滤出实际使用pod
|
31
|
+
File.open(file_path, 'r') do |file|
|
32
|
+
file.each_line do |line|
|
33
|
+
new_line = line.strip
|
34
|
+
if new_line.start_with?("pod")
|
35
|
+
lines << new_line
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
#给获取的pod list 排序,排除因组件顺序调整导致获取SHA1值不一样
|
40
|
+
lines = lines.sort
|
41
|
+
lines.each do |line|
|
42
|
+
content << line
|
43
|
+
end
|
29
44
|
checksum = Digest::SHA1.hexdigest(content)
|
30
45
|
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
31
46
|
return checksum
|
@@ -153,15 +153,38 @@ class PodUpdateConfig
|
|
153
153
|
@@lockfile = nil
|
154
154
|
@@repo_update = true
|
155
155
|
@@prepare_time = 0
|
156
|
+
@@checksum = nil
|
157
|
+
@@large_pod_hash = {}
|
158
|
+
@@is_mtxx = false
|
159
|
+
|
156
160
|
def self.add_value(value)
|
157
161
|
@@pods << value
|
158
162
|
end
|
163
|
+
def self.set_is_mtxx(value)
|
164
|
+
@@is_mtxx = value
|
165
|
+
end
|
166
|
+
def self.is_mtxx()
|
167
|
+
@@is_mtxx
|
168
|
+
end
|
159
169
|
def self.set_lockfile(path)
|
160
170
|
@@lockfile = Pod::Lockfile.from_file(path) if path
|
161
171
|
end
|
162
172
|
def self.lockfile()
|
163
173
|
@@lockfile
|
164
174
|
end
|
175
|
+
def self.set_checksum(checksum)
|
176
|
+
@@checksum = checksum
|
177
|
+
end
|
178
|
+
def self.checksum
|
179
|
+
@@checksum
|
180
|
+
end
|
181
|
+
def self.add_pod_hash(name,size)
|
182
|
+
@@large_pod_hash[name]=size
|
183
|
+
end
|
184
|
+
def self.large_pod_hash
|
185
|
+
@@large_pod_hash
|
186
|
+
end
|
187
|
+
|
165
188
|
# 一个类方法,用于显示数组中的值
|
166
189
|
def self.repo_update
|
167
190
|
@@repo_update
|
@@ -10,7 +10,7 @@ module CBin
|
|
10
10
|
@skip_simulator = skip_simulator
|
11
11
|
@configuration = configuration
|
12
12
|
@file_accessors = pod_target.file_accessors unless pod_target.nil?
|
13
|
-
@base_dir = "#{Pathname.pwd}/
|
13
|
+
@base_dir = "#{Pathname.pwd}/all_build/Build"
|
14
14
|
end
|
15
15
|
|
16
16
|
# 构建
|
@@ -92,7 +92,7 @@ module CBin
|
|
92
92
|
|
93
93
|
# xxx.framework 所在目录
|
94
94
|
def product_dir
|
95
|
-
@product_dir = "#{@base_dir}
|
95
|
+
@product_dir = "#{@base_dir}/Products"
|
96
96
|
@product_dir
|
97
97
|
end
|
98
98
|
|
@@ -48,7 +48,7 @@ module CBin
|
|
48
48
|
# podspec写入文件
|
49
49
|
def write_binary_podspec(spec)
|
50
50
|
UI.info "写入podspec:`#{@pod_target}`".yellow
|
51
|
-
podspec_dir = "#{Pathname.pwd}/
|
51
|
+
podspec_dir = "#{Pathname.pwd}/all_build/Build/Products/podspec"
|
52
52
|
FileUtils.mkdir(podspec_dir) unless File.exist?(podspec_dir)
|
53
53
|
file = "#{podspec_dir}/#{@pod_target.pod_name}.podspec.json"
|
54
54
|
FileUtils.rm_rf(file) if File.exist?(file)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cocoapods-meitu-bin/config/config'
|
1
2
|
module CBin
|
2
3
|
class PodSize
|
3
4
|
include Pod
|
@@ -15,6 +16,9 @@ module CBin
|
|
15
16
|
return
|
16
17
|
end
|
17
18
|
@@lock.synchronize do
|
19
|
+
size = pod[:size].to_i
|
20
|
+
size = ('%.0f' % (size / 1024)).to_f
|
21
|
+
PodUpdateConfig.add_pod_hash(pod[:name],size)
|
18
22
|
File.open(@@tmp_file_path, "a") do |f|
|
19
23
|
f.write(format_pod_size(pod))
|
20
24
|
end
|
@@ -2,6 +2,9 @@ require 'cocoapods/installer/project_cache/target_metadata.rb'
|
|
2
2
|
require 'parallel'
|
3
3
|
require 'cocoapods'
|
4
4
|
require 'xcodeproj'
|
5
|
+
require 'json'
|
6
|
+
require 'timeout'
|
7
|
+
require 'net/http'
|
5
8
|
require 'cocoapods-meitu-bin/native/pod_source_installer'
|
6
9
|
require 'cocoapods-meitu-bin/helpers/pod_size_helper'
|
7
10
|
require 'cocoapods-meitu-bin/config/config'
|
@@ -114,17 +117,6 @@ module Pod
|
|
114
117
|
def perform_post_install_actions
|
115
118
|
start_time = Time.now
|
116
119
|
old_perform_post_install_actions
|
117
|
-
cost_time_hash['perform_post_install_actions'] = Time.now - start_time
|
118
|
-
# 打印有多少个源码库,多少二进制库
|
119
|
-
print_source_bin_statistics
|
120
|
-
# 打印耗时
|
121
|
-
print_cost_time
|
122
|
-
# 打印大小大于阈值的库
|
123
|
-
CBin::PodSize.print_pods
|
124
|
-
end
|
125
|
-
|
126
|
-
# 打印有多少个源码库,多少二进制库
|
127
|
-
def print_source_bin_statistics
|
128
120
|
source_pods = []
|
129
121
|
bin_pods = []
|
130
122
|
@pod_targets.map do |target|
|
@@ -134,16 +126,85 @@ module Pod
|
|
134
126
|
bin_pods << target
|
135
127
|
end
|
136
128
|
end
|
137
|
-
|
129
|
+
cost_time_hash['perform_post_install_actions'] = Time.now - start_time
|
130
|
+
|
131
|
+
# 打印有多少个源码库,多少二进制库
|
132
|
+
print_source_bin_statistics(source_pods,bin_pods)
|
133
|
+
# 打印耗时
|
134
|
+
print_cost_time
|
135
|
+
# 打印大小大于阈值的库
|
136
|
+
CBin::PodSize.print_pods
|
137
|
+
if PodUpdateConfig.is_mtxx
|
138
|
+
begin
|
139
|
+
data = {
|
140
|
+
"meitu_bin_version" => CBin::VERSION,
|
141
|
+
"large_pod_hash" => PodUpdateConfig.large_pod_hash
|
142
|
+
}
|
143
|
+
all_time = 0
|
144
|
+
cost_time_hash.each do |key, value|
|
145
|
+
time = ('%.1f' % value).to_f
|
146
|
+
data[key] = time
|
147
|
+
all_time = all_time + time
|
148
|
+
end
|
149
|
+
data["pod_time"] = all_time
|
150
|
+
binary_rate = bin_pods.size.to_f / @pod_targets.size.to_f
|
151
|
+
data["binary_rate"] = ('%.2f' % binary_rate).to_f
|
152
|
+
data["source_count"] = source_pods.size
|
153
|
+
data["binary_count"] = bin_pods.size
|
154
|
+
data["targets_count"] = @pod_targets.size
|
155
|
+
source = "unknown user"
|
156
|
+
if ENV['NODE_NAME']
|
157
|
+
source = ENV['NODE_NAME']
|
158
|
+
else
|
159
|
+
source = `git config user.email`
|
160
|
+
source = source.gsub("\n", "")
|
161
|
+
end
|
162
|
+
data_json = {
|
163
|
+
"subject" => "MTXX pod time profiler",
|
164
|
+
"type" => "pod_time_profiler",
|
165
|
+
"source" => source,
|
166
|
+
"data" => data
|
167
|
+
}
|
168
|
+
begin
|
169
|
+
timeout(3) do
|
170
|
+
json_data = [data_json].to_json
|
171
|
+
api_url = "http://event-adapter-internal.prism.cloud.meitu-int.com/api/v1/http/send/batch"
|
172
|
+
headers = { "Content-Type" => "application/json" }
|
173
|
+
uri = URI(api_url)
|
174
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
175
|
+
request = Net::HTTP::Post.new(uri.path, headers)
|
176
|
+
request.body = json_data
|
177
|
+
response = http.request(request)
|
178
|
+
if ENV['MEITU_USE_POD_SOURCE'] == '1'
|
179
|
+
puts "pod_time_profiler: Response code: #{response.code}"
|
180
|
+
puts "pod_time_profiler: data_json: #{data_json}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
rescue Timeout::Error
|
184
|
+
puts "pod_time_profiler: 上报pod操作操作已超时"
|
185
|
+
end
|
186
|
+
rescue => error
|
187
|
+
puts "pod_time_profiler: 上报pod 耗时统计失败,失败原因:#{error}"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# 打印有多少个源码库,多少二进制库
|
194
|
+
def print_source_bin_statistics(source_pods,bin_pods)
|
195
|
+
|
196
|
+
UI.puts "\npod_time_profiler: 总共有 #{@pod_targets.size} 个Pod库,二进制有 #{bin_pods.size} 个,源码有 #{source_pods.size} 个".green
|
138
197
|
# 打印二进制库
|
139
198
|
if ENV['statistics_bin'] == '1'
|
140
199
|
UI.puts "二进制库:".green
|
141
200
|
UI.puts bin_pods
|
142
201
|
end
|
143
202
|
# 打印源码库
|
144
|
-
if ENV['
|
203
|
+
if ENV['MEITU_USE_POD_SOURCE'] == '1'
|
145
204
|
UI.puts "源码库:".green
|
146
|
-
|
205
|
+
source_pods.each do |pod|
|
206
|
+
UI.puts "pod_time_profiler: #{pod.name}"
|
207
|
+
end
|
147
208
|
end
|
148
209
|
end
|
149
210
|
|
@@ -5,26 +5,39 @@ require 'cocoapods/user_interface'
|
|
5
5
|
require 'digest'
|
6
6
|
require 'yaml'
|
7
7
|
require 'cocoapods'
|
8
|
-
|
8
|
+
require 'json'
|
9
|
+
require 'net/http'
|
9
10
|
#获取服务端podfile.lock文件
|
10
11
|
def get_podfile_lock
|
11
12
|
begin
|
12
13
|
# 默认是获取要获取服务端podfile.lock文件
|
13
14
|
is_load_podfile_lock = true
|
15
|
+
#目前只支持MTXX target "MTXX" 项目 #想要支持其他项目可以添加对应 target "xxx"
|
16
|
+
content = File.read(Pod::Config.instance.podfile_path)
|
17
|
+
if content
|
18
|
+
if content.include?("target \"MTXX\"")
|
19
|
+
is_load_podfile_lock = true
|
20
|
+
PodUpdateConfig.set_is_mtxx(true)
|
21
|
+
else
|
22
|
+
is_load_podfile_lock = false
|
23
|
+
PodUpdateConfig.set_is_mtxx(false)
|
24
|
+
end
|
25
|
+
end
|
14
26
|
# MEITU_LOAD_CACHE_PODFILE_LOCK 为false时不获取服务端podfile.lock文件
|
15
27
|
if ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] && ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] == 'false'
|
16
28
|
is_load_podfile_lock = false
|
17
29
|
end
|
18
30
|
# 判断是否有update参数 时不获取服务端podfile.lock文件
|
19
31
|
ARGV.each do |arg|
|
20
|
-
if arg == 'update'
|
32
|
+
if arg == 'update' || arg == '--no-cloud'
|
21
33
|
is_load_podfile_lock = false
|
22
34
|
end
|
23
35
|
end
|
24
36
|
# podfile.lock文件下载和使用逻辑
|
25
37
|
if is_load_podfile_lock
|
26
38
|
#获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
|
27
|
-
checksum = Pod::Config.instance.
|
39
|
+
checksum = get_checksum(Pod::Config.instance.podfile_path)
|
40
|
+
PodUpdateConfig.set_checksum(checksum)
|
28
41
|
Pod::UI.puts "当前podfile文件的checksum:#{checksum}".green
|
29
42
|
# zip下载地址
|
30
43
|
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
|
@@ -159,10 +172,25 @@ def get_branch_name
|
|
159
172
|
branch_value = branch_value.gsub("\n", "")
|
160
173
|
branch_value
|
161
174
|
end
|
162
|
-
|
175
|
+
#过滤出来podfile中实际有效每行内容,拼接成字符串在SHA1 后UTF-8编码下 用来当做依赖缓存文件的key
|
163
176
|
def get_checksum(file_path)
|
164
177
|
return nil unless File.exist?(file_path)
|
165
|
-
content =
|
178
|
+
content = ""
|
179
|
+
lines = []
|
180
|
+
#过滤出实际使用pod
|
181
|
+
File.open(file_path, 'r') do |file|
|
182
|
+
file.each_line do |line|
|
183
|
+
new_line = line.strip
|
184
|
+
if new_line.start_with?("pod")
|
185
|
+
lines << new_line
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
#给获取的pod list 排序,排除因组件顺序调整导致获取SHA1值不一样
|
190
|
+
lines = lines.sort
|
191
|
+
lines.each do |line|
|
192
|
+
content << line
|
193
|
+
end
|
166
194
|
checksum = Digest::SHA1.hexdigest(content)
|
167
195
|
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
168
196
|
return checksum
|
@@ -217,19 +245,13 @@ end
|
|
217
245
|
# 注册 pod install 钩子
|
218
246
|
Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
|
219
247
|
#基于podfile的checksum上报云端podfile.lock文件
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
upload_podfile_lock(checksum)
|
226
|
-
end
|
227
|
-
#判断是否在 mbox 工作目录执行pod install
|
228
|
-
if system("mbox status > /dev/null 2>&1")
|
229
|
-
upload_mbox_podfile_lock
|
248
|
+
if PodUpdateConfig.is_mtxx
|
249
|
+
if PodUpdateConfig.checksum
|
250
|
+
upload_podfile_lock(PodUpdateConfig.checksum)
|
251
|
+
end
|
252
|
+
upload_branch_podfile_lock
|
230
253
|
end
|
231
|
-
|
232
|
-
upload_branch_podfile_lock
|
254
|
+
|
233
255
|
end
|
234
256
|
|
235
257
|
Pod::HooksManager.register('cocoapods-meitu-bin', :source_provider) do |context, _|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-meitu-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|