cocoapods-meitu-bin 1.2.3 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebb5a3689a2c0965a08d686c8b9065f4b15e59fc7949eb124aa467a192268f97
4
- data.tar.gz: 1ae316557c112e0e7352d459d09b233e2f9ad1f85563ea45005194ffaa157705
3
+ metadata.gz: d27332c19899d2616ca39da9eb2d13d98184216975d6f1408bdb162856bcc24a
4
+ data.tar.gz: eee1c74f1fa28b591eb67f7bddeab453c070ace04fccc336cb9ada5935b11364
5
5
  SHA512:
6
- metadata.gz: 7db6ab9850a98c37bc3f94eb9d95f0f1d4b5212f1ee8fd46f6e70805272fd4e920c6637f3ea132cabce9445bfd1834951a629cb8f6ca614b1d3671670738ae19
7
- data.tar.gz: 7037358e37bba3f04a1b07ef63890f133b53e4895cb4951d2880a06ba31b3bde35dad5d304489b5e91dff4589f07ec65a767fe1786a390e3fee016f2f9640e9e
6
+ metadata.gz: a33d6edea1cc51c1a0a17717235e2ee102d7d2ca207d3c1560b3c3ea11082b01c545f9152c8e7e06f1d5ee52381049447418fad9fc290d94044fa3ced8cb090e
7
+ data.tar.gz: db8b46477b4cc6c4533c28f0130f623650f48cf6bb88b56f1e0c0aedd0c5d4216fc09de5ba4456c97121d00ed7f3a29f1327d757d4710370e784fa77ce91d520
@@ -5,6 +5,7 @@ require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
5
5
  require 'cocoapods-meitu-bin/config/config'
6
6
  require 'yaml'
7
7
  require 'digest'
8
+ # require 'concurrent'
8
9
 
9
10
  module Pod
10
11
  class Command
@@ -28,6 +29,7 @@ module Pod
28
29
  def self.options
