zabel 1.0.2 → 1.0.3

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: 89413297b2ba01b9d67f3bd364566b73ad66164fbcffba18c13f799a35f0b760
4
- data.tar.gz: 31e676f429656820d38993ffc31b5a6521bd510dedaab32464f5ab3a69ddf3f8
3
+ metadata.gz: c252d78baa1f53c925ae86fcd441c044e36240b25d4d9586e27e922901c0cc91
4
+ data.tar.gz: f3d310882935e4010bdce00b4a0fb248df34639a8af59a35f032491d2b478881
5
5
  SHA512:
6
- metadata.gz: 8644fe694d350d9799affc0eb50f0cc668380dbbf32361d5fb48a29c02cf330bfe63d2769311e3c64f6f33e351b0d028429022cf0a9d6099c9664e5d3db58cf9
7
- data.tar.gz: 56102a92ef122f2cd71c80f6c5e61b561cff1c14021d7dbd77ee4175b708a62f5dc64f2e1150324582f25a02cbbd553782ee9b34517b1b4beeb998e24db457ba
6
+ metadata.gz: c6adde390bb82e92bbf984530690bf399b062e689696bdff2fcc82e2d4c2cd9109ee54f8ead16308000999577cca6865893580aeaef37228e388c51ab678f62a
7
+ data.tar.gz: ab08a8ac353e898945f8d7b7866caf890a027e31729af110d89d1bed1b32d71130ab6a0a282d0bb352ff2bed948e82f8000458a2545897651e7de5c499976c31
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  tmp
9
+ bundle
9
10
  Pods
10
11
  build*
11
12
  cache
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Zabel, is a build cacher for Xcode, using Xcodeproj and MD5, to detect and cache products for targets. Designed for CI by now. Zabel is not Bazel.
4
4
 
5
+ WARNING: BE CAREFUL IN PRODUCTION ENVIRONMENT.
6
+
5
7
  ## Feature
6
8
 
7
9
  - only support Cocoapods targets now
@@ -23,9 +25,13 @@ Zabel, is a build cacher for Xcode, using Xcodeproj and MD5, to detect and cache
23
25
 
24
26
  ## Installation
25
27
 
28
+ Please use Ruby 2.x.
29
+
26
30
  Add this line to your application's Gemfile:
27
31
 
28
32
  ```ruby
33
+ source "https://rubygems.org"
34
+
29
35
  gem 'zabel'
30
36
  ```
31
37
 
@@ -33,30 +39,53 @@ And then execute:
33
39
 
34
40
  $ bundle
35
41
 
42
+ Or install in local path:
43
+
44
+ $ bundle install --path vendor/bundle
45
+
36
46
  Or install it yourself as:
37
47
 
38
- $ gem install zabel
48
+ $ [sudo] gem install zabel
39
49
 
40
50
  ## Usage
41
51
 
42
- Simply add zabel before your xcodebuild/fastlane command. Please ensure that your command can work without zabel.
52
+ Simply add zabel before your xcodebuild/fastlane command. Please ensure that your command can work without zabel.
43
53
 
44
- ```
45
- zabel xcodebuild/fastlane xxx
46
- ```
54
+ $ [bundle exec] zabel xcodebuild/fastlane ...
47
55
 
48
56
  ## Advanced usage
49
57
 
50
58
  You can controll your cache keys, which can be more or less. Please ensure that your arguments are same in pre and post.
51
59
 
52
- ```
53
- zabel pre -configuration Release abc
54
- xcodebuild/fastlane xxx
55
- zabel post -configuration Release abc
56
- ```
60
+ $ [bundle exec] zabel pre -configuration Debug ...
61
+ $ xcodebuild/fastlane ...
62
+ $ [bundle exec] zabel post -configuration Debug ...
63
+
64
+ Importantly, configuration argument must be set with zabel.
65
+
66
+ ## Options
67
+
68
+ You can custom some options by yourself.
69
+
70
+ Zabel stores caches in `~/zabel` by default. You can change this path.
71
+
72
+ $ export ZABEL_CACHE_ROOT=xxx
73
+
74
+ Zabel uses LRU to clear unuse old caches, to keep max count with 10000 by default. You can change this number.
75
+
76
+ $ export ZABEL_CACHE_COUNT=12345
77
+
78
+ Zable caches targets which count of source files is greater than or equal 1 by default. You can set this value to 0 or more than 1 to achieve higher total speed.
79
+
80
+ $ export ZABEL_MIN_SOURCE_FILE_COUNT=10
81
+
82
+ Zabel detects module map dependecy by default. However, there are bugs of xcodebuild or swift-frontend, which emits unnecessary, incorrect and even cycle modulemap dependencies. Cycle dependency targets will be miss every time. To test by run "ruby test/one.rb test/todo/modulemap_file/Podfile". You can disable this feature.
83
+
84
+ $ export ZABEL_NOT_DETECT_MODULE_MAP_DEPENDENCY=YES
57
85
 
