akcache 1.0.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d001cd84ab783a9c6f3ba14d1399dae3bb6ff8d7c7ae743aea6cfa4366291559
4
- data.tar.gz: '098e73b29a1aad794f7b280b26f3cfd3b5bee0e706740e8c4cdad28daabc11cf'
3
+ metadata.gz: 890961de10e634c3aecdfabf9e89d93b78c50a310e04e44d3ea75c0fb4565c53
4
+ data.tar.gz: a7f2473162f65bc4f67a66abb1d7a93e97a2647a720856900671b43850bf9036
5
5
  SHA512:
6
- metadata.gz: d307138f05c3dc3f12be15cc38403d468a3b4d52aa1512266a32b42ff8d93e36f56b2529a70719f54552340496b4f53756ce6448040fd1034e0e47fff3cc3714
7
- data.tar.gz: '09ab5c36cec65518130573d6e85ad3bc0858bd65eef8854c93ed87dba11d9197fe6b5a124d0e8a15f2f5e3e655b2ec554113d75c3cd53096f8c3938bf2583bba'
6
+ metadata.gz: 765afe47fcc2df2d63095d49c8817b6212efa7c64d768a97105da8626075244de37bfb0549af153e08d910dc06c0f37a10775179094f7923f4d061e452ba3cbb
7
+ data.tar.gz: 87006aa95d29ec372f9e28d88b6c0c70d397a297f9019af031d3bb0503117f8be061d4a02e18e168a27edecdd1e6fbc418ee9f6cb5f9a2b118bf03a01b08c052
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akcache (1.0.0)
4
+ akcache (1.0.2)
5
5
  xcodeproj (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Kcache
1
+ # AKCache
2
+
2
3
 
3
4
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kcache`. To experiment with that code, run `bin/console` for an interactive prompt.
4
5
 
data/bin/kcache CHANGED
@@ -5,7 +5,7 @@ require 'kcache'
5
5
  manager = CacheManager.new
6
6
 
7
7
  if ARGV[0] == "xcodebuild" or ARGV[0] == "fastlane"
8
- manager.project_task_begin
8
+ manager.project_task_begin(ARGV)
9
9
  raise unless system(*ARGV)
10
10
  manager.project_task_end
11
11
 
data/kcache.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.email = ["1433233832@qq.com"]
13
13
 
14
14
  spec.summary = "a cache tool"
15
- spec.description = "a cache tool that can promote xcode build time"
15
+ spec.description = "a cache tool that can reduce xcode archive time"
16
16
  spec.homepage = "https://github.com/yusheng00"
17
17
  spec.license = "MIT"
18
18
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
@@ -0,0 +1,29 @@
1
+ # AKMall
2
+
3
+ [![CI Status](https://img.shields.io/travis/pangyulei/AKMall.svg?style=flat)](https://travis-ci.org/pangyulei/AKMall)
4
+ [![Version](https://img.shields.io/cocoapods/v/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
5
+ [![License](https://img.shields.io/cocoapods/l/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
6
+ [![Platform](https://img.shields.io/cocoapods/p/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
7
+
8
+ ## Example
9
+
10
+ To run the example project, clone the repo, and run `pod install` from the Example directory first.
11
+
12
+ ## Requirements
13
+
14
+ ## Installation
15
+
16
+ AKMall is available through [CocoaPods](https://cocoapods.org). To install
17
+ it, simply add the following line to your Podfile:
18
+
19
+ ```ruby
20
+ pod 'AKMall'
21
+ ```
22
+
23
+ ## Author
24
+
25
+ pangyulei, pangyulei@gmail.com
26
+
27
+ ## License
28
+
29
+ AKMall is available under the MIT license. See the LICENSE file for more info.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kcache
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.2"
5
5
  end
data/lib/kcache.rb CHANGED
@@ -9,7 +9,6 @@ require "find"
9
9
  require 'set'
10
10
 
11
11
  #配置
12
- Target_Build_Configuration = "Release"
13
12
 
14
13
  TARGET_CACHE_CONFIG = "target_cache_config.yml"
15
14
 
@@ -36,11 +35,12 @@ OBJROOT = "OBJROOT"
36
35
 
37
36
 
38
37
  #变量
38
+ $target_build_configuration = "Release"
39
39
  $podfile_spec_checksums = nil
40
40
  $file_md5_hash = {}
41
+ $exclude_target = []
41
42
 
42
-
43
- class CacheManager
43
+ class CacheManager
44
44
 
45
45
  def get_cache_root
46
46
  return Dir.home + "/ysCache"
@@ -82,23 +82,24 @@ $file_md5_hash = {}
82
82
  end
83
83
  return wrapper_project_paths.uniq
84
84
  end
85
+
85
86
 
86
87
  def backup_project(project)
87
- command = "cp \"#{project.path}/project.pbxproj\" \"#{project.path}/project.ysTest_backup_pbxproj\""
88
+ command = "cp \"#{project.path}/project.pbxproj\" \"#{project.path}/ysTest_backup.pbxproj\""
88
89
  raise unless system command
89
90
  end
90
91
 
91
92
  def clean_temp_files
92
- command = "rm -rf Pods/*.xcodeproj/project.ysTest_backup_pbxproj"
93
- raise unless system command
93
+ # command = "rm -rf Pods/*.xcodeproj/ysTest_backup.pbxproj"
94
+ # raise unless system command
94
95
 
95
96
  command = "rm -rf Pods/*.xcodeproj/*.#{FILE_NAME_TARGET_CONTEXT}"
96
97
  raise unless system command
97
98
  end
98
99
 
99
100
  def restore_project(project)
100
- if File.exist? "#{project.path}/project.ysTest_backup_pbxproj"
101
- command = "mv \"#{project.path}/project.ysTest_backup_pbxproj\" \"#{project.path}/project.pbxproj\""
101
+ if File.exist? "#{project.path}/ysTest_backup.pbxproj"
102
+ command = "mv \"#{project.path}/ysTest_backup.pbxproj\" \"#{project.path}/project.pbxproj\""
102
103
  raise unless system command
103
104
  end
104
105
  end
@@ -152,6 +153,7 @@ $file_md5_hash = {}
152
153
  file_path = file.file_ref.real_path.to_s
153
154
  files.push file_path
154
155
  end
156
+
155
157
  #获取所有头文件(.h)
156
158
  target.headers_build_phase.files.each do | file |
157
159
  file_path = file.file_ref.real_path.to_s
@@ -186,7 +188,7 @@ $file_md5_hash = {}
186
188
  $podfile_spec_checksums = podfile_lock["SPEC CHECKSUMS"]
187
189
  end
188
190
 
189
- project_configuration = project.build_configurations.detect { | config | config.name == Target_Build_Configuration}
191
+ project_configuration = project.build_configurations.detect { | config | config.name == $target_build_configuration}
190
192
  project_configuration_content = project_configuration.pretty_print.to_yaml
191
193
 
192
194
  project_xcconfig = ""
@@ -197,7 +199,7 @@ $file_md5_hash = {}
197
199
  end
198
200
  end
199
201
 
200
- target_configuration = target.build_configurations.detect { | config | config.name == Target_Build_Configuration}
202
+ target_configuration = target.build_configurations.detect { | config | config.name == $target_build_configuration}
201
203
  target_configuration_content = target_configuration.pretty_print.to_yaml
202
204
 
203
205
  target_xcconfig = ""
@@ -296,7 +298,7 @@ $file_md5_hash = {}
296
298
  if target_context[:target_md5] != target_md5 or target_context[:product_md5] != get_file_md5(target_cache_dir + "/" + FILE_NAME_PRODUCT)
297
299
  command = "rm -rf \"#{target_cache_dir}\""
298
300
  raise unless system command
299
- puts "<ERROR> #{target.name} target md5 dose not match: #{target_cache_dir}"
301
+ puts "<ERROR> #{target.name} target md5 does not match: #{target_cache_dir}"
300
302
  end
301
303
 
302
304
  dependency_exit = true
@@ -306,12 +308,12 @@ $file_md5_hash = {}
306
308
  dependency_file = item[0]
307
309
  dependency_md5 = item[1]
308
310
  unless File.exist? dependency_file
309
- # puts "<WARNING> #{target.name} dependency file miss: #{dependency_file}"
311
+ puts "<WARNING> #{target.name} dependency file miss: #{dependency_file}"
310
312
  dependency_exit = false
311
313
  break
312
314
  end
313
315
  unless get_file_md5(dependency_file) == dependency_md5
314
- # puts "<WARNING> #{target.name} dependency file md5 dose not match: #{dependency_file}"
316
+ puts "<WARNING> #{target.name} dependency file md5 does not match: #{dependency_file}"
315
317
  dependency_exit = false
316
318
  break
317
319
  end
@@ -344,7 +346,7 @@ $file_md5_hash = {}
344
346
  end
345
347
 
346
348
  def inject_flag_action(project, target)
347
- command_exec = "kcache"
349
+ command_exec = "\"#{$0}\""
348
350
  inject_phase = target.new_shell_script_build_phase("ys_inject_#{target.name}")
349
351
  inject_phase.shell_script = "#{command_exec} #{"inject"} #{target.name} \"#{project.path}\""
350
352
  inject_phase.show_env_vars_in_log = '1'
@@ -352,8 +354,6 @@ $file_md5_hash = {}
352
354
 
353
355
  def inject_copy_action(project, target, target_context)
354
356
  target_cache_dir = target_context[:hit_target_cache_dir]
355
- target_product_dir = target_context[:build_product_dir]
356
- build_intermediate_dir = target_context[:build_intermediate_dir]
357
357
 
358
358
  target.build_phases.delete_if { | build_phase |
359
359
  build_phase.class == Xcodeproj::Project::Object::PBXHeadersBuildPhase or
@@ -361,15 +361,9 @@ $file_md5_hash = {}
361
361
  build_phase.class == Xcodeproj::Project::Object::PBXResourcesBuildPhase
362
362
  }
363
363
 
364
- # if target.name == "EURLocalizedStrings"
365
- # target.build_phases.delete_if { |phase|
366
- # phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase
367
- # }
368
- # end
369
-
370
- command_exec = "kcache"
364
+ command_exec = "\"#{$0}\""
371
365
  inject_phase = target.new_shell_script_build_phase("ys_copy_#{target.name}")
372
- inject_phase.shell_script = "#{command_exec} #{"copy"} \"#{target_cache_dir}\" \"#{target_product_dir}\" \"#{build_intermediate_dir}\""
366
+ inject_phase.shell_script = "#{command_exec} #{"copy"} \"#{target_cache_dir}\""
373
367
  inject_phase.show_env_vars_in_log = '1'
374
368
  end
375
369
 
@@ -379,10 +373,10 @@ $file_md5_hash = {}
379
373
  start_time = Time.now
380
374
  target_cache_dir = ARGV[1]
381
375
  cache_product_path = target_cache_dir + "/#{FILE_NAME_PRODUCT}"
382
-
376
+
383
377
  [SYMROOT, CONFIGURATION_BUILD_DIR, CONFIGURATION_TEMP_DIR, OBJROOT, TARGET_BUILD_DIR, TARGET_TEMP_DIR, SRCROOT, FULL_PRODUCT_NAME].sort.each do | key |
384
378
  unless ENV.has_key? key and ENV[key] and ENV[key].size > 0
385
- raise "<INFO> #{target.name} should have #{key}"
379
+ raise "<INFO> #{$0} should have #{key}"
386
380
  break
387
381
  end
388
382
  end
@@ -413,7 +407,6 @@ $file_md5_hash = {}
413
407
  def add_cache(target, target_info)
414
408
  target_md5 = target_info[:target_md5]
415
409
  product_dir = target_info[CONFIGURATION_BUILD_DIR]
416
- # intermediate_dir = target_info[TARGET_TEMP_DIR]
417
410
  full_product_name = target_info[FULL_PRODUCT_NAME]
418
411
 
419
412
  Dir.glob("#{product_dir}/**/*.modulemap").each do | modulemap |
@@ -493,23 +486,69 @@ $file_md5_hash = {}
493
486
  return true
494
487
 
495
488
  end
489
+
490
+ def get_custom_config_information
491
+ if File.exist? "project_cache_config.yml"
492
+ custom_config = YAML.load (File.read("project_cache_config.yml"))
493
+ $exclude_target = custom_config[:exclude_targets]
494
+ else
495
+ source = {
496
+ :description => nil,
497
+ :dependency_check => true,
498
+ :exclude_targets => ["target1", "target2"],
499
+ }.to_yaml
500
+
501
+ substitution_list = {
502
+ /:description:/ => "# You can assign values to these parameters to achieve some custom functions\n",
503
+ /:dependency_check:/ => "\n\n# Whether to check the dependencies of the target. For exzample: target A depends on target B. Under normal circumstances, target B is recompiled, then target A will be recompiled, but if the dependencies are not checked, target A will not be recompiled at this time\n:dependency_check:",
504
+ /:exclude_targets:/ => "\n\n# the targets that will not participate in cache dependency detection\n:exclude_targets:",
505
+ }
506
+
507
+ substitution_list.each do |pattern, replacement|
508
+ source.gsub!(pattern, replacement)
509
+ end
510
+ puts source
511
+ File.write("project_cache_config.yml", source)
512
+ end
496
513
 
497
- def project_task_begin
514
+ end
498
515
 
499
- clean_temp_files
516
+
517
+ def project_task_begin(argv)
518
+
519
+ argv.each do |prama|
520
+ if prama.include? "configuration"
521
+ if prama.include? "Debug"
522
+ $target_build_configuration = "Debug"
523
+ elsif prama.include? "Release"
524
+ $target_build_configuration = "Release"
525
+ end
526
+ end
527
+ end
528
+
500
529
  projects = get_projects
501
530
  total_count = 0
502
531
  hit_count = 0
503
532
  miss_count = 0
504
533
  error_count = 0
505
534
  hit_target_md5_cache_set = Set.new
535
+ miss_target_cache_set = Set.new
536
+
537
+ get_custom_config_information
506
538
 
507
539
  pre_targets_info = {}
540
+
541
+ projects.each do |project|
542
+ restore_project(project)
543
+ backup_project(project)
544
+ end
545
+
546
+ clean_temp_files
547
+
548
+ projects = get_projects
549
+
508
550
  projects.each do |project|
509
551
  project.native_targets.each do |target|
510
- target.build_phases.delete_if { |phase|
511
- phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase and phase.name.include? "ys_"
512
- }
513
552
  if can_cache_target(target)
514
553
  total_count = total_count + 1
515
554
  source_files = get_target_source_files(target)
@@ -539,58 +578,86 @@ $file_md5_hash = {}
539
578
  end
540
579
  end
541
580
  end
542
-
543
- projects.each do |project|
544
- project.native_targets.each do |target|
545
- target_info = pre_targets_info[target]
546
- next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
547
- hit_target_cache_dirs = target_info[:hit_target_cache_dir]
548
- next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
549
- target_md5 = target_info[:target_md5]
550
-
551
- really_hit_dir = ""
552
- hit_target_cache_dirs.each do |hit_target_cache_dir|
553
- all_dependency_target_exist = true
554
- hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
555
- if hit_targets_info[:dependency_targets_md5]
556
- hit_targets_info[:dependency_targets_md5].each do | item |
557
- dependency_target = item[0]
558
- dependency_target_md5 = item[1]
559
- unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
560
- puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} dose not hit"
561
- all_dependency_target_exist = false
581
+
582
+ while true
583
+ projects.each do |project|
584
+ project.native_targets.each do |target|
585
+ target_info = pre_targets_info[target]
586
+ next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
587
+ next unless target_info and target_info[:target_status] != CACHE_STATUS_HIT
588
+ hit_target_cache_dirs = target_info[:hit_target_cache_dir]
589
+ next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
590
+ target_md5 = target_info[:target_md5]
591
+
592
+ target_really_hit_dir = ""
593
+ target_really_miss = false
594
+ hit_target_cache_dirs.each do |hit_target_cache_dir|
595
+ all_dependency_target_exist = true
596
+ target_really_miss = false
597
+ hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
598
+ if hit_targets_info[:dependency_targets_md5]
599
+ hit_targets_info[:dependency_targets_md5].each do | item |
600
+ dependency_target = item[0]
601
+ dependency_target_md5 = item[1]
602
+ if $exclude_target.include? dependency_target
603
+ puts "<INFO> #{target.name} #{target_md5} hit cache, dependency target #{dependency_target}-#{dependency_target_md5} skip check"
604
+ next
605
+ end
606
+
607
+ if miss_target_cache_set.include? "#{dependency_target}"
608
+ puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
609
+ target_really_miss = true
610
+ all_dependency_target_exist = false
611
+ break
612
+ end
613
+
614
+ unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
615
+ puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
616
+ all_dependency_target_exist = false
617
+ target_really_miss = true
618
+ break
619
+ end
620
+ end
621
+
622
+ if all_dependency_target_exist
623
+ target_really_hit_dir = hit_target_cache_dir
624
+ break
625
+ end
626
+
627
+ if target_really_miss
562
628
  break
563
629
  end
564
- end
565
-
566
- if all_dependency_target_exist
567
- really_hit_dir = hit_target_cache_dir
568
- break
569
630
  end
570
631
  end
632
+
633
+ if target_really_hit_dir.length > 0
634
+ puts "<INFO> #{target.name} #{target_md5} hit cache"
635
+ hit_count = hit_count + 1
636
+ hit_target_info = YAML.load(File.read(target_really_hit_dir + "/" + FILE_NAME_CONTEXT))
637
+ target_info = target_info.merge!(hit_target_info)
638
+ target_info[:target_status] = CACHE_STATUS_HIT
639
+ target_info[:hit_target_cache_dir] = target_really_hit_dir
640
+ inject_copy_action(project, target, target_info)
641
+ end
642
+
643
+ if target_really_miss
644
+ miss_count = miss_count + 1
645
+ miss_target_cache_set.add "#{target.name}"
646
+ hit_target_md5_cache_set.delete "#{target.name}-#{target_info[:target_md5]}"
647
+ target_info[:target_status] = CACHE_STATUS_MISS
648
+ target_info.delete(:hit_target_cache_dir)
649
+ inject_flag_action(project, target)
650
+ end
651
+
652
+ File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
571
653
  end
572
-
573
- if really_hit_dir.length > 0
574
- puts "<INFO> #{target.name} #{target_md5} hit cache"
575
- hit_count = hit_count + 1
576
- hit_target_info = YAML.load(File.read(really_hit_dir + "/" + FILE_NAME_CONTEXT))
577
- target_info = target_info.merge!(hit_target_info)
578
- target_info[:target_status] = CACHE_STATUS_HIT
579
- target_info[:hit_target_cache_dir] = really_hit_dir
580
- inject_copy_action(project, target, target_info)
581
- else
582
- puts "<INFO> #{target.name} #{target_md5} miss cache for reason dependency miss"
583
- target_info[:target_status] = CACHE_STATUS_MISS
584
- target_info.delete(:hit_target_cache_dir)
585
- inject_flag_action(project, target)
586
- miss_count = miss_count + 1
587
- end
588
- File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
589
-
654
+ project.save
655
+ end
656
+ if total_count == hit_count + miss_count + error_count
657
+ break
658
+ else
659
+ puts "<INFO> continue to find hit cache"
590
660
  end
591
-
592
- backup_project(project)
593
- project.save
594
661
  end
595
662
  puts "<INFO> total count: #{total_count}, hit count: #{hit_count}, miss_count: #{miss_count}, error_count: #{error_count}"
596
663
  end
@@ -741,7 +808,6 @@ $file_md5_hash = {}
741
808
 
742
809
  puts "<INFO> total add cache count: #{total_add_count}"
743
810
  end
744
-
745
811
 
746
812
  end
747
813
 
data/lib/pod_plugin.rb ADDED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yusheng
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- description: a cache tool that can promote xcode build time
27
+ description: a cache tool that can reduce xcode archive time
28
28
  email:
29
29
  - 1433233832@qq.com
30
30
  executables:
@@ -47,7 +47,9 @@ files:
47
47
  - bin/setup
48
48
  - kcache.gemspec
49
49
  - lib/kcache.rb
50
+ - lib/kcache/README.md
50
51
  - lib/kcache/version.rb
52
+ - lib/pod_plugin.rb
51
53
  homepage: https://github.com/yusheng00
52
54
  licenses:
53
55
  - MIT
@@ -55,7 +57,7 @@ metadata:
55
57
  homepage_uri: https://github.com/yusheng00
56
58
  source_code_uri: https://github.com/yusheng00
57
59
  changelog_uri: https://github.com/yusheng00
58
- post_install_message:
60
+ post_install_message:
59
61
  rdoc_options: []
60
62
  require_paths:
61
63
  - lib
@@ -70,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
72
  - !ruby/object:Gem::Version
71
73
  version: '0'
72
74
  requirements: []
73
- rubygems_version: 3.0.6
74
- signing_key:
75
+ rubygems_version: 3.1.6
76
+ signing_key:
75
77
  specification_version: 4
76
78
  summary: a cache tool
77
79
  test_files: []