29
30
  [
30
31
  %w[--clean 全部二进制包制作完成后删除编译临时目录],
32
+ %w[--shell-project 是否依赖壳工程编译产物一次编译生成所有组件的编译产物],
31
33
  %w[--clean-single 每制作完一个二进制包就删除该编译临时目录],
32
34
  %w[--repo-update 更新Podfile中指定的repo仓库],
33
35
  %w[--full-build 是否全量打包],
@@ -40,6 +42,7 @@ module Pod
40
42
  @pods = argv.shift_argument
41
43
  @clean = argv.flag?('clean', false)
42
44
  @clean_single = argv.flag?('clean-single', false)
45
+ @shell_project = argv.flag?('shell-project', false)
43
46
  @repo_update = argv.flag?('repo-update', false)
44
47
  @full_build = argv.flag?('full-build', false)
45
48
  @skip_simulator = argv.flag?('skip-simulator', false)
@@ -70,7 +73,11 @@ module Pod
70
73
  # 删除编译产物
71
74
  clean_build_pods
72
75
  # 编译所有pod_targets
73
- results = build_pod_targets
76
+ #根据@shell_project 判断是执行 build_shell_project_pod_targets 还是 build_pod_targets
77
+ if @shell_project
78
+ PodUpdateConfig.set_shell_project
79
+ end
80
+ results = @shell_project ? build_shell_project_pod_targets : build_pod_targets
74
81
  # 执行post_build命令
75
82
  post_build(results)
76
83
  # 删除编译产物
@@ -292,6 +299,129 @@ module Pod
292
299
  results
293
300
  end
294
301
  end
302
+ # 基于壳工程编译产物进行个组件的zip压缩 上传和对应二进制podspec生成上传
303
+ def build_shell_project_pod_targets
304
+ UI.title "Build all pod targets(#{@full_build ? '全量打包' : '非全量打包'})".green do
305
+ pod_targets = @analyze_result.pod_targets.uniq
306
+ success_pods = []
307
+ fail_pods = []
308
+ local_pods = []
309
+ external_pods = []
310
+ binary_pods = []
311
+ created_pods = []
312
+ # # 指定线程池的大小(例如,这里创建一个拥有 16 个线程的池)
313
+ # pool = Concurrent::ThreadPoolExecutor.new(max_threads: 16)
314
+ # # 创建一个互斥锁
315
+ # mutex = Mutex.new
316
+ pod_targets.map do |pod_target|
317
+ begin
318
+ version = @version_helper.version(pod_target.pod_name, pod_target.root_spec.version.to_s, @analyze_result.specifications, @configuration, podfile.include_dependencies?)
319
+ # 黑名单(不分全量和非全量)
320
+ next if skip_build?(pod_target)
321
+ # 白名单(有白名单,只看白名单,不分全量和非全量)
322
+ next if !@write_list.nil? && !@write_list.empty? && !@write_list.include?(pod_target.pod_name)
323
+ # 本地库
324
+ if @sandbox.local?(pod_target.pod_name)
325
+ local_pods << pod_target.pod_name
326
+ show_skip_tip("#{pod_target.pod_name} 是本地库")
327
+ next
328
+ end
329
+ # 外部源(如 git)
330
+ if @sandbox.checkout_sources[pod_target.pod_name]
331
+ external_pods << pod_target.pod_name
332
+ show_skip_tip("#{pod_target.pod_name} 以external方式引入")
333
+ next
334
+ end
335
+ # 无源码
336
+ if !@sandbox.local?(pod_target.pod_name) && !pod_target.should_build?
337
+ binary_pods << pod_target.pod_name
338
+ show_skip_tip("#{pod_target.pod_name} 无需编译")
339
+ next
340
+ end
341
+ # 非全量编译、不在白名单中且已经有相应的二进制版本
342
+ if has_created_binary?(pod_target.pod_name, version)
343
+ created_pods << pod_target.pod_name
344
+ show_skip_tip("#{pod_target.pod_name}(#{version}) 已经有二进制版本了")
345
+ next
346
+ end
347
+ # # 提交一个任务给线程池
348
+ # pool.post do
349
+ # # 在这里执行你的任务逻辑
350
+ # # 构建产物
351
+ # builder = Builder.new(pod_target, @sandbox.checkout_sources, @skip_simulator, @configuration)
352
+ # # result = builder.build
353
+ # # fail_pods << pod_target.pod_name unless result
354
+ # # next unless result
355
+ # builder.create_binary
356
+ # # 压缩并上传zip
357
+ # zip_helper = ZipFileHelper.new(pod_target, version, builder.product_dir, builder.build_as_framework?, @configuration)
358
+ # result = zip_helper.zip_lib
359
+ # mutex.synchronize do
360
+ # # 在互斥锁的保护下,安全地修改共享资源
361
+ # fail_pods << pod_target.pod_name unless result
362
+ # end
363
+ # next unless result
364
+ # # result = zip_helper.upload_zip_lib
365
+ # # fail_pods << pod_target.pod_name unless result
366
+ # # next unless result
367
+ # # 生成二进制podspec并上传
368
+ # podspec_creator = PodspecUtil.new(pod_target, version, builder.build_as_framework?, @configuration)
369
+ # bin_spec = podspec_creator.create_binary_podspec
370
+ # bin_spec_file = podspec_creator.write_binary_podspec(bin_spec)
371
+ # # result = podspec_creator.push_binary_podspec(bin_spec_file)
372
+ # # fail_pods << pod_target.pod_name unless result
373
+ # mutex.synchronize do
374
+ # # 在互斥锁的保护下,安全地修改共享资源
375
+ # success_pods << pod_target.pod_name if result
376
+ # end
377
+ # end
378
+ # 在这里执行你的任务逻辑
379
+ # 构建产物
380
+ builder = Builder.new(pod_target, @sandbox.checkout_sources, @skip_simulator, @configuration)
381
+ # result = builder.build
382
+ # fail_pods << pod_target.pod_name unless result
383
+ # next unless result
384
+ builder.create_binary
385
+ # 压缩并上传zip
386
+ zip_helper = ZipFileHelper.new(pod_target, version, builder.product_dir, builder.build_as_framework?, @configuration)
387
+ result = zip_helper.zip_lib
388
+ fail_pods << pod_target.pod_name unless result
389
+ next unless result
390
+ result = zip_helper.upload_zip_lib
391
+ fail_pods << pod_target.pod_name unless result
392
+ next unless result
393
+ # 生成二进制podspec并上传
394
+ podspec_creator = PodspecUtil.new(pod_target, version, builder.build_as_framework?, @configuration)
395
+ bin_spec = podspec_creator.create_binary_podspec
396
+ bin_spec_file = podspec_creator.write_binary_podspec(bin_spec)
397
+ result = podspec_creator.push_binary_podspec(bin_spec_file)
398
+ fail_pods << pod_target.pod_name unless result
399
+ success_pods << pod_target.pod_name if result
400
+ rescue Pod::StandardError => e
401
+ UI.info "`#{pod_target}`失败,原因:#{e}".red
402
+ fail_pods << pod_target.pod_name
403
+ next
404
+ end
405
+ end
406
+ # 关闭线程池,等待所有任务完成
407
+ # pool.shutdown
408
+ # pool.wait_for_termination
409
+ results = {
410
+ 'Total' => pod_targets,
411
+ 'Success' => success_pods,
412
+ 'Fail' => fail_pods,
413
+ 'Local' => local_pods,
414
+ 'External' => external_pods,
415
+ 'No Source File' => binary_pods,
416
+ 'Created Binary' => created_pods,
417
+ 'Black List' => @black_list || [],
418
+ 'Write List' => @write_list || []
419
+ }
420
+
421
+ show_results(results)
422
+ results
423
+ end
424
+ end
295
425
 
296
426
  def show_skip_tip(title)
297
427
  UI.info title.yellow
@@ -156,7 +156,16 @@ class PodUpdateConfig
156
156
  @@checksum = nil
157
157
  @@large_pod_hash = {}
158
158
  @@is_mtxx = false
159
+ @@is_clear = false
160
+ @@shell_project = false
159
161
 
162
+
163
+ def self.set_shell_project
164
+ @@shell_project = true
165
+ end
166
+ def self.shell_project
167
+ @@shell_project
168
+ end
160
169
  def self.add_value(value)
161
170
  @@pods << value
162
171
  end
@@ -205,5 +214,9 @@ class PodUpdateConfig
205
214
  def self.clear
206
215
  @@pods = []
207
216
  @@lockfile = nil
217
+ @@is_clear = true
218
+ end
219
+ def self.is_clear
220
+ @@is_clear
208
221
  end
209
222
  end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "1.2.3"
2
+ VERSION = "1.3.1"
3
3
  end
4
4
 
5
5
  module Pod
@@ -1,3 +1,4 @@
1
+ require 'cocoapods-meitu-bin/config/config'
1
2
 
2
3
  module CBin
3
4
  module BuildAll
@@ -11,6 +12,9 @@ module CBin
11
12
  @configuration = configuration
12
13
  @file_accessors = pod_target.file_accessors unless pod_target.nil?
13
14
  @base_dir = "#{Pathname.pwd}/build_pods"
15
+ if PodUpdateConfig.shell_project
16
+ @base_dir = "#{Pathname.pwd}/all_build/Build"
17
+ end
14
18
  end
15
19
 
16
20
  # 构建
@@ -92,7 +96,7 @@ module CBin
92
96
 
93
97
  # xxx.framework 所在目录
94
98
  def product_dir
95
- @product_dir = "#{@base_dir}/#{@pod_target}/Products"
99
+ @product_dir = "#{@base_dir}/Products"
96
100
  @product_dir
97
101
  end
98
102
 
@@ -1,4 +1,4 @@
1
-
1
+ require 'cocoapods-meitu-bin/config/config'
2
2
  module CBin
3
3
  module BuildAll
4
4
  class PodspecUtil
@@ -48,11 +48,10 @@ 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}/build_pods/#{@pod_target}/Products/podspec"
51
+ podspec_dir = PodUpdateConfig.shell_project ? "#{Pathname.pwd}/all_build/Build/Products/podspec" : "#{Pathname.pwd}/build_pods/#{@pod_target}/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)
55
-
56
55
  File.open(file, "w+") do |f|
