akcache 1.0.0 → 1.1.1
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +2 -1
- data/kcache.gemspec +1 -1
- data/lib/kcache/README.md +29 -0
- data/lib/kcache/version.rb +1 -1
- data/lib/kcache.rb +140 -77
- data/lib/pod_plugin.rb +0 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a09a77cf0dd1f6e164eedf0a94b3e2f87009416c2ca271acb24a2823c26dd190
|
4
|
+
data.tar.gz: 636c83770b0dfc9d78219333daf57cb33b548d69c4f58a85eb753a5355f62f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca2435c52e371036a4465960eb3504ecf587628becff5f3dd1a15ff5f92b745bcf02ad5d77d23dad0aac0614cd196d3f7c1b906b976dc04e8ff5e42b9b976bd
|
7
|
+
data.tar.gz: 8b2185ff6a399a12af7c297c690596d8ac4989d0d3e30bfc41276186fdc98196050773f2a3b0e2aa84a163cfa2e18a81ae6a493011e607c0b9f633bedc2b0346
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
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/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
|
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
|
+
[](https://travis-ci.org/pangyulei/AKMall)
|
4
|
+
[](https://cocoapods.org/pods/AKMall)
|
5
|
+
[](https://cocoapods.org/pods/AKMall)
|
6
|
+
[](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.
|
data/lib/kcache/version.rb
CHANGED
data/lib/kcache.rb
CHANGED
@@ -38,9 +38,9 @@ OBJROOT = "OBJROOT"
|
|
38
38
|
#变量
|
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}/
|
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/
|
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}/
|
101
|
-
command = "mv \"#{project.path}/
|
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
|
@@ -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
|
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
|
-
|
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
|
-
|
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 = "
|
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
|
-
|
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}\"
|
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> #{
|
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 |
|
@@ -440,7 +433,14 @@ $file_md5_hash = {}
|
|
440
433
|
puts "<INFO> #{command} should succeed"
|
441
434
|
return false
|
442
435
|
end
|
443
|
-
|
436
|
+
|
437
|
+
already_target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
|
438
|
+
already_target_cache_dirs.each do |path|
|
439
|
+
if File.exist? path
|
440
|
+
raise unless system "rm -rf \"#{path}\""
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
444
|
target_cache_dir = get_cache_root + "/" + target.name + "-" + target_md5 + "-" + (Time.now.to_f * 1000).to_i.to_s
|
445
445
|
if File.exist? target_cache_dir
|
446
446
|
puts "<INFO> #{target_cache_dir} should not exist"
|
@@ -486,23 +486,59 @@ $file_md5_hash = {}
|
|
486
486
|
return true
|
487
487
|
|
488
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
|
489
513
|
|
490
|
-
|
514
|
+
end
|
491
515
|
|
492
|
-
|
516
|
+
|
517
|
+
def project_task_begin
|
518
|
+
|
493
519
|
projects = get_projects
|
494
520
|
total_count = 0
|
495
521
|
hit_count = 0
|
496
522
|
miss_count = 0
|
497
523
|
error_count = 0
|
498
524
|
hit_target_md5_cache_set = Set.new
|
525
|
+
miss_target_cache_set = Set.new
|
526
|
+
|
527
|
+
get_custom_config_information
|
499
528
|
|
500
529
|
pre_targets_info = {}
|
530
|
+
|
531
|
+
projects.each do |project|
|
532
|
+
restore_project(project)
|
533
|
+
backup_project(project)
|
534
|
+
end
|
535
|
+
|
536
|
+
clean_temp_files
|
537
|
+
|
538
|
+
projects = get_projects
|
539
|
+
|
501
540
|
projects.each do |project|
|
502
541
|
project.native_targets.each do |target|
|
503
|
-
target.build_phases.delete_if { |phase|
|
504
|
-
phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase and phase.name.include? "ys_"
|
505
|
-
}
|
506
542
|
if can_cache_target(target)
|
507
543
|
total_count = total_count + 1
|
508
544
|
source_files = get_target_source_files(target)
|
@@ -532,58 +568,86 @@ $file_md5_hash = {}
|
|
532
568
|
end
|
533
569
|
end
|
534
570
|
end
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
571
|
+
|
572
|
+
while true
|
573
|
+
projects.each do |project|
|
574
|
+
project.native_targets.each do |target|
|
575
|
+
target_info = pre_targets_info[target]
|
576
|
+
next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
|
577
|
+
next unless target_info and target_info[:target_status] != CACHE_STATUS_HIT
|
578
|
+
hit_target_cache_dirs = target_info[:hit_target_cache_dir]
|
579
|
+
next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
|
580
|
+
target_md5 = target_info[:target_md5]
|
581
|
+
|
582
|
+
target_really_hit_dir = ""
|
583
|
+
target_really_miss = false
|
584
|
+
hit_target_cache_dirs.each do |hit_target_cache_dir|
|
585
|
+
all_dependency_target_exist = true
|
586
|
+
target_really_miss = false
|
587
|
+
hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
|
588
|
+
if hit_targets_info[:dependency_targets_md5]
|
589
|
+
hit_targets_info[:dependency_targets_md5].each do | item |
|
590
|
+
dependency_target = item[0]
|
591
|
+
dependency_target_md5 = item[1]
|
592
|
+
if $exclude_target.include? dependency_target
|
593
|
+
puts "<INFO> #{target.name} #{target_md5} hit cache, dependency target #{dependency_target}-#{dependency_target_md5} skip check"
|
594
|
+
next
|
595
|
+
end
|
596
|
+
|
597
|
+
if miss_target_cache_set.include? "#{dependency_target}"
|
598
|
+
puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
|
599
|
+
target_really_miss = true
|
600
|
+
all_dependency_target_exist = false
|
601
|
+
break
|
602
|
+
end
|
603
|
+
|
604
|
+
unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
|
605
|
+
puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
|
606
|
+
all_dependency_target_exist = false
|
607
|
+
target_really_miss = true
|
608
|
+
break
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
if all_dependency_target_exist
|
613
|
+
target_really_hit_dir = hit_target_cache_dir
|
614
|
+
break
|
615
|
+
end
|
616
|
+
|
617
|
+
if target_really_miss
|
555
618
|
break
|
556
619
|
end
|
557
|
-
end
|
558
|
-
|
559
|
-
if all_dependency_target_exist
|
560
|
-
really_hit_dir = hit_target_cache_dir
|
561
|
-
break
|
562
620
|
end
|
563
621
|
end
|
622
|
+
|
623
|
+
if target_really_hit_dir.length > 0
|
624
|
+
puts "<INFO> #{target.name} #{target_md5} hit cache"
|
625
|
+
hit_count = hit_count + 1
|
626
|
+
hit_target_info = YAML.load(File.read(target_really_hit_dir + "/" + FILE_NAME_CONTEXT))
|
627
|
+
target_info = target_info.merge!(hit_target_info)
|
628
|
+
target_info[:target_status] = CACHE_STATUS_HIT
|
629
|
+
target_info[:hit_target_cache_dir] = target_really_hit_dir
|
630
|
+
inject_copy_action(project, target, target_info)
|
631
|
+
end
|
632
|
+
|
633
|
+
if target_really_miss
|
634
|
+
miss_count = miss_count + 1
|
635
|
+
miss_target_cache_set.add "#{target.name}"
|
636
|
+
hit_target_md5_cache_set.delete "#{target.name}-#{target_info[:target_md5]}"
|
637
|
+
target_info[:target_status] = CACHE_STATUS_MISS
|
638
|
+
target_info.delete(:hit_target_cache_dir)
|
639
|
+
inject_flag_action(project, target)
|
640
|
+
end
|
641
|
+
|
642
|
+
File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
|
564
643
|
end
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
target_info[:target_status] = CACHE_STATUS_HIT
|
572
|
-
target_info[:hit_target_cache_dir] = really_hit_dir
|
573
|
-
inject_copy_action(project, target, target_info)
|
574
|
-
else
|
575
|
-
puts "<INFO> #{target.name} #{target_md5} miss cache for reason dependency miss"
|
576
|
-
target_info[:target_status] = CACHE_STATUS_MISS
|
577
|
-
target_info.delete(:hit_target_cache_dir)
|
578
|
-
inject_flag_action(project, target)
|
579
|
-
miss_count = miss_count + 1
|
580
|
-
end
|
581
|
-
File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
|
582
|
-
|
644
|
+
project.save
|
645
|
+
end
|
646
|
+
if total_count == hit_count + miss_count + error_count
|
647
|
+
break
|
648
|
+
else
|
649
|
+
puts "<INFO> continue to find hit cache"
|
583
650
|
end
|
584
|
-
|
585
|
-
backup_project(project)
|
586
|
-
project.save
|
587
651
|
end
|
588
652
|
puts "<INFO> total count: #{total_count}, hit count: #{hit_count}, miss_count: #{miss_count}, error_count: #{error_count}"
|
589
653
|
end
|
@@ -734,7 +798,6 @@ $file_md5_hash = {}
|
|
734
798
|
|
735
799
|
puts "<INFO> total add cache count: #{total_add_count}"
|
736
800
|
end
|
737
|
-
|
738
801
|
|
739
802
|
end
|
740
803
|
|
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.
|
4
|
+
version: 1.1.1
|
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
|
+
date: 2021-12-31 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
|
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.
|
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: []
|