cocoapods-binary-cache 0.1.9 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-binary-cache/cache/validator_dependencies_graph.rb +1 -1
- data/lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb +21 -3
- data/lib/cocoapods-binary-cache/helper/checksum.rb +1 -1
- data/lib/cocoapods-binary-cache/hooks/pre_install.rb +12 -2
- data/lib/cocoapods-binary-cache/pod-binary/helper/build.rb +27 -29
- data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +37 -15
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb +1 -1
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +11 -1
- data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +11 -4
- data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +11 -3
- data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb +224 -152
- data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb +59 -37
- data/lib/command/config.rb +23 -8
- data/lib/command/executor/base.rb +9 -0
- data/lib/command/executor/fetcher.rb +21 -3
- data/lib/command/executor/prebuilder.rb +6 -6
- data/lib/command/executor/pusher.rb +20 -4
- data/lib/command/executor/visualizer.rb +3 -1
- data/lib/command/prebuild.rb +4 -0
- data/lib/command/visualize.rb +6 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14f6a05df17d10b35b5ddfb5d263cdeaed50e4e3bf348b6606c27036317c173
|
4
|
+
data.tar.gz: 856426aa42021e6fc6b69f1de0be1e1fbc2dc96f0ac50b146f380280a3dee236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '090730e3c268eb4f3dc0a1d0d07546e9ed4bc92dae2962a4ebc1d65f58996762aa1866414a683cf94ebee6894ebaec3d916a62cd7fe65295d9e2d6a576fb7488'
|
7
|
+
data.tar.gz: ee499933ce3bb03ec19eefcd52e50dc2170ed92e7f8f9c557e8a7c8d38f9ee1730402666937a494efe655604b320b5b6d012f31a982eb21051fab891a7367a69
|
@@ -8,7 +8,7 @@ module PodPrebuild
|
|
8
8
|
def validate(accumulated)
|
9
9
|
return accumulated if library_evolution_supported? || @pod_lockfile.nil?
|
10
10
|
|
11
|
-
dependencies_graph = DependenciesGraph.new(@pod_lockfile.lockfile)
|
11
|
+
dependencies_graph = DependenciesGraph.new(lockfile: @pod_lockfile.lockfile, invert_edge: true)
|
12
12
|
clients = dependencies_graph.get_clients(accumulated.discard(@ignored_pods).missed.to_a)
|
13
13
|
unless PodPrebuild.config.dev_pods_enabled?
|
14
14
|
clients = clients.reject { |client| @pod_lockfile.dev_pods.keys.include?(client) }
|
@@ -10,10 +10,12 @@ require_relative "graph_visualizer"
|
|
10
10
|
# https://github.com/monora/rgl/blob/master/lib/rgl/adjacency.rb
|
11
11
|
|
12
12
|
class DependenciesGraph
|
13
|
-
def initialize(
|
14
|
-
@lockfile = lockfile
|
13
|
+
def initialize(options)
|
14
|
+
@lockfile = options[:lockfile]
|
15
|
+
@devpod_only = options[:devpod_only]
|
16
|
+
@max_deps = options[:max_deps].to_i if options[:max_deps]
|
15
17
|
# A normal edge is an edge (one direction) from library A to library B which is a dependency of A.
|
16
|
-
@invert_edge =
|
18
|
+
@invert_edge = options[:invert_edge] || false
|
17
19
|
end
|
18
20
|
|
19
21
|
# Input : a list of library names.
|
@@ -40,6 +42,10 @@ class DependenciesGraph
|
|
40
42
|
@dependencies ||= (@lockfile && @lockfile.to_hash["PODS"])
|
41
43
|
end
|
42
44
|
|
45
|
+
def dev_pod_sources
|
46
|
+
@dev_pod_sources ||= @lockfile.to_hash["EXTERNAL SOURCES"].select { |_, attributes| attributes.key?(:path) } || {}
|
47
|
+
end
|
48
|
+
|
43
49
|
# Convert array of dictionaries -> a dictionary with format {A: [A's dependencies]}
|
44
50
|
def pod_to_dependencies
|
45
51
|
dependencies
|
@@ -49,6 +55,8 @@ class DependenciesGraph
|
|
49
55
|
|
50
56
|
def add_vertex(graph, pod)
|
51
57
|
node_name = sanitized_pod_name(pod)
|
58
|
+
return if @devpod_only && dev_pod_sources[node_name].nil?
|
59
|
+
|
52
60
|
graph.add_vertex(node_name)
|
53
61
|
node_name
|
54
62
|
end
|
@@ -57,10 +65,20 @@ class DependenciesGraph
|
|
57
65
|
Pod::Dependency.from_string(name).name
|
58
66
|
end
|
59
67
|
|
68
|
+
def reach_max_deps(deps)
|
69
|
+
return unless @max_deps
|
70
|
+
return deps.count > @max_deps unless @devpod_only
|
71
|
+
|
72
|
+
deps = deps.reject { |name| dev_pod_sources[name].nil? }
|
73
|
+
deps.count > @max_deps
|
74
|
+
end
|
75
|
+
|
60
76
|
def graph
|
61
77
|
@graph ||= begin
|
62
78
|
graph = RGL::DirectedAdjacencyGraph.new
|
63
79
|
pod_to_dependencies.each do |pod, dependencies|
|
80
|
+
next if reach_max_deps(dependencies)
|
81
|
+
|
64
82
|
pod_node = add_vertex(graph, pod)
|
65
83
|
next if pod_node.nil?
|
66
84
|
|
@@ -5,7 +5,7 @@ require "digest/md5"
|
|
5
5
|
|
6
6
|
class FolderChecksum
|
7
7
|
def self.git_checksum(dir)
|
8
|
-
checksum_of_files(`git ls-files #{dir}`.split("\n"))
|
8
|
+
checksum_of_files(`git ls-files #{File.realdirpath(dir).shellescape}`.split("\n"))
|
9
9
|
rescue => e
|
10
10
|
Pod::UI.warn "Cannot get checksum of tracked files under #{dir}: #{e}"
|
11
11
|
checksum_of_files(Dir["#{dir}/**/*"].reject { |f| File.directory?(f) })
|
@@ -2,13 +2,14 @@ module PodPrebuild
|
|
2
2
|
class PreInstallHook
|
3
3
|
include ObjectSpace
|
4
4
|
|
5
|
-
attr_reader :installer_context, :podfile, :prebuild_sandbox, :cache_validation
|
5
|
+
attr_reader :installer_context, :podfile, :prebuild_sandbox, :standard_sandbox, :cache_validation
|
6
6
|
|
7
7
|
def initialize(installer_context)
|
8
8
|
@installer_context = installer_context
|
9
9
|
@podfile = installer_context.podfile
|
10
10
|
@pod_install_options = {}
|
11
11
|
@prebuild_sandbox = nil
|
12
|
+
@standard_sandbox = installer_context.sandbox
|
12
13
|
@cache_validation = nil
|
13
14
|
end
|
14
15
|
|
@@ -24,6 +25,7 @@ module PodPrebuild
|
|
24
25
|
prebuild! if PodPrebuild.config.prebuild_job?
|
25
26
|
|
26
27
|
PodPrebuild::Env.next_stage!
|
28
|
+
prepare_for_integration
|
27
29
|
log_section "🤖 Resume pod installation"
|
28
30
|
require_relative "../pod-binary/integration"
|
29
31
|
end
|
@@ -51,7 +53,6 @@ module PodPrebuild
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def create_prebuild_sandbox
|
54
|
-
standard_sandbox = installer_context.sandbox
|
55
56
|
@prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
|
56
57
|
Pod::UI.message "Create prebuild sandbox at #{@prebuild_sandbox.root}"
|
57
58
|
end
|
@@ -102,6 +103,15 @@ module PodPrebuild
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
106
|
+
def prepare_for_integration
|
107
|
+
# Remove local podspec of external sources so that it downloads sources correctly.
|
108
|
+
# Otherwise, with incremental pod installation, CocoaPods downloads the sources
|
109
|
+
# based on the `s.source` declaration in the podspecs which are sometimes incorrect.
|
110
|
+
PodPrebuild.config.prebuilt_pod_names.each do |name|
|
111
|
+
@standard_sandbox.remove_local_podspec(name) if @standard_sandbox.checkout_sources.key?(name)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
105
115
|
def log_section(message)
|
106
116
|
Pod::UI.puts "-----------------------------------------"
|
107
117
|
Pod::UI.puts message
|
@@ -1,39 +1,37 @@
|
|
1
1
|
require_relative "../../pod-rome/xcodebuild_raw"
|
2
2
|
require_relative "../../pod-rome/xcodebuild_command"
|
3
3
|
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return if targets.empty?
|
4
|
+
module PodPrebuild
|
5
|
+
def self.build(options)
|
6
|
+
targets = options[:targets] || []
|
7
|
+
return if targets.empty?
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
options[:sandbox] = Pod::Sandbox.new(Pathname(options[:sandbox])) unless options[:sandbox].is_a?(Pod::Sandbox)
|
10
|
+
options[:build_dir] = build_dir(options[:sandbox].root)
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
raise "The build directory was not found in the expected location" unless options[:build_dir].directory?
|
12
|
+
case targets[0].platform.name
|
13
|
+
when :ios, :tvos, :watchos
|
14
|
+
PodPrebuild::XcodebuildCommand.new(options).run
|
15
|
+
when :osx
|
16
|
+
xcodebuild(
|
17
|
+
sandbox: options[:sandbox],
|
18
|
+
targets: targets,
|
19
|
+
configuration: options[:configuration],
|
20
|
+
sdk: "macosx",
|
21
|
+
args: options[:args]
|
22
|
+
)
|
23
|
+
else
|
24
|
+
raise "Unsupported platform for '#{targets[0].name}': '#{targets[0].platform.name}'"
|
28
25
|
end
|
26
|
+
raise "The build directory was not found in the expected location" unless options[:build_dir].directory?
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def self.remove_build_dir(sandbox_root)
|
30
|
+
path = build_dir(sandbox_root)
|
31
|
+
path.rmtree if path.exist?
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
34
|
+
def self.build_dir(sandbox_root)
|
35
|
+
sandbox_root.parent + "build"
|
38
36
|
end
|
39
37
|
end
|
@@ -2,28 +2,50 @@ module Pod
|
|
2
2
|
class Installer
|
3
3
|
def alter_specs_for_prebuilt_pods
|
4
4
|
cache = []
|
5
|
+
|
6
|
+
@original_specs = analysis_result.specifications
|
7
|
+
.map { |spec| [spec.name, Pod::Specification.from_file(spec.defined_in_file)] }
|
8
|
+
.to_h
|
9
|
+
|
5
10
|
analysis_result.specifications
|
6
11
|
.select { |spec| should_integrate_prebuilt_pod?(spec.root.name) }
|
7
|
-
.
|
12
|
+
.group_by(&:root)
|
13
|
+
.each do |_, specs|
|
14
|
+
first_subspec_or_self = specs.find(&:subspec?) || specs[0]
|
15
|
+
specs.each do |spec|
|
16
|
+
alterations = {
|
17
|
+
:source_files => true,
|
18
|
+
:resources => true,
|
19
|
+
:license => true,
|
20
|
+
:vendored_framework => spec == first_subspec_or_self
|
21
|
+
}
|
22
|
+
alter_spec(spec, alterations, cache)
|
23
|
+
end
|
24
|
+
end
|
8
25
|
end
|
9
26
|
|
10
|
-
|
27
|
+
private
|
28
|
+
|
29
|
+
def alter_spec(spec, alterations, cache)
|
11
30
|
targets = Pod.fast_get_targets_for_pod_name(spec.root.name, pod_targets, cache)
|
12
|
-
targets.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
31
|
+
platforms = targets.map { |target| target.platform.name.to_s }.uniq
|
32
|
+
|
33
|
+
if alterations[:vendored_framework]
|
34
|
+
targets.each do |target|
|
35
|
+
# Use the prebuilt frameworks as vendered frameworks.
|
36
|
+
# The framework_file_path rule is decided in `install_for_prebuild`,
|
37
|
+
# as to compitable with older version and be less wordy.
|
38
|
+
framework_file_path = target.framework_name
|
39
|
+
framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
|
40
|
+
framework_file_path = PodPrebuild.config.prebuilt_path(path: framework_file_path)
|
41
|
+
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
|
42
|
+
end
|
20
43
|
end
|
21
44
|
|
22
|
-
platforms
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
empty_liscence(spec) # to avoid the warning of missing license
|
45
|
+
empty_source_files(spec, platforms) if alterations[:source_files]
|
46
|
+
tweak_resources_for_xib(spec, platforms) if alterations[:resources]
|
47
|
+
tweak_resources_for_resource_bundles(spec, platforms) if alterations[:resources]
|
48
|
+
empty_liscence(spec) if alterations[:license]
|
27
49
|
end
|
28
50
|
|
29
51
|
def tweak_resources_for_xib(spec, platforms)
|
@@ -17,7 +17,7 @@ module Pod
|
|
17
17
|
# If the path isn't an absolute path, we add a realtive prefix.
|
18
18
|
old_read_link=`which readlink`
|
19
19
|
readlink () {
|
20
|
-
path=`$old_read_link $1`;
|
20
|
+
path=`$old_read_link "$1"`;
|
21
21
|
if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
|
22
22
|
echo $path;
|
23
23
|
else
|
@@ -18,8 +18,18 @@ module Pod
|
|
18
18
|
original_create_pod_installer(name)
|
19
19
|
end
|
20
20
|
|
21
|
+
def original_specs_by_platform(name)
|
22
|
+
specs_for_pod(name).map do |platform, specs|
|
23
|
+
specs_ = specs.map { |spec| @original_specs[spec.name] }
|
24
|
+
[platform, specs_]
|
25
|
+
end.to_h
|
26
|
+
end
|
27
|
+
|
21
28
|
def create_prebuilt_source_installer(name)
|
22
|
-
|
29
|
+
# A source installer needs to install with the original spec (instead of the altered spec).
|
30
|
+
# Otherwise, the cache will be corrupted because CocoaPods packs necessary dirs/files from temp dir
|
31
|
+
# to the cache dir based on the spec.
|
32
|
+
source_installer = PodSourceInstaller.new(sandbox, podfile, original_specs_by_platform(name))
|
23
33
|
pod_installer = PrebuiltSourceInstaller.new(
|
24
34
|
sandbox,
|
25
35
|
podfile,
|
@@ -11,7 +11,7 @@ module Pod
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def install!
|
14
|
-
@source_installer.install!
|
14
|
+
@source_installer.install!
|
15
15
|
install_prebuilt_framework!
|
16
16
|
end
|
17
17
|
|
@@ -39,8 +39,10 @@ module Pod
|
|
39
39
|
walk(real_file_folder) do |child|
|
40
40
|
source = child
|
41
41
|
# only make symlink to file and `.framework` folder
|
42
|
-
if child.directory? && [".framework", ".dSYM"].include?(child.extname)
|
43
|
-
|
42
|
+
if child.directory? && [".framework", ".xcframework", ".dSYM"].include?(child.extname)
|
43
|
+
if [".framework", ".xcframework"].include?(child.extname)
|
44
|
+
mirror_with_symlink(source, real_file_folder, target_folder)
|
45
|
+
end
|
44
46
|
# Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
|
45
47
|
# That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
|
46
48
|
# We need more setup to support local debuging with prebuilt dSYM
|
@@ -58,10 +60,15 @@ module Pod
|
|
58
60
|
next unless metadata.static_framework?
|
59
61
|
|
60
62
|
metadata.resources.each do |path|
|
61
|
-
target_file_path = path
|
63
|
+
target_file_path = Pathname(path)
|
62
64
|
.sub("${PODS_ROOT}", sandbox.root.to_path)
|
63
65
|
.sub("${PODS_CONFIGURATION_BUILD_DIR}", sandbox.root.to_path)
|
66
|
+
next if target_file_path.exist?
|
67
|
+
|
64
68
|
real_file_path = real_file_folder + metadata.framework_name + File.basename(path)
|
69
|
+
|
70
|
+
# TODO (thuyen): Fix https://github.com/grab/cocoapods-binary-cache/issues/45
|
71
|
+
|
65
72
|
case File.extname(path)
|
66
73
|
when ".xib"
|
67
74
|
# https://github.com/grab/cocoapods-binary-cache/issues/7
|
@@ -14,6 +14,13 @@ module Pod
|
|
14
14
|
@lockfile_wrapper = lockfile && PodPrebuild::Lockfile.new(lockfile)
|
15
15
|
end
|
16
16
|
|
17
|
+
def installation_options
|
18
|
+
# Skip integrating user targets for prebuild Pods project.
|
19
|
+
@installation_options ||= Pod::Installer::InstallationOptions.new(
|
20
|
+
super.to_h.merge(:integrate_targets => false)
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
17
24
|
def run_code_gen!(targets)
|
18
25
|
return if PodPrebuild.config.prebuild_code_gen.nil?
|
19
26
|
|
@@ -42,8 +49,8 @@ module Pod
|
|
42
49
|
|
43
50
|
run_code_gen!(targets)
|
44
51
|
|
45
|
-
|
46
|
-
|
52
|
+
PodPrebuild.remove_build_dir(sandbox_path)
|
53
|
+
PodPrebuild.build(
|
47
54
|
sandbox: sandbox_path,
|
48
55
|
targets: targets,
|
49
56
|
configuration: PodPrebuild.config.prebuild_config,
|
@@ -51,9 +58,10 @@ module Pod
|
|
51
58
|
bitcode_enabled: PodPrebuild.config.bitcode_enabled?,
|
52
59
|
device_build_enabled: PodPrebuild.config.device_build_enabled?,
|
53
60
|
disable_dsym: PodPrebuild.config.disable_dsym?,
|
61
|
+
log_path: PodPrebuild.config.xcodebuild_log_path,
|
54
62
|
args: PodPrebuild.config.build_args
|
55
63
|
)
|
56
|
-
|
64
|
+
PodPrebuild.remove_build_dir(sandbox_path)
|
57
65
|
|
58
66
|
targets.each do |target|
|
59
67
|
collect_metadata(target, sandbox.framework_folder_path_for_target_name(target.name))
|
@@ -1,189 +1,261 @@
|
|
1
1
|
require_relative "xcodebuild_raw"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
module PodPrebuild
|
4
|
+
class XcodebuildCommand # rubocop:disable Metrics/ClassLength
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
case options[:targets][0].platform.name
|
8
|
+
when :ios
|
9
|
+
@options[:device] = "iphoneos"
|
10
|
+
@options[:simulator] = "iphonesimulator"
|
11
|
+
when :tvos
|
12
|
+
@options[:device] = "appletvos"
|
13
|
+
@options[:simulator] = "appletvsimulator"
|
14
|
+
when :watchos
|
15
|
+
@options[:device] = "watchos"
|
16
|
+
@options[:simulator] = "watchsimulator"
|
17
|
+
end
|
18
|
+
@build_args = make_up_build_args(options[:args] || {})
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# When merging contents of `simulator` & `device`, prefer contents of `device` over `simulator`
|
32
|
-
# https://github.com/grab/cocoapods-binary-cache/issues/25
|
33
|
-
collect_output(target, Dir[target_products_dir_of(target, device) + "/*"])
|
34
|
-
create_universal_framework(target)
|
21
|
+
def run
|
22
|
+
sdks.each { |sdk| build_for_sdk(sdk) }
|
23
|
+
|
24
|
+
targets.each do |target|
|
25
|
+
if PodPrebuild.config.xcframework?
|
26
|
+
create_xcframework(target)
|
27
|
+
elsif sdks.count > 1
|
28
|
+
create_fat_framework(target)
|
29
|
+
else
|
30
|
+
collect_output(target, Dir[target_products_dir_of(target, sdks[0]) + "/*"])
|
31
|
+
end
|
35
32
|
end
|
36
33
|
end
|
37
|
-
end
|
38
34
|
|
39
|
-
|
35
|
+
private
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
def sdks
|
38
|
+
@sdks ||= begin
|
39
|
+
sdks_ = []
|
40
|
+
sdks_ << simulator if build_types.include?(:simulator)
|
41
|
+
sdks_ << device if build_types.include?(:device)
|
42
|
+
sdks_
|
43
|
+
end
|
47
44
|
end
|
48
|
-
end
|
49
45
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
args_[:simulator] ||= []
|
54
|
-
args_[:device] ||= []
|
55
|
-
args_[:default] += ["BITCODE_GENERATION_MODE=bitcode"] if bitcode_enabled?
|
56
|
-
args_[:default] += ["DEBUG_INFORMATION_FORMAT=dwarf"] if disable_dsym?
|
57
|
-
args_[:simulator] += ["ARCHS=x86_64", "ONLY_ACTIVE_ARCH=NO"] if simulator == "iphonesimulator"
|
58
|
-
args_[:simulator] += args_[:default]
|
59
|
-
args_[:device] += args_[:default]
|
60
|
-
args_
|
61
|
-
end
|
46
|
+
def preferred_sdk
|
47
|
+
@preferred_sdk ||= sdks.include?(device) ? device : sdks[0]
|
48
|
+
end
|
62
49
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
args: sdk == simulator ? @build_args[:simulator] : @build_args[:device]
|
72
|
-
)
|
73
|
-
end
|
50
|
+
def build_types
|
51
|
+
@build_types ||= begin
|
52
|
+
# TODO (thuyen): Add DSL options `build_for_types` to specify build types
|
53
|
+
types = [:simulator]
|
54
|
+
types << :device if device_build_enabled?
|
55
|
+
types
|
56
|
+
end
|
57
|
+
end
|
74
58
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
59
|
+
def make_up_build_args(args)
|
60
|
+
# Note: The build arguments explicitly passed from config_cocoapods_binary_cache
|
61
|
+
# should be preceded by the default arguments so that they could take higher priority
|
62
|
+
# when there are argument collisions in the xcodebuild command.
|
63
|
+
# For ex. `xcodebuild AN_ARG=1 AN_ARG=2` should use `AN_ARG=2` instead.
|
64
|
+
args_ = args.clone
|
65
|
+
args_[:default] ||= []
|
66
|
+
args_[:simulator] ||= []
|
67
|
+
args_[:device] ||= []
|
68
|
+
args_[:default].prepend("BITCODE_GENERATION_MODE=bitcode") if bitcode_enabled?
|
69
|
+
args_[:default].prepend("DEBUG_INFORMATION_FORMAT=dwarf") if disable_dsym?
|
70
|
+
args_[:simulator].prepend("ARCHS=x86_64", "ONLY_ACTIVE_ARCH=NO") if simulator == "iphonesimulator"
|
71
|
+
args_[:simulator] += args_[:default]
|
72
|
+
args_[:device].prepend("ONLY_ACTIVE_ARCH=NO")
|
73
|
+
args_[:device] += args_[:default]
|
74
|
+
args_
|
75
|
+
end
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
def build_for_sdk(sdk)
|
78
|
+
PodPrebuild::XcodebuildCommand.xcodebuild(
|
79
|
+
sandbox: sandbox,
|
80
|
+
scheme: scheme,
|
81
|
+
targets: targets.map(&:label),
|
82
|
+
configuration: configuration,
|
83
|
+
sdk: sdk,
|
84
|
+
deployment_target: targets.map { |t| t.platform.deployment_target }.max.to_s,
|
85
|
+
log_path: log_path(sdk),
|
86
|
+
args: sdk == simulator ? @build_args[:simulator] : @build_args[:device]
|
87
|
+
)
|
88
|
+
end
|
85
89
|
|
86
|
-
|
87
|
-
|
88
|
-
|
90
|
+
def create_xcframework(target)
|
91
|
+
non_framework_paths = Dir[target_products_dir_of(target, preferred_sdk) + "/*"] \
|
92
|
+
- [framework_path_of(target, preferred_sdk)] \
|
93
|
+
- dsym_paths_of(target, preferred_sdk) \
|
94
|
+
- bcsymbolmap_paths_of(target, preferred_sdk)
|
95
|
+
collect_output(target, non_framework_paths)
|
96
|
+
|
97
|
+
output = "#{output_path(target)}/#{target.product_module_name}.xcframework"
|
98
|
+
FileUtils.rm_rf(output)
|
99
|
+
|
100
|
+
cmd = ["xcodebuild", "-create-xcframework", "-allow-internal-distribution"]
|
89
101
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
# for each sdk, the order of params must be -framework then -debug-symbols
|
103
|
+
# to prevent duplicated file error when copying dSYMs
|
104
|
+
sdks.each do |sdk|
|
105
|
+
cmd << "-framework" << framework_path_of(target, sdk)
|
106
|
+
|
107
|
+
unless disable_dsym?
|
108
|
+
dsyms = dsym_paths_of(target, sdk)
|
109
|
+
cmd += dsyms.map { |dsym| "-debug-symbols #{dsym}" }
|
110
|
+
end
|
111
|
+
|
112
|
+
if bitcode_enabled?
|
113
|
+
bcsymbolmaps = bcsymbolmap_paths_of(target, sdk)
|
114
|
+
cmd += bcsymbolmaps.map { |bcsymbolmap| "-debug-symbols #{bcsymbolmap}" }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
cmd << "-output" << output
|
119
|
+
|
120
|
+
Pod::UI.puts "- Create xcframework: #{target}".magenta
|
121
|
+
Pod::UI.puts_indented "$ #{cmd.join(' ')}" unless PodPrebuild.config.silent_build?
|
122
|
+
|
123
|
+
`#{cmd.join(" ")}`
|
100
124
|
end
|
101
|
-
end
|
102
125
|
|
103
|
-
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
|
126
|
+
def create_fat_framework(target)
|
127
|
+
# When merging contents of `simulator` & `device`, prefer contents of `device` over `simulator`
|
128
|
+
# https://github.com/grab/cocoapods-binary-cache/issues/25
|
129
|
+
collect_output(target, Dir[target_products_dir_of(target, device) + "/*"])
|
130
|
+
|
131
|
+
merge_framework_binary(target)
|
132
|
+
merge_framework_dsym(target)
|
133
|
+
merge_swift_headers(target)
|
134
|
+
merge_swift_modules(target)
|
108
135
|
end
|
109
|
-
end
|
110
136
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
framework_path_of(target, device),
|
115
|
-
"#{output_path(target)}/#{target.product_module_name}.framework"
|
116
|
-
].map { |p| p + path_suffix }
|
117
|
-
return unless File.exist?(simulator_) && File.exist?(device_)
|
137
|
+
def merge_framework_binary(target)
|
138
|
+
merge_contents(target, "/#{target.product_module_name}", &method(:create_fat_binary))
|
139
|
+
end
|
118
140
|
|
119
|
-
|
120
|
-
|
141
|
+
def merge_framework_dsym(target)
|
142
|
+
merge_contents(
|
143
|
+
target,
|
144
|
+
".dSYM/Contents/Resources/DWARF/#{target.product_module_name}",
|
145
|
+
&method(:create_fat_binary)
|
146
|
+
)
|
147
|
+
end
|
121
148
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
149
|
+
def merge_swift_headers(target)
|
150
|
+
merge_contents(target, "/Headers/#{target.product_module_name}-Swift.h") do |options|
|
151
|
+
merged_header = <<~HEREDOC
|
152
|
+
#if TARGET_OS_SIMULATOR // merged by cocoapods-binary
|
153
|
+
#{File.read(options[:simulator])}
|
154
|
+
#else // merged by cocoapods-binary
|
155
|
+
#{File.read(options[:device])}
|
156
|
+
#endif // merged by cocoapods-binary
|
157
|
+
HEREDOC
|
158
|
+
File.write(options[:output], merged_header.strip)
|
159
|
+
end
|
160
|
+
end
|
128
161
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
162
|
+
def merge_swift_modules(target)
|
163
|
+
merge_contents(target, "/Modules/#{target.product_module_name}.swiftmodule") do |options|
|
164
|
+
# Note: swiftmodules of `device` were copied beforehand,
|
165
|
+
# here, we only need to copy swiftmodules of `simulator`
|
166
|
+
FileUtils.cp_r(options[:simulator] + "/.", options[:output])
|
167
|
+
end
|
135
168
|
end
|
136
|
-
end
|
137
169
|
|
138
|
-
|
139
|
-
|
140
|
-
|
170
|
+
def merge_contents(target, path_suffix, &merger)
|
171
|
+
simulator_, device_, output_ = [
|
172
|
+
framework_path_of(target, simulator),
|
173
|
+
framework_path_of(target, device),
|
174
|
+
"#{output_path(target)}/#{target.product_module_name}.framework"
|
175
|
+
].map { |p| p + path_suffix }
|
176
|
+
return unless File.exist?(simulator_) && File.exist?(device_)
|
141
177
|
|
142
|
-
|
143
|
-
|
144
|
-
end
|
178
|
+
merger.call(simulator: simulator_, device: device_, output: output_)
|
179
|
+
end
|
145
180
|
|
146
|
-
|
147
|
-
|
148
|
-
|
181
|
+
def create_fat_binary(options)
|
182
|
+
cmd = ["lipo", " -create"]
|
183
|
+
cmd << "-output" << options[:output]
|
184
|
+
cmd << options[:simulator] << options[:device]
|
185
|
+
`#{cmd.join(" ")}`
|
186
|
+
end
|
149
187
|
|
150
|
-
|
151
|
-
|
152
|
-
|
188
|
+
def collect_output(target, paths)
|
189
|
+
FileUtils.mkdir_p(output_path(target))
|
190
|
+
paths = [paths] unless paths.is_a?(Array)
|
191
|
+
paths.each do |path|
|
192
|
+
FileUtils.rm_rf(File.join(output_path(target), File.basename(path)))
|
193
|
+
FileUtils.cp_r(path, output_path(target))
|
194
|
+
end
|
195
|
+
end
|
153
196
|
|
154
|
-
|
155
|
-
|
156
|
-
|
197
|
+
def target_products_dir_of(target, sdk)
|
198
|
+
"#{build_dir}/#{configuration}-#{sdk}/#{target.name}"
|
199
|
+
end
|
157
200
|
|
158
|
-
|
159
|
-
|
160
|
-
|
201
|
+
def framework_path_of(target, sdk)
|
202
|
+
"#{target_products_dir_of(target, sdk)}/#{target.product_module_name}.framework"
|
203
|
+
end
|
161
204
|
|
162
|
-
|
163
|
-
|
164
|
-
|
205
|
+
def dsym_paths_of(target, sdk)
|
206
|
+
Dir["#{target_products_dir_of(target, sdk)}/*.dSYM"]
|
207
|
+
end
|
165
208
|
|
166
|
-
|
167
|
-
|
168
|
-
|
209
|
+
def bcsymbolmap_paths_of(target, sdk)
|
210
|
+
Dir["#{target_products_dir_of(target, sdk)}/*.bcsymbolmap"]
|
211
|
+
end
|
169
212
|
|
170
|
-
|
171
|
-
|
172
|
-
|
213
|
+
def sandbox
|
214
|
+
@options[:sandbox]
|
215
|
+
end
|
173
216
|
|
174
|
-
|
175
|
-
|
176
|
-
|
217
|
+
def build_dir
|
218
|
+
@options[:build_dir]
|
219
|
+
end
|
177
220
|
|
178
|
-
|
179
|
-
|
180
|
-
|
221
|
+
def output_path(target)
|
222
|
+
"#{@options[:output_path]}/#{target.label}"
|
223
|
+
end
|
181
224
|
|
182
|
-
|
183
|
-
|
184
|
-
|
225
|
+
def scheme
|
226
|
+
@options[:scheme]
|
227
|
+
end
|
228
|
+
|
229
|
+
def targets
|
230
|
+
@options[:targets]
|
231
|
+
end
|
232
|
+
|
233
|
+
def configuration
|
234
|
+
@options[:configuration]
|
235
|
+
end
|
236
|
+
|
237
|
+
def bitcode_enabled?
|
238
|
+
@options[:bitcode_enabled]
|
239
|
+
end
|
185
240
|
|
186
|
-
|
187
|
-
|
241
|
+
def device_build_enabled?
|
242
|
+
@options[:device_build_enabled]
|
243
|
+
end
|
244
|
+
|
245
|
+
def device
|
246
|
+
@options[:device] || "iphoneos"
|
247
|
+
end
|
248
|
+
|
249
|
+
def simulator
|
250
|
+
@options[:simulator] || "iphonesimulator"
|
251
|
+
end
|
252
|
+
|
253
|
+
def disable_dsym?
|
254
|
+
@options[:disable_dsym]
|
255
|
+
end
|
256
|
+
|
257
|
+
def log_path(sdk)
|
258
|
+
@options[:log_path].nil? ? nil : "#{@options[:log_path]}_#{sdk}"
|
259
|
+
end
|
188
260
|
end
|
189
261
|
end
|
@@ -1,42 +1,64 @@
|
|
1
1
|
require "fourflusher"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
3
|
+
module PodPrebuild
|
4
|
+
class XcodebuildCommand
|
5
|
+
PLATFORM_OF_SDK = {
|
6
|
+
"iphonesimulator" => "iOS",
|
7
|
+
"appletvsimulator" => "tvOS",
|
8
|
+
"watchsimulator" => "watchOS"
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
DESTINATION_OF_SDK = {
|
12
|
+
"iphoneos" => "\"generic/platform=iOS\"",
|
13
|
+
"iphonesimulator" => "\"generic/platform=iOS Simulator\""
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
def self.xcodebuild(options)
|
17
|
+
sdk = options[:sdk] || "iphonesimulator"
|
18
|
+
targets = options[:targets] || [options[:target]]
|
19
|
+
platform = PLATFORM_OF_SDK[sdk]
|
20
|
+
|
21
|
+
cmd = ["xcodebuild"]
|
22
|
+
cmd << "-project" << options[:sandbox].project_path.realdirpath.shellescape
|
23
|
+
targets.each { |target| cmd << "-target" << target }
|
24
|
+
cmd << "-configuration" << options[:configuration]
|
25
|
+
cmd << "-sdk" << sdk
|
26
|
+
if DESTINATION_OF_SDK.key?(sdk)
|
27
|
+
cmd << "-destination" << DESTINATION_OF_SDK[sdk]
|
28
|
+
else
|
29
|
+
unless platform.nil?
|
30
|
+
cmd << Fourflusher::SimControl.new.destination(:oldest, platform, options[:deployment_target])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
cmd += options[:args] if options[:args]
|
34
|
+
cmd << "build"
|
35
|
+
|
36
|
+
if options[:log_path].nil?
|
37
|
+
cmd << "2>&1"
|
38
|
+
else
|
39
|
+
FileUtils.mkdir_p(File.dirname(options[:log_path]))
|
40
|
+
cmd << "> #{options[:log_path].shellescape}"
|
41
|
+
end
|
42
|
+
cmd = cmd.join(" ")
|
43
|
+
|
44
|
+
Pod::UI.puts_indented "$ #{cmd}" unless PodPrebuild.config.silent_build?
|
45
|
+
|
46
|
+
log = `#{cmd}`
|
47
|
+
return if $?.exitstatus.zero? # rubocop:disable Style/SpecialGlobalVars
|
48
|
+
|
49
|
+
begin
|
50
|
+
require "xcpretty" # TODO (thuyen): Revise this dependency
|
51
|
+
# use xcpretty to print build log
|
52
|
+
# 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
|
53
|
+
printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => "auto"})
|
54
|
+
log.each_line do |line|
|
55
|
+
printer.pretty_print(line)
|
56
|
+
end
|
57
|
+
rescue
|
58
|
+
Pod::UI.puts log.red
|
59
|
+
ensure
|
60
|
+
raise "Fail to build targets: #{targets}"
|
61
|
+
end
|
36
62
|
end
|
37
|
-
rescue
|
38
|
-
Pod::UI.puts log.red
|
39
|
-
ensure
|
40
|
-
raise "Fail to build targets: #{targets}"
|
41
63
|
end
|
42
64
|
end
|
data/lib/command/config.rb
CHANGED
@@ -29,6 +29,10 @@ module PodPrebuild
|
|
29
29
|
@cache_repo ||= cache_repo_config["remote"]
|
30
30
|
end
|
31
31
|
|
32
|
+
def local_cache?
|
33
|
+
cache_repo.nil?
|
34
|
+
end
|
35
|
+
|
32
36
|
def cache_path
|
33
37
|
@cache_path ||= File.expand_path(cache_repo_config["local"])
|
34
38
|
end
|
@@ -54,7 +58,9 @@ module PodPrebuild
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def prebuilt_path(path: nil)
|
57
|
-
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
|
58
64
|
end
|
59
65
|
|
60
66
|
def validate_dsl_config
|
@@ -99,19 +105,22 @@ module PodPrebuild
|
|
99
105
|
@dsl_config[:device_build_enabled]
|
100
106
|
end
|
101
107
|
|
102
|
-
def
|
103
|
-
@dsl_config[:
|
108
|
+
def xcframework?
|
109
|
+
@dsl_config[:xcframework]
|
104
110
|
end
|
105
111
|
|
106
|
-
def
|
107
|
-
|
108
|
-
option.is_a?(Array) ? option.include?(name) : option
|
112
|
+
def disable_dsym?
|
113
|
+
@dsl_config[:disable_dsym]
|
109
114
|
end
|
110
115
|
|
111
116
|
def dont_remove_source_code?
|
112
117
|
@dsl_config[:dont_remove_source_code]
|
113
118
|
end
|
114
119
|
|
120
|
+
def xcodebuild_log_path
|
121
|
+
@dsl_config[:xcodebuild_log_path]
|
122
|
+
end
|
123
|
+
|
115
124
|
def build_args
|
116
125
|
@dsl_config[:build_args]
|
117
126
|
end
|
@@ -132,6 +141,10 @@ module PodPrebuild
|
|
132
141
|
@dsl_config[:strict_diagnosis]
|
133
142
|
end
|
134
143
|
|
144
|
+
def silent_build?
|
145
|
+
@dsl_config[:silent_build]
|
146
|
+
end
|
147
|
+
|
135
148
|
def targets_to_prebuild_from_cli
|
136
149
|
@cli_config[:prebuild_targets] || []
|
137
150
|
end
|
@@ -166,14 +179,16 @@ module PodPrebuild
|
|
166
179
|
:dev_pods_enabled,
|
167
180
|
:bitcode_enabled,
|
168
181
|
:device_build_enabled,
|
182
|
+
:xcframework,
|
169
183
|
:disable_dsym,
|
170
|
-
:still_download_sources,
|
171
184
|
:dont_remove_source_code,
|
185
|
+
:xcodebuild_log_path,
|
172
186
|
:build_args,
|
173
187
|
:save_cache_validation_to,
|
174
188
|
:validate_prebuilt_settings,
|
175
189
|
:prebuild_code_gen,
|
176
|
-
:strict_diagnosis
|
190
|
+
:strict_diagnosis,
|
191
|
+
:silent_build
|
177
192
|
]
|
178
193
|
end
|
179
194
|
|
@@ -2,6 +2,7 @@ module PodPrebuild
|
|
2
2
|
class CommandExecutor
|
3
3
|
def initialize(options)
|
4
4
|
@config = options[:config]
|
5
|
+
prepare_cache_dir
|
5
6
|
end
|
6
7
|
|
7
8
|
def installer
|
@@ -11,6 +12,14 @@ module PodPrebuild
|
|
11
12
|
end
|
12
13
|
end
|
13
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
|
21
|
+
end
|
22
|
+
|
14
23
|
def git(cmd, options = {})
|
15
24
|
comps = ["git"]
|
16
25
|
comps << "-C" << @config.cache_path unless options[:cache_repo] == false
|
@@ -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
|
-
|
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
|
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"]
|
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,23 +4,23 @@ 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
11
|
@repo_update = options[:repo_update]
|
12
|
-
@fetcher = PodPrebuild::CacheFetcher.new(options)
|
13
|
-
@pusher = PodPrebuild::CachePusher.new(options)
|
12
|
+
@fetcher = PodPrebuild::CacheFetcher.new(options) unless options[:no_fetch]
|
13
|
+
@pusher = PodPrebuild::CachePusher.new(options) if options[:push_cache]
|
14
14
|
end
|
15
15
|
|
16
16
|
def run
|
17
|
-
@fetcher
|
17
|
+
@fetcher&.run
|
18
18
|
prebuild
|
19
19
|
changes = PodPrebuild::JSONFile.new(@config.prebuild_delta_path)
|
20
20
|
return if changes.empty?
|
21
21
|
|
22
22
|
sync_cache(changes)
|
23
|
-
@pusher
|
23
|
+
@pusher&.run
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
@@ -8,11 +8,13 @@ module PodPrebuild
|
|
8
8
|
@lockfile = options[:lockfile]
|
9
9
|
@open = options[:open]
|
10
10
|
@output_dir = options[:output_dir]
|
11
|
+
@devpod_only = options[:devpod_only]
|
12
|
+
@max_deps = options[:max_deps]
|
11
13
|
end
|
12
14
|
|
13
15
|
def run
|
14
16
|
FileUtils.mkdir_p(@output_dir)
|
15
|
-
graph = DependenciesGraph.new(@lockfile)
|
17
|
+
graph = DependenciesGraph.new(lockfile: @lockfile, devpod_only: @devpod_only, max_deps: @max_deps)
|
16
18
|
output_path = "#{@output_dir}/graph.png"
|
17
19
|
graph.write_graphic_file(output_path: output_path)
|
18
20
|
system("open #{@output_path}") if @open
|
data/lib/command/prebuild.rb
CHANGED
@@ -5,11 +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"],
|
12
14
|
["--repo-update", "Update pod repo before installing"],
|
15
|
+
["--no-fetch", "Do not perform a cache fetch beforehand"],
|
13
16
|
["--push", "Push cache to repo upon completion"],
|
14
17
|
["--all", "Prebuild all binary pods regardless of cache validation"],
|
15
18
|
["--targets", "Targets to prebuild. Use comma (,) to specify a list of targets"]
|
@@ -30,6 +33,7 @@ module Pod
|
|
30
33
|
config: prebuild_config,
|
31
34
|
cache_branch: argv.shift_argument || "master",
|
32
35
|
repo_update: argv.flag?("repo-update"),
|
36
|
+
no_fetch: argv.flag?("fetch") == false,
|
33
37
|
push_cache: argv.flag?("push")
|
34
38
|
)
|
35
39
|
end
|
data/lib/command/visualize.rb
CHANGED
@@ -7,7 +7,9 @@ module Pod
|
|
7
7
|
self.arguments = [CLAide::Argument.new("OUTPUT-DIR", false)]
|
8
8
|
def self.options
|
9
9
|
[
|
10
|
-
["--open", "Open the graph upon completion"]
|
10
|
+
["--open", "Open the graph upon completion"],
|
11
|
+
["--devpod_only", "Only include development pod"],
|
12
|
+
["--max_deps", "Only include pod with number of dependencies <= max_deps"]
|
11
13
|
]
|
12
14
|
end
|
13
15
|
|
@@ -17,7 +19,9 @@ module Pod
|
|
17
19
|
config: prebuild_config,
|
18
20
|
lockfile: config.lockfile,
|
19
21
|
output_dir: argv.shift_argument || ".",
|
20
|
-
open: argv.flag?("open")
|
22
|
+
open: argv.flag?("open"),
|
23
|
+
devpod_only: argv.flag?("devpod_only"),
|
24
|
+
max_deps: argv.option("max_deps")
|
21
25
|
)
|
22
26
|
end
|
23
27
|
|
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.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bang Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-05 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
|
@@ -186,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
200
|
- !ruby/object:Gem::Version
|
187
201
|
version: '0'
|
188
202
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
203
|
+
rubygems_version: 3.1.2
|
190
204
|
signing_key:
|
191
205
|
specification_version: 4
|
192
206
|
summary: Reduce build time by building pod frameworks and cache to remote storage,
|