57
56
  f.write(spec.to_pretty_json)
58
57
  end
@@ -47,6 +47,9 @@ module Pod
47
47
  if PodUpdateConfig.lockfile
48
48
  self.instance_variable_set("@lockfile",PodUpdateConfig.lockfile)
49
49
  end
50
+ if PodUpdateConfig.is_clear
51
+ self.instance_variable_set("@lockfile",PodUpdateConfig.lockfile)
52
+ end
50
53
 
51
54
  plugin_sources = run_source_provider_hooks
52
55
  analyzer = create_analyzer(plugin_sources)
@@ -132,7 +132,7 @@ module Pod
132
132
 
133
133
  start_time = Time.now
134
134
  @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
135
- UI.puts "Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
135
+ UI.puts "pod_time_profiler: Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
136
136
  resolver_specs_by_target
137
137
  rescue Molinillo::ResolverError => e
138
138
  handle_resolver_error(e)
@@ -12,7 +12,10 @@ def get_podfile_lock
12
12
  begin
13
13
  # 默认是获取要获取服务端podfile.lock文件
14
14
  is_load_podfile_lock = true
15
- #目前只支持MTXX target "MTXX" 项目 #想要支持其他项目可以添加对应 target "xxx"
15
+ #获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
16
+ checksum = get_checksum(Pod::Config.instance.podfile_path)
17
+ PodUpdateConfig.set_checksum(checksum)
18
+ #目前只支持MTXX target "MTXX" 项目 想要支持其他项目可以添加对应 target "xxx"
16
19
  content = File.read(Pod::Config.instance.podfile_path)