58
86
  ## Changelog
59
87
 
88
+ - 1.0.3 support bundle install
60
89
  - 1.0.2 support legacy build system
61
90
  - 1.0.1 support xcodebuild archive and fastlane
62
91
  - 1.0.0
data/bin/zabel CHANGED
@@ -24,8 +24,17 @@ elsif ARGV.include?("-configuration") or ARGV.include?("--configuration")
24
24
  Zabel::zabel_post(ARGV)
25
25
 
26
26
  puts "[ZABEL]<INFO> duration = #{(Time.now - total_start_time).to_i} s in stage all"
27
- else
28
- puts "version: #{Zabel::VERSION}"
29
- puts "exec: #{$0}"
27
+ elsif ARGV.size == 0 or (ARGV.size == 1 and ARGV[0].include?("v"))
28
+ puts "ver: #{Zabel::VERSION}"
29
+ puts "exe: #{$0}"
30
30
  puts "url: https://github.com/WeijunDeng/Zabel"
31
+ else
32
+ puts "Usage: "
33
+ puts "IMPORTANT: configuration must be set."
34
+ puts "For example:"
35
+ puts "zabel xcodebuild archive -workspace app.xcworkspace -scheme app -configuration Debug ..."
36
+ puts "zabel fastlane gym --workspace app.xcworkspace --scheme app --configuration Debug ..."
37
+ puts ""
38
+ puts "Advanced usage:"
39
+ puts "zabel pre -configuration Debug && xcodebuild/fastlane ... && zabel post -configuration Debug"
31
40
  end
data/lib/zabel.rb CHANGED
@@ -74,10 +74,6 @@ module Zabel
74
74
  return 1
75
75
  end
76
76
 
77
- def self.zabel_should_extract_once
78
- return false
79
- end
80
-
81
77
  def self.zabel_get_projects
82
78
  # TODO: to support more project, not only Pods
83
79
  pods_project = Xcodeproj::Project.open("Pods/Pods.xcodeproj")
@@ -645,23 +641,7 @@ module Zabel
645
641
  return potential_hit_target_cache_dirs
646
642
  end
647
643
 
648
- # see https://github.com/CocoaPods/Xcodeproj/blob/master/lib/xcodeproj/project/object/native_target.rb#L239
649
- # and this is faster, without searching deeply.
650
- def self.zabel_fast_add_dependency(project, target_target, target, subproject_reference)
651
- container_proxy = project.new(Xcodeproj::Project::PBXContainerItemProxy)
652
- container_proxy.container_portal = subproject_reference.uuid
653
- container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
654
- container_proxy.remote_global_id_string = target.uuid
655
- container_proxy.remote_info = target.name
656
-
657
- dependency = project.new(Xcodeproj::Project::PBXTargetDependency)
658
- dependency.name = target.name
659
- dependency.target_proxy = container_proxy
660
-
661
- target_target.dependencies << dependency
662
- end
663
-
664
- def self.zabel_disable_build_and_inject_extract(project, target, inject_project, inject_target, inject_scripts, target_context)
644
+ def self.zabel_disable_build_and_inject_extract(project, target, target_context)
665
645
  target_cache_dir = target_context[:hit_target_cache_dir]
666
646
 
667
647
  # touch to update mtime
@@ -674,34 +654,24 @@ module Zabel
674
654
  build_phase.class == Xcodeproj::Project::Object::PBXResourcesBuildPhase
675
655
  }
676
656
 
