Class: PodUpdateConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-meitu-bin/config/config.rb

Constant Summary collapse

@@pods =
[]
@@lockfile =
nil
@@repo_update =
true
@@prepare_time =
0
@@checksum =
nil
@@large_pod_hash =
{}
@@is_mtxx =
false
@@is_clear =
false
@@shell_project =
false
@@is_podfile_lock_nil =

是否设置podfile.lock = nil

false
@@checkout_options =
{}
@@dependency_relationships =

存储所有组件的依赖关系集合,格式: { pod_name => { dependencies: { dep_name => { version: version, requirement: requirement } } } }

{}
@@external_source_commit =

用于存储外部源的commit信息

{}
@@external_source =

用于存储需要过滤的外部源信息

[]
@@external_source_binary =

用于存储需要记录制作的external_source 组件

[]
@@pods_with_commit =

记录 Podfile 中通过 :commit 指定的本地组件及其 git 信息,格式: { pod_name => { git: git_url, commit: commit_hash } } mbox 激活组件,避免关联组件都切换到源码,影响编译速度

{}
@@worktree_identities =

local path 组件在当前一次 resolve 中的身份快照(root_name => worktree_identity)

{}
{}

Class Method Summary collapse

Class Method Details

.add_pod_hash(name, size) ⇒ Object



406
407
408
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 406

def self.add_pod_hash(name,size)
  @@large_pod_hash[name]=size
end

.add_value(value) ⇒ Object



385
386
387
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 385

def self.add_value(value)
  @@pods << value
end

.checkout_optionsObject



275
276
277
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 275

def self.checkout_options
  @@checkout_options
end

.checksumObject



403
404
405
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 403

def self.checksum
  @@checksum
end

.clearObject



430
431
432
433
434
435
436
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 430

def self.clear
  @@pods = []
  @@lockfile = nil
  @@is_clear = true
  @@worktree_identities = {}
  @@promoted_local_pods = {}
end

.dependency_relationshipsObject

获取依赖关系集合



192
193
194
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 192

def self.dependency_relationships
  @@dependency_relationships
end

.external_sourceObject



207
208
209
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 207

def self.external_source()
  @@external_source
end

.external_source_binaryObject



267
268
269
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 267

def self.external_source_binary()
  @@external_source_binary
end

.get_checkout_option(pod_name) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 279

def self.get_checkout_option(pod_name)
  options = @@checkout_options[pod_name]

  # return nil unless !podfile.use_source_pods.include?(pod_name)
  return nil unless options

  # 优先返回commit信息
  if options[:commit]
    options[:commit]
  # 其次返回tag信息
  elsif options[:tag]
    options[:tag]
  else
    nil
  end
end

.get_with_commit(pod_name) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 222

def self.get_with_commit(pod_name)
  options = @@pods_with_commit[pod_name]
  return nil unless options
  # 优先返回commit信息
  if options[:commit]
    options[:commit]
    # 其次返回tag信息
  elsif options[:tag]
    options[:tag]
  else
    nil
  end

end

.get_worktree_identity(pod_name) ⇒ Object



243
244
245
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 243

def self.get_worktree_identity(pod_name)
  @@worktree_identities[Pod::Specification.root_name(pod_name)]
end

.is_clearObject



437
438
439
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 437

def self.is_clear
  @@is_clear
end

.is_mtxxObject



391
392
393
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 391

def self.is_mtxx()
  @@is_mtxx
end

.is_podfile_lock_nilObject



440
441
442
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 440

def self.is_podfile_lock_nil
  @@is_podfile_lock_nil
end

.large_pod_hashObject



409
410
411
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 409

def self.large_pod_hash
  @@large_pod_hash
end

.lockfileObject



397
398
399
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 397

def self.lockfile()
  @@lockfile
end

.parse_checkout_options(lockfile_path) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 296

def self.parse_checkout_options(lockfile_path)
  return unless File.exist?(lockfile_path)
  
  begin
    content = File.read(lockfile_path)
    checkout_section = content.split('CHECKOUT OPTIONS:').last.split('SPEC REPOS:').first.strip
    
    options = {}
    current_pod = nil
    
    checkout_section.each_line do |line|
      line = line.strip
      next if line.empty?
      
      if line.start_with?('  ')
        # 这是pod的选项
        if current_pod
          key, value = line.strip.split(': ', 2)
          options[current_pod] ||= {}
          options[current_pod][key] = value
        end
      else
        # 这是pod名称
        current_pod = line.strip
      end
    end
    
    set_checkout_options(options)
    
    if ENV['p_bin_d'] == '1'
      puts "\nPodfile.lock CHECKOUT OPTIONS:".yellow
      options.each do |pod, opts|
        puts "#{pod}:"
        opts.each do |key, value|
          puts "  #{key}: #{value}"
        end
      end
    end
  rescue => e
    warn "Failed to parse CHECKOUT OPTIONS from Podfile.lock: #{e.message}"
  end
end

.parse_checkout_options_from_specs(checkout_options_hash, podfile, path_commit_pods) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 339

def self.parse_checkout_options_from_specs(checkout_options_hash,podfile,path_commit_pods)
  options = {}
  
  checkout_options_hash.each do |pod_name, opts|
    # 保存有 commit 或 tag 信息的组件
    # 注意:不再过滤 use_source_pods 中的组件,因为从二进制切换到源码时
    # 也需要保留 checkout options(commit/tag),否则会导致找不到正确的下载源
    if opts[:commit] || opts[:tag]
      options[pod_name] = {
        :git => opts[:git],
        :commit => opts[:commit],
        :tag => opts[:tag]
      }.compact
    end
  end
  path_commit_pods.each do |pod_name, opts|
    options[pod_name] = opts if options[pod_name].nil?
    # puts "追加本地组件 #{pod_name} 的 commit 信息: #{opts[:commit]}".yellow
  end
  set_checkout_options(options)
  
  # 调试输出
#    Pod::UI.puts "[DEBUG] parse_checkout_options_from_specs: 解析到的 checkout_options 数量=#{options.size}".yellow
#    if options['MTLivePhoto'] || options['MTLPCloudService']
#      Pod::UI.puts "[DEBUG] MTLivePhoto checkout_option: #{options['MTLivePhoto'].inspect}".yellow
#      Pod::UI.puts "[DEBUG] MTLPCloudService checkout_option: #{options['MTLPCloudService'].inspect}".yellow
#    end
#    Pod::UI.puts "[DEBUG] checkout_options_hash 输入: #{checkout_options_hash.keys.join(', ')}".yellow if checkout_options_hash.keys.include?('MTLivePhoto') || checkout_options_hash.keys.include?('MTLPCloudService')
  
  if ENV['p_bin_v'] == '1'
    puts "\nResolver Specs CHECKOUT OPTIONS (commit/tag):".yellow
    options.each do |pod, opts|
      puts "#{pod}:"
      opts.each do |key, value|
        puts "  #{key}: #{value}"
      end
    end
  end
end

.podsObject



427
428
429
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 427

def self.pods
  @@pods
end

.pods_with_commitObject

读取本地组件列表



218
219
220
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 218

def self.pods_with_commit
  @@pods_with_commit
end

.prepare_timeObject



423
424
425
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 423

def self.prepare_time
  @@prepare_time
end

.promote_local_pod(pod_name, metadata = {}) ⇒ Object



251
252
253
254
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 251

def self.promote_local_pod(pod_name,  = {})
  # metadata 默认包含命中的 binary version 与 identity,便于后续日志/排障追踪。
  @@promoted_local_pods[Pod::Specification.root_name(pod_name)] = 
end

Returns:

  • (Boolean)


256
257
258
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 256

def self.promoted_local_pod?(pod_name)
  @@promoted_local_pods.key?(Pod::Specification.root_name(pod_name))
end


260
261
262
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 260

def self.promoted_local_pods
  @@promoted_local_pods
end

.repo_updateObject

一个类方法,用于显示数组中的值



414
415
416
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 414

def self.repo_update
  @@repo_update
end

.resultObject



200
201
202
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 200

def self.result
  @@result
end

.set_checkout_options(options) ⇒ Object



271
272
273
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 271

def self.set_checkout_options(options)
  @@checkout_options = options
end

.set_checksum(checksum) ⇒ Object



400
401
402
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 400

def self.set_checksum(checksum)
  @@checksum = checksum
end

.set_dependency_relationships(relationships) ⇒ Object

设置依赖关系集合



187
188
189
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 187

def self.set_dependency_relationships(relationships)
  @@dependency_relationships = relationships
end

.set_external_source(dic) ⇒ Object



204
205
206
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 204

def self.set_external_source(dic)
  @@external_source << dic
end

.set_external_source_binary(dic) ⇒ Object



264
265
266
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 264

def self.set_external_source_binary(dic)
  @@external_source_binary << dic
end

.set_is_mtxx(value) ⇒ Object



388
389
390
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 388

def self.set_is_mtxx(value)
  @@is_mtxx = value
end

.set_is_podfile_lock_nil(value) ⇒ Object



443
444
445
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 443

def self.set_is_podfile_lock_nil(value)
  @@is_podfile_lock_nil = value
end

.set_lockfile(path) ⇒ Object



394
395
396
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 394

def self.set_lockfile(path)
  @@lockfile = Pod::Lockfile.from_file(path) if path
end

.set_pods_with_commit(pods) ⇒ Object

存储最新解析到的本地组件列表(包含路径与 commit)



213
214
215
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 213

def self.set_pods_with_commit(pods)
  @@pods_with_commit = pods
end

.set_prepare_time(time) ⇒ Object



420
421
422
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 420

def self.set_prepare_time(time)
  @@prepare_time = time
end

.set_repo_updateObject



417
418
419
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 417

def self.set_repo_update
  @@repo_update = false
end

.set_result(result) ⇒ Object



196
197
198
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 196

def self.set_result(result)
  @@result = result
end

.set_shell_projectObject



379
380
381
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 379

def self.set_shell_project
  @@shell_project = true
end

.set_worktree_identity(pod_name, identity) ⇒ Object



237
238
239
240
241
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 237

def self.set_worktree_identity(pod_name, identity)
  return if identity.nil? || identity.empty?

  @@worktree_identities[Pod::Specification.root_name(pod_name)] = identity
end

.shell_projectObject



382
383
384
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 382

def self.shell_project
  @@shell_project
end

.worktree_identitiesObject



247
248
249
# File 'lib/cocoapods-meitu-bin/config/config.rb', line 247

def self.worktree_identities
  @@worktree_identities
end