17
20
  if content
18
21
  if content.include?("target \"MTXX\"")
@@ -35,16 +38,13 @@ def get_podfile_lock
35
38
  end
36
39
  # podfile.lock文件下载和使用逻辑
37
40
  if is_load_podfile_lock
38
- #获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
39
- checksum = get_checksum(Pod::Config.instance.podfile_path)
40
- PodUpdateConfig.set_checksum(checksum)
41
- Pod::UI.puts "当前podfile文件的checksum:#{checksum}".green
41
+ Pod::UI.puts "pod_time_profiler: 当前podfile文件的checksum:#{checksum}".green
42
42
  # zip下载地址
43
43
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
44
44
  # 判断服务端是否存在该podfile.lock
45
45
  is_load_podfile_lock = false
46
46
  if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
47
- Pod::UI.puts "匹配到精准podfile.lock文件,使用当前podfile文件的checksum:#{checksum}获取对应的podfile.lock文件".green
47
+ Pod::UI.puts "pod_time_profiler: 匹配到精准podfile.lock文件,使用当前podfile文件的checksum:#{checksum}获取对应的podfile.lock文件".green
48
48
  is_load_podfile_lock = true
49
49
  end
50
50
 
@@ -52,27 +52,27 @@ def get_podfile_lock
52
52
  branch_value = get_branch_name
53
53
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{branch_value}/podfile.lock.zip"
54
54
  if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
55
- Pod::UI.puts "无法匹配到精准podfile.lock文件,使用当前分支:#{branch_value} 对应的podfile.lock文件".green
55
+ Pod::UI.puts "pod_time_profiler: 无法匹配到精准podfile.lock文件,使用当前分支:#{branch_value} 对应的podfile.lock文件".green
56
56
  is_load_podfile_lock = true
57
57
  end
58
58
  #兜底使用develop的podfile.lock
59
59
  if !is_load_podfile_lock
60
- Pod::UI.puts "服务端不存在该podfile.lock文件,使用develop分支的podfile.lock文件兜底".green
60
+ Pod::UI.puts "pod_time_profiler: 服务端不存在该podfile.lock文件,使用develop分支的podfile.lock文件兜底".green
61
61
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/develop/podfile.lock.zip"
62
62
  is_load_podfile_lock = true
63
63
  end
64
64
  end
65
65
  # 判断是否需要下载podfile.lock文件
66
66
  if is_load_podfile_lock
67
- Pod::UI.puts "获取服务端存储的podfile.lcok文件".green
67
+ Pod::UI.puts "pod_time_profiler: 获取服务端存储的podfile.lcok文件".green
68
68
  #下载并解压的podfile.zip文件
69
69
  if system("curl -O #{curl} > /dev/null 2>&1") && system("unzip -o podfile.lock.zip > /dev/null 2>&1")
70
- Pod::UI.puts "下载并解压podfile.lcok文件成功".green
70
+ Pod::UI.puts "pod_time_profiler: 下载并解压podfile.lcok文件成功".green
71
71
  `rm -rf podfile.lock.zip`
72
72
  # 设置获取到的podfile.lock对象
73
73
  PodUpdateConfig.set_lockfile(Pod::Config.instance.installation_root + 'Podfile.lock')
