cocoapods-meitu-bin 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86aab10f2c27b3bfbdf44ed3b6874b7d6be473bb91dcd8a51c0e5906547d48e6
4
- data.tar.gz: a3b0f074a9ee8c24c8043c558314ea3bdfc3b28d1513e87909717547819b8460
3
+ metadata.gz: 7031e306ba5fe02226aa2ef9d1e35d27c6de7683c3ff0010c430bec87778bdd8
4
+ data.tar.gz: 571e8af4cdeb6b04f669ee6fcc3111a44a626df6e8f5d6887e7afbebfbca443d
5
5
  SHA512:
6
- metadata.gz: '088de3a018fda2b6b9215b61a26e101881fd4ca2a5a1f2ec9c4a9a4773b4ac3d11c4cd880a4ee979fc776a76bb54fcada03ae198b7dc14096903ee8d43a78f1c'
7
- data.tar.gz: 7bf240596cded061b4dc3f86006c4e47f4fa9d5613a37b9d2655943ad8c980930e639159737fcd5f4ec5d7564cb5deecf7918ccfacaaf03257bb8a72a1026763
6
+ metadata.gz: 0675d5f0d9aa51c0fdd09a567da454c1644f035b5f40867910b5984834aecb807b27586e73b991a05c1e0222c3f49ef195c0deb1cae82a4e729d45f49d84b79a
7
+ data.tar.gz: 6607870a45cb753f7a86426f0637d0f30b5a2fc38912c8a0a5fab00af1bea2e0dec17d4f1b42a494c61bc3f4a317be83a44dae098ed7032934a7574fdc9c8c0b
@@ -47,7 +47,7 @@ module Pod
47
47
  @full_build = argv.flag?('full-build', false)
48
48
  @skip_simulator = argv.flag?('skip-simulator', false)
49
49
  @configuration = argv.option('configuration', 'Debug')
50
- @base_dir = "#{Pathname.pwd}/build_pods"
50
+ @base_dir = ENV['POD_BUILD_BASE_DIR'] || "#{Pathname.pwd}/all_build/Build"
51
51
  @version_helper = BinHelper.new
52
52
  super
53
53
  end
@@ -106,8 +106,10 @@ module Pod
106
106
  def read_config
107
107
  UI.title 'Read config from file `BinConfig.yaml`'.green do
108
108
  config_file = File.join(Pod::Config.instance.project_root, 'BinConfig.yaml')
109
+ UI.info "BinConfig:`#{config_file}`".yellow
109
110
  return unless File.exist?(config_file)
110
111
  config = YAML.safe_load(File.open(config_file))
112
+ UI.info "BinConfig:`#{config}`".yellow
111
113
  return if config.nil?
112
114
  build_config = config['build_config']
113
115
  return if build_config.nil?
@@ -115,6 +117,7 @@ module Pod
115
117
  @post_build = build_config['post_build']
116
118
  @black_list = build_config['black_list']
117
119
  @write_list = build_config['write_list']
120
+ UI.info "BinConfig:`#{@write_list}`".yellow
118
121
  end
119
122
  end
120
123
 
@@ -212,7 +215,9 @@ module Pod
212
215
  # 黑名单(不分全量和非全量)
213
216
  next if skip_build?(pod_target)
214
217
  # 白名单(有白名单,只看白名单,不分全量和非全量)
215
- next if !@write_list.nil? && !@write_list.empty? && !@write_list.include?(pod_target.pod_name)
218
+ UI.info "USE_WHITELIST:`#{ ENV['USE_WHITELIST']}`".yellow
219
+ UI.info "include?:`#{@write_list.include?(pod_target.pod_name)}`".yellow
220
+ next if ENV['USE_WHITELIST'] && !@write_list.nil? && !@write_list.empty? && !@write_list.include?(pod_target.pod_name)
216
221
  # 本地库
217
222
  if @sandbox.local?(pod_target.pod_name)
218
223
  local_pods << pod_target.pod_name
@@ -301,7 +306,7 @@ module Pod
301
306
  # 黑名单(不分全量和非全量)
302
307
  next if skip_build?(pod_target)
303
308
  # 白名单(有白名单,只看白名单,不分全量和非全量)
304
- next if !@write_list.nil? && !@write_list.empty? && !@write_list.include?(pod_target.pod_name)
309
+ next if ENV['USE_WHITELIST'] && !@write_list.nil? && !@write_list.empty? && !@write_list.include?(pod_target.pod_name)
305
310
  # 本地库
306
311
  if @sandbox.local?(pod_target.pod_name)
307
312
  local_pods << pod_target.pod_name
@@ -309,7 +314,12 @@ module Pod
309
314
  next
310
315
  end
311
316
  # 外部源(如 git)
