akcache 1.0.2 → 1.1.3

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: e3229f591d1e3e0a9f2ac7c46569c018e8738a530b474e0f10d7da6911a7843d
4
- data.tar.gz: 297e492a42510ebe3822c7b43af56f4ea0d0f1478a19536a2510fa439352d139
3
+ metadata.gz: 61606c56e5669af26ac45d1570d7c03b9f7162fada8fa21f81b7d6e31cfd73c9
4
+ data.tar.gz: 1a4f8d700c08f5f3a4c76b98859587a39fbf84a6a3f4e9d0f726c14b78506238
5
5
  SHA512:
6
- metadata.gz: 3bd43ec15c23d3aff54471c2ab3eea726fc1a4845d51287baaf710e8201c5dc29de13d6a97ab14fed66e98bc1231b1b3bc70b6e6023589deda5b80a4e7c50790
7
- data.tar.gz: eb0a3cb807d8e8b3212080202ff61925c9fdda0dd7001bd7369ad76ae801f87c9be6fbcf98a4d5299ae56eb426c13fba64141543873c204e9bc9c2714edb374c
6
+ metadata.gz: c1bcf43339041a467e95482b9ed716d1422075aa1dd71340119df6f7aaf84046497de93501ca4740703887cf3e5d90f4f107d8860bdeb783a3aa422b077fc91e
7
+ data.tar.gz: 75be160670313f6ed6f1add935ac70f1851e69ed0597e9ac3a69817c4b4bda6d3bf959d10bf80c5c8b52abd90990dadc850e2c8246d9532726bbe1a647a60f50
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
 
@@ -18,7 +18,7 @@ elsif ARGV[0] == "copy"
18
18
  manager.copy_cache
19
19
 
20
20
  elsif ARGV[0] == "begin"
21
- manager.project_task_begin
21
+ manager.project_task_begin(ARGV)
22
22
 
23
23
  elsif ARGV[0] == "end"
24
24
  manager.project_task_end
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.2"
4
+ VERSION = "1.1.3"
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 = ""
@@ -264,7 +266,10 @@ $file_md5_hash = {}
264
266
  source_md5_list.push path + " : " + get_file_md5(path)
265
267
  end
266
268
  end
269
+ else
270
+ source_md5_list.push "Target configuration: #{$target_build_configuration}"
267
271
  end
272
+
268
273
  source_md5_content = source_md5_list.join("\n")
269
274
  return source_md5_content
270
275
 
@@ -296,7 +301,7 @@ $file_md5_hash = {}
296
301
  if target_context[:target_md5] != target_md5 or target_context[:product_md5] != get_file_md5(target_cache_dir + "/" + FILE_NAME_PRODUCT)
297
302
  command = "rm -rf \"#{target_cache_dir}\""
298
303
  raise unless system command
299
- puts "<ERROR> #{target.name} target md5 dose not match: #{target_cache_dir}"
304
+ puts "<ERROR> #{target.name} target md5 does not match: #{target_cache_dir}"
300
305
  end
301
306
 
302
307
  dependency_exit = true
@@ -306,12 +311,12 @@ $file_md5_hash = {}
306
311
  dependency_file = item[0]
307
312
  dependency_md5 = item[1]
308
313
  unless File.exist? dependency_file
309
- # puts "<WARNING> #{target.name} dependency file miss: #{dependency_file}"
314
+ puts "<WARNING> #{target.name} dependency file miss: #{dependency_file}"
310
315
  dependency_exit = false
311
316
  break
312
317
  end
313
318
  unless get_file_md5(dependency_file) == dependency_md5
314
- # puts "<WARNING> #{target.name} dependency file md5 dose not match: #{dependency_file}"
319
+ puts "<WARNING> #{target.name} dependency file md5 does not match: #{dependency_file}"
315
320
  dependency_exit = false
316
321
  break
317
322
  end
@@ -352,8 +357,6 @@ $file_md5_hash = {}
352
357
 
353
358
  def inject_copy_action(project, target, target_context)
354
359
  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
360
 
358
361
  target.build_phases.delete_if { | build_phase |
359
362
  build_phase.class == Xcodeproj::Project::Object::PBXHeadersBuildPhase or
@@ -361,14 +364,9 @@ $file_md5_hash = {}
361
364
  build_phase.class == Xcodeproj::Project::Object::PBXResourcesBuildPhase
362
365
  }
363
366
 
364
- # if target.name == "EURLocalizedStrings"
365
- # target.build_phases.delete_if { |phase|
366
- # phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase
367
- # }
368
- # end
369
367
  command_exec = "\"#{$0}\""
370
368
  inject_phase = target.new_shell_script_build_phase("ys_copy_#{target.name}")
371
- inject_phase.shell_script = "#{command_exec} #{"copy"} \"#{target_cache_dir}\" \"#{target_product_dir}\" \"#{build_intermediate_dir}\""
369
+ inject_phase.shell_script = "#{command_exec} #{"copy"} \"#{target_cache_dir}\""
372
370
  inject_phase.show_env_vars_in_log = '1'
373
371
  end
374
372
 
@@ -378,10 +376,10 @@ $file_md5_hash = {}
378
376
  start_time = Time.now
379
377
  target_cache_dir = ARGV[1]
380
378
  cache_product_path = target_cache_dir + "/#{FILE_NAME_PRODUCT}"
381
-
379
+
382
380
  [SYMROOT, CONFIGURATION_BUILD_DIR, CONFIGURATION_TEMP_DIR, OBJROOT, TARGET_BUILD_DIR, TARGET_TEMP_DIR, SRCROOT, FULL_PRODUCT_NAME].sort.each do | key |
383
381
  unless ENV.has_key? key and ENV[key] and ENV[key].size > 0
384
- raise "<INFO> #{target.name} should have #{key}"
382
+ raise "<INFO> #{$0} should have #{key}"
385
383
  break
386
384
  end
387
385
  end
@@ -412,7 +410,6 @@ $file_md5_hash = {}
412
410
  def add_cache(target, target_info)
413
411
  target_md5 = target_info[:target_md5]
414
412
  product_dir = target_info[CONFIGURATION_BUILD_DIR]
415
- # intermediate_dir = target_info[TARGET_TEMP_DIR]
416
413
  full_product_name = target_info[FULL_PRODUCT_NAME]
417
414
 
418
415
  Dir.glob("#{product_dir}/**/*.modulemap").each do | modulemap |
@@ -492,23 +489,69 @@ $file_md5_hash = {}
492
489
  return true
493
490
 
494
491
  end
492
+
493
+ def get_custom_config_information
494
+ if File.exist? "project_cache_config.yml"
495
+ custom_config = YAML.load (File.read("project_cache_config.yml"))
496
+ $exclude_target = custom_config[:exclude_targets]
497
+ else
498
+ source = {
499
+ :description => nil,
500
+ :dependency_check => true,
501
+ :exclude_targets => ["target1", "target2"],
502
+ }.to_yaml
503
+
504
+ substitution_list = {
505
+ /:description:/ => "# You can assign values to these parameters to achieve some custom functions\n",
506
+ /: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:",
507
+ /:exclude_targets:/ => "\n\n# the targets that will not participate in cache dependency detection\n:exclude_targets:",
508
+ }
509
+
510
+ substitution_list.each do |pattern, replacement|
511
+ source.gsub!(pattern, replacement)
512
+ end
513
+ puts source
514
+ File.write("project_cache_config.yml", source)
515
+ end
516
+
517
+ end
495
518
 
496
- def project_task_begin
497
519
 
498
- clean_temp_files
520
+ def project_task_begin(argv)
521
+
522
+ argv.each do |prama|
523
+ if prama.include? "configuration"
524
+ if prama.include? "Debug"
525
+ $target_build_configuration = "Debug"
526
+ elsif prama.include? "Release"
527
+ $target_build_configuration = "Release"
528
+ end
529
+ end
530
+ end
531
+
499
532
  projects = get_projects
500
533
  total_count = 0
501
534
  hit_count = 0
502
535
  miss_count = 0
503
536
  error_count = 0
504
537
  hit_target_md5_cache_set = Set.new
538
+ miss_target_cache_set = Set.new
539
+
540
+ get_custom_config_information
505
541
 
506
542
  pre_targets_info = {}
543
+
544
+ projects.each do |project|
545
+ restore_project(project)
546
+ backup_project(project)
547
+ end
548
+
549
+ clean_temp_files
550
+
551
+ projects = get_projects
552
+
507
553
  projects.each do |project|
508
554
  project.native_targets.each do |target|
509
- target.build_phases.delete_if { |phase|
510
- phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase and phase.name.include? "ys_"
511
- }
512
555
  if can_cache_target(target)
513
556
  total_count = total_count + 1
514
557
  source_files = get_target_source_files(target)
@@ -538,58 +581,86 @@ $file_md5_hash = {}
538
581
  end
539
582
  end
540
583
  end
541
-
542
- projects.each do |project|
543
- project.native_targets.each do |target|
544
- target_info = pre_targets_info[target]
545
- next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
546
- hit_target_cache_dirs = target_info[:hit_target_cache_dir]
547
- next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
548
- target_md5 = target_info[:target_md5]
549
-
550
- really_hit_dir = ""
551
- hit_target_cache_dirs.each do |hit_target_cache_dir|
552
- all_dependency_target_exist = true
553
- hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
554
- if hit_targets_info[:dependency_targets_md5]
555
- hit_targets_info[:dependency_targets_md5].each do | item |
556
- dependency_target = item[0]
557
- dependency_target_md5 = item[1]
558
- unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
559
- puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} dose not hit"
560
- all_dependency_target_exist = false
584
+
585
+ while true
586
+ projects.each do |project|
587
+ project.native_targets.each do |target|
588
+ target_info = pre_targets_info[target]
589
+ next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
590
+ next unless target_info and target_info[:target_status] != CACHE_STATUS_HIT
591
+ hit_target_cache_dirs = target_info[:hit_target_cache_dir]
592
+ next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
593
+ target_md5 = target_info[:target_md5]
594
+
595
+ target_really_hit_dir = ""
596
+ target_really_miss = false
597
+ hit_target_cache_dirs.each do |hit_target_cache_dir|
598
+ all_dependency_target_exist = true
599
+ target_really_miss = false
600
+ hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
601
+ if hit_targets_info[:dependency_targets_md5]
602
+ hit_targets_info[:dependency_targets_md5].each do | item |
603
+ dependency_target = item[0]
604
+ dependency_target_md5 = item[1]
605
+ if $exclude_target.include? dependency_target
606
+ puts "<INFO> #{target.name} #{target_md5} hit cache, dependency target #{dependency_target}-#{dependency_target_md5} skip check"
607
+ next
608
+ end
609
+
610
+ if miss_target_cache_set.include? "#{dependency_target}"
611
+ puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
612
+ target_really_miss = true
613
+ all_dependency_target_exist = false
614
+ break
615
+ end
616
+
617
+ unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
618
+ puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
619
+ all_dependency_target_exist = false
620
+ target_really_miss = true
621
+ break
622
+ end
623
+ end
624
+
625
+ if all_dependency_target_exist
626
+ target_really_hit_dir = hit_target_cache_dir
627
+ break
628
+ end
629
+
630
+ if target_really_miss
561
631
  break
562
632
  end
563
- end
564
-
565
- if all_dependency_target_exist
566
- really_hit_dir = hit_target_cache_dir
567
- break
568
633
  end
569
634
  end
635
+
636
+ if target_really_hit_dir.length > 0
637
+ puts "<INFO> #{target.name} #{target_md5} hit cache"
638
+ hit_count = hit_count + 1
639
+ hit_target_info = YAML.load(File.read(target_really_hit_dir + "/" + FILE_NAME_CONTEXT))
640
+ target_info = target_info.merge!(hit_target_info)
641
+ target_info[:target_status] = CACHE_STATUS_HIT
642
+ target_info[:hit_target_cache_dir] = target_really_hit_dir
643
+ inject_copy_action(project, target, target_info)
644
+ end
645
+
646
+ if target_really_miss
647
+ miss_count = miss_count + 1
648
+ miss_target_cache_set.add "#{target.name}"
649
+ hit_target_md5_cache_set.delete "#{target.name}-#{target_info[:target_md5]}"
650
+ target_info[:target_status] = CACHE_STATUS_MISS
651
+ target_info.delete(:hit_target_cache_dir)
652
+ inject_flag_action(project, target)
653
+ end
654
+
655
+ File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
570
656
  end
571
-
572
- if really_hit_dir.length > 0
573
- puts "<INFO> #{target.name} #{target_md5} hit cache"
574
- hit_count = hit_count + 1
575
- hit_target_info = YAML.load(File.read(really_hit_dir + "/" + FILE_NAME_CONTEXT))
576
- target_info = target_info.merge!(hit_target_info)
577
- target_info[:target_status] = CACHE_STATUS_HIT
578
- target_info[:hit_target_cache_dir] = really_hit_dir
579
- inject_copy_action(project, target, target_info)
580
- else
581
- puts "<INFO> #{target.name} #{target_md5} miss cache for reason dependency miss"
582
- target_info[:target_status] = CACHE_STATUS_MISS
583
- target_info.delete(:hit_target_cache_dir)
584
- inject_flag_action(project, target)
585
- miss_count = miss_count + 1
586
- end
587
- File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
588
-
657
+ project.save
658
+ end
659
+ if total_count == hit_count + miss_count + error_count
660
+ break
661
+ else
662
+ puts "<INFO> continue to find hit cache"
589
663
  end
590
-
591
- backup_project(project)
592
- project.save
593
664
  end
594
665
  puts "<INFO> total count: #{total_count}, hit count: #{hit_count}, miss_count: #{miss_count}, error_count: #{error_count}"
595
666
  end
@@ -740,7 +811,6 @@ $file_md5_hash = {}
740
811
 
741
812
  puts "<INFO> total add cache count: #{total_add_count}"
742
813
  end
743
-
744
814
 
745
815
  end
746
816
 
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.2
4
+ version: 1.1.3
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-11 00:00:00.000000000 Z
11
+ date: 2022-01-11 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: []