cocoapods-binary-cache 0.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 +7 -0
- data/lib/cocoapods-binary-cache.rb +4 -0
- data/lib/cocoapods-binary-cache/cache/all.rb +9 -0
- data/lib/cocoapods-binary-cache/cache/validation_result.rb +69 -0
- data/lib/cocoapods-binary-cache/cache/validator.rb +21 -0
- data/lib/cocoapods-binary-cache/cache/validator_accumulated.rb +4 -0
- data/lib/cocoapods-binary-cache/cache/validator_base.rb +92 -0
- data/lib/cocoapods-binary-cache/cache/validator_dependencies_graph.rb +20 -0
- data/lib/cocoapods-binary-cache/cache/validator_dev_pods.rb +22 -0
- data/lib/cocoapods-binary-cache/cache/validator_exclusion.rb +14 -0
- data/lib/cocoapods-binary-cache/cache/validator_non_dev_pods.rb +13 -0
- data/lib/cocoapods-binary-cache/cache/validator_with_podfile.rb +9 -0
- data/lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb +95 -0
- data/lib/cocoapods-binary-cache/dependencies_graph/graph_visualizer.rb +74 -0
- data/lib/cocoapods-binary-cache/gem_version.rb +6 -0
- data/lib/cocoapods-binary-cache/helper/benchmark_show.rb +11 -0
- data/lib/cocoapods-binary-cache/helper/checksum.rb +12 -0
- data/lib/cocoapods-binary-cache/helper/json.rb +37 -0
- data/lib/cocoapods-binary-cache/helper/lockfile.rb +67 -0
- data/lib/cocoapods-binary-cache/helper/path_utils.rb +8 -0
- data/lib/cocoapods-binary-cache/helper/podspec.rb +17 -0
- data/lib/cocoapods-binary-cache/hooks/post_install.rb +16 -0
- data/lib/cocoapods-binary-cache/hooks/pre_install.rb +141 -0
- data/lib/cocoapods-binary-cache/main.rb +21 -0
- data/lib/cocoapods-binary-cache/pod-binary/LICENSE.txt +22 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +25 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/target_definition.rb +36 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb +90 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/names.rb +36 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/passer.rb +25 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/podfile_options.rb +2 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb +71 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb +45 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration.rb +12 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +93 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb +36 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb +23 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +28 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb +29 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +111 -0
- data/lib/cocoapods-binary-cache/pod-binary/integration/validation.rb +20 -0
- data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +224 -0
- data/lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb +69 -0
- data/lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb +11 -0
- data/lib/cocoapods-binary-cache/pod-binary/tool/tool.rb +12 -0
- data/lib/cocoapods-binary-cache/pod-rome/LICENSE.txt +22 -0
- data/lib/cocoapods-binary-cache/pod-rome/build_framework.rb +247 -0
- data/lib/cocoapods-binary-cache/prebuild_cache.rb +49 -0
- data/lib/cocoapods-binary-cache/prebuild_output/metadata.rb +47 -0
- data/lib/cocoapods-binary-cache/prebuild_output/output.rb +71 -0
- data/lib/cocoapods-binary-cache/scheme_editor.rb +35 -0
- data/lib/cocoapods-binary-cache/state_store.rb +11 -0
- data/lib/cocoapods-binary-cache/ui.rb +9 -0
- data/lib/cocoapods_plugin.rb +5 -0
- data/lib/command/binary.rb +18 -0
- data/lib/command/config.rb +31 -0
- data/lib/command/executor/base.rb +20 -0
- data/lib/command/executor/fetcher.rb +44 -0
- data/lib/command/executor/prebuilder.rb +58 -0
- data/lib/command/executor/pusher.rb +19 -0
- data/lib/command/executor/visualizer.rb +20 -0
- data/lib/command/fetch.rb +23 -0
- data/lib/command/helper/zip.rb +20 -0
- data/lib/command/prebuild.rb +29 -0
- data/lib/command/visualize.rb +30 -0
- metadata +193 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
# Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
|
2
|
+
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
|
3
|
+
|
4
|
+
require "benchmark"
|
5
|
+
|
6
|
+
class BenchmarkShow
|
7
|
+
def self.benchmark
|
8
|
+
time = Benchmark.measure { yield }
|
9
|
+
Pod::UI.puts "🕛 Time elapsed: #{time}"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
|
2
|
+
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
|
3
|
+
|
4
|
+
require "digest/md5"
|
5
|
+
|
6
|
+
class FolderChecksum
|
7
|
+
def self.checksum(dir)
|
8
|
+
files = Dir["#{dir}/**/*"].reject { |f| File.directory?(f) }
|
9
|
+
content = files.map { |f| File.read(f) }.join
|
10
|
+
Digest::MD5.hexdigest(content).to_s
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module PodPrebuild
|
4
|
+
class JSONFile
|
5
|
+
attr_reader :path
|
6
|
+
attr_reader :data
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
@path = path
|
10
|
+
@data = load_json
|
11
|
+
end
|
12
|
+
|
13
|
+
def empty?
|
14
|
+
@data.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
def [](key)
|
18
|
+
@data[key]
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(key, value)
|
22
|
+
@data[key] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def save!
|
26
|
+
File.open(@path, "w") { |f| f.write(JSON.pretty_generate(@data)) }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_json
|
32
|
+
File.open(@path) { |f| JSON.parse(f.read) }
|
33
|
+
rescue
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module PodPrebuild
|
2
|
+
class Lockfile
|
3
|
+
attr_reader :lockfile, :data
|
4
|
+
|
5
|
+
def initialize(lockfile)
|
6
|
+
@lockfile = lockfile
|
7
|
+
@data = lockfile.to_hash
|
8
|
+
end
|
9
|
+
|
10
|
+
def pods
|
11
|
+
@pods ||= (@data["PODS"] || []).map { |v| pod_from(v) }.to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
def external_sources
|
15
|
+
@data["EXTERNAL SOURCES"] || {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def dev_pod_names
|
19
|
+
# There are 2 types of external sources:
|
20
|
+
# - Development pods: declared with `:path` option in Podfile, corresponding to `:path` in the Lockfile
|
21
|
+
# - External remote pods: declared with `:git` option in Podfile, corresponding to `:git` in the Lockfile
|
22
|
+
# --------------------
|
23
|
+
# EXTERNAL SOURCES:
|
24
|
+
# ADevPod:
|
25
|
+
# :path: path/to/dev_pod
|
26
|
+
# AnExternalRemotePod:
|
27
|
+
# :git: git@remote_url
|
28
|
+
# :commit: abc1234
|
29
|
+
# --------------------
|
30
|
+
@dev_pod_names ||= external_sources.select { |_, attributes| attributes.key?(:path) }.keys.to_set
|
31
|
+
end
|
32
|
+
|
33
|
+
def dev_pods
|
34
|
+
dev_pod_names_ = dev_pod_names
|
35
|
+
@dev_pods ||= pods.select { |name, _| dev_pod_names_.include?(name) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def non_dev_pods
|
39
|
+
dev_pod_names_ = dev_pod_names
|
40
|
+
@non_dev_pods ||= pods.reject { |name, _| dev_pod_names_.include?(name) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def subspec_pods
|
44
|
+
pods.keys
|
45
|
+
.select { |k| k.include?("/") }
|
46
|
+
.group_by { |k| k.split("/")[0] }
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Parse an item under `PODS` section of a Lockfile
|
52
|
+
# @param hash_or_string: an item under `PODS` section, could be a Hash (if having dependencies) or a String
|
53
|
+
# Examples:
|
54
|
+
# --------------------------
|
55
|
+
# PODS:
|
56
|
+
# - FrameworkA (0.0.1)
|
57
|
+
# - FrameworkB (0.0.2):
|
58
|
+
# - DependencyOfB
|
59
|
+
# -------------------------
|
60
|
+
# @return [framework_name, version] (for ex. ["AFramework", "0.0.1"])
|
61
|
+
def pod_from(hash_or_string)
|
62
|
+
name_with_version = hash_or_string.is_a?(Hash) ? hash_or_string.keys[0] : hash_or_string
|
63
|
+
match = name_with_version.match(/(\S+) \((\S+)\)/)
|
64
|
+
[match[1], match[2]]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
|
2
|
+
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
|
3
|
+
|
4
|
+
class PathUtils
|
5
|
+
def self.remove_last_path_component(path, num_components = 1)
|
6
|
+
path.split("/")[0...-num_components].join("/")
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
def empty_source_files?
|
4
|
+
return subspecs.all?(&:empty_source_files?) unless subspecs.empty?
|
5
|
+
|
6
|
+
check = lambda do |patterns|
|
7
|
+
patterns = [patterns] if patterns.is_a?(String)
|
8
|
+
patterns.reject(&:empty?).all? do |pattern|
|
9
|
+
Xcodeproj::Constants::HEADER_FILES_EXTENSIONS.any? { |ext| pattern.end_with?(ext) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
available_platforms.all? do |platform|
|
13
|
+
check.call(consumer(platform).source_files)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PodPrebuild
|
2
|
+
class PostInstallHook
|
3
|
+
def initialize(installer_context)
|
4
|
+
@installer_context = installer_context
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
return unless Pod::Podfile::DSL.dev_pods_enabled && @installer_context.sandbox.instance_of?(Pod::PrebuildSandbox)
|
9
|
+
|
10
|
+
# Modify pods scheme to support code coverage
|
11
|
+
# If we don't prebuild dev pod -> no need to care about this in Pod project
|
12
|
+
# because we setup in the main project (ex. DriverCI scheme)
|
13
|
+
SchemeEditor.edit_to_support_code_coverage(@installer_context.sandbox) if Pod.is_prebuild_stage
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module PodPrebuild
|
2
|
+
class PreInstallHook
|
3
|
+
include ObjectSpace
|
4
|
+
|
5
|
+
attr_reader :installer_context, :podfile, :prebuild_sandbox, :cache_validation
|
6
|
+
|
7
|
+
def initialize(installer_context)
|
8
|
+
@installer_context = installer_context
|
9
|
+
@podfile = installer_context.podfile
|
10
|
+
@pod_install_options = {}
|
11
|
+
@prebuild_sandbox = nil
|
12
|
+
@cache_validation = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
require_relative "../pod-binary/helper/feature_switches"
|
17
|
+
return if Pod.is_prebuild_stage
|
18
|
+
|
19
|
+
log_section "🚀 Prebuild frameworks"
|
20
|
+
ensure_valid_podfile
|
21
|
+
save_installation_states
|
22
|
+
prepare_environment
|
23
|
+
create_prebuild_sandbox
|
24
|
+
Pod::UI.section("Detect implicit dependencies") { detect_implicit_dependencies }
|
25
|
+
Pod::UI.section("Validate prebuilt cache") { validate_cache }
|
26
|
+
prebuild! if Pod::Podfile::DSL.prebuild_job?
|
27
|
+
reset_environment
|
28
|
+
log_section "🤖 Resume pod installation"
|
29
|
+
require_relative "../pod-binary/integration"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def save_installation_states
|
35
|
+
save_pod_install_options
|
36
|
+
save_states_from_dsl
|
37
|
+
end
|
38
|
+
|
39
|
+
def save_pod_install_options
|
40
|
+
# Fetch original installer (which is running this pre-install hook) options,
|
41
|
+
# then pass them to our installer to perform update if needed
|
42
|
+
# Looks like this is the most appropriate way to figure out that something should be updated
|
43
|
+
@original_installer = ObjectSpace.each_object(Pod::Installer).first
|
44
|
+
@pod_install_options[:update] = @original_installer.update
|
45
|
+
@pod_install_options[:repo_update] = @original_installer.repo_update
|
46
|
+
end
|
47
|
+
|
48
|
+
def ensure_valid_podfile
|
49
|
+
podfile.target_definition_list.each do |target_definition|
|
50
|
+
next if target_definition.explicit_prebuilt_pod_names.empty?
|
51
|
+
raise "cocoapods-binary-cache requires `use_frameworks!`" unless target_definition.uses_frameworks?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def prepare_environment
|
56
|
+
Pod::UI.puts "Prepare environment"
|
57
|
+
Pod.is_prebuild_stage = true
|
58
|
+
Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
|
59
|
+
Pod::Installer.force_disable_integration true # don't integrate targets
|
60
|
+
Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
|
61
|
+
Pod::Installer.disable_install_complete_message true # disable install complete message
|
62
|
+
end
|
63
|
+
|
64
|
+
def reset_environment
|
65
|
+
Pod::UI.puts "Reset environment"
|
66
|
+
Pod.is_prebuild_stage = false
|
67
|
+
Pod::Installer.force_disable_integration false
|
68
|
+
Pod::Podfile::DSL.enable_prebuild_patch false
|
69
|
+
Pod::Config.force_disable_write_lockfile false
|
70
|
+
Pod::Installer.disable_install_complete_message false
|
71
|
+
Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
|
72
|
+
end
|
73
|
+
|
74
|
+
def save_states_from_dsl
|
75
|
+
# Note: DSL is reloaded when creating an installer (Pod::Installer.new).
|
76
|
+
# Any mutation to DSL is highly discouraged
|
77
|
+
# --> Rather, perform mutation on PodPrebuild::StateStore instead
|
78
|
+
PodPrebuild::StateStore.excluded_pods += Pod::Podfile::DSL.excluded_pods
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_prebuild_sandbox
|
82
|
+
standard_sandbox = installer_context.sandbox
|
83
|
+
@prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
|
84
|
+
Pod::UI.puts "Create prebuild sandbox at #{@prebuild_sandbox.root}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def detect_implicit_dependencies
|
88
|
+
@original_installer.resolve_dependencies
|
89
|
+
all_specs = @original_installer.analysis_result.specifications
|
90
|
+
pods_with_empty_source_files = all_specs
|
91
|
+
.group_by { |spec| spec.name.split("/")[0] }
|
92
|
+
.select { |_, specs| specs.all?(&:empty_source_files?) }
|
93
|
+
.keys
|
94
|
+
|
95
|
+
PodPrebuild::StateStore.excluded_pods += pods_with_empty_source_files
|
96
|
+
Pod::UI.puts "Exclude pods with empty source files: #{pods_with_empty_source_files.to_a}"
|
97
|
+
|
98
|
+
# TODO (thuyen): Detect dependencies of a prebuilt pod and treat them as prebuilt pods as well
|
99
|
+
end
|
100
|
+
|
101
|
+
def validate_cache
|
102
|
+
prebuilt_lockfile = Pod::Lockfile.from_file(prebuild_sandbox.root + "Manifest.lock")
|
103
|
+
@cache_validation = PodPrebuild::CacheValidator.new(
|
104
|
+
podfile: podfile,
|
105
|
+
pod_lockfile: installer_context.lockfile,
|
106
|
+
prebuilt_lockfile: prebuilt_lockfile,
|
107
|
+
validate_prebuilt_settings: Pod::Podfile::DSL.validate_prebuilt_settings,
|
108
|
+
generated_framework_path: prebuild_sandbox.generate_framework_path,
|
109
|
+
sandbox_root: prebuild_sandbox.root,
|
110
|
+
ignored_pods: PodPrebuild::StateStore.excluded_pods,
|
111
|
+
prebuilt_pod_names: @original_installer.prebuilt_pod_names
|
112
|
+
).validate
|
113
|
+
path_to_save_cache_validation = Pod::Podfile::DSL.save_cache_validation_to
|
114
|
+
@cache_validation.update_to(path_to_save_cache_validation) unless path_to_save_cache_validation.nil?
|
115
|
+
cache_validation.print_summary
|
116
|
+
PodPrebuild::StateStore.cache_validation = cache_validation
|
117
|
+
end
|
118
|
+
|
119
|
+
def prebuild!
|
120
|
+
binary_installer = Pod::PrebuildInstaller.new(
|
121
|
+
sandbox: prebuild_sandbox,
|
122
|
+
podfile: podfile,
|
123
|
+
lockfile: installer_context.lockfile,
|
124
|
+
cache_validation: cache_validation
|
125
|
+
)
|
126
|
+
binary_installer.update = @pod_install_options[:update]
|
127
|
+
binary_installer.repo_update = @pod_install_options[:repo_update]
|
128
|
+
|
129
|
+
Pod::UI.title("Prebuilding...") do
|
130
|
+
binary_installer.clean_delta_file
|
131
|
+
binary_installer.install!
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def log_section(message)
|
136
|
+
Pod::UI.puts "-----------------------------------------"
|
137
|
+
Pod::UI.puts message
|
138
|
+
Pod::UI.puts "-----------------------------------------"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
|
2
|
+
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
|
3
|
+
|
4
|
+
require_relative "ui"
|
5
|
+
require_relative "dependencies_graph/dependencies_graph"
|
6
|
+
require_relative "cache/all"
|
7
|
+
require_relative "helper/benchmark_show"
|
8
|
+
require_relative "helper/json"
|
9
|
+
require_relative "helper/lockfile"
|
10
|
+
require_relative "helper/path_utils"
|
11
|
+
require_relative "helper/podspec"
|
12
|
+
require_relative "state_store"
|
13
|
+
require_relative "hooks/post_install"
|
14
|
+
require_relative "hooks/pre_install"
|
15
|
+
require_relative "pod-binary/prebuild_dsl"
|
16
|
+
require_relative "pod-binary/prebuild_hook"
|
17
|
+
require_relative "pod-binary/prebuild"
|
18
|
+
require_relative "prebuild_cache"
|
19
|
+
require_relative "prebuild_output/metadata"
|
20
|
+
require_relative "prebuild_output/output"
|
21
|
+
require_relative "scheme_editor"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 leavez <gaojiji@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
# Returns the names of pod targets detected as prebuilt, including
|
4
|
+
# those declared in Podfile and their dependencies
|
5
|
+
def prebuilt_pod_names
|
6
|
+
prebuilt_pod_targets.map(&:name)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Returns the pod targets detected as prebuilt, including
|
10
|
+
# those declared in Podfile and their dependencies
|
11
|
+
def prebuilt_pod_targets
|
12
|
+
@prebuilt_pod_targets ||= begin
|
13
|
+
explicit_prebuilt_pod_names = aggregate_targets
|
14
|
+
.flat_map { |target| target.target_definition.explicit_prebuilt_pod_names }
|
15
|
+
.uniq
|
16
|
+
|
17
|
+
targets = pod_targets.select { |target| explicit_prebuilt_pod_names.include?(target.pod_name) }
|
18
|
+
dependencies = targets.flat_map(&:recursive_dependent_targets) # Treat dependencies as prebuilt pods
|
19
|
+
all = (targets + dependencies).uniq
|
20
|
+
all = all.reject { |target| sandbox.local?(target.pod_name) } unless Podfile::DSL.dev_pods_enabled?
|
21
|
+
all
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Pod
|
2
|
+
class Podfile
|
3
|
+
class TargetDefinition
|
4
|
+
def detect_prebuilt_pod(name, requirements)
|
5
|
+
@explicit_prebuilt_pod_names ||= []
|
6
|
+
options = requirements.last
|
7
|
+
if Pod::Podfile::DSL.prebuild_all?
|
8
|
+
@explicit_prebuilt_pod_names << Specification.root_name(name)
|
9
|
+
elsif options.is_a?(Hash) && options[:binary]
|
10
|
+
@explicit_prebuilt_pod_names << Specification.root_name(name)
|
11
|
+
end
|
12
|
+
options.delete(:binary) if options.is_a?(Hash)
|
13
|
+
requirements.pop if options.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the names of pod targets explicitly declared as prebuilt in Podfile
|
17
|
+
# using `:binary => true`.
|
18
|
+
# In case `prebuild_all` is ON via `config_cocoapods_binary_cache`, returns the
|
19
|
+
# name of all pod targets
|
20
|
+
def explicit_prebuilt_pod_names
|
21
|
+
names = @explicit_prebuilt_pod_names || []
|
22
|
+
names += parent.explicit_prebuilt_pod_names if !parent.nil? && parent.is_a?(TargetDefinition)
|
23
|
+
names
|
24
|
+
end
|
25
|
+
|
26
|
+
# ---- patch method ----
|
27
|
+
# We want modify `store_pod` method, but it's hard to insert a line in the
|
28
|
+
# implementation. So we patch a method called in `store_pod`.
|
29
|
+
original_parse_inhibit_warnings = instance_method(:parse_inhibit_warnings)
|
30
|
+
define_method(:parse_inhibit_warnings) do |name, requirements|
|
31
|
+
detect_prebuilt_pod(name, requirements)
|
32
|
+
original_parse_inhibit_warnings.bind(self).call(name, requirements)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative "../tool/tool"
|
2
|
+
require_relative "prebuild_sandbox"
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
|
6
|
+
# a flag that indicate stages
|
7
|
+
class_attr_accessor :is_prebuild_stage
|
8
|
+
|
9
|
+
# a switch for the `pod` DSL to make it only valid for ':binary => true'
|
10
|
+
class Podfile
|
11
|
+
module DSL
|
12
|
+
@@enable_prebuild_patch = false
|
13
|
+
|
14
|
+
# when enable, `pod` function will skip all pods without 'prebuild => true'
|
15
|
+
def self.enable_prebuild_patch(value)
|
16
|
+
@@enable_prebuild_patch = value
|
17
|
+
end
|
18
|
+
|
19
|
+
# --- patch ---
|
20
|
+
old_method = instance_method(:pod)
|
21
|
+
|
22
|
+
define_method(:pod) do |name, *args|
|
23
|
+
if !@@enable_prebuild_patch
|
24
|
+
old_method.bind(self).(name, *args)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
# patched content
|
29
|
+
should_prebuild = Pod::Podfile::DSL.prebuild_all
|
30
|
+
local = false
|
31
|
+
|
32
|
+
options = args.last
|
33
|
+
if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
|
34
|
+
should_prebuild = options[Pod::Prebuild.keyword]
|
35
|
+
local = (options[:path] != nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
old_method.bind(self).call(name, *args) if should_prebuild && (!local || Podfile::DSL.dev_pods_enabled)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# a force disable option for integral
|
44
|
+
class Installer
|
45
|
+
def self.force_disable_integration(value)
|
46
|
+
@@force_disable_integration = value
|
47
|
+
end
|
48
|
+
|
49
|
+
old_method = instance_method(:integrate_user_project)
|
50
|
+
define_method(:integrate_user_project) do
|
51
|
+
if @@force_disable_integration
|
52
|
+
return
|
53
|
+
end
|
54
|
+
old_method.bind(self).()
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# a option to disable install complete message
|
59
|
+
class Installer
|
60
|
+
def self.disable_install_complete_message(value)
|
61
|
+
@@disable_install_complete_message = value
|
62
|
+
end
|
63
|
+
|
64
|
+
old_method = instance_method(:print_post_install_message)
|
65
|
+
define_method(:print_post_install_message) do
|
66
|
+
if @@disable_install_complete_message
|
67
|
+
return
|
68
|
+
end
|
69
|
+
old_method.bind(self).()
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# option to disable write lockfiles
|
74
|
+
class Config
|
75
|
+
@@force_disable_write_lockfile = false
|
76
|
+
def self.force_disable_write_lockfile(value)
|
77
|
+
@@force_disable_write_lockfile = value
|
78
|
+
end
|
79
|
+
|
80
|
+
old_method = instance_method(:lockfile_path)
|
81
|
+
define_method(:lockfile_path) do
|
82
|
+
if @@force_disable_write_lockfile
|
83
|
+
# As config is a singleton, sandbox_root refer to the standard sandbox.
|
84
|
+
return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + "Manifest.lock.tmp"
|
85
|
+
else
|
86
|
+
return old_method.bind(self).()
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|