Skip to content

Commit 442cd3c

Browse files
chore(*): update framework path
1 parent 03a2739 commit 442cd3c

File tree

10 files changed

+60
-63
lines changed

10 files changed

+60
-63
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cocoapods-binary-cache (0.1.5)
4+
cocoapods-binary-cache (0.1.6)
55
cocoapods (>= 1.5.0)
66
fourflusher (~> 2.0)
77
rgl (~> 0.5.6)
@@ -138,7 +138,7 @@ PLATFORMS
138138

139139
DEPENDENCIES
140140
bacon
141-
bundler (~> 1.3)
141+
bundler (>= 1.3)
142142
cocoapods
143143
cocoapods-binary-cache!
144144
mocha
@@ -153,4 +153,4 @@ DEPENDENCIES
153153
xcpretty
154154

155155
BUNDLED WITH
156-
1.17.3
156+
2.1.2

cocoapods-binary-cache.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
2222
spec.add_dependency "rgl", "~> 0.5.6"
2323
spec.add_dependency "xcpretty", "~> 0.3.0"
2424

25-
spec.add_development_dependency "bundler", "~> 1.3"
25+
spec.add_development_dependency "bundler", ">= 1.3"
2626
spec.add_development_dependency "rake", "~> 10.0"
2727
end

lib/cocoapods-binary-cache/diagnosis/integration.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def run
1010
should_be_integrated = should_be_integrated.map { |name| name.split("/")[0] }.to_set
1111
unintegrated = should_be_integrated.reject do |name|
1212
module_name = spec(name)&.module_name || name
13-
framework_path = @standard_sandbox.pod_dir(name) + "#{module_name}.framework"
13+
framework_path = \
14+
@standard_sandbox.pod_dir(name) + \
15+
PodPrebuild::Config.instance.prebuilt_path(path: "#{module_name}.framework")
1416
framework_path.exist?
1517
end
1618
Pod::UI.puts "🚩 Unintegrated frameworks: #{unintegrated}".yellow unless unintegrated.empty?

lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Pod
44
class PrebuildSandbox < Sandbox
55
# [String] standard_sandbox_path
66
def self.from_standard_sanbox_path(path)
7-
prebuild_sandbox_path = Pathname.new(path).realpath + ".." + PodPrebuild::Config.instance.prebuild_path
7+
prebuild_sandbox_path = Pathname.new(path).realpath + ".." + PodPrebuild::Config.instance.prebuild_sandbox_path
88
self.new(prebuild_sandbox_path)
99
end
1010

lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def alter_spec(spec, cache)
1515
# as to compitable with older version and be less wordy.
1616
framework_file_path = target.framework_name
1717
framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
18+
framework_file_path = PodPrebuild::Config.instance.prebuilt_path(path: framework_file_path)
1819
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
1920
end
2021

lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,64 +17,28 @@ def install_for_prebuild!(standard_sanbox)
1717
# TODO (bang): Unify to 1 sandbox to optimize and avoid inconsistency
1818
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
1919
# if spec used in multiple platforms, it may return multiple paths
20-
target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)
21-
22-
def walk(path, &action)
23-
return unless path.exist?
24-
path.children.each do |child|
25-
result = action.call(child, &action)
26-
if child.directory?
27-
walk(child, &action) if result
28-
end
29-
end
30-
end
31-
32-
def make_link(source, target)
33-
source = Pathname.new(source)
34-
target = Pathname.new(target)
35-
target.parent.mkpath unless target.parent.exist?
36-
relative_source = source.relative_path_from(target.parent)
37-
FileUtils.ln_sf(relative_source, target)
38-
end
39-
40-
def mirror_with_symlink(source, basefolder, target_folder)
41-
target = target_folder + source.relative_path_from(basefolder)
42-
make_link(source, target)
43-
end
44-
20+
target_names = prebuild_sandbox.existed_target_names_for_pod_name(name)
4521
target_names.each do |name|
46-
47-
# symbol link copy all substructure
4822
real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
4923

5024
# If have only one platform, just place int the root folder of this pod.
5125
# If have multiple paths, we use a sperated folder to store different
5226
# platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
53-
5427
target_folder = standard_sanbox.pod_dir(self.name)
55-
if target_names.count > 1
56-
target_folder += real_file_folder.basename
57-
end
58-
59-
if !standard_sanbox.local?(name)
60-
target_folder.rmtree if target_folder.exist?
61-
target_folder.mkpath
62-
else
63-
system "find #{target_folder} -type l -delete" # Only clean up symlink, keep source code for local pod
64-
end
28+
target_folder += real_file_folder.basename if target_names.count > 1
29+
target_folder += PodPrebuild::Config.instance.prebuilt_path
30+
target_folder.rmtree if target_folder.exist?
31+
target_folder.mkpath
6532

6633
walk(real_file_folder) do |child|
6734
source = child
6835
# only make symlink to file and `.framework` folder
69-
if child.directory? and [".framework", ".dSYM"].include? child.extname
70-
if child.extname == ".framework"
71-
mirror_with_symlink(source, real_file_folder, target_folder)
72-
else
73-
# Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
74-
# That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
75-
# We need more setup to support local debuging with prebuilt dSYM
76-
end
77-
next false # return false means don't go deeper
36+
if child.directory? && [".framework", ".dSYM"].include?(child.extname)
37+
mirror_with_symlink(source, real_file_folder, target_folder) if child.extname == ".framework"
38+
# Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
39+
# That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
40+
# We need more setup to support local debuging with prebuilt dSYM
41+
next false # Don't go deeper
7842
elsif child.file?
7943
mirror_with_symlink(source, real_file_folder, target_folder)
8044
next true
@@ -88,8 +52,9 @@ def mirror_with_symlink(source, basefolder, target_folder)
8852
next unless metadata.static_framework?
8953

9054
metadata.resources.each do |path|
91-
target_file_path = path.sub("${PODS_ROOT}", sandbox.root.to_path)
92-
.sub("${PODS_CONFIGURATION_BUILD_DIR}", sandbox.root.to_path)
55+
target_file_path = path
56+
.sub("${PODS_ROOT}", sandbox.root.to_path)
57+
.sub("${PODS_CONFIGURATION_BUILD_DIR}", sandbox.root.to_path)
9358
real_file_path = real_file_folder + metadata.framework_name + File.basename(path)
9459
case File.extname(path)
9560
when ".xib"
@@ -107,6 +72,31 @@ def mirror_with_symlink(source, basefolder, target_folder)
10772
end
10873
end
10974
end
75+
76+
private
77+
78+
def walk(path, &action)
79+
return unless path.exist?
80+
81+
path.children.each do |child|
82+
result = action.call(child, &action)
83+
if child.directory?
84+
walk(child, &action) if result
85+
end
86+
end
87+
end
88+
89+
def make_link(source, target)
90+
source = Pathname.new(source)
91+
target = Pathname.new(target)
92+
target.parent.mkpath unless target.parent.exist?
93+
relative_source = source.relative_path_from(target.parent)
94+
FileUtils.ln_sf(relative_source, target)
95+
end
96+
97+
def mirror_with_symlink(source, basefolder, target_folder)
98+
make_link(source, target_folder + source.relative_path_from(basefolder))
99+
end
110100
end
111101
end
112102
end

lib/cocoapods-binary-cache/pod-binary/prebuild.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def collect_metadata(target, output_path)
211211
.file_accessors
212212
.map { |f| f.resource_bundles.keys }
213213
.flatten
214-
.map { |name| "#{name}.bundle" }
214+
.map { |name| PodPrebuild::Config.instance.prebuilt_path(path: "#{name}.bundle") }
215215
metadata.build_settings = pods_project.targets
216216
.detect { |native_target| native_target.name == target.name }
217217
.build_configurations

lib/command/config.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
module PodPrebuild
44
class Config
5-
attr_reader :cache_repo, :cache_path, :prebuild_path, :prebuild_delta_path
5+
attr_reader :cache_repo, :cache_path, :prebuild_sandbox_path, :prebuild_delta_path
66

77
def initialize(path)
88
@data = PodPrebuild::JSONFile.new(path)
99
@cache_repo = @data["cache_repo"] || @data["prebuilt_cache_repo"]
1010
@cache_path = File.expand_path(@data["cache_path"])
11-
@prebuild_path = @data["prebuild_path"] || "_Prebuild"
11+
@prebuild_sandbox_path = @data["prebuild_path"] || "_Prebuild"
1212
@prebuild_delta_path = @data["prebuild_delta_path"] || "_Prebuild_delta/changes.json"
1313
end
1414

@@ -21,11 +21,15 @@ def manifest_path(in_cache: false)
2121
end
2222

2323
def root_dir(in_cache)
24-
in_cache ? @cache_path : @prebuild_path
24+
in_cache ? @cache_path : @prebuild_sandbox_path
2525
end
2626

2727
def generated_frameworks_dir(in_cache: false)
2828
root_dir(in_cache) + "/GeneratedFrameworks"
2929
end
30+
31+
def prebuilt_path(path: nil)
32+
path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}"
33+
end
3034
end
3135
end

lib/command/executor/fetcher.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def fetch_cache(repo, branch, dest_dir)
3131
end
3232

3333
def unzip_cache
34-
Pod::UI.puts "Unzipping cache: #{@config.cache_path} -> #{@config.prebuild_path}".green
35-
FileUtils.rm_rf(@config.prebuild_path)
36-
FileUtils.mkdir_p(@config.prebuild_path)
34+
Pod::UI.puts "Unzipping cache: #{@config.cache_path} -> #{@config.prebuild_sandbox_path}".green
35+
FileUtils.rm_rf(@config.prebuild_sandbox_path)
36+
FileUtils.mkdir_p(@config.prebuild_sandbox_path)
3737

3838
if File.exist?(@config.manifest_path(in_cache: true))
3939
FileUtils.cp(

scripts/integration_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ check_prebuilt_integration() {
6666

6767
local should_fail=false
6868
for pod in $(cat ".stats/pods_to_integrate.txt"); do
69-
local framework_dir="Pods/${pod}/${pod}.framework"
69+
local framework_dir="Pods/${pod}/_Prebuilt/${pod}.framework"
7070
if [[ ! -f "${framework_dir}/${pod}" ]]; then
7171
should_fail=true
7272
echo "🚩 Prebuilt framework ${pod} was not integrated. Expect to have: ${framework_dir}"

0 commit comments

Comments
 (0)