Class: Pod::PrebuildInstaller
- Inherits:
-
Installer
show all
- Defined in:
- lib/cocoapods-binary-cache/pod-binary/prebuild.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Installer
#add_vendered_framework, #alter_spec, #alter_specs_for_prebuilt_pods, #empty_liscence, #empty_source_files, #prebuilt_pod_names, #prebuilt_pod_targets, #should_integrate_prebuilt_pod?, #tweak_resources_for_resource_bundles, #tweak_resources_for_xib, #validate_every_pod_only_have_one_form
Constructor Details
Returns a new instance of PrebuildInstaller.
12
13
14
15
16
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 12
def initialize(options)
super(options[:sandbox], options[:podfile], options[:lockfile])
@cache_validation = options[:cache_validation]
@lockfile_wrapper = lockfile && PodPrebuild::Lockfile.new(lockfile)
end
|
Instance Attribute Details
#lockfile_wrapper ⇒ Object
Returns the value of attribute lockfile_wrapper.
10
11
12
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 10
def lockfile_wrapper
@lockfile_wrapper
end
|
Instance Method Details
#clean_delta_file ⇒ Object
123
124
125
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 123
def clean_delta_file
prebuild_output.clean_delta_file
end
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 127
def collect_metadata(target, output_path)
metadata = PodPrebuild::Metadata.in_dir(output_path)
metadata.framework_name = target.framework_name
metadata.static_framework = target.static_framework?
resource_paths = target.resource_paths
metadata.resources = resource_paths.is_a?(Hash) ? resource_paths.values.flatten : resource_paths
metadata.resource_bundles = target
.file_accessors
.map { |f| f.resource_bundles.keys }
.flatten
.map { |name| "#{name}.bundle" }
metadata.build_settings = pods_project.targets
.detect { |native_target| native_target.name == target.name }
.build_configurations
.detect { |config| config.name == PodPrebuild.config.prebuild_config }
.build_settings
metadata.source_hash = @lockfile_wrapper && @lockfile_wrapper.dev_pod_hash(target.name)
project_root = PathUtils.remove_last_path_component(@sandbox.standard_sanbox_path.to_s)
metadata.project_root = project_root
metadata.save!
end
|
#prebuild_frameworks! ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 38
def prebuild_frameworks!
existed_framework_folder = sandbox.generate_framework_path
sandbox_path = sandbox.root
targets = PodPrebuild::BuildOrder.order_targets(targets_to_prebuild)
Pod::UI.puts "Prebuild frameworks (total #{targets.count}): #{targets.map(&:name)}"
Pod::Prebuild.remove_build_dir(sandbox_path)
run_code_gen!(targets)
targets.each do |target|
output_path = sandbox.framework_folder_path_for_target_name(target.name)
output_path.mkpath unless output_path.exist?
Pod::Prebuild.build(
sandbox: sandbox_path,
target: target,
configuration: PodPrebuild.config.prebuild_config,
output_path: output_path,
bitcode_enabled: PodPrebuild.config.bitcode_enabled?,
device_build_enabled: PodPrebuild.config.device_build_enabled?,
disable_dsym: PodPrebuild.config.disable_dsym?,
args: PodPrebuild.config.build_args
)
collect_metadata(target, output_path)
end
Pod::Prebuild.remove_build_dir(sandbox_path)
targets.each do |target|
root_path = sandbox.pod_dir(target.name)
target_folder = sandbox.framework_folder_path_for_target_name(target.name)
unless target.should_build?
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
next
end
target.spec_consumers.each do |consumer|
file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
lib_paths = file_accessor.vendored_frameworks || []
lib_paths += file_accessor.vendored_libraries
lib_paths.each do |lib_path|
relative = lib_path.relative_path_from(root_path)
destination = target_folder + relative
destination.dirname.mkpath unless destination.dirname.exist?
FileUtils.cp_r(lib_path, destination, :remove_destination => true)
end
end
end
targets.each do |target|
sandbox.save_pod_name_for_target target
end
all_needed_names = pod_targets.map(&:name).uniq
useless_target_names = sandbox.exsited_framework_target_names.reject do |name|
all_needed_names.include? name
end
useless_target_names.each do |name|
Pod::UI.message "Remove: #{name}"
path = sandbox.framework_folder_path_for_target_name(name)
path.rmtree if path.exist?
end
if PodPrebuild.config.dont_remove_source_code?
path = sandbox.root + "Manifest.lock.tmp"
path.rmtree if path.exist?
else
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
to_delete_files = sandbox_path.children.reject { |file| to_remain_files.include?(File.basename(file)) }
to_delete_files.each { |file| file.rmtree if file.exist? }
end
prebuild_output.write_delta_file(
updated: targets.map { |target| target.label.to_s },
deleted: useless_target_names
)
end
|
#prebuild_output ⇒ Object
26
27
28
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 26
def prebuild_output
@prebuild_output ||= PodPrebuild::Output.new(sandbox)
end
|
#run_code_gen!(targets) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 18
def run_code_gen!(targets)
return if PodPrebuild.config.prebuild_code_gen.nil?
Pod::UI.title("Running code generation...") do
PodPrebuild.config.prebuild_code_gen.call(self, targets)
end
end
|
#targets_to_prebuild ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 30
def targets_to_prebuild
to_build = PodPrebuild.config.targets_to_prebuild_from_cli
if to_build.empty?
to_build = PodPrebuild.config.prebuild_all_pods? ? @cache_validation.all : @cache_validation.missed
end
pod_targets.select { |target| to_build.include?(target.name) }
end
|