312
- if @sandbox.checkout_sources[pod_target.pod_name]
317
+ excluded_names = PodUpdateConfig.external_source_binary
318
+ .map { |s| s[:name] }
319
+ .compact # 过滤nil值
320
+ .uniq # 去重
321
+
322
+ if @sandbox.checkout_sources[pod_target.pod_name] && !excluded_names.include?(pod_target.pod_name) && !pod_target.should_build?
313
323
  external_pods << pod_target.pod_name
314
324
  show_skip_tip("#{pod_target.pod_name} 以external方式引入")
315
325
  next
@@ -164,34 +164,144 @@ class PodUpdateConfig
164
164
  @@is_mtxx = false
165
165
  @@is_clear = false
166
166
  @@shell_project = false
167
+ @@checkout_options = {}
168
+ @@dependency_relationships = {} # 存储所有组件的依赖关系集合,格式: { pod_name => { dependencies: { dep_name => { version: version, requirement: requirement } } } }
169
+
170
+ # 用于存储外部源的commit信息
167
171
  @@external_source_commit = {}
172
+ # 用于存储需要过滤的外部源信息
173
+ @@external_source = []
174
+ # 用于存储需要记录制作的external_source 组件
175
+ @@external_source_binary = []
176
+
177
+ # 设置依赖关系集合
178
+ def self.set_dependency_relationships(relationships)
179
+ @@dependency_relationships = relationships
180
+ end
181
+
182
+ # 获取依赖关系集合
183
+ def self.dependency_relationships
184
+ @@dependency_relationships
185
+ end
186
+
187
+ def self.set_result(result)
188
+ @@result = result
189
+ end
190
+
191
+ def self.result
192
+ @@result
193
+ end
194
+
195
+ def self.set_external_source(dic)
196
+ @@external_source << dic
197
+ end
198
+ def self.external_source()
199
+ @@external_source
200
+ end
201
+
202
+
203
+ def self.set_external_source_binary(dic)
204
+ @@external_source_binary << dic
205
+ end
206
+ def self.external_source_binary()
207
+ @@external_source_binary
208
+ end
209
+
210
+ def self.set_checkout_options(options)
211
+ @@checkout_options = options
212
+ end
213
+
214
+ def self.checkout_options
215
+ @@checkout_options
216
+ end
168
217
 
218
+ def self.get_checkout_option(pod_name,podfile)
219
+ options = @@checkout_options[pod_name]
169
220
 
221
+ # return nil unless !podfile.use_source_pods.include?(pod_name)
222
+ return nil unless options
170
223
 
171
- def self.set_external_source_commit
172
- podfile_obj = Pod::Config.instance.podfile
173
- # 遍历 Podfile 中的目标定义
174
- podfile_obj.target_definitions.each do |target_name, target_definition|
175
- target_definition.dependencies.each do |dependency|
176
- if dependency.external_source
177
- # if dependency.name == "MTBusinessBaseKit"
178
- # puts dependency.external_source
179
- # end
180
- if dependency.external_source[:commit]
181
- git_commit = dependency.external_source[:commit]
182
- # puts "Git Commit for #{dependency}: #{git_commit}"
183
- if @@external_source_commit[dependency.name].nil?
184
- @@external_source_commit[dependency.name] = git_commit
185
- end
224
+ # 优先返回commit信息
225
+ if options[:commit]
226
+ options[:commit]
227
+ # 其次返回tag信息
228
+ elsif options[:tag]
229
+ options[:tag]
230
+ else
231
+ nil
232
+ end
233
+ end
234
+
235
+ def self.parse_checkout_options(lockfile_path)
236
+ return unless File.exist?(lockfile_path)
237
+
238
+ begin
239
+ content = File.read(lockfile_path)
240
+ checkout_section = content.split('CHECKOUT OPTIONS:').last.split('SPEC REPOS:').first.strip
241
+
242
+ options = {}
243
+ current_pod = nil
244
+
245
+ checkout_section.each_line do |line|
246
+ line = line.strip
247
+ next if line.empty?
248
+
249
+ if line.start_with?(' ')
250
+ # 这是pod的选项
251
+ if current_pod
252
+ key, value = line.strip.split(': ', 2)
253
+ options[current_pod] ||= {}
254
+ options[current_pod][key] = value
255
+ end
256
+ else
257
+ # 这是pod名称
258
+ current_pod = line.strip
259
+ end
260
+ end
261
+
262
+ set_checkout_options(options)
263
+
264
+ if ENV['p_bin_d'] == '1'
265
+ puts "\nPodfile.lock CHECKOUT OPTIONS:".yellow
266
+ options.each do |pod, opts|
267
+ puts "#{pod}:"
268
+ opts.each do |key, value|
269
+ puts " #{key}: #{value}"
186
270
  end
187
271
  end
188
272
  end
273
+ rescue => e
274
+ warn "Failed to parse CHECKOUT OPTIONS from Podfile.lock: #{e.message}"
189
275
  end
190
- puts "#{@@external_source_commit}" if ENV['p_bin_d'] == '1'
191
276
  end
192
- def self.external_source_commit
193
- @@external_source_commit
277
+
278
+ def self.parse_checkout_options_from_specs(checkout_options_hash,podfile)
279
+ options = {}
280
+
281
+ checkout_options_hash.each do |pod_name, opts|
282
+ # 保存有 commit 或 tag 信息的组件
283
+ if (opts[:commit] || opts[:tag]) && !podfile.use_source_pods.include?(pod_name)
284
+ options[pod_name] = {
285
+ :git => opts[:git],
286
+ :commit => opts[:commit],
287
+ :tag => opts[:tag]
288
+ }.compact
289
+ end
290
+ end
291
+
292
+ set_checkout_options(options)
293
+
294
+ if ENV['p_bin_v'] == '1'
295
+ puts "\nResolver Specs CHECKOUT OPTIONS (commit/tag):".yellow
296
+ options.each do |pod, opts|
297
+ puts "#{pod}:"
298
+ opts.each do |key, value|
299
+ puts " #{key}: #{value}"
300
+ end
301
+ end
302
+ end
194
303
  end
304
+
195
305
  def self.set_shell_project
196
306
  @@shell_project = true
197
307
  end
@@ -251,4 +361,4 @@ class PodUpdateConfig
251
361
  def self.is_clear
252
362
  @@is_clear
253
363
  end
254
- end
364
+ end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  end
4
4
 
5
5
  module Pod
@@ -17,19 +17,25 @@ module CBin
17
17
  specs = specifications.map(&:name).select { |spec|
18
18
  spec.include?(pod_name) && !spec.include?('/Binary')
19
19
  }.sort!
20
- # puts "#{pod_name}:#{include_dependencies}"
21
- if include_dependencies
22
- specs << dependencies_str(pod_name, specifications)
20
+
21
+ version_name = PodUpdateConfig.dependency_relationships[pod_name]
22
+ if version_name
23
+ specs << version_name
23
24
  else
24
- if !ENV['MEITU_USE_OPEN_COMMIT']
25
- specs << dependencies_commit_str(pod_name, specifications)
26
- end
25
+ specs << binary_version_pods_str(pod_name,specifications)
27
26
  end
27
+
28
28
  specs << minimum_deployment_target_str
29
29
  specs << bundle_identifier_str
30
30
  specs << random_value_str
31
- specs << xcode_version
31
+ if ENV['xcode_version']
32
+ specs << ENV['xcode_version']
33
+ else
34
+ specs << xcode_version
35
+ end
36
+
32
37
  specs << (configuration.nil? ? 'Debug' : configuration)
38
+
33
39
  specs_str = specs.join('')
34
40
  if ENV['p_bin_v'] == '1'
35
41
  UI.puts "`#{pod_name}`:#{specs_str}".red
@@ -42,6 +48,77 @@ module CBin
42
48
  "#{original_version}.bin#{specs_str_md5}"
43
49
  end
44
50
 
51
+
52
+ # 获取参与二进制版本号生成的组件的tag/commit信息
53
+ def binary_version_pods_str(pod_name,specifications)
54
+ # 获取所有直接和间接依赖
55
+ all_dependencies = get_all_dependencies(pod_name, specifications)
56
+ return '' if all_dependencies.nil? || all_dependencies.empty?
57
+ result = []
58
+ all_dependencies.each do |pod_name|
59
+ # 优先使用 get_checkout_option 中的 commit 或 tag
60
+ checkout_option = PodUpdateConfig.get_checkout_option(pod_name)
61
+ if checkout_option
62
+ result << "#{pod_name}(#{checkout_option})"
63
+ next
64
+ end
65
+
66
+ # 如果没有 commit 或 tag,则使用版本号
67
+ specifications.each do |spec|
68
+ if spec.root.name == pod_name
69
+ version = spec.root.version.to_s
70
+ # 如果是二进制版本,去掉二进制版本号后缀
71
+ version_arr = version.split('.')
72
+ if version_arr.last.include?('bin')
73
+ version_arr.delete_at(version_arr.size - 1)
74
+ version = version_arr.join('.')
75
+ end
76
+ result << "#{pod_name}(#{version})"
77
+ break
78
+ end
79
+ end
80
+ end
81
+
82
+ if ENV['p_bin_v'] == '1'
83
+ UI.puts "参与二进制版本号生成的组件:#{result.join(',')}".yellow
84
+ end
85
+
86
+ result.join(',')
87
+ end
88
+
89
+ # 递归获取所有依赖(包括直接依赖和间接依赖)
90
+ def get_all_dependencies(pod_name, specifications)
91
+ result = Set.new([pod_name]) # 添加当前 pod 到结果集
92
+ visited = Set.new
93
+ get_dependencies_recursively(pod_name, specifications, result, visited)
94
+
95
+ if ENV['p_bin_v'] == '1'
96
+ UI.puts "\n#{pod_name} 及其依赖:".yellow
97
+ result.each do |dep|
98
+ UI.puts "- #{dep}"
99
+ end
100
+ end
101
+
102
+ result.to_a
103
+ end
104
+
105
+ # 递归获取单个组件的所有依赖
106
+ def get_dependencies_recursively(pod_name, specifications, result, visited)
107
+ return if visited.include?(pod_name)
108
+ visited.add(pod_name)
109
+
110
+ specifications.each do |spec|
111
+ if spec.root.name == pod_name
112
+ spec.dependencies.each do |dep|
113
+ next if dep.root_name == pod_name # 跳过自依赖
114
+ result.add(dep.root_name)
115
+ get_dependencies_recursively(dep.root_name, specifications, result, visited)
116
+ end
117
+ break
118
+ end
119
+ end
120
+ end
121
+
45
122
  #最低部署目标,参与二进制版本生成
46
123
  def minimum_deployment_target_str
47
124
  CBin.config.minimum_deployment_target
@@ -63,8 +140,8 @@ module CBin
63
140
  end
64
141
 
65
142
  def self.xcode_version
66
- xcode_version = `xcodebuild -version`.split(' ').join('')
67
- xcode_version
143
+ xcode_version = `xcodebuild -version`.split(' ').join('')
144
+ xcode_version
68
145
  end
69
146
 
70
147
  # 将当前 Pod 库的依赖库拼接成字符串(格式:pod1_name(pod1_version),pod2_name(pod2_version),...)
@@ -78,7 +155,7 @@ module CBin
78
155
  end
79
156
 
80
157
  if deps.empty?
81
- UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
158
+ UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_v'] == '1'
82
159
  return ''
83
160
  end
84
161
  result = []
@@ -87,14 +164,16 @@ module CBin
87
164
  next
88
165
  end
89
166
  version = dep_version(dep, specifications)
90
- if !ENV['MEITU_USE_OPEN_COMMIT']
91
- if PodUpdateConfig.external_source_commit[dep.name]
92
- version = PodUpdateConfig.external_source_commit[dep.name]
93
- end
94
- end
167
+ # if !ENV['MEITU_USE_OPEN_COMMIT']
168
+ # if PodUpdateConfig.external_source_commit[dep.name]
169
+ # version = PodUpdateConfig.external_source_commit[dep.name]
170
+ # end
171
+ # end
172
+ commit = find_dependency_by_name(podfile, dep.name)
173
+ version = commit unless commit.nil?
95
174
  result << "#{dep.name}(#{version})"
96
175
  end
97
- if ENV['p_bin_d'] == '1'
176
+ if ENV['p_bin_v'] == '1'
98
177
  if result.empty?
99
178
  UI.puts "`#{pod_name}`无依赖库".red
100
179
  else
@@ -113,7 +192,7 @@ module CBin
113
192
  end
114
193
 
115
194
  if deps.empty?
116
- UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
195
+ UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_v'] == '1'
117
196
  return ''
118
197
  end
119
198
  result = []
@@ -121,9 +200,13 @@ module CBin
121
200
  if dep.root_name == pod_name
122
201
  next
123
202
  end
124
- if PodUpdateConfig.external_source_commit[dep.name]
125
- result << "#{dep.name}(#{PodUpdateConfig.external_source_commit[dep.name]})"
203
+ commit = find_dependency_by_name(podfile, dep.name)
204
+ if commit
205
+ result << "#{dep.name}(#{commit})"
126
206
  end
207
+ # if PodUpdateConfig.external_source_commit[dep.name]
208
+ # result << "#{dep.name}(#{PodUpdateConfig.external_source_commit[dep.name]})"
209
+ # end
127
210
  end
128
211
  result.join(',')
129
212
  end
@@ -13,7 +13,7 @@ module CBin
13
13
  @file_accessors = pod_target.file_accessors unless pod_target.nil?
14
14
  @base_dir = "#{Pathname.pwd}/build_pods"
15
15
  if PodUpdateConfig.shell_project
16
- @base_dir = "#{Pathname.pwd}/all_build/Build"
16
+ @base_dir = ENV['POD_BUILD_BASE_DIR'] || "#{Pathname.pwd}/all_build/Build"
17
17
  end
18
18
  end
19
19
 
@@ -66,6 +66,9 @@ module CBin
66
66
  # 是否以framework形式构建
67
67
  def build_as_framework?
68
68
  path = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}"
69
+ if ENV['POD_BUILD_BASE_DIR']
70
+ path = "#{product_dir}/#{iphoneos}/#{@pod_target.framework_name}"
71
+ end
69
72
  File.exist?(path)
70
73
  end
71
74
 
@@ -96,7 +99,13 @@ module CBin
96
99
 
97
100
  # xxx.framework 所在目录
98
101
  def product_dir
99
- @product_dir = "#{@base_dir}/Products"
102
+ path = ENV['POD_BUILD_BASE_DIR']
103
+ if path
104
+ @product_dir = path
105
+ else
106
+ @product_dir = "#{@base_dir}/Products"
107
+ end
108
+
100
109
  @product_dir
