cocoapods-kz 0.1.2 → 0.1.3
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dbfec23581ec953d3d7886a2aa6007bbbb10f5d3355fa6a81fd532cb9cd3a6e
|
|
4
|
+
data.tar.gz: ad0eea404a2b6e8015c8f5e574c3cff081e40c4f6a7f8647fa2cf0a1598a7dd0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8884f42d577af7e435d804ad0c028b9e296123d0b0b10cbffa64cc244db7c52b4910cbaff33d6eabaa898371f1aaa09866b7b9ee679f65f682766b74fd052d5f
|
|
7
|
+
data.tar.gz: d8fba21db82fc7d30ccb5536434e5cf020319c56f31920a5723d1c6fbb47c7f6cbf6122a97c9e3d4e0f1c0682571fa65ece9a728edfc632bec4ab165b63dbe78
|
|
@@ -98,7 +98,7 @@ module KZ
|
|
|
98
98
|
xcframework_path = destination_path + "#{framework_basename}.xcframework"
|
|
99
99
|
return xcframework_path if File.exist?(xcframework_path) && !Dir.empty?(xcframework_path)
|
|
100
100
|
|
|
101
|
-
if self.create_xcframework(origin_framework_path,
|
|
101
|
+
if self.create_xcframework(origin_framework_path, framework_basename, xcframework_path)
|
|
102
102
|
return xcframework_path
|
|
103
103
|
else
|
|
104
104
|
return origin_framework_path
|
|
@@ -121,34 +121,47 @@ module KZ
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
# 找到真机arm64 framework
|
|
124
|
+
# 找到真机arm64 framework
|
|
125
125
|
xc_framework_path = ""
|
|
126
|
-
xc_simulator_framework_path = ""
|
|
127
126
|
available_libraries.each do |available_librarie|
|
|
128
|
-
if available_librarie["
|
|
129
|
-
if available_librarie["SupportedArchitectures"].include?("
|
|
130
|
-
|
|
127
|
+
if available_librarie["SupportedPlatform"] == "ios"
|
|
128
|
+
if available_librarie["SupportedArchitectures"].include?("arm64")
|
|
129
|
+
xc_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
|
|
131
130
|
end
|
|
132
|
-
elsif available_librarie["SupportedPlatform"] == "ios"
|
|
133
|
-
if available_librarie["SupportedArchitectures"].include?("arm64")
|
|
134
|
-
xc_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
|
|
135
|
-
end
|
|
136
131
|
end
|
|
137
132
|
end
|
|
138
133
|
|
|
139
|
-
|
|
140
|
-
if self.create_xcframework(xc_framework_path, xc_simulator_framework_path, framework_basename, xcframework_path)
|
|
141
|
-
return xcframework_path
|
|
142
|
-
else
|
|
134
|
+
if xc_framework_path == "" || !self.create_xcframework(xc_framework_path, framework_basename, xcframework_path)
|
|
143
135
|
return origin_framework_path
|
|
136
|
+
else
|
|
137
|
+
return xcframework_path
|
|
144
138
|
end
|
|
145
139
|
else
|
|
146
140
|
return origin_framework_path
|
|
147
141
|
end
|
|
148
142
|
end
|
|
149
143
|
|
|
150
|
-
|
|
144
|
+
# 将 xcframework slice 中直接提供的 .a 包装成 create_xcframework 可处理的 .framework。
|
|
145
|
+
# 除了静态库本身,也保留同级目录中的 Headers、Modules 等支持文件。
|
|
146
|
+
def self.convert_static_library_to_framework(origin_library_path, framework_basename, destination_path)
|
|
147
|
+
return origin_library_path unless File.extname(origin_library_path.to_s) == ".a"
|
|
148
|
+
|
|
149
|
+
framework_path = destination_path + "#{framework_basename}.framework"
|
|
150
|
+
framework_library_path = framework_path + origin_library_path.basename
|
|
151
|
+
framework_executable_path = framework_path + framework_basename
|
|
152
|
+
FileUtils.mkdir_p(framework_path)
|
|
153
|
+
Dir.children(origin_library_path.parent).each do |entry|
|
|
154
|
+
FileUtils.cp_r(origin_library_path.parent + entry, framework_path)
|
|
155
|
+
end
|
|
156
|
+
FileUtils.mv(framework_library_path, framework_executable_path)
|
|
157
|
+
KZLog.log("'#{origin_library_path.basename}' 已包装为 framework,继续创建 xcframework")
|
|
158
|
+
framework_path
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def self.create_xcframework(origin_framework_path, framework_basename, destination_xcframework_path)
|
|
151
162
|
tempdir = Pathname(Dir.mktmpdir)
|
|
163
|
+
origin_framework_path = self.convert_static_library_to_framework(origin_framework_path, framework_basename, tempdir + "origin")
|
|
164
|
+
|
|
152
165
|
arm64_path = tempdir + "arm64"
|
|
153
166
|
FileUtils.mkdir_p(arm64_path)
|
|
154
167
|
arm64_framework_path = arm64_path + "#{framework_basename}.framework"
|
|
@@ -161,20 +174,14 @@ module KZ
|
|
|
161
174
|
simulator_path = tempdir + "simulator"
|
|
162
175
|
FileUtils.mkdir_p(simulator_path)
|
|
163
176
|
simulator_framework_path = simulator_path + "#{framework_basename}.framework"
|
|
164
|
-
FileUtils.cp_r(
|
|
177
|
+
FileUtils.cp_r(arm64_framework_path, simulator_framework_path)
|
|
165
178
|
simulator_framework_exe_path = simulator_framework_path + framework_basename
|
|
166
|
-
contain_x8664 = self.contain_x8664?(simulator_framework_exe_path)
|
|
167
|
-
if contain_x8664
|
|
168
|
-
KZLog.run_shell("lipo #{simulator_framework_exe_path} -thin x86_64 -output #{simulator_framework_exe_path}")
|
|
169
|
-
else
|
|
170
|
-
FileUtils.rm(simulator_framework_exe_path)
|
|
171
|
-
end
|
|
172
179
|
|
|
173
180
|
temp_framwork_exe_path = tempdir + "#{framework_basename}_arm64_simulator"
|
|
174
|
-
if self.is_dynamic_library?(
|
|
181
|
+
if self.is_dynamic_library?(arm64_framework_exe_path)
|
|
175
182
|
KZLog.log("'#{origin_framework_path.basename}' 是一个动态库,开始做Load command转换")
|
|
176
183
|
|
|
177
|
-
xcrun_vtool_show_result = `xcrun vtool -arch arm64 -show #{
|
|
184
|
+
xcrun_vtool_show_result = `xcrun vtool -arch arm64 -show #{arm64_framework_exe_path}`.lines.map(&:chomp)
|
|
178
185
|
framework_sdk_version = "16.0"
|
|
179
186
|
framework_deployment_version = "12.0"
|
|
180
187
|
reach_cmd_tag = false
|
|
@@ -205,8 +212,8 @@ module KZ
|
|
|
205
212
|
else
|
|
206
213
|
ar_x_path = tempdir + "ar_x"
|
|
207
214
|
FileUtils.mkdir_p(ar_x_path)
|
|
208
|
-
if self.is_current_ar_archive?(
|
|
209
|
-
KZLog.log("'#{
|
|
215
|
+
if self.is_current_ar_archive?(arm64_framework_exe_path)
|
|
216
|
+
KZLog.log("'#{arm64_framework_path.basename}' 是一个ar archive类型静态库,开始拆分.o并重新构建")
|
|
210
217
|
|
|
211
218
|
ar_x_success = KZLog.run_shell("cd #{ar_x_path}; ar x #{arm64_framework_exe_path}")
|
|
212
219
|
if ar_x_success
|
|
@@ -232,11 +239,7 @@ module KZ
|
|
|
232
239
|
end
|
|
233
240
|
end
|
|
234
241
|
|
|
235
|
-
|
|
236
|
-
KZLog.run_shell("lipo -create #{temp_framwork_exe_path} #{simulator_framework_exe_path} -output #{simulator_framework_exe_path}")
|
|
237
|
-
else
|
|
238
|
-
FileUtils.mv("#{temp_framwork_exe_path}", simulator_framework_exe_path)
|
|
239
|
-
end
|
|
242
|
+
FileUtils.mv("#{temp_framwork_exe_path}", simulator_framework_exe_path)
|
|
240
243
|
FileUtils.mkdir_p(destination_xcframework_path) unless File.exist?(destination_xcframework_path)
|
|
241
244
|
KZLog.run_shell("xcodebuild -create-xcframework -framework $(readlink -f '#{arm64_framework_path}') -framework $(readlink -f '#{simulator_framework_path}') -output #{destination_xcframework_path}")
|
|
242
245
|
FileUtils.rm_r(tempdir)
|
|
@@ -254,11 +257,6 @@ module KZ
|
|
|
254
257
|
return file_result.include?("current ar archive")
|
|
255
258
|
end
|
|
256
259
|
|
|
257
|
-
def self.contain_x8664?(file_path)
|
|
258
|
-
file_result = `file -b #{file_path}`
|
|
259
|
-
return file_result.include?("for architecture x86_64")
|
|
260
|
-
end
|
|
261
|
-
|
|
262
260
|
def self.contain_multiple_arch?(file_path)
|
|
263
261
|
file_result = `lipo -info #{file_path}`
|
|
264
262
|
return file_result.include?("Architectures in the fat file")
|
|
@@ -13,7 +13,7 @@ module KZ
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
def self.log(log_string, type = :normal, skip_count = 1)
|
|
16
|
-
if KZGlobalHelper.instance.debug || type == :error
|
|
16
|
+
if KZGlobalHelper.instance.debug || type == :error
|
|
17
17
|
loc = caller_locations(skip_count, 1).first
|
|
18
18
|
puts "#{loc.path}:#{loc.lineno} ⬇️"
|
|
19
19
|
puts "\e[36m【Cocoapods-kz】\e[0m#{@log_types[type]}【#{type}】#{@log_types[:reset]}#{log_string}"
|
|
@@ -24,7 +24,7 @@ module KZ
|
|
|
24
24
|
stdout, stderr, status = Open3.capture3(cmd)
|
|
25
25
|
|
|
26
26
|
self.log(stdout, :normal, 2) unless stdout.empty?
|
|
27
|
-
self.log(stderr, :error, 2) unless stderr.empty?
|
|
27
|
+
self.log(stderr, status.success? ? :warning : :error, 2) unless stderr.empty?
|
|
28
28
|
|
|
29
29
|
return status.success?
|
|
30
30
|
end
|
|
@@ -14,13 +14,13 @@ module Pod
|
|
|
14
14
|
|
|
15
15
|
xcframeworks = target.xcframeworks.values.flatten
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
# XCFramework 的输出目录由 xcframework.target_name 决定,不能只根据
|
|
18
|
+
# have_same_root 判断是否冲突:首个同名 target 或其他 root pod 也可能复制到
|
|
19
|
+
# 同一个 destination。所有 Copy XCFramework 脚本都加 destination 级别的锁;
|
|
20
|
+
# 不同 destination 的复制仍可并行。
|
|
21
|
+
unless xcframeworks.empty?
|
|
21
22
|
script_content = File.read(target.copy_xcframeworks_script_path)
|
|
22
|
-
|
|
23
|
-
File.write(target.copy_xcframeworks_script_path, new_script_content)
|
|
23
|
+
File.write(target.copy_xcframeworks_script_path, kz_lock_xcframework_rsync(script_content))
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
if use_input_output_paths? && !xcframeworks.empty?
|
|
@@ -64,6 +64,30 @@ module Pod
|
|
|
64
64
|
native_target, script_path, input_paths_by_config, output_paths_by_config)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
# 保留 CocoaPods 原始 rsync 命令,仅在执行前插入 destination 级别的文件锁。
|
|
69
|
+
# 不同 destination 可并行复制;同一 destination 的多个脚本会串行执行。
|
|
70
|
+
def kz_lock_xcframework_rsync(script_content)
|
|
71
|
+
lock_marker = '# COCOAPODS_KZ_XCFRAMEWORK_RSYNC_LOCK'
|
|
72
|
+
return script_content if script_content.include?(lock_marker)
|
|
73
|
+
|
|
74
|
+
rsync_pattern = /^([ \t]*)(rsync\s+--delete\b[^\r\n]*)$/
|
|
75
|
+
match = rsync_pattern.match(script_content)
|
|
76
|
+
unless match
|
|
77
|
+
raise 'Unable to locate the XCFramework rsync command for the copy lock patch.'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
indent = match[1]
|
|
81
|
+
rsync_command = match[2]
|
|
82
|
+
locked_command = [
|
|
83
|
+
"#{indent}#{lock_marker}",
|
|
84
|
+
"#{indent}# Serialize only copies that share the same XCFramework destination.",
|
|
85
|
+
"#{indent}local lock_file=\"${PODS_XCFRAMEWORKS_BUILD_DIR}/.cocoapods-kz-xcframeworks-$(printf '%s' \"${destination}\" | shasum -a 256 | awk '{print $1}').lock\"",
|
|
86
|
+
"#{indent}/usr/bin/lockf -k -w \"${lock_file}\" #{rsync_command}",
|
|
87
|
+
].join("\n")
|
|
88
|
+
|
|
89
|
+
script_content.sub(rsync_pattern, locked_command)
|
|
90
|
+
end
|
|
67
91
|
end
|
|
68
92
|
end
|
|
69
93
|
end
|