677
- extract_script = "#{$0} #{STAGE_EXTRACT} \"#{target_cache_dir}\" \"#{target_context[:build_product_dir]}\" \"#{target_context[:build_intermediate_dir]}\""
678
-
679
- if zabel_should_extract_once
680
- subproject_reference = nil
681
- project.main_group.files.each do | file |
682
- if file.class == Xcodeproj::Project::Object::PBXFileReference and File.basename(file.path) == File.basename(inject_project.path)
683
- subproject_reference = file
684
- break
685
- end
686
- end
687
-
688
- unless subproject_reference
689
- subproject_reference = project.main_group.new_reference(inject_project.path, :group)
690
- end
691
-
692
- zabel_fast_add_dependency(project, target, inject_target, subproject_reference)
693
-
694
- inject_scripts.push extract_script
695
- else
696
- inject_phase = target.new_shell_script_build_phase("zabel_extract_#{target.name}")
697
- inject_phase.shell_script = extract_script
698
- inject_phase.show_env_vars_in_log = '1'
657
+ zabel_exec = "\"#{$0}\""
658
+ if ENV["BUNDLE_BIN_PATH"] and ENV["BUNDLE_BIN_PATH"].size > 0 and ENV["BUNDLE_GEMFILE"] and ENV["BUNDLE_GEMFILE"].size > 0
659
+ zabel_exec = "cd \"#{File.dirname(ENV["BUNDLE_GEMFILE"])}\" && \"#{ENV["BUNDLE_BIN_PATH"]}\" exe zabel"
699
660
  end
661
+ extract_script = "#{zabel_exec} #{STAGE_EXTRACT} \"#{target_cache_dir}\" \"#{target_context[:build_product_dir]}\" \"#{target_context[:build_intermediate_dir]}\""
662
+
663
+ inject_phase = target.new_shell_script_build_phase("zabel_extract_#{target.name}")
664
+ inject_phase.shell_script = extract_script
665
+ inject_phase.show_env_vars_in_log = '1'
700
666
  end
701
667
 
702
668
  def self.zabel_inject_printenv(project, target)
669
+ zabel_exec = "\"#{$0}\""
670
+ if ENV["BUNDLE_BIN_PATH"] and ENV["BUNDLE_BIN_PATH"].size > 0 and ENV["BUNDLE_GEMFILE"] and ENV["BUNDLE_GEMFILE"].size > 0
671
+ zabel_exec = "cd \"#{File.dirname(ENV["BUNDLE_GEMFILE"])}\" && \"#{ENV["BUNDLE_BIN_PATH"]}\" exe zabel"
672
+ end
703
673
  inject_phase = target.new_shell_script_build_phase("zabel_printenv_#{target.name}")
704
- inject_phase.shell_script = "#{$0} #{STAGE_PRINTENV} #{target.name} \"#{project.path}\""
674
+ inject_phase.shell_script = "#{zabel_exec} #{STAGE_PRINTENV} #{target.name} \"#{project.path}\""
705
675
  inject_phase.show_env_vars_in_log = '1'
706
676
  end
707
677
 
@@ -728,15 +698,6 @@ module Zabel
728
698
 
729
699
  zabel_clean_temp_files
730
700
 
731
- if zabel_should_extract_once
732
- inject_project = Xcodeproj::Project.new("Pods/zabel.xcodeproj")
733
- inject_target = inject_project.new_aggregate_target("zabel")
734
- inject_phase = inject_target.new_shell_script_build_phase("zabel_extract")
735
- inject_phase.show_env_vars_in_log = '1'
736
- inject_project.save
737
- inject_scripts = []
738
- end
739
-
740
701
  projects = zabel_get_projects
741
702
 
742
703
  pre_targets_context = {}
@@ -823,7 +784,7 @@ module Zabel
823
784
  target_context = pre_targets_context[target]
824
785
 
825
786
  if target_context[:target_status] == STATUS_HIT
826
- zabel_disable_build_and_inject_extract(project, target, inject_project, inject_target, inject_scripts, target_context)
787
+ zabel_disable_build_and_inject_extract(project, target, target_context)
827
788
  else
828
789
  unless target_context[:target_status] == STATUS_MISS
829
790
  target_context[:target_status] = STATUS_MISS
@@ -844,12 +805,6 @@ module Zabel
844
805
  zabel_clean_backup_project(project)
845
806
  end
846
807
  end
847
-
848
- if zabel_should_extract_once and inject_scripts.size > 0
849
- inject_scripts = (["startTime_s=`date +%s`"] + inject_scripts + ["echo \"[ZABEL]<INFO> duration = $[ `date +%s` - $startTime_s ] s in stage #{STAGE_EXTRACT}\""]).flatten
850
- inject_phase.shell_script = inject_scripts.join("\n")
851
- inject_project.save
852
- end
853
808
 
854
809
  puts "[ZABEL]<INFO> total #{hit_count + miss_count} hit #{hit_count} miss #{miss_count} iteration #{iteration_count}"
855
810
 
data/lib/zabel/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zabel
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dengweijun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-01 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj