akcache 1.1.1 → 2.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: a09a77cf0dd1f6e164eedf0a94b3e2f87009416c2ca271acb24a2823c26dd190
4
- data.tar.gz: 636c83770b0dfc9d78219333daf57cb33b548d69c4f58a85eb753a5355f62f6f
3
+ metadata.gz: 4f1e7c5b3e86764ec008d18297ddd6046bef0bba071131cb071f547216f98643
4
+ data.tar.gz: e40db2fb5988f4d10979fee186b9c2edaccbefb01ba15689727ce6940bdd86a4
5
5
  SHA512:
6
- metadata.gz: 8ca2435c52e371036a4465960eb3504ecf587628becff5f3dd1a15ff5f92b745bcf02ad5d77d23dad0aac0614cd196d3f7c1b906b976dc04e8ff5e42b9b976bd
7
- data.tar.gz: 8b2185ff6a399a12af7c297c690596d8ac4989d0d3e30bfc41276186fdc98196050773f2a3b0e2aa84a163cfa2e18a81ae6a493011e607c0b9f633bedc2b0346
6
+ metadata.gz: 55e5fde66337bd885753e702737b5e063b4af05ce2825bf4071ff1dbbde1c1476a0195db9a9b686bac07224757d33b0c71b459cd6e25aec00fc53c2f43cfa1aa
7
+ data.tar.gz: dd9221c730af1b32c8525479bc36b3417949f01fa3c923f343f92fc738d8e2bcaeb9b696ff9109f24bbd76552bcfff38b0b4c98b0041ba8dc546cd5487d0ebd4
data/bin/kcache CHANGED
@@ -5,20 +5,18 @@ 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
 
12
12
  elsif ARGV[0] == "inject"
13
-
14
13
  manager.set_prama_to_yaml
15
14
 
16
15
  elsif ARGV[0] == "copy"
17
-
18
16
  manager.copy_cache
19
17
 
20
18
  elsif ARGV[0] == "begin"
21
- manager.project_task_begin
19
+ manager.project_task_begin(ARGV)
22
20
 
23
21
  elsif ARGV[0] == "end"
24
22
  manager.project_task_end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kcache
4
- VERSION = "1.1.1"
4
+ VERSION = "2.0.0"
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,6 +35,8 @@ OBJROOT = "OBJROOT"
36
35
 
37
36
 
38
37
  #变量
38
+ $target_build_configuration = "Release"
39
+ $project_build_branch = "master"
39
40
  $podfile_spec_checksums = nil
40
41
  $file_md5_hash = {}
41
42
  $exclude_target = []
@@ -43,9 +44,21 @@ $exclude_target = []
43
44
  class CacheManager
44
45
 
45
46
  def get_cache_root
46
- return Dir.home + "/ysCache"
47
+ return Dir.home + "/ysCache" +"/#{$project_build_branch}"
48
+ end
49
+
50
+ def get_default_cache_root
51
+ return Dir.home + "/ysCache/master"
47
52
  end
48
53
 
54
+ def is_private_target(target)
55
+ if target.name.start_with? "AK" or target.name.start_with? "EUR" or target.name.start_with? "A4K"
56
+ return true
57
+ else
58
+ return false
59
+ end
60
+ end
61
+
49
62
  def get_content_without_pwd(content)
50
63
  content = content.gsub("#{Dir.pwd}/", "").gsub(/#{Dir.pwd}(\W|$)/, '\1')
51
64
  return content
@@ -188,7 +201,7 @@ class CacheManager
188
201
  $podfile_spec_checksums = podfile_lock["SPEC CHECKSUMS"]
189
202
  end
190
203
 
191
- project_configuration = project.build_configurations.detect { | config | config.name == Target_Build_Configuration}
204
+ project_configuration = project.build_configurations.detect { | config | config.name == $target_build_configuration}
192
205
  project_configuration_content = project_configuration.pretty_print.to_yaml
193
206
 
194
207
  project_xcconfig = ""
@@ -199,7 +212,7 @@ class CacheManager
199
212
  end
200
213
  end
201
214
 
202
- target_configuration = target.build_configurations.detect { | config | config.name == Target_Build_Configuration}
215
+ target_configuration = target.build_configurations.detect { | config | config.name == $target_build_configuration}
203
216
  target_configuration_content = target_configuration.pretty_print.to_yaml
204
217
 
205
218
  target_xcconfig = ""
@@ -266,7 +279,10 @@ class CacheManager
266
279
  source_md5_list.push path + " : " + get_file_md5(path)
267
280
  end
268
281
  end
282
+ else
283
+ source_md5_list.push "Target configuration: #{$target_build_configuration}"
269
284
  end
285
+
270
286
  source_md5_content = source_md5_list.join("\n")
271
287
  return source_md5_content
272
288
 
@@ -279,7 +295,11 @@ class CacheManager
279
295
 
280
296
  dependency_start_time = Time.now
281
297
 
282
- target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
298
+ if is_private_target(target)
299
+ target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
300
+ else
301
+ target_cache_dirs = Dir.glob(get_default_cache_root + "/" + target.name + "-" + target_md5 + "-*")
302
+ end
283
303
 
284
304
  hit_results = []
285
305
 
@@ -434,14 +454,25 @@ class CacheManager
434
454
  return false
435
455
  end
436
456
 
437
- already_target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
457
+
458
+ if is_private_target(target)
459
+ already_target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
460
+ else
461
+ already_target_cache_dirs = Dir.glob(get_default_cache_root + "/" + target.name + "-" + target_md5 + "-*")
462
+ end
463
+
438
464
  already_target_cache_dirs.each do |path|
439
465
  if File.exist? path
440
466
  raise unless system "rm -rf \"#{path}\""
441
467
  end
442
468
  end
443
469
 
444
- target_cache_dir = get_cache_root + "/" + target.name + "-" + target_md5 + "-" + (Time.now.to_f * 1000).to_i.to_s
470
+ if is_private_target(target)
471
+ target_cache_dir = get_cache_root + "/" + target.name + "-" + target_md5 + "-" + (Time.now.to_f * 1000).to_i.to_s
472
+ else
473
+ target_cache_dir = get_default_cache_root + "/" + target.name + "-" + target_md5 + "-" + (Time.now.to_f * 1000).to_i.to_s
474
+ end
475
+
445
476
  if File.exist? target_cache_dir
446
477
  puts "<INFO> #{target_cache_dir} should not exist"
447
478
  raise unless system "rm -rf \"#{target_cache_dir}\""
@@ -514,7 +545,19 @@ class CacheManager
514
545
  end
515
546
 
516
547
 
517
- def project_task_begin
548
+ def project_task_begin(argv)
549
+
550
+ argv.each do |prama|
551
+ if prama.include? "configuration"
552
+ if prama.include? "Debug"
553
+ $target_build_configuration = "Debug"
554
+ elsif prama.include? "Release"
555
+ $target_build_configuration = "Release"
556
+ end
557
+ elsif prama.include? "branch:"
558
+ $project_build_branch = prama.dup.gsub!("branch:", "")
559
+ end
560
+ end
518
561
 
519
562
  projects = get_projects
520
563
  total_count = 0
@@ -539,6 +582,9 @@ class CacheManager
539
582
 
540
583
  projects.each do |project|
541
584
  project.native_targets.each do |target|
585
+ target.build_phases.delete_if { |phase|
586
+ phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase and phase.name.include? "ys_"
587
+ }
542
588
  if can_cache_target(target)
543
589
  total_count = total_count + 1
544
590
  source_files = get_target_source_files(target)
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.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yusheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-31 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj