cocoapods-binary-cache 0.1.7 → 0.1.12

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-binary-cache/cache/validation_result.rb +4 -0
  3. data/lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb +20 -25
  4. data/lib/cocoapods-binary-cache/dependencies_graph/graph_visualizer.rb +29 -38
  5. data/lib/cocoapods-binary-cache/diagnosis/diagnosis.rb +9 -1
  6. data/lib/cocoapods-binary-cache/diagnosis/integration.rb +3 -1
  7. data/lib/cocoapods-binary-cache/helper/podspec.rb +4 -2
  8. data/lib/cocoapods-binary-cache/hooks/post_install.rb +2 -12
  9. data/lib/cocoapods-binary-cache/hooks/pre_install.rb +19 -36
  10. data/lib/cocoapods-binary-cache/main.rb +0 -1
  11. data/lib/cocoapods-binary-cache/pod-binary/helper/build.rb +27 -29
  12. data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +1 -1
  13. data/lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb +14 -13
  14. data/lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb +7 -10
  15. data/lib/cocoapods-binary-cache/pod-binary/integration.rb +1 -2
  16. data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +32 -15
  17. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb +1 -1
  18. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb +0 -3
  19. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb +29 -0
  20. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +25 -11
  21. data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +30 -19
  22. data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +30 -108
  23. data/lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb +0 -2
  24. data/lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb +0 -1
  25. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb +222 -146
  26. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb +45 -32
  27. data/lib/cocoapods-binary-cache/prebuild_output/output.rb +6 -4
  28. data/lib/cocoapods-binary-cache/state_store.rb +16 -6
  29. data/lib/command/config.rb +42 -4
  30. data/lib/command/executor/base.rb +18 -1
  31. data/lib/command/executor/fetcher.rb +21 -3
  32. data/lib/command/executor/prebuilder.rb +9 -7
  33. data/lib/command/executor/pusher.rb +20 -4
  34. data/lib/command/executor/visualizer.rb +3 -2
  35. data/lib/command/prebuild.rb +6 -0
  36. metadata +17 -7
  37. data/lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb +0 -52
  38. data/lib/cocoapods-binary-cache/pod-binary/helper/passer.rb +0 -25
  39. data/lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb +0 -29
  40. data/lib/cocoapods-binary-cache/pod-binary/tool/tool.rb +0 -12
  41. data/lib/cocoapods-binary-cache/scheme_editor.rb +0 -35
@@ -16,7 +16,7 @@ module PodPrebuild
16
16
  end
17
17
 
18
18
  def clean_delta_file
19
- puts "Clean delta file: #{prebuild_delta_path}"
19
+ Pod::UI.message "Clean delta file: #{prebuild_delta_path}"
20
20
  FileUtils.rm_rf(prebuild_delta_path)
21
21
  end
22
22
 
@@ -24,14 +24,16 @@ module PodPrebuild
24
24
  FileUtils.mkdir_p dir unless File.directory?(dir)
25
25
  end
26
26
 
27
- # Input 2 arrays of library names
28
- def write_delta_file(updated, deleted)
27
+ def write_delta_file(options)
28
+ updated = options[:updated]
29
+ deleted = options[:deleted]
30
+
29
31
  if updated.empty? && deleted.empty?
30
32
  Pod::UI.puts "No changes in prebuild"
31
33
  return
32
34
  end
33
35
 
34
- Pod::UI.puts "Write prebuild changes to: #{prebuild_delta_path}"
36
+ Pod::UI.message "Write prebuild changes to: #{prebuild_delta_path}"
35
37
  create_dir_if_needed(delta_dir)
36
38
  changes = PodPrebuild::JSONFile.new(prebuild_delta_path)
37
39
  changes["updated"] = updated
@@ -1,11 +1,21 @@
1
1
  module PodPrebuild
2
- class StateStore
3
- @excluded_pods = Set.new
4
- @cache_validation = CacheValidationResult.new
2
+ def self.state
3
+ @state ||= State.new
4
+ end
5
+
6
+ class State
7
+ def initialize
8
+ @store = {
9
+ :cache_validation => CacheValidationResult.new
10
+ }
11
+ end
12
+
13
+ def update(data)
14
+ @store.merge!(data)
15
+ end
5
16
 
6
- class << self
7
- attr_accessor :excluded_pods
8
- attr_accessor :cache_validation
17
+ def cache_validation
18
+ @store[:cache_validation]
9
19
  end
10
20
  end
11
21
  end
@@ -5,13 +5,14 @@ module PodPrebuild
5
5
  PodPrebuild::Config.instance
6
6
  end
7
7
 
8
- class Config
8
+ class Config # rubocop:disable Metrics/ClassLength
9
9
  attr_accessor :dsl_config, :cli_config
10
10
 
11
11
  def initialize(path)
12
12
  @deprecated_config = File.exist?(path) ? PodPrebuild::JSONFile.new(path).data : {}
13
13
  @dsl_config = {}
14
14
  @cli_config = {}
15
+ @detected_config = {}
15
16
  end
16
17
 
17
18
  def self.instance
@@ -28,6 +29,10 @@ module PodPrebuild
28
29
  @cache_repo ||= cache_repo_config["remote"]
29
30
  end
30
31
 
32
+ def local_cache?
33
+ cache_repo.nil?
34
+ end
35
+
31
36
  def cache_path
32
37
  @cache_path ||= File.expand_path(cache_repo_config["local"])
33
38
  end
@@ -53,7 +58,9 @@ module PodPrebuild
53
58
  end
54
59
 
55
60
  def prebuilt_path(path: nil)
56
- path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}"
61
+ p = Pathname.new(path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}")
62
+ p = p.sub_ext(".xcframework") if xcframework? && p.extname == ".framework"
63
+ p.to_s
57
64
  end
58
65
 
59
66
  def validate_dsl_config
@@ -83,7 +90,7 @@ module PodPrebuild
83
90
  end
84
91
 
85
92
  def excluded_pods
86
- @dsl_config[:excluded_pods] || Set.new
93
+ ((@dsl_config[:excluded_pods] || Set.new) + (@detected_config[:excluded_pods] || Set.new)).to_set
87
94
  end
88
95
 
89
96
  def dev_pods_enabled?
@@ -98,6 +105,10 @@ module PodPrebuild
98
105
  @dsl_config[:device_build_enabled]
99
106
  end
100
107
 
108
+ def xcframework?
109
+ @dsl_config[:xcframework]
110
+ end
111
+
101
112
  def disable_dsym?
102
113
  @dsl_config[:disable_dsym]
103
114
  end
@@ -122,10 +133,34 @@ module PodPrebuild
122
133
  @dsl_config[:prebuild_code_gen]
123
134
  end
124
135
 
136
+ def strict_diagnosis?
137
+ @dsl_config[:strict_diagnosis]
138
+ end
139
+
140
+ def silent_build?
141
+ @dsl_config[:silent_build]
142
+ end
143
+
125
144
  def targets_to_prebuild_from_cli
126
145
  @cli_config[:prebuild_targets] || []
127
146
  end
128
147
 
148
+ def update_detected_prebuilt_pod_names!(value)
149
+ @detected_config[:prebuilt_pod_names] = value
150
+ end
151
+
152
+ def update_detected_excluded_pods!(value)
153
+ @detected_config[:excluded_pods] = value
154
+ end
155
+
156
+ def prebuilt_pod_names
157
+ @detected_config[:prebuilt_pod_names] || Set.new
158
+ end
159
+
160
+ def tracked_prebuilt_pod_names
161
+ prebuilt_pod_names - excluded_pods
162
+ end
163
+
129
164
  private
130
165
 
131
166
  def applicable_dsl_config
@@ -140,12 +175,15 @@ module PodPrebuild
140
175
  :dev_pods_enabled,
141
176
  :bitcode_enabled,
142
177
  :device_build_enabled,
178
+ :xcframework,
143
179
  :disable_dsym,
144
180
  :dont_remove_source_code,
145
181
  :build_args,
146
182
  :save_cache_validation_to,
147
183
  :validate_prebuilt_settings,
148
- :prebuild_code_gen
184
+ :prebuild_code_gen,
185
+ :strict_diagnosis,
186
+ :silent_build
149
187
  ]
150
188
  end
151
189
 
@@ -2,6 +2,22 @@ module PodPrebuild
2
2
  class CommandExecutor
3
3
  def initialize(options)
4
4
  @config = options[:config]
5
+ prepare_cache_dir
6
+ end
7
+
8
+ def installer
9
+ @installer ||= begin
10
+ pod_config = Pod::Config.instance
11
+ Pod::Installer.new(pod_config.sandbox, pod_config.podfile, pod_config.lockfile)
12
+ end
13
+ end
14
+
15
+ def use_local_cache?
16
+ @config.cache_repo.nil?
17
+ end
18
+
19
+ def prepare_cache_dir
20
+ FileUtils.mkdir_p(@config.cache_path) if @config.cache_path
5
21
  end
6
22
 
7
23
  def git(cmd, options = {})
@@ -10,7 +26,8 @@ module PodPrebuild
10
26
  comps << cmd
11
27
  comps << "&> /dev/null" if options[:ignore_output]
12
28
  comps << "|| true" if options[:can_fail]
13
- `#{comps.join(" ")}`
29
+ cmd = comps.join(" ")
30
+ raise "Fail to run command '#{cmd}'" unless system(cmd)
14
31
  end
15
32
 
16
33
  def git_clone(cmd, options = {})
@@ -1,8 +1,11 @@
1
+ require "parallel"
1
2
  require_relative "base"
2
3
  require_relative "../helper/zip"
3
4
 
4
5
  module PodPrebuild
5
6
  class CacheFetcher < CommandExecutor
7
+ attr_reader :cache_branch
8
+
6
9
  def initialize(options)
7
10
  super(options)
8
11
  @cache_branch = options[:cache_branch]
@@ -10,14 +13,28 @@ module PodPrebuild
10
13
 
11
14
  def run
12
15
  Pod::UI.step("Fetching cache") do
13
- fetch_cache(@config.cache_repo, @cache_branch, @config.cache_path)
16
+ if @config.local_cache?
17
+ print_message_for_local_cache(@config.cache_path)
18
+ else
19
+ fetch_remote_cache(@config.cache_repo, @cache_branch, @config.cache_path)
20
+ end
14
21
  unzip_cache
15
22
  end
16
23
  end
17
24
 
18
25
  private
19
26
 
20
- def fetch_cache(repo, branch, dest_dir)
27
+ def print_message_for_local_cache(cache_dir)
28
+ Pod::UI.puts "You're using local cache at: #{cache_dir}.".yellow
29
+ message = <<~HEREDOC
30
+ To enable remote cache (with a git repo), add the `remote` field to the repo config in the `cache_repo` option.
31
+ For more details, check out this doc:
32
+ https://github.com/grab/cocoapods-binary-cache/blob/master/docs/configure_cocoapods_binary_cache.md#cache_repo-
33
+ HEREDOC
34
+ Pod::UI.puts message
35
+ end
36
+
37
+ def fetch_remote_cache(repo, branch, dest_dir)
21
38
  Pod::UI.puts "Fetching cache from #{repo} (branch: #{branch})".green
22
39
  if Dir.exist?(dest_dir + "/.git")
23
40
  git("fetch origin #{branch}")
@@ -41,7 +58,8 @@ module PodPrebuild
41
58
  @config.manifest_path
42
59
  )
43
60
  end
44
- Dir[@config.generated_frameworks_dir(in_cache: true) + "/*.zip"].each do |path|
61
+ zip_paths = Dir[@config.generated_frameworks_dir(in_cache: true) + "/*.zip"]
62
+ Parallel.each(zip_paths, in_threads: 8) do |path|
45
63
  ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir)
46
64
  end
47
65
  end
@@ -4,29 +4,31 @@ require_relative "pusher"
4
4
 
5
5
  module PodPrebuild
6
6
  class CachePrebuilder < CommandExecutor
7
+ attr_reader :repo_update, :fetcher, :pusher
8
+
7
9
  def initialize(options)
8
10
  super(options)
9
- @cache_branch = options[:cache_branch]
10
- @push_cache = options[:push_cache]
11
- @fetcher = PodPrebuild::CacheFetcher.new(options)
12
- @pusher = PodPrebuild::CachePusher.new(options)
11
+ @repo_update = options[:repo_update]
12
+ @fetcher = PodPrebuild::CacheFetcher.new(options) unless options[:no_fetch]
13
+ @pusher = PodPrebuild::CachePusher.new(options) if options[:push_cache]
13
14
  end
14
15
 
15
16
  def run
16
- @fetcher.run
17
+ @fetcher&.run
17
18
  prebuild
18
19
  changes = PodPrebuild::JSONFile.new(@config.prebuild_delta_path)
19
20
  return if changes.empty?
20
21
 
21
22
  sync_cache(changes)
22
- @pusher.run if @push_cache
23
+ @pusher&.run
23
24
  end
24
25
 
25
26
  private
26
27
 
27
28
  def prebuild
28
29
  Pod::UI.step("Installation") do
29
- Pod::Command::Install.new(CLAide::ARGV.new([])).run
30
+ installer.repo_update = @repo_update
31
+ installer.install!
30
32
  end
31
33
  end
32
34
 
@@ -2,6 +2,8 @@ require_relative "base"
2
2
 
3
3
  module PodPrebuild
4
4
  class CachePusher < CommandExecutor
5
+ attr_reader :cache_branch
6
+
5
7
  def initialize(options)
6
8
  super(options)
7
9
  @cache_branch = options[:cache_branch]
@@ -9,11 +11,25 @@ module PodPrebuild
9
11
 
10
12
  def run
11
13
  Pod::UI.step("Pushing cache") do
12
- commit_message = "Update prebuilt cache".shellescape
13
- git("add .")
14
- git("commit -m '#{commit_message}'")
15
- git("push origin #{@cache_branch}")
14
+ if @config.local_cache?
15
+ print_message_for_local_cache
16
+ else
17
+ commit_and_push_cache
18
+ end
16
19
  end
17
20
  end
21
+
22
+ private
23
+
24
+ def print_message_for_local_cache
25
+ Pod::UI.puts "Skip pushing cache as you're using local cache".yellow
26
+ end
27
+
28
+ def commit_and_push_cache
29
+ commit_message = "Update prebuilt cache"
30
+ git("add .")
31
+ git("commit -m '#{commit_message}'")
32
+ git("push origin #{@cache_branch}")
33
+ end
18
34
  end
19
35
  end
@@ -13,8 +13,9 @@ module PodPrebuild
13
13
  def run
14
14
  FileUtils.mkdir_p(@output_dir)
15
15
  graph = DependenciesGraph.new(@lockfile)
16
- graph.write_graphic_file("png", "#{@output_dir}/graph", Set.new)
17
- `open #{@output_dir}/graph.png` if @open
16
+ output_path = "#{@output_dir}/graph.png"
17
+ graph.write_graphic_file(output_path: output_path)
18
+ system("open #{@output_path}") if @open
18
19
  end
19
20
  end
20
21
  end
@@ -5,10 +5,14 @@ module Pod
5
5
  class Command
6
6
  class Binary < Command
7
7
  class Prebuild < Binary
8
+ attr_reader :prebuilder
9
+
8
10
  self.arguments = [CLAide::Argument.new("CACHE-BRANCH", false)]
9
11
  def self.options
10
12
  [
11
13
  ["--config", "Config (Debug, Test...) to prebuild"],
14
+ ["--repo-update", "Update pod repo before installing"],
15
+ ["--no-fetch", "Do not perform a cache fetch beforehand"],
12
16
  ["--push", "Push cache to repo upon completion"],
13
17
  ["--all", "Prebuild all binary pods regardless of cache validation"],
14
18
  ["--targets", "Targets to prebuild. Use comma (,) to specify a list of targets"]
@@ -28,6 +32,8 @@ module Pod
28
32
  @prebuilder = PodPrebuild::CachePrebuilder.new(
29
33
  config: prebuild_config,
30
34
  cache_branch: argv.shift_argument || "master",
35
+ repo_update: argv.flag?("repo-update"),
36
+ no_fetch: argv.flag?("fetch") == false,
31
37
  push_cache: argv.flag?("push")
32
38
  )
33
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bang Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: parallel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -132,9 +146,7 @@ files:
132
146
  - lib/cocoapods-binary-cache/pod-binary/helper/build.rb
133
147
  - lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb
134
148
  - lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/target_definition.rb
135
- - lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb
136
149
  - lib/cocoapods-binary-cache/pod-binary/helper/names.rb
137
- - lib/cocoapods-binary-cache/pod-binary/helper/passer.rb
138
150
  - lib/cocoapods-binary-cache/pod-binary/helper/podfile_options.rb
139
151
  - lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb
140
152
  - lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb
@@ -142,20 +154,18 @@ files:
142
154
  - lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb
143
155
  - lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb
144
156
  - lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb
157
+ - lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb
145
158
  - lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb
146
- - lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb
147
159
  - lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb
148
160
  - lib/cocoapods-binary-cache/pod-binary/integration/validation.rb
149
161
  - lib/cocoapods-binary-cache/pod-binary/prebuild.rb
150
162
  - lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb
151
163
  - lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb
152
- - lib/cocoapods-binary-cache/pod-binary/tool/tool.rb
153
164
  - lib/cocoapods-binary-cache/pod-rome/LICENSE.txt
154
165
  - lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb
155
166
  - lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb
156
167
  - lib/cocoapods-binary-cache/prebuild_output/metadata.rb
157
168
  - lib/cocoapods-binary-cache/prebuild_output/output.rb
158
- - lib/cocoapods-binary-cache/scheme_editor.rb
159
169
  - lib/cocoapods-binary-cache/state_store.rb
160
170
  - lib/cocoapods-binary-cache/ui.rb
161
171
  - lib/cocoapods_plugin.rb
@@ -1,52 +0,0 @@
1
- require_relative "../tool/tool"
2
- require_relative "prebuild_sandbox"
3
-
4
- module Pod
5
- # a force disable option for integral
6
- class Installer
7
- def self.force_disable_integration(value)
8
- @@force_disable_integration = value
9
- end
10
-
11
- old_method = instance_method(:integrate_user_project)
12
- define_method(:integrate_user_project) do
13
- if @@force_disable_integration
14
- return
15
- end
16
- old_method.bind(self).()
17
- end
18
- end
19
-
20
- # a option to disable install complete message
21
- class Installer
22
- def self.disable_install_complete_message(value)
23
- @@disable_install_complete_message = value
24
- end
25
-
26
- old_method = instance_method(:print_post_install_message)
27
- define_method(:print_post_install_message) do
28
- if @@disable_install_complete_message
29
- return
30
- end
31
- old_method.bind(self).()
32
- end
33
- end
34
-
35
- # option to disable write lockfiles
36
- class Config
37
- @@force_disable_write_lockfile = false
38
- def self.force_disable_write_lockfile(value)
39
- @@force_disable_write_lockfile = value
40
- end
41
-
42
- old_method = instance_method(:lockfile_path)
43
- define_method(:lockfile_path) do
44
- if @@force_disable_write_lockfile
45
- # As config is a singleton, sandbox_root refer to the standard sandbox.
46
- return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + "Manifest.lock.tmp"
47
- else
48
- return old_method.bind(self).()
49
- end
50
- end
51
- end
52
- end