cocoapods-binary-cache 0.1.1 → 0.1.7
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 +4 -4
- data/lib/cocoapods-binary-cache.rb +0 -2
- data/lib/cocoapods-binary-cache/cache/validator.rb +2 -3
- data/lib/cocoapods-binary-cache/cache/validator_base.rb +28 -8
- data/lib/cocoapods-binary-cache/cache/validator_dependencies_graph.rb +7 -2
- data/lib/cocoapods-binary-cache/cache/validator_dev_pods.rb +21 -13
- data/lib/cocoapods-binary-cache/cache/validator_non_dev_pods.rb +1 -1
- data/lib/cocoapods-binary-cache/diagnosis/base.rb +13 -0
- data/lib/cocoapods-binary-cache/diagnosis/diagnosis.rb +16 -0
- data/lib/cocoapods-binary-cache/diagnosis/integration.rb +21 -0
- data/lib/cocoapods-binary-cache/env.rb +32 -0
- data/lib/cocoapods-binary-cache/helper/checksum.rb +10 -4
- data/lib/cocoapods-binary-cache/helper/lockfile.rb +26 -3
- data/lib/cocoapods-binary-cache/helper/podspec.rb +1 -0
- data/lib/cocoapods-binary-cache/hooks/post_install.rb +19 -2
- data/lib/cocoapods-binary-cache/hooks/pre_install.rb +11 -14
- data/lib/cocoapods-binary-cache/main.rb +2 -1
- data/lib/cocoapods-binary-cache/pod-binary/helper/build.rb +39 -0
- data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +1 -1
- data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/target_definition.rb +3 -10
- data/lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb +0 -38
- data/lib/cocoapods-binary-cache/pod-binary/helper/names.rb +2 -11
- data/lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb +1 -2
- data/lib/cocoapods-binary-cache/pod-binary/integration.rb +0 -1
- data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +4 -1
- data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +5 -2
- data/lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb +2 -2
- data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +42 -50
- data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +59 -47
- data/lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb +2 -59
- data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb +176 -0
- data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb +43 -0
- data/lib/cocoapods-binary-cache/prebuild_output/metadata.rb +16 -0
- data/lib/cocoapods-binary-cache/prebuild_output/output.rb +8 -37
- data/lib/cocoapods-binary-cache/scheme_editor.rb +1 -1
- data/lib/command/binary.rb +21 -2
- data/lib/command/config.rb +150 -9
- data/lib/command/executor/fetcher.rb +10 -5
- data/lib/command/executor/prebuilder.rb +2 -1
- data/lib/command/executor/pusher.rb +1 -1
- data/lib/command/fetch.rb +0 -1
- data/lib/command/helper/zip.rb +1 -1
- data/lib/command/prebuild.rb +14 -2
- data/lib/command/push.rb +22 -0
- metadata +19 -14
- data/lib/cocoapods-binary-cache/gem_version.rb +0 -6
- data/lib/cocoapods-binary-cache/pod-rome/build_framework.rb +0 -247
- data/lib/cocoapods-binary-cache/prebuild_cache.rb +0 -49
|
@@ -4,65 +4,8 @@ module Pod
|
|
|
4
4
|
class Podfile
|
|
5
5
|
module DSL
|
|
6
6
|
def config_cocoapods_binary_cache(options)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
apply_config.call(:prebuild_config)
|
|
12
|
-
apply_config.call(:prebuild_job)
|
|
13
|
-
apply_config.call(:prebuild_all) # TODO (thuyen): Revise this option
|
|
14
|
-
apply_config.call(:prebuild_all_vendor_pods)
|
|
15
|
-
apply_config.call(:excluded_pods)
|
|
16
|
-
apply_config.call(:dev_pods_enabled)
|
|
17
|
-
apply_config.call(:bitcode_enabled)
|
|
18
|
-
apply_config.call(:dont_remove_source_code)
|
|
19
|
-
apply_config.call(:custom_device_build_options)
|
|
20
|
-
apply_config.call(:custom_simulator_build_options)
|
|
21
|
-
apply_config.call(:save_cache_validation_to)
|
|
22
|
-
apply_config.call(:validate_prebuilt_settings)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
@prebuild_config = "Debug"
|
|
26
|
-
@prebuild_job = false
|
|
27
|
-
@prebuild_all = false
|
|
28
|
-
@prebuild_all_vendor_pods = false
|
|
29
|
-
@excluded_pods = Set.new
|
|
30
|
-
@dev_pods_enabled = false
|
|
31
|
-
@bitcode_enabled = false
|
|
32
|
-
@dont_remove_source_code = false
|
|
33
|
-
@custom_device_build_options = []
|
|
34
|
-
@custom_simulator_build_options = []
|
|
35
|
-
@save_cache_validation_to = nil
|
|
36
|
-
# A proc to validate the provided build settings (per target) with the build settings of the prebuilt frameworks
|
|
37
|
-
# For example, in Podfile:
|
|
38
|
-
# -----------------------------------------------
|
|
39
|
-
# validate_prebuilt_settings do |target|
|
|
40
|
-
# settings = {}
|
|
41
|
-
# settings["MACH_O_TYPE"] == "staticlib"
|
|
42
|
-
# settings["SWIFT_VERSION"] == swift_version_of(target)
|
|
43
|
-
# settings
|
|
44
|
-
# end
|
|
45
|
-
# -----------------------------------------------
|
|
46
|
-
@validate_prebuilt_settings = nil
|
|
47
|
-
|
|
48
|
-
class << self
|
|
49
|
-
attr_accessor :prebuild_config
|
|
50
|
-
attr_accessor :prebuild_job
|
|
51
|
-
attr_accessor :prebuild_all
|
|
52
|
-
attr_accessor :prebuild_all_vendor_pods
|
|
53
|
-
attr_accessor :excluded_pods
|
|
54
|
-
attr_accessor :dev_pods_enabled
|
|
55
|
-
attr_accessor :bitcode_enabled
|
|
56
|
-
attr_accessor :dont_remove_source_code
|
|
57
|
-
attr_accessor :custom_device_build_options
|
|
58
|
-
attr_accessor :custom_simulator_build_options
|
|
59
|
-
attr_accessor :save_cache_validation_to
|
|
60
|
-
attr_accessor :validate_prebuilt_settings
|
|
61
|
-
|
|
62
|
-
alias prebuild_job? prebuild_job
|
|
63
|
-
alias prebuild_all? prebuild_all
|
|
64
|
-
alias prebuild_all_vendor_pods? prebuild_all_vendor_pods
|
|
65
|
-
alias dev_pods_enabled? dev_pods_enabled
|
|
7
|
+
PodPrebuild.config.dsl_config = options
|
|
8
|
+
PodPrebuild.config.validate_dsl_config
|
|
66
9
|
end
|
|
67
10
|
end
|
|
68
11
|
end
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
require_relative "xcodebuild_raw"
|
|
2
|
+
|
|
3
|
+
class XcodebuildCommand
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@options = options
|
|
6
|
+
case options[:target].platform.name
|
|
7
|
+
when :ios
|
|
8
|
+
@options[:device] = "iphoneos"
|
|
9
|
+
@options[:simulator] = "iphonesimulator"
|
|
10
|
+
when :tvos
|
|
11
|
+
@options[:device] = "appletvos"
|
|
12
|
+
@options[:simulator] = "appletvsimulator"
|
|
13
|
+
when :watchos
|
|
14
|
+
@options[:device] = "watchos"
|
|
15
|
+
@options[:simulator] = "watchsimulator"
|
|
16
|
+
end
|
|
17
|
+
@build_args = make_up_build_args(options[:args] || {})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
build_for_sdk(simulator)
|
|
22
|
+
if device_build_enabled?
|
|
23
|
+
build_for_sdk(device)
|
|
24
|
+
create_universal_framework
|
|
25
|
+
merge_dsym unless disable_dsym?
|
|
26
|
+
merge_swift_headers
|
|
27
|
+
merge_swift_modules
|
|
28
|
+
end
|
|
29
|
+
collect_output(Dir[target_products_dir_of(simulator) + "/*"])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def make_up_build_args(args)
|
|
35
|
+
args_ = args.clone
|
|
36
|
+
args_[:default] ||= []
|
|
37
|
+
args_[:simulator] ||= []
|
|
38
|
+
args_[:device] ||= []
|
|
39
|
+
args_[:default] += ["BITCODE_GENERATION_MODE=bitcode"] if bitcode_enabled?
|
|
40
|
+
args_[:default] += ["DEBUG_INFORMATION_FORMAT=dwarf"] if disable_dsym?
|
|
41
|
+
args_[:simulator] += ["ARCHS=x86_64", "ONLY_ACTIVE_ARCH=NO"] if simulator == "iphonesimulator"
|
|
42
|
+
args_[:simulator] += args_[:default]
|
|
43
|
+
args_[:device] += args_[:default]
|
|
44
|
+
args_
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def build_for_sdk(sdk)
|
|
48
|
+
framework_path = framework_path_of(sdk)
|
|
49
|
+
if Dir.exist?(framework_path)
|
|
50
|
+
Pod::UI.puts "Framework already exists at: #{framework_path}"
|
|
51
|
+
return
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
succeeded, = xcodebuild(
|
|
55
|
+
sandbox: sandbox,
|
|
56
|
+
target: target.label,
|
|
57
|
+
configuration: configuration,
|
|
58
|
+
sdk: sdk,
|
|
59
|
+
deployment_target: target.platform.deployment_target.to_s,
|
|
60
|
+
args: sdk == simulator ? @build_args[:simulator] : @build_args[:device]
|
|
61
|
+
)
|
|
62
|
+
raise "Build framework failed: #{target.label}" unless succeeded
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def create_universal_framework
|
|
66
|
+
create_fat_binary(
|
|
67
|
+
simulator: "#{framework_path_of(simulator)}/#{module_name}",
|
|
68
|
+
device: "#{framework_path_of(device)}/#{module_name}"
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def merge_dsym
|
|
73
|
+
simulator_dsym = framework_path_of(simulator) + ".dSYM"
|
|
74
|
+
device_dsym = framework_path_of(device) + ".dSYM"
|
|
75
|
+
return unless File.exist?(simulator_dsym) && File.exist?(device_dsym)
|
|
76
|
+
|
|
77
|
+
create_fat_binary(
|
|
78
|
+
simulator: "#{simulator_dsym}/Contents/Resources/DWARF/#{module_name}",
|
|
79
|
+
device: "#{device_dsym}/Contents/Resources/DWARF/#{module_name}"
|
|
80
|
+
)
|
|
81
|
+
collect_output(simulator_dsym)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def create_fat_binary(options)
|
|
85
|
+
cmd = ["lipo", " -create"]
|
|
86
|
+
cmd << "-output" << options[:simulator]
|
|
87
|
+
cmd << options[:simulator] << options[:device]
|
|
88
|
+
Pod::UI.puts `#{cmd.join(" ")}`
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def merge_swift_headers
|
|
92
|
+
simulator_header_path = framework_path_of(simulator) + "/Headers/#{module_name}-Swift.h"
|
|
93
|
+
device_header_path = framework_path_of(device) + "/Headers/#{module_name}-Swift.h"
|
|
94
|
+
return unless File.exist?(simulator_header_path) && File.exist?(device_header_path)
|
|
95
|
+
|
|
96
|
+
merged_header = <<~HEREDOC
|
|
97
|
+
#if TARGET_OS_SIMULATOR // merged by cocoapods-binary
|
|
98
|
+
#{File.read(simulator_header_path)}
|
|
99
|
+
#else // merged by cocoapods-binary
|
|
100
|
+
#{File.read(device_header_path)}
|
|
101
|
+
#endif // merged by cocoapods-binary
|
|
102
|
+
HEREDOC
|
|
103
|
+
File.write(simulator_header_path, merged_header.strip)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def merge_swift_modules
|
|
107
|
+
simulator_swift_module_path = framework_path_of(simulator) + "/Modules/#{module_name}.swiftmodule"
|
|
108
|
+
device_swift_module_path = framework_path_of(device) + "/Modules/#{module_name}.swiftmodule"
|
|
109
|
+
return unless File.exist?(simulator_swift_module_path) && File.exist?(device_swift_module_path)
|
|
110
|
+
|
|
111
|
+
FileUtils.cp_r(
|
|
112
|
+
device_swift_module_path + "/.",
|
|
113
|
+
simulator_swift_module_path
|
|
114
|
+
)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def collect_output(paths)
|
|
118
|
+
paths = [paths] unless paths.is_a?(Array)
|
|
119
|
+
paths.each do |path|
|
|
120
|
+
FileUtils.rm_rf(File.join(output_path, File.basename(path)))
|
|
121
|
+
FileUtils.mv(path, output_path)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def target_products_dir_of(sdk)
|
|
126
|
+
"#{build_dir}/#{configuration}-#{sdk}/#{target.name}"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def framework_path_of(sdk)
|
|
130
|
+
"#{target_products_dir_of(sdk)}/#{module_name}.framework"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def module_name
|
|
134
|
+
target.product_module_name
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def sandbox
|
|
138
|
+
@options[:sandbox]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def build_dir
|
|
142
|
+
@options[:build_dir]
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def output_path
|
|
146
|
+
@options[:output_path]
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def target
|
|
150
|
+
@options[:target]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def configuration
|
|
154
|
+
@options[:configuration]
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def bitcode_enabled?
|
|
158
|
+
@options[:bitcode_enabled]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def device_build_enabled?
|
|
162
|
+
@options[:device_build_enabled]
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def device
|
|
166
|
+
@options[:device] || "iphoneos"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def simulator
|
|
170
|
+
@options[:simulator] || "iphonesimulator"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def disable_dsym?
|
|
174
|
+
@options[:disable_dsym]
|
|
175
|
+
end
|
|
176
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require "fourflusher"
|
|
2
|
+
|
|
3
|
+
PLATFORM_OF_SDK = {
|
|
4
|
+
"iphonesimulator" => "iOS",
|
|
5
|
+
"appletvsimulator" => "tvOS",
|
|
6
|
+
"watchsimulator" => "watchOS"
|
|
7
|
+
}.freeze
|
|
8
|
+
|
|
9
|
+
def xcodebuild(options)
|
|
10
|
+
sdk = options[:sdk] || "iphonesimulator"
|
|
11
|
+
platform = PLATFORM_OF_SDK[sdk]
|
|
12
|
+
|
|
13
|
+
cmd = ["xcodebuild"]
|
|
14
|
+
cmd << "-project" << options[:sandbox].project_path.realdirpath
|
|
15
|
+
cmd << "-scheme" << options[:target]
|
|
16
|
+
cmd << "-configuration" << options[:configuration]
|
|
17
|
+
cmd << "-sdk" << sdk
|
|
18
|
+
cmd << Fourflusher::SimControl.new.destination(:oldest, platform, options[:deployment_target]) unless platform.nil?
|
|
19
|
+
cmd += options[:args] if options[:args]
|
|
20
|
+
cmd << "2>&1"
|
|
21
|
+
cmd = cmd.join(" ")
|
|
22
|
+
|
|
23
|
+
puts "xcodebuild command: #{cmd}"
|
|
24
|
+
log = `#{cmd}`
|
|
25
|
+
|
|
26
|
+
succeeded = $?.exitstatus.zero?
|
|
27
|
+
unless succeeded
|
|
28
|
+
begin
|
|
29
|
+
raise "Unexpected error" unless log.include?("** BUILD FAILED **")
|
|
30
|
+
|
|
31
|
+
require "xcpretty" # TODO (thuyen): Revise this dependency
|
|
32
|
+
# use xcpretty to print build log
|
|
33
|
+
# 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
|
|
34
|
+
printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => "auto"})
|
|
35
|
+
log.each_line do |line|
|
|
36
|
+
printer.pretty_print(line)
|
|
37
|
+
end
|
|
38
|
+
rescue
|
|
39
|
+
puts log.red
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
[succeeded, log]
|
|
43
|
+
end
|
|
@@ -43,5 +43,21 @@ module PodPrebuild
|
|
|
43
43
|
def build_settings=(value)
|
|
44
44
|
@data["build_settings"] = value
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
def source_hash
|
|
48
|
+
@data["source_hash"] || {}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def source_hash=(value)
|
|
52
|
+
@data["source_hash"] = value
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def project_root
|
|
56
|
+
@data["project_root"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def project_root=(value)
|
|
60
|
+
@data["project_root"] = value
|
|
61
|
+
end
|
|
46
62
|
end
|
|
47
63
|
end
|
|
@@ -7,18 +7,17 @@ module PodPrebuild
|
|
|
7
7
|
@sandbox = prebuild_sandbox
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
@
|
|
10
|
+
def prebuild_delta_path
|
|
11
|
+
@prebuild_delta_path ||= PodPrebuild.config.prebuild_delta_path
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
"#{delta_dir}/changes.json"
|
|
14
|
+
def delta_dir
|
|
15
|
+
@delta_dir ||= File.dirname(prebuild_delta_path)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
def clean_delta_file
|
|
20
|
-
puts "Clean delta file: #{
|
|
21
|
-
FileUtils.rm_rf(
|
|
19
|
+
puts "Clean delta file: #{prebuild_delta_path}"
|
|
20
|
+
FileUtils.rm_rf(prebuild_delta_path)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def create_dir_if_needed(dir)
|
|
@@ -32,40 +31,12 @@ module PodPrebuild
|
|
|
32
31
|
return
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
Pod::UI.puts "Write prebuild changes to: #{
|
|
34
|
+
Pod::UI.puts "Write prebuild changes to: #{prebuild_delta_path}"
|
|
36
35
|
create_dir_if_needed(delta_dir)
|
|
37
|
-
changes = PodPrebuild::JSONFile.new(
|
|
36
|
+
changes = PodPrebuild::JSONFile.new(prebuild_delta_path)
|
|
38
37
|
changes["updated"] = updated
|
|
39
38
|
changes["deleted"] = deleted
|
|
40
39
|
changes.save!
|
|
41
40
|
end
|
|
42
|
-
|
|
43
|
-
def process_prebuilt_dev_pods
|
|
44
|
-
devpod_output_path = "#{delta_dir}/devpod_prebuild_output/"
|
|
45
|
-
create_dir_if_needed(devpod_output_path)
|
|
46
|
-
Pod::UI.puts "Copy prebuilt devpod frameworks to output dir: #{devpod_output_path}"
|
|
47
|
-
|
|
48
|
-
# Inject project path (where the framework is built) to support generating code coverage later
|
|
49
|
-
project_root = PathUtils.remove_last_path_component(@sandbox.standard_sanbox_path.to_s)
|
|
50
|
-
template_file_path = devpod_output_path + "prebuilt_map"
|
|
51
|
-
File.open(template_file_path, "w") do |file|
|
|
52
|
-
file.write(project_root)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# FIXME (thuyen): Revise usage of cache_miss_dev_pods_dic
|
|
56
|
-
# The behavior of processing outputs of dev pods and non-dev pods should be very SIMILAR
|
|
57
|
-
cache_miss_dev_pods_dic = {}
|
|
58
|
-
|
|
59
|
-
cache_miss_dev_pods_dic.each do |name, hash|
|
|
60
|
-
Pod::UI.puts "Output dev pod lib: #{name} hash: #{hash}"
|
|
61
|
-
built_lib_path = @sandbox.framework_folder_path_for_target_name(name)
|
|
62
|
-
next unless File.directory?(built_lib_path)
|
|
63
|
-
|
|
64
|
-
FileUtils.cp(template_file_path, "#{built_lib_path}/#{name}.framework")
|
|
65
|
-
target_dir = "#{devpod_output_path}#{name}_#{hash}"
|
|
66
|
-
Pod::UI.puts "From: #{built_lib_path} -> #{target_dir}"
|
|
67
|
-
FileUtils.cp_r(built_lib_path, target_dir)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
41
|
end
|
|
71
42
|
end
|
|
@@ -12,7 +12,7 @@ class SchemeEditor
|
|
|
12
12
|
scheme_name = File.basename(file_path, '.*')
|
|
13
13
|
next unless sandbox.local?(scheme_name)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Pod::UI.message "Modify scheme to enable coverage symbol when prebuild: #{scheme_name}"
|
|
16
16
|
|
|
17
17
|
doc = File.open(file_path, 'r') { |f| REXML::Document.new(f) }
|
|
18
18
|
scheme = doc.elements['Scheme']
|
data/lib/command/binary.rb
CHANGED
|
@@ -2,16 +2,35 @@ require "fileutils"
|
|
|
2
2
|
require_relative "config"
|
|
3
3
|
require_relative "fetch"
|
|
4
4
|
require_relative "prebuild"
|
|
5
|
+
require_relative "push"
|
|
5
6
|
require_relative "visualize"
|
|
6
7
|
|
|
7
8
|
module Pod
|
|
8
9
|
class Command
|
|
9
10
|
class Binary < Command
|
|
10
11
|
self.abstract_command = true
|
|
11
|
-
self.
|
|
12
|
+
def self.options
|
|
13
|
+
[
|
|
14
|
+
["--repo", "Cache repo (in accordance with `cache_repo` in `config_cocoapods_binary_cache`)"]
|
|
15
|
+
]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(argv)
|
|
19
|
+
super
|
|
20
|
+
load_podfile
|
|
21
|
+
update_cli_config(:repo => argv.option("repo"))
|
|
22
|
+
end
|
|
12
23
|
|
|
13
24
|
def prebuild_config
|
|
14
|
-
@prebuild_config ||= PodPrebuild
|
|
25
|
+
@prebuild_config ||= PodPrebuild.config
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_podfile
|
|
29
|
+
Pod::Config.instance.podfile
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update_cli_config(options)
|
|
33
|
+
PodPrebuild.config.cli_config.merge!(options)
|
|
15
34
|
end
|
|
16
35
|
end
|
|
17
36
|
end
|
data/lib/command/config.rb
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
require_relative "../cocoapods-binary-cache/helper/json"
|
|
2
2
|
|
|
3
3
|
module PodPrebuild
|
|
4
|
+
def self.config
|
|
5
|
+
PodPrebuild::Config.instance
|
|
6
|
+
end
|
|
7
|
+
|
|
4
8
|
class Config
|
|
5
|
-
|
|
9
|
+
attr_accessor :dsl_config, :cli_config
|
|
6
10
|
|
|
7
11
|
def initialize(path)
|
|
8
|
-
@
|
|
9
|
-
@
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
+
@deprecated_config = File.exist?(path) ? PodPrebuild::JSONFile.new(path).data : {}
|
|
13
|
+
@dsl_config = {}
|
|
14
|
+
@cli_config = {}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.instance
|
|
18
|
+
@instance ||= new("PodBinaryCacheConfig.json")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def reset!
|
|
22
|
+
@deprecated_config = {}
|
|
23
|
+
@dsl_config = {}
|
|
24
|
+
@cli_config = {}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def cache_repo
|
|
28
|
+
@cache_repo ||= cache_repo_config["remote"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def cache_path
|
|
32
|
+
@cache_path ||= File.expand_path(cache_repo_config["local"])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def prebuild_sandbox_path
|
|
36
|
+
@dsl_config[:prebuild_sandbox_path] || @deprecated_config["prebuild_path"] || "_Prebuild"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def prebuild_delta_path
|
|
40
|
+
@dsl_config[:prebuild_delta_path] || @deprecated_config["prebuild_delta_path"] || "_Prebuild_delta/changes.json"
|
|
12
41
|
end
|
|
13
42
|
|
|
14
43
|
def manifest_path(in_cache: false)
|
|
@@ -16,16 +45,128 @@ module PodPrebuild
|
|
|
16
45
|
end
|
|
17
46
|
|
|
18
47
|
def root_dir(in_cache)
|
|
19
|
-
in_cache ?
|
|
48
|
+
in_cache ? cache_path : prebuild_sandbox_path
|
|
20
49
|
end
|
|
21
50
|
|
|
22
51
|
def generated_frameworks_dir(in_cache: false)
|
|
23
52
|
root_dir(in_cache) + "/GeneratedFrameworks"
|
|
24
53
|
end
|
|
25
54
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
def prebuilt_path(path: nil)
|
|
56
|
+
path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def validate_dsl_config
|
|
60
|
+
inapplicable_options = @dsl_config.keys - applicable_dsl_config
|
|
61
|
+
return if inapplicable_options.empty?
|
|
62
|
+
|
|
63
|
+
message = <<~HEREDOC
|
|
64
|
+
[WARNING] The following options (in `config_cocoapods_binary_cache`) are not correct: #{inapplicable_options}.
|
|
65
|
+
Available options: #{applicable_dsl_config}.
|
|
66
|
+
Check out the following doc for more details
|
|
67
|
+
https://github.com/grab/cocoapods-binary-cache/blob/master/docs/configure_cocoapods_binary_cache.md
|
|
68
|
+
HEREDOC
|
|
69
|
+
|
|
70
|
+
Pod::UI.puts message.yellow
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def prebuild_config
|
|
74
|
+
@cli_config[:prebuild_config] || @dsl_config[:prebuild_config] || "Debug"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def prebuild_job?
|
|
78
|
+
@cli_config[:prebuild_job] || @dsl_config[:prebuild_job]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def prebuild_all_pods?
|
|
82
|
+
@cli_config[:prebuild_all_pods] || @dsl_config[:prebuild_all_pods]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def excluded_pods
|
|
86
|
+
@dsl_config[:excluded_pods] || Set.new
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def dev_pods_enabled?
|
|
90
|
+
@dsl_config[:dev_pods_enabled]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def bitcode_enabled?
|
|
94
|
+
@dsl_config[:bitcode_enabled]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def device_build_enabled?
|
|
98
|
+
@dsl_config[:device_build_enabled]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def disable_dsym?
|
|
102
|
+
@dsl_config[:disable_dsym]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def dont_remove_source_code?
|
|
106
|
+
@dsl_config[:dont_remove_source_code]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def build_args
|
|
110
|
+
@dsl_config[:build_args]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def save_cache_validation_to
|
|
114
|
+
@dsl_config[:save_cache_validation_to]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def validate_prebuilt_settings
|
|
118
|
+
@dsl_config[:validate_prebuilt_settings]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def prebuild_code_gen
|
|
122
|
+
@dsl_config[:prebuild_code_gen]
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def targets_to_prebuild_from_cli
|
|
126
|
+
@cli_config[:prebuild_targets] || []
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
private
|
|
130
|
+
|
|
131
|
+
def applicable_dsl_config
|
|
132
|
+
[
|
|
133
|
+
:cache_repo,
|
|
134
|
+
:prebuild_sandbox_path,
|
|
135
|
+
:prebuild_delta_path,
|
|
136
|
+
:prebuild_config,
|
|
137
|
+
:prebuild_job,
|
|
138
|
+
:prebuild_all_pods,
|
|
139
|
+
:excluded_pods,
|
|
140
|
+
:dev_pods_enabled,
|
|
141
|
+
:bitcode_enabled,
|
|
142
|
+
:device_build_enabled,
|
|
143
|
+
:disable_dsym,
|
|
144
|
+
:dont_remove_source_code,
|
|
145
|
+
:build_args,
|
|
146
|
+
:save_cache_validation_to,
|
|
147
|
+
:validate_prebuilt_settings,
|
|
148
|
+
:prebuild_code_gen
|
|
149
|
+
]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def cache_repo_config
|
|
153
|
+
@cache_repo_config ||= begin
|
|
154
|
+
repo = @cli_config[:repo] || "default"
|
|
155
|
+
config_ = @dsl_config[:cache_repo] || {}
|
|
156
|
+
if config_[repo].nil?
|
|
157
|
+
message = <<~HEREDOC
|
|
158
|
+
[Deprecated] Configs in `PodBinaryCacheConfig.json` are deprecated.
|
|
159
|
+
Declare option `cache_repo` in `config_cocoapods_binary_cache` instead.
|
|
160
|
+
Check out the following doc for more details
|
|
161
|
+
https://github.com/grab/cocoapods-binary-cache/blob/master/docs/configure_cocoapods_binary_cache.md
|
|
162
|
+
HEREDOC
|
|
163
|
+
Pod::UI.puts message.yellow
|
|
164
|
+
end
|
|
165
|
+
config_[repo] || {
|
|
166
|
+
"remote" => @deprecated_config["cache_repo"] || @deprecated_config["prebuilt_cache_repo"],
|
|
167
|
+
"local" => @deprecated_config["cache_path"] || "~/.cocoapods-binary-cache/prebuilt-frameworks"
|
|
168
|
+
}
|
|
169
|
+
end
|
|
29
170
|
end
|
|
30
171
|
end
|
|
31
172
|
end
|