cocoapods-meitu-bin 2.0.1 → 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: 44b755bd80acc307a5c25f91cd7d07911fb0f81df3342739a3e099bdbc3eb6e0
4
- data.tar.gz: fc5c280e229de927df2e429da8494146de709d16429ecc143e05447244ad34a8
3
+ metadata.gz: 7031e306ba5fe02226aa2ef9d1e35d27c6de7683c3ff0010c430bec87778bdd8
4
+ data.tar.gz: 571e8af4cdeb6b04f669ee6fcc3111a44a626df6e8f5d6887e7afbebfbca443d
5
5
  SHA512:
6
- metadata.gz: e23a6e77f03c087df977c2d23418e2b5a3da59eca718923dfe9653136dd9ef8252c4596b59ddc1c1c3160b19e810b980f049ffd3303183eb5ce25d61ceea89cf
7
- data.tar.gz: 20441e3f37762cb9c2039fc1a0bffbbfe1f899d2ec64693570008f4489b27c4f8e17a402dfe7cc01fe3b05a085f51e8aa241219d23ba47772659465b2d32d334
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,41 +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 = {}
168
- @@binary_version_pods = []
169
-
170
- def self.set_binary_version_pods(pods)
171
- @@binary_version_pods = pods
172
- end
173
-
174
- def self.binary_version_pods
175
- @@binary_version_pods
176
- end
177
-
178
- def self.set_external_source_commit
179
- podfile_obj = Pod::Config.instance.podfile
180
- # 遍历 Podfile 中的目标定义
181
- podfile_obj.target_definitions.each do |target_name, target_definition|
182
- target_definition.dependencies.each do |dependency|
183
- if dependency.external_source
184
- # if dependency.name == "MTBusinessBaseKit"
185
- # puts dependency.external_source
186
- # end
187
- if dependency.external_source[:commit]
188
- git_commit = dependency.external_source[:commit]
189
- # puts "Git Commit for #{dependency}: #{git_commit}"
190
- if @@external_source_commit[dependency.name].nil?
191
- @@external_source_commit[dependency.name] = git_commit
192
- end
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
217
+
218
+ def self.get_checkout_option(pod_name,podfile)
219
+ options = @@checkout_options[pod_name]
220
+
221
+ # return nil unless !podfile.use_source_pods.include?(pod_name)
222
+ return nil unless options
223
+
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}"
193
270
  end
194
271
  end
195
272
  end
273
+ rescue => e
274
+ warn "Failed to parse CHECKOUT OPTIONS from Podfile.lock: #{e.message}"
196
275
  end
197
- puts "#{@@external_source_commit}" if ENV['p_bin_d'] == '1'
198
276
  end
199
- def self.external_source_commit
200
- @@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
201
303
  end
304
+
202
305
  def self.set_shell_project
203
306
  @@shell_project = true
204
307
  end
@@ -258,4 +361,4 @@ class PodUpdateConfig
258
361
  def self.is_clear
259
362
  @@is_clear
260
363
  end
261
- end
364
+ end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "2.0.1"
2
+ VERSION = "3.0.0"
3
3
  end
4
4
 
5
5
  module Pod
@@ -17,21 +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
28
- specs << binary_version_pods_str(specifications)
27
+
29
28
  specs << minimum_deployment_target_str
30
29
  specs << bundle_identifier_str
31
30
  specs << random_value_str
32
- specs << xcode_version
31
+ if ENV['xcode_version']
32
+ specs << ENV['xcode_version']
33
+ else
34
+ specs << xcode_version
35
+ end
36
+
33
37
  specs << (configuration.nil? ? 'Debug' : configuration)
34
-
38
+
35
39
  specs_str = specs.join('')
36
40
  if ENV['p_bin_v'] == '1'
37
41
  UI.puts "`#{pod_name}`:#{specs_str}".red
@@ -44,23 +48,22 @@ module CBin
44
48
  "#{original_version}.bin#{specs_str_md5}"
45
49
  end
46
50
 
47
- # 获取参与二进制版本号生成的组件的tag/commit信息
48
- def binary_version_pods_str(specifications)
49
- binary_version_pods = PodUpdateConfig.binary_version_pods
50
- return '' if binary_version_pods.empty?
51
51
 
52
+ # 获取参与二进制版本号生成的组件的tag/commit信息
53
+ def binary_version_pods_str(pod_name,specifications)
52
54
  # 获取所有直接和间接依赖
53
- all_dependencies = get_all_dependencies(binary_version_pods, specifications)
54
-
55
+ all_dependencies = get_all_dependencies(pod_name, specifications)
56
+ return '' if all_dependencies.nil? || all_dependencies.empty?
55
57
  result = []
56
58
  all_dependencies.each do |pod_name|
57
- # 优先使用 external_source_commit
58
- if PodUpdateConfig.external_source_commit[pod_name]
59
- result << "#{pod_name}(#{PodUpdateConfig.external_source_commit[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})"
60
63
  next
61
64
  end
62
65
 
63
- # 如果没有 external_source_commit,则使用版本号
66
+ # 如果没有 commit 或 tag,则使用版本号
64
67
  specifications.each do |spec|
65
68
  if spec.root.name == pod_name
66
69
  version = spec.root.version.to_s
@@ -84,25 +87,18 @@ module CBin
84
87
  end
85
88
 
86
89
  # 递归获取所有依赖(包括直接依赖和间接依赖)
87
- def get_all_dependencies(pod_names, specifications)
88
- result = Set.new(pod_names)
90
+ def get_all_dependencies(pod_name, specifications)
91
+ result = Set.new([pod_name]) # 添加当前 pod 到结果集
89
92
  visited = Set.new
90
-
91
- pod_names.each do |pod_name|
92
- get_dependencies_recursively(pod_name, specifications, result, visited)
93
- end
94
-
95
- # 打印所有PopRock相关的间接依赖
96
- if ENV['p_bin_d'] == '1'
97
- poprock_deps = result.select { |name| name.include?('PopRock') }
98
- if poprock_deps.any?
99
- UI.puts "\nPopRock相关组件及其依赖:".yellow
100
- poprock_deps.each do |dep|
101
- UI.puts "- #{dep}"
102
- end
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}"
103
99
  end
104
100
  end
105
-
101
+
106
102
  result.to_a
107
103
  end
108
104
 
@@ -144,8 +140,8 @@ module CBin
144
140
  end
145
141
 
146
142
  def self.xcode_version
147
- xcode_version = `xcodebuild -version`.split(' ').join('')
148
- xcode_version
143
+ xcode_version = `xcodebuild -version`.split(' ').join('')
144
+ xcode_version
149
145
  end
150
146
 
151
147
  # 将当前 Pod 库的依赖库拼接成字符串(格式:pod1_name(pod1_version),pod2_name(pod2_version),...)
@@ -159,7 +155,7 @@ module CBin
159
155
  end
160
156
 
161
157
  if deps.empty?
162
- UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
158
+ UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_v'] == '1'
163
159
  return ''
164
160
  end
165
161
  result = []
@@ -168,14 +164,16 @@ module CBin
168
164
  next
169
165
  end
170
166
  version = dep_version(dep, specifications)
171
- if !ENV['MEITU_USE_OPEN_COMMIT']
172
- if PodUpdateConfig.external_source_commit[dep.name]
173
- version = PodUpdateConfig.external_source_commit[dep.name]
174
- end
175
- 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?
176
174
  result << "#{dep.name}(#{version})"
177
175
  end
178
- if ENV['p_bin_d'] == '1'
176
+ if ENV['p_bin_v'] == '1'
179
177
  if result.empty?
180
178
  UI.puts "`#{pod_name}`无依赖库".red
181
179
  else
@@ -194,7 +192,7 @@ module CBin
194
192
  end
195
193
 
196
194
  if deps.empty?
197
- UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
195
+ UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_v'] == '1'
198
196
  return ''
199
197
  end
200
198
  result = []
@@ -202,9 +200,13 @@ module CBin
202
200
  if dep.root_name == pod_name
203
201
  next
204
202
  end
205
- if PodUpdateConfig.external_source_commit[dep.name]
206
- 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})"
207
206
  end
207
+ # if PodUpdateConfig.external_source_commit[dep.name]
208
+ # result << "#{dep.name}(#{PodUpdateConfig.external_source_commit[dep.name]})"
209
+ # end
208
210
  end
209
211
  result.join(',')
210
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|
@@ -112,39 +112,81 @@ module Pod
112
112
  end.uniq
113
113
  @platforms_by_dependency.each_value(&:uniq!)
114
114
 
115
- # 遍历locked_dependencies,将二进制版本号的最后一位删掉
115
+ # 遍历locked_dependencies
116
+ # 1) 将二进制版本号的最后一位删掉
117
+ # 2) 移除 external_source(去锁定)
116
118
  locked_dependencies.each do |value|
117
119
  next if value.nil?
118
120
  # 获取 Pod::Dependency
119
121
  dep = value.payload
120
- next if dep.external_source
121
- # 修改版本号限制
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 后缀)
122
133
  requirements = dep.requirement.as_list.map do |req|
123
134
  req_arr = req.split('.').delete_if { |r| r.include?('bin') }
124
135
  req_arr.join('.')
125
136
  end
137
+
126
138
  # 重新生成 Pod::Dependency
127
- 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})
128
140
  value.payload = dep
129
141
  end
130
142
 
131
143
  start_time = Time.now
132
144
  @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
133
145
  UI.puts "pod_time_profiler: Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
134
- #记录podfile 中commit 使用的组件map,提供后面二进制版本生成使用
135
- 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
136
177
  resolver_specs_by_target
137
178
  rescue Molinillo::ResolverError => e
138
179
  handle_resolver_error(e)
139
180
  end
140
181
 
182
+
183
+
141
184
  old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
142
185
  define_method(:resolver_specs_by_target) do
143
186
  specs_by_target = old_resolver_specs_by_target.bind(self).call
144
187
 
145
188
  sources_manager = Config.instance.sources_manager
146
189
  use_source_pods = podfile.use_source_pods
147
- PodUpdateConfig.set_binary_version_pods(podfile.binary_version_pods)
148
190
 
149
191
  # 从BinConfig读取black_list
150
192
  black_list = read_black_list
@@ -164,6 +206,7 @@ module Pod
164
206
  []
165
207
  end
166
208
 
209
+
167
210
  # Parallel.map(rspecs, in_threads: 8) do |rspec|
168
211
  specs_by_target[target] = rspecs.map do |rspec|
169
212
  # 含有 subspecs 的组件暂不处理
@@ -171,8 +214,13 @@ module Pod
171
214
 
172
215
  # developments 组件采用默认输入的 spec (development pods 的 source 为 nil)
173
216
  # 可以使 :podspec => "htts://IMYFoundation.podspec"可以走下去,by slj
217
+ dependency_source = PodUpdateConfig.get_checkout_option(rspec.root.name,podfile)
218
+
174
219
  unless rspec.spec.respond_to?(:spec_source) && rspec.spec.spec_source
175
- next rspec
220
+
221
+ if dependency_source.nil?
222
+ next rspec
223
+ end
176
224
  end
177
225
 
178
226
  # 采用二进制依赖并且不为开发组件
@@ -180,7 +228,7 @@ module Pod
180
228
  if use_binary
181
229
  source = sources_manager.binary_source
182
230
  configuration = ENV['configuration'] || podfile.configuration
183
- 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?)
184
232
  else
185
233
  # 获取podfile中的source
186
234
  podfile_sources = podfile.sources.uniq.map { |source| sources_manager.source_with_name_or_url(source) }
@@ -210,7 +258,7 @@ module Pod
210
258
  # 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
211
259
  # 造成 subspec_by_name 返回 nil,这个是正常现象
212
260
  next unless specification
213
-
261
+ is_exist_binary_version = true
214
262
  used_by_only = if Pod.match_version?('~> 1.7')
215
263
  rspec.used_by_non_library_targets_only
216
264
  else
@@ -227,12 +275,31 @@ module Pod
227
275
  # 没有从新的 source 找到对应版本组件,直接返回原 rspec
228
276
  missing_binary_specs << rspec.spec if use_binary
229
277
  # UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
278
+ is_exist_binary_version = false
230
279
  rspec
231
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
+
232
292
  rspec
233
293
  end.compact
234
294
  end
235
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
236
303
  # if missing_binary_specs.any?
237
304
  # missing_binary_specs.uniq.each do |spec|
238
305
  # # UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
@@ -272,6 +339,59 @@ module Pod
272
339
  CBin::BuildAll::BinHelper.new
273
340
  end
274
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
275
395
  end
276
396
 
277
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.1
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: 2025-06-05 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