101
110
  end
102
111
 
@@ -106,7 +115,11 @@ module CBin
106
115
  end
107
116
 
108
117
  def iphoneos
109
- "#{@configuration}-iphoneos"
118
+ iphoneos = "#{@configuration}-iphoneos"
119
+ if ENV['POD_BUILD_BASE_DIR']
120
+ iphoneos = "iphoneos"
121
+ end
122
+ iphoneos
110
123
  end
111
124
 
112
125
  def iphonesimulator
@@ -312,7 +325,14 @@ ibtool \
312
325
  return [] if @file_accessors.nil?
313
326
  resource_bundles = @file_accessors.flat_map(&:resource_bundles)
314
327
  return [] if resource_bundles.nil? || resource_bundles.size == 0
315
- resource_bundles.compact.flat_map(&:keys).map { |key| "#{product_dir}/#{iphoneos}/#{@pod_target}/#{key}.bundle" }
328
+ resource_bundles.compact.flat_map(&:keys).map do |key|
329
+ if ENV['POD_BUILD_BASE_DIR']
330
+ "#{product_dir}/#{iphoneos}/#{key}.bundle"
331
+ else
332
+ "#{product_dir}/#{iphoneos}/#{@pod_target}/#{key}.bundle"
333
+ end
334
+
335
+ end
316
336
  end
317
337
 
318
338
  # 获取podspec中resource/resources
@@ -374,6 +394,9 @@ ibtool \
374
394
  # 拷贝 framework
375
395
  def copy_framework
376
396
  source_path = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}"
397
+ if ENV['POD_BUILD_BASE_DIR']
398
+ source_path = "#{product_dir}/#{iphoneos}/#{@pod_target.framework_name}"
399
+ end
377
400
  if File.exist?(source_path)
378
401
  `rsync -av #{source_path} #{product_dir}`
379
402
  end
@@ -49,7 +49,7 @@ module CBin
49
49
  def write_binary_podspec(spec)
50
50
  UI.info "写入podspec:`#{@pod_target}`".yellow
51
51
  podspec_dir = PodUpdateConfig.shell_project ? "#{Pathname.pwd}/all_build/Build/Products/podspec" : "#{Pathname.pwd}/build_pods/#{@pod_target}/Products/podspec"