74
74
  #获取analyzer
75
- Pod::UI.puts "提前根据checksum命中podfile.lcok进行依赖分析".green
75
+ Pod::UI.puts "pod_time_profiler: 提前根据checksum命中podfile.lcok进行依赖分析".green
76
76
  analyzer = Pod::Installer::Analyzer.new(
77
77
  Pod::Config.instance.sandbox,
78
78
  Pod::Config.instance.podfile,
@@ -89,13 +89,13 @@ def get_podfile_lock
89
89
  end
90
90
  end
91
91
  else
92
- puts "获取podfile.lcok文件失败"
92
+ puts "pod_time_profiler: 获取podfile.lcok文件失败"
93
93
  `rm -rf podfile.lock.zip`
94
94
  end
95
95
  end
96
96
  end
97
97
  rescue => error
98
- puts "podfile.lcok相关处理发生异常,报错原因:#{error}"
98
+ puts "pod_time_profiler: podfile.lcok相关处理发生异常,报错原因:#{error}"
99
99
  PodUpdateConfig.clear
100
100
  `rm -rf podfile.lock.zip`
101
101
  `rm -rf podfile.lock`
@@ -109,20 +109,20 @@ def upload_podfile_lock(checksum,upload = false)
109
109
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
110
110
  # 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
111
111
  if upload || !system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
112
- Pod::UI.puts "根据checksum:#{checksum}上报podfile.lcok文件到服务端".green
112
+ Pod::UI.puts "pod_time_profiler: 根据checksum:#{checksum}上报podfile.lcok文件到服务端".green
113
113
  if upload
114
- puts "mbox工作目录/mtxx/MTXX/podfile 对应的checksum = #{checksum}"
114
+ puts "pod_time_profiler: mbox工作目录/mtxx/MTXX/podfile 对应的checksum = #{checksum}"
115
115
  end
116
116
  if system("zip podfile.lock.zip Podfile.lock > /dev/null 2>&1") && system("curl -F \"name=MTXX\" -F \"version=#{checksum}\" -F \"file=@#{Pathname.pwd}/podfile.lock.zip\" http://nezha.community.cloud.meitu.com/file/upload.json > /dev/null 2>&1")
117
- Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
117
+ Pod::UI.puts "pod_time_profiler: 上报podfile.lcok文件到服务端成功".green
118
118
  `rm -rf podfile.lock.zip`
119
119
  else
120
- Pod::UI.puts "上报podfile.lcok文件到服务端失败".red
120
+ Pod::UI.puts "pod_time_profiler: 上报podfile.lcok文件到服务端失败".red
121
121
  `rm -rf podfile.lock.zip`
122
122
  end
123
123
  end
124
124
  rescue => error
125
- puts "上传podfile.lcok文件失败,失败原因:#{error}"
125
+ puts "pod_time_profiler: 上传podfile.lcok文件失败,失败原因:#{error}"
126
126
  `rm -rf podfile.zip`
127
127
  end
128
128
  end
@@ -134,7 +134,7 @@ def upload_mbox_podfile_lock
134
134
  upload_podfile_lock(checksum,true )
135
135
  end
136
136
  rescue => error
137
- puts "mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
137
+ puts "pod_time_profiler: mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
138
138
  end
139
139
  end
140
140
  def upload_branch_podfile_lock
@@ -142,10 +142,10 @@ def upload_branch_podfile_lock
142
142
  branch_value = get_branch_name
143
143
  if branch_value && branch_value.is_a?(String) && branch_value.length > 0
144
144
  if system("zip podfile.lock.zip Podfile.lock > /dev/null 2>&1") && system("curl -F \"name=MTXX\" -F \"version=#{branch_value}\" -F \"file=@#{Pathname.pwd}/podfile.lock.zip\" http://nezha.community.cloud.meitu.com/file/upload.json > /dev/null 2>&1")
145
- Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端成功".green
145
+ Pod::UI.puts "pod_time_profiler: 根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端成功".green
146
146
  `rm -rf podfile.lock.zip`
147
147
  else
148
- Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端失败".red
148
+ Pod::UI.puts "pod_time_profiler: 根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端失败".red
149
149
  `rm -rf podfile.lock.zip`
150
150
  end
151
151
  end
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.3
4
+ version: 1.3.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-09-02 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel