Class: Pod::Installer
- Inherits:
-
Object
show all
- Defined in:
- lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb,
lib/cocoapods-binary-cache/pod-binary/integration/validation.rb,
lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.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/remove_target_files.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
Overview
a option to disable install complete message
Defined Under Namespace
Classes: PodSourceInstaller
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.disable_install_complete_message(value) ⇒ Object
60
61
62
|
# File 'lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb', line 60
def self.disable_install_complete_message(value)
@@disable_install_complete_message = value
end
|
.force_disable_integration(value) ⇒ Object
45
46
47
|
# File 'lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb', line 45
def self.force_disable_integration(value)
@@force_disable_integration = value
end
|
Instance Method Details
#add_vendered_framework(spec, platform, added_framework_file_path) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 73
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
|
# 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
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
88
89
90
91
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 88
def empty_liscence(spec)
spec.attributes_hash["license"] = {}
spec.root.attributes_hash["license"] = {}
end
|
#empty_source_files(spec, platforms) ⇒ Object
81
82
83
84
85
86
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 81
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)
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 Podfile::DSL.dev_pods_enabled?
all
end
end
|
#remove_target_files_if_needed ⇒ Object
Remove the old target files if prebuild frameworks changed
4
5
6
7
8
9
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/remove_target_files.rb', line 4
def remove_target_files_if_needed
changes = Pod::Prebuild::Passer.prebuild_pods_changes
updated_names = []
if changes.nil?
updated_names = PrebuildSandbox.from_standard_sandbox(sandbox).exsited_framework_pod_names
else
added = changes.added
changed = changes.changed
deleted = changes.deleted
updated_names = added + changed + deleted
end
updated_names.each do |name|
root_name = Specification.root_name(name)
next if !Pod::Podfile::DSL.dev_pods_enabled && sandbox.local?(root_name)
UI.puts "Delete cached files: #{root_name}"
target_path = sandbox.pod_dir(root_name)
target_path.rmtree if target_path.exist?
support_path = sandbox.target_support_files_dir(root_name)
support_path.rmtree if support_path.exist?
end
end
|
#should_integrate_prebuilt_pod?(name) ⇒ Boolean
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb', line 17
def should_integrate_prebuilt_pod?(name)
if Pod::Podfile::DSL.prebuild_job?
PodPrebuild::StateStore.cache_validation.include?(name)
else
PodPrebuild::StateStore.cache_validation.hit?(name)
end
end
|
#tweak_resources_for_resource_bundles(spec, platforms) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 55
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 { |n| n + ".bundle" }
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
28
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
|
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 28
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
|