52
- FileUtils.mkdir(podspec_dir) unless File.exist?(podspec_dir)
52
+ FileUtils.mkdir_p(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
55
  File.open(file, "w+") do |f|
@@ -65,15 +65,29 @@ module CBin
65
65
  repo_name = Pod::Config.instance.sources_manager.binary_source.name
66
66
  # repo_name = 'example-private-spec-bin'
67
67
  argvs = %W[#{repo_name} #{binary_podsepc_json} --skip-import-validation --use-libraries --allow-warnings --verbose]
68
- begin
69
- push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
70
- push.validate!
71
- push.run
72
- return true
73
- rescue Pod::StandardError => e
74
- UI.info "推送podspec:`#{@pod_target}`失败,#{e.to_s}".red
75
- return false
68
+
69
+ start_time = Time.now
70
+ timeout = ENV['PODSPEC_PUSH_TIMEOUT'] ? ENV['PODSPEC_PUSH_TIMEOUT'].to_i : 15 # Default 15 seconds timeout
71
+ last_error = nil
72
+
73
+ while (Time.now - start_time) < timeout
74
+ begin
75
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
76
+ push.validate!
77
+ push.run
78
+ return true
79
+ rescue Pod::StandardError => e
80
+ last_error = e
81
+ remaining_time = timeout - (Time.now - start_time)
82
+ if remaining_time > 0
83
+ UI.info "推送podspec:`#{@pod_target}`失败,将在#{remaining_time.round(1)}秒后重试,错误:#{e.to_s}".yellow
84
+ sleep(1) # Wait 1 second before retrying
85
+ end
86
+ end
76
87
  end
88
+
89
+ UI.info "推送podspec:`#{@pod_target}`失败,已超过#{timeout}秒重试时间,跳过此次处理,错误:#{last_error.to_s}".red
90
+ return false
77
91
  end
78
92
 
79
93
  private
@@ -17,6 +17,20 @@ module Pod
17
17
  if !lockfile.nil? && lockfile.internal_data.empty?
18
18
  @lockfile = Lockfile.from_file(config.lockfile_path) if config.lockfile_path
19
19
  end
20
+
21
+ podfile.use_source_pods.each do |name|
22
+ # 如果lockfile存在,移除external_source_pods和checkout_options中的name元素
23
+ if !lockfile.nil? && lockfile.internal_data && lockfile.internal_data['EXTERNAL SOURCES']
24
+ # 从external_source_pods中移除
25
+ lockfile.internal_data['EXTERNAL SOURCES'].delete(name)
26
+ end
27
+
28
+ if !lockfile.nil? && lockfile.internal_data && lockfile.internal_data['CHECKOUT OPTIONS']
29
+ # 从checkout_options中移除
30
+ lockfile.internal_data['CHECKOUT OPTIONS'].delete(name)
31
+ end
32
+ end
33
+
20
34
  mtxx_create_analyzer(plugin_sources)
21
35
  end
22
36
 
@@ -60,6 +74,25 @@ module Pod
60
74
 
61
75
  UI.section 'Analyzing dependencies' do
62
76
  analyze(analyzer)
77
+ excluded_names = PodUpdateConfig.external_source
78
+ .map { |s| s[:name] }
79
+ .compact
80
+ .uniq
81
+
82
+ if excluded_names
83
+ filtered_pod_targets = @pod_targets.select do |pod_target|
84
+ excluded_names.include?(pod_target.pod_name)
85
+ end
86
+
87
+ filtered_pod_targets.each do |pod_target|
88
+ # puts pod_target.pod_name
89
+ UI.puts "pod_time_profiler: predownloaded_pods_binary: #{pod_target.pod_name}".green
90
+ # if pod_target.should_build?
91
+ # end
92
+ sandbox.predownloaded_pods.delete(pod_target.pod_name)
93
+ end
94
+ end
95
+
63
96
  validate_build_configurations
64
97
  end
65
98
 
@@ -69,6 +102,7 @@ module Pod
69
102
  end if deployment?
70
103
  cost_time_hash['prepare'] = PodUpdateConfig.prepare_time
71
104
  cost_time_hash['resolve_dependencies'] = Time.now - start_time
105
+
72
106
  analyzer
73
107
  end
74
108
 
@@ -123,6 +157,7 @@ module Pod
123
157
  source_pods = []
124
158
  bin_pods = []
125
159
  @pod_targets.map do |target|
160
+ target.uses_swift?
126
161
  if target.should_build?
127
162
  source_pods << target
128
163
  else
@@ -59,7 +59,34 @@ module Pod
59
59
  }
60
60
  Lockfile.new(hash)
61
61
  end
62
-
62
+ # def generate_external_sources_data(podfile)
63
+ # excluded_names = PodUpdateConfig.external_source
64
+ # .map { |s| s[:name] }
65
+ # .compact # 过滤空值[1]
66
+ # .uniq
67
+ # deps = podfile.dependencies.select(&:external?)
68
+ # deps = deps.sort { |d, other| d.name <=> other.name }
69
+ # sources = {}
70
+ # deps.each { |d| sources[d.root_name] = d.external_source }
71
+ # sources
72
+ # end
73
+ #根据 CocoaPods 依赖处理机制,修改后的方法应增加过滤逻辑:
74
+ def generate_external_sources_data(podfile)
75
+ excluded_names = PodUpdateConfig.external_source
76
+ .map { |s| s[:name] }
77
+ .compact # 过滤nil值
78
+ .uniq # 去重
79
+
80
+ deps = podfile.dependencies.select(&:external?)
81
+
82
+ deps = deps.reject { |d| excluded_names.include?(d.root_name) } if excluded_names.any?
83
+
84
+ deps = deps.sort { |d, other| d.name <=> other.name }
85
+
86
+ sources = {}
87
+ deps.each { |d| sources[d.root_name] = d.external_source }
88
+ sources
89
+ end
63
90
  def generate_spec_repos(spec_repos)
64
91
  result = Hash.new
65
92
  spec_repos.map do |source, specs|
@@ -1,11 +1,10 @@
1
-
2
-
3
1
  require 'cocoapods'
4
2
  require 'cocoapods-meitu-bin/native/podfile_env'
5
3
 
6
4
  module Pod
7
5
  class Podfile
8
6
  # TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
7
+ BINARY_VERSION_PODS = 'binary_version_pods'.freeze
9
8
 
10
9
  module DSL
11
10
  def allow_prerelease!
@@ -43,6 +42,13 @@ module Pod
43
42
  def set_configuration_env(env = "dev")
44
43
  set_internal_hash_value(CONFIGURATION_ENV, env)
45
44
  end
45
+
46
+ # 设置参与二进制库版本号生成的组件名称
47
+ def set_binary_version_pods(pods)
48
+ hash_binary_version_pods = get_internal_hash_value(BINARY_VERSION_PODS) || []
49
+ hash_binary_version_pods += Array(pods)
50
+ set_internal_hash_value(BINARY_VERSION_PODS, hash_binary_version_pods)
51
+ end
46
52
  end
47
53
 
48
54
  alias old_plugins plugins
@@ -85,6 +91,11 @@ module Pod
85
91
  get_internal_hash_value(CONFIGURATION, "Debug")
86
92
  end
87
93
 
94
+ # 获取参与二进制库版本号生成的组件名称列表
95
+ def binary_version_pods
96
+ get_internal_hash_value(BINARY_VERSION_PODS, []) + String(ENV[BINARY_VERSION_PODS]).split('|').uniq
97
+ end
98
+
88
99
  private
89
100
 
90
101
  def valid_bin_plugin
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  require 'parallel'
4
2
  require 'cocoapods'
5
3
  require 'cocoapods-meitu-bin/native/podfile'
@@ -114,32 +112,75 @@ module Pod
114
112
  end.uniq
115
113
  @platforms_by_dependency.each_value(&:uniq!)
116
114
 
117
- # 遍历locked_dependencies,将二进制版本号的最后一位删掉
115
+ # 遍历locked_dependencies
116
+ # 1) 将二进制版本号的最后一位删掉
117
+ # 2) 移除 external_source(去锁定)
118
118
  locked_dependencies.each do |value|
119
119
  next if value.nil?
120
120
  # 获取 Pod::Dependency
121
121
  dep = value.payload
122
- next if dep.external_source
123
- # 修改版本号限制
122
+
123
+ # 移除 external_source,使其走常规源解析
124
+ external_source = dep.external_source
125
+ if external_source
126
+ external_source = nil
127
+ else
128
+ # 非external_source 仍保持不动,直接跳过
129
+ next if dep.external_source
130
+ end
131
+
132
+ # 修改版本号限制(移除 bin 后缀)
124
133
  requirements = dep.requirement.as_list.map do |req|
125
134
  req_arr = req.split('.').delete_if { |r| r.include?('bin') }
126
135
  req_arr.join('.')
127
136
  end
137
+
128
138
  # 重新生成 Pod::Dependency
129
- dep = Dependency.new(dep.name, requirements, {:source => dep.podspec_repo, :external_source => dep.external_source})
139
+ dep = Dependency.new(dep.name, requirements, {:source => dep.podspec_repo, :external_source => external_source})
130
140
  value.payload = dep
131
141
  end
132
142
 
133
143
  start_time = Time.now
134
144
  @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
135
145
  UI.puts "pod_time_profiler: Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
136
- #记录podfile 中commit 使用的组件map,提供后面二进制版本生成使用
137
- PodUpdateConfig.set_external_source_commit
146
+ start_time = Time.now
147
+ external_source_pods = @podfile_dependency_cache.podfile_dependencies.select(&:external_source).map(&:root_name).uniq
148
+ checkout_options = sandbox.checkout_sources.select { |root_name, _| external_source_pods.include? root_name }
149
+
150
+ if podfile.use_binaries?
151
+ PodUpdateConfig.parse_checkout_options_from_specs(checkout_options,podfile)
152
+ end
153
+ all_pods = {}
154
+ @activated.vertices.each do |vertex|
155
+ all_pods[ "#{vertex[1].name.split("/").first }"] = vertex[1].payload.version.version
156
+ end
157
+ result = {}
158
+ all_pods.each do |key ,version|
159
+ vertex = @activated.vertices[key]
160
+ deps = get_all_dependencies(vertex)
161
+ pod_names = ""
162
+ deps.each do |name ,version|
163
+ checkout_option = PodUpdateConfig.get_checkout_option(name,podfile)
164
+ if checkout_option
165
+ name_version = "#{name.split("/").first }_#{checkout_option}"
166
+ pod_names << "|" << name_version unless pod_names.include?(name_version)
167
+ else
168
+ name_version = "#{name.split("/").first }_#{version[:version].version}"
169
+ pod_names << "|" << name_version unless pod_names.include?(name_version)
170
+ end
171
+
172
+ end
173
+ result[key] = pod_names
174
+ end
175
+ PodUpdateConfig.set_dependency_relationships(result)
176
+ UI.puts "pod_time_profiler: dependency_relationships:#{'%.1f' % (Time.now - start_time)}s".green
138
177
  resolver_specs_by_target
139
178
  rescue Molinillo::ResolverError => e
140
179
  handle_resolver_error(e)
141
180
  end
142
181
 
182
+
183
+
143
184
  old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
144
185
  define_method(:resolver_specs_by_target) do
145
186
  specs_by_target = old_resolver_specs_by_target.bind(self).call
@@ -165,6 +206,7 @@ module Pod
165
206
  []
166
207
  end
167
208
 
209
+
168
210
  # Parallel.map(rspecs, in_threads: 8) do |rspec|
169
211
  specs_by_target[target] = rspecs.map do |rspec|
170
212
  # 含有 subspecs 的组件暂不处理
@@ -172,8 +214,13 @@ module Pod
172
214
 
173
215
  # developments 组件采用默认输入的 spec (development pods 的 source 为 nil)
174
216
  # 可以使 :podspec => "htts://IMYFoundation.podspec"可以走下去,by slj
217
+ dependency_source = PodUpdateConfig.get_checkout_option(rspec.root.name,podfile)
218
+
175
219
  unless rspec.spec.respond_to?(:spec_source) && rspec.spec.spec_source
176
- next rspec
220
+
221
+ if dependency_source.nil?
222
+ next rspec
223
+ end
177
224
  end
178
225
 
179
226
  # 采用二进制依赖并且不为开发组件
@@ -181,7 +228,7 @@ module Pod
181
228
  if use_binary
182
229
  source = sources_manager.binary_source
183
230
  configuration = ENV['configuration'] || podfile.configuration
184
- spec_version = version_helper.version(rspec.root.name, rspec.spec.version, specifications, configuration, podfile.include_dependencies?)
231
+ spec_version = version_helper.version(rspec.root.name, rspec.spec.version, specifications, configuration, podfile.include_dependencies?)
185
232
  else
186
233
  # 获取podfile中的source
187
234
  podfile_sources = podfile.sources.uniq.map { |source| sources_manager.source_with_name_or_url(source) }
@@ -211,7 +258,7 @@ module Pod
211
258
  # 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
212
259
  # 造成 subspec_by_name 返回 nil,这个是正常现象
213
260
  next unless specification
214
-
261
+ is_exist_binary_version = true
215
262
  used_by_only = if Pod.match_version?('~> 1.7')
216
263
  rspec.used_by_non_library_targets_only
217
264
  else
@@ -228,12 +275,31 @@ module Pod
228
275
  # 没有从新的 source 找到对应版本组件,直接返回原 rspec
229
276
  missing_binary_specs << rspec.spec if use_binary
230
277
  # UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
278
+ is_exist_binary_version = false
231
279
  rspec
232
280
  end
281
+ # 有对应二进制组件版本才进行替换记录,否则走之前pre-downloading 逻辑
282
+ if is_exist_binary_version && sandbox.predownloaded?(rspec.root.name) && spec_version.is_a?(String) && spec_version.include?("bin")
283
+ PodUpdateConfig.set_external_source({"name":rspec.root.name,"source":dependency_source})
284
+ end
285
+ if $ARGV.include?("bin") || !is_exist_binary_version
286
+ # 记录为制作的 external_source 组件,为后续二进制制作准备
287
+ if dependency_source && spec_version.is_a?(String) && spec_version.include?("bin")
288
+ PodUpdateConfig.set_external_source_binary({"name":rspec.root.name,"source":dependency_source})
289
+ end
290
+ end
291
+
233
292
  rspec
234
293
  end.compact
235
294
  end
236
295
 
296
+ def print_dependency_tree(vertex, indent = 0)
297
+ puts "#{' ' * indent}#{vertex.name} (#{vertex.payload&.version || '?'})"
298
+
299
+ vertex.outgoing_edges.each do |edge|
300
+ print_dependency_tree(edge.destination, indent + 1)
301
+ end
302
+ end
237
303
  # if missing_binary_specs.any?
238
304
  # missing_binary_specs.uniq.each do |spec|
239
305
  # # UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
@@ -273,6 +339,59 @@ module Pod
273
339
  CBin::BuildAll::BinHelper.new
274
340
  end
275
341
  end
342
+
343
+ # 获取组件的所有依赖(包括直接和间接依赖)
344
+ def get_all_dependencies(vertex, visited = Set.new, dependencies = {})
345
+ return dependencies if vertex.nil? || visited.include?(vertex.name)
346
+
347
+ visited.add(vertex.name)
348
+
349
+ # 添加当前组件信息
350
+ dependencies[vertex.name] = {
351
+ version: vertex.payload&.version,
352
+ dependencies: {}
353
+ }
354
+
355
+ # 递归处理所有直接依赖
356
+ vertex.outgoing_edges&.each do |edge|
357
+ dest_vertex = edge.destination
358
+ next if dest_vertex.nil?
359
+
360
+ dep_name = dest_vertex.name
361
+
362
+ # 记录直接依赖信息
363
+ dependencies[vertex.name][:dependencies][dep_name] = {
364
+ version: dest_vertex.payload&.version,
365
+ requirement: edge.requirement&.to_s
366
+ }
367
+
368
+ # 递归获取间接依赖
369
+ get_all_dependencies(dest_vertex, visited, dependencies)
370
+ end
371
+
372
+ dependencies
373
+ end
374
+
375
+ # 打印组件的所有依赖树
376
+ def print_dependency_tree(vertex, indent = 0, visited = Set.new)
377
+ return if visited.include?(vertex.name)
378
+ visited.add(vertex.name)
379
+
380
+ puts "#{' ' * indent}#{vertex.name} (#{vertex.payload&.version || '?'})"
381
+
382
+ vertex.outgoing_edges.each do |edge|
383
+ print_dependency_tree(edge.destination, indent + 1, visited)
384
+ end
385
+ end
386
+
387
+ # 获取所有组件的完整依赖关系
388
+ def get_all_components_dependencies
389
+ result = {}
390
+ @activated.vertices.each do |name, vertex|
391
+ result[name] = get_all_dependencies(vertex)
392
+ end
393
+ result
394
+ end
276
395
  end
277
396
 
278
397
  if Pod.match_version?('~> 1.4.0')
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: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
11
+ date: 2025-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel