Class: Pod::Installer
- Inherits:
-
Object
show all
- Defined in:
- lib/cocoapods-binary-cache/pod-binary/integration/validation.rb,
lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb,
lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb,
lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb
Defined Under Namespace
Classes: Analyzer, PodSourceInstaller
Instance Method Summary
collapse
Instance Method Details
#add_vendered_framework(spec, platform, added_framework_file_path) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 76
def add_vendered_framework(spec, platform, added_framework_file_path)
spec.attributes_hash[platform] = {} if spec.attributes_hash[platform].nil?
vendored_frameworks = spec.attributes_hash[platform]["vendored_frameworks"] || []
vendored_frameworks = [vendored_frameworks] if vendored_frameworks.is_a?(String)
vendored_frameworks += [added_framework_file_path]
spec.attributes_hash[platform]["vendored_frameworks"] = vendored_frameworks
end
|
#alter_spec(spec, cache) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 10
def alter_spec(spec, cache)
targets = Pod.fast_get_targets_for_pod_name(spec.root.name, pod_targets, cache)
targets.each do |target|
framework_file_path = target.framework_name
framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
framework_file_path = PodPrebuild.config.prebuilt_path(path: framework_file_path)
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
end
platforms = targets.map { |target| target.platform.name.to_s }.uniq
empty_source_files(spec, platforms)
tweak_resources_for_xib(spec, platforms)
tweak_resources_for_resource_bundles(spec, platforms)
empty_liscence(spec)
end
|
#alter_specs_for_prebuilt_pods ⇒ Object
3
4
5
6
7
8
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 3
def alter_specs_for_prebuilt_pods
cache = []
analysis_result.specifications
.select { |spec| should_integrate_prebuilt_pod?(spec.root.name) }
.each { |spec| alter_spec(spec, cache) }
end
|
#empty_liscence(spec) ⇒ Object
91
92
93
94
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 91
def empty_liscence(spec)
spec.attributes_hash["license"] = {}
spec.root.attributes_hash["license"] = {}
end
|
#empty_source_files(spec, platforms) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 84
def empty_source_files(spec, platforms)
spec.attributes_hash["source_files"] = []
platforms.each do |platform|
spec.attributes_hash[platform]["source_files"] = [] unless spec.attributes_hash[platform].nil?
end
end
|
#prebuilt_pod_names ⇒ Object
Returns the names of pod targets detected as prebuilt, including those declared in Podfile and their dependencies
5
6
7
|
# File 'lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb', line 5
def prebuilt_pod_names
prebuilt_pod_targets.map(&:name).to_set
end
|
#prebuilt_pod_targets ⇒ Object
Returns the pod targets detected as prebuilt, including those declared in Podfile and their dependencies
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb', line 11
def prebuilt_pod_targets
@prebuilt_pod_targets ||= begin
explicit_prebuilt_pod_names = aggregate_targets
.flat_map { |target| target.target_definition.explicit_prebuilt_pod_names }
.uniq
targets = pod_targets.select { |target| explicit_prebuilt_pod_names.include?(target.pod_name) }
dependencies = targets.flat_map(&:recursive_dependent_targets)
all = (targets + dependencies).uniq
all = all.reject { |target| sandbox.local?(target.pod_name) } unless PodPrebuild.config.dev_pods_enabled?
all
end
end
|
#should_integrate_prebuilt_pod?(name) ⇒ Boolean
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb', line 19
def should_integrate_prebuilt_pod?(name)
if PodPrebuild.config.prebuild_job? && PodPrebuild.config.targets_to_prebuild_from_cli.empty?
PodPrebuild.state.cache_validation.include?(name)
else
prebuilt = PodPrebuild.state.cache_validation.hit + PodPrebuild.config.targets_to_prebuild_from_cli
prebuilt.include?(name)
end
end
|
#tweak_resources_for_resource_bundles(spec, platforms) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 56
def tweak_resources_for_resource_bundles(spec, platforms)
add_resource_bundles_to_resources = lambda do |attributes|
return if attributes.nil?
resource_bundles = attributes["resource_bundles"] || {}
resource_bundle_names = resource_bundles.keys
attributes["resource_bundles"] = nil
attributes["resources"] ||= []
attributes["resources"] = [attributes["resources"]] if attributes["resources"].is_a?(String)
attributes["resources"] += resource_bundle_names.map do |name|
PodPrebuild.config.prebuilt_path(path: "#{name}.bundle")
end
end
add_resource_bundles_to_resources.call(spec.attributes_hash)
platforms.each do |platform|
add_resource_bundles_to_resources.call(spec.attributes_hash[platform])
end
end
|
#tweak_resources_for_xib(spec, platforms) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 29
def tweak_resources_for_xib(spec, platforms)
change_xib_to_nib = ->(path) { path.sub(".xib", ".nib") }
update_resources = lambda do |resources|
if resources.is_a?(String)
change_xib_to_nib.call(resources)
elsif resources.is_a?(Array)
resources.map { |item| change_xib_to_nib.call(item) }
end
end
spec.attributes_hash["resources"] = update_resources.call(spec.attributes_hash["resources"])
platforms.each do |platform|
next if spec.attributes_hash[platform].nil?
platform_resources = spec.attributes_hash[platform]["resources"]
spec.attributes_hash[platform]["resources"] = update_resources.call(platform_resources)
end
end
|
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/validation.rb', line 3
def validate_every_pod_only_have_one_form
multi_targets_pods = pod_targets
.group_by(&:pod_name)
.select do |_, targets|
is_multi_targets = targets.map { |t| t.platform.name }.uniq.count > 1
is_multi_forms = targets.map { |t| prebuilt_pod_targets.include?(t) }.uniq.count > 1
is_multi_targets && is_multi_forms
end
return if multi_targets_pods.empty?
warnings = "One pod can only be prebuilt or not prebuilt. These pod have different forms in multiple targets:\n"
warnings += multi_targets_pods
.map { |name, targets| " #{name}: #{targets.map { |t| t.platform.name }}" }
.join("\n")
raise Informative, warnings
end
|