cocoapods-jxedt 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/lib/cocoapods-jxedt/binary/Intergation.rb +303 -0
- data/lib/cocoapods-jxedt/binary/config.rb +139 -0
- data/lib/cocoapods-jxedt/binary/helper/names.rb +78 -0
- data/lib/cocoapods-jxedt/binary/helper/podfile_options.rb +116 -0
- data/lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb +18 -0
- data/lib/cocoapods-jxedt/binary/helper/target_definition.rb +34 -0
- data/lib/cocoapods-jxedt/binary/hooks/CocoapodsJxedtHook.rb +25 -0
- data/lib/cocoapods-jxedt/binary/hooks/post_install.rb +35 -0
- data/lib/cocoapods-jxedt/binary/hooks/pre_install.rb +61 -0
- data/lib/cocoapods-jxedt/binary/main.rb +3 -0
- data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_command.rb +265 -0
- data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_raw.rb +68 -0
- data/lib/cocoapods-jxedt/binary/podfile_dsl.rb +26 -0
- data/lib/cocoapods-jxedt/binary/prebuild.rb +210 -0
- data/lib/cocoapods-jxedt/binary/targets/pod_target.rb +103 -0
- data/lib/cocoapods-jxedt/command/header/header.rb +157 -0
- data/lib/cocoapods-jxedt/command/jxedt.rb +40 -0
- data/lib/cocoapods-jxedt/command/options/options.rb +33 -0
- data/lib/cocoapods-jxedt/command.rb +1 -0
- data/lib/cocoapods-jxedt/gem_version.rb +3 -0
- data/lib/cocoapods-jxedt/tool.rb +12 -0
- data/lib/cocoapods-jxedt.rb +1 -0
- data/lib/cocoapods_plugin.rb +3 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c38c0828fdaf7acdd4f9aea09b68194af1d2e9e6117ca1c6156618e7b1bc8cd6
|
4
|
+
data.tar.gz: 4d19e409eefaa4a2eac16c7c72e6874a2a626c49bf1a20cd216a7d5ef842395c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6587bbe4ed16a1a0f354b8bb07008399c2031ccf28544e4c75b8180005c5653670fa8d86c8868275fd389b700f8e6d8d18c4fea9c3061742f44e751f47fdcce3
|
7
|
+
data.tar.gz: 3968415ded4a515d99569a2f060ae732055233c4c8703048346eaf52a2e0665dd659af92889b11cf959ce78f69d8b92719f68247fc4231133a04501d0ea7b933
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2023 guojiashuang <guojiashuang@58.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# cocoapods-jxedt
|
2
|
+
|
3
|
+
cocoapods-jxedt提供组件二进制链接的功能,你不需要更改podspec源文件,只需要在Podfile文件中配置好use_binary的标识,执行`pod install`的时候就会帮你完成二进制链接的工作。
|
4
|
+
使用cocoapods-jxedt理论上来说可以使你的pods工程编译时间减少到秒级,取决于你怎样配置二进制文件。
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
### 使用已发布的插件
|
8
|
+
|
9
|
+
$ gem install cocoapods-jxedt
|
10
|
+
|
11
|
+
### 本地编译插件安装
|
12
|
+
|
13
|
+
$ rake build
|
14
|
+
|
15
|
+
$ sudo rake install
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
打开Podfile文件,在合适的位置添加
|
20
|
+
|
21
|
+
```
|
22
|
+
plugin 'cocoapods-jxedt'
|
23
|
+
all_binary!
|
24
|
+
binary_dir('../_Prebuild')
|
25
|
+
```
|
26
|
+
或
|
27
|
+
```
|
28
|
+
plugin 'cocoapods-jxedt'
|
29
|
+
options = {
|
30
|
+
'all_binary': true, # 全部开启bianry,默认false
|
31
|
+
'binary_dir': '../_Prebuild', # binary编译的最终路径,默认为'../_Prebuild'
|
32
|
+
'binary_switch': true, # 二进制开关,设置为关则不hook pre_install过程,默认开
|
33
|
+
'prebuild_job': true, #开启预编译任务,默认开启
|
34
|
+
'excluded_pods': ['WIMPhotoBrowser', 'JXFavoriteLib'], # 排除binary的组件
|
35
|
+
'framework_header_search_enabled': true, # 是否开启binary的header search path功能,默认不开启
|
36
|
+
'configurations': ['Release', 'Debug'], # 支持的configurations,默认只编译Release
|
37
|
+
'xcframework': false, # 编译结果是否为xcframework,默认false
|
38
|
+
'dev_pods_enabled': false, # 开发中的pod是否支持binary,默认false
|
39
|
+
'simulator_build_enabled': false, # 是否编译模拟器,默认不支持
|
40
|
+
'clean_build': false, # build的时候是否clean,默认不clean
|
41
|
+
'build_args': { # 编译的配置
|
42
|
+
'default':["ONLY_ACTIVE_ARCH=NO", "BUILD_LIBRARY_FOR_DISTRIBUTION=YES"],
|
43
|
+
'device':["ARCHS='arm64'"], # "ARCHS='arm64 armv7 armv7s'"
|
44
|
+
'simulator':["ARCHS='x86_64'"] # "ARCHS='arm64 x86_64 i386'
|
45
|
+
}
|
46
|
+
}
|
47
|
+
cocoapods_jxedt_config(options)
|
48
|
+
```
|
49
|
+
|
50
|
+
如果只需要某个组件实现二进制的链接,你可以
|
51
|
+
```
|
52
|
+
pod 'PodA', :binary => true # 明确的指定某个pod组件支持binary
|
53
|
+
|
54
|
+
pod 'PodB', :framework_header_search => false # 明确指出某个pod不支持配置framework的`HEADER_SEARCH_PATH`
|
55
|
+
```
|
56
|
+
|
57
|
+
## 原理
|
58
|
+
...
|
59
|
+
待完善
|
60
|
+
|
61
|
+
## TODO
|
62
|
+
- [x] 支持从已有framework文件完成源码和二进制切换
|
63
|
+
- [x] 解决依赖的组件被打成framework,头文件依赖的问题
|
64
|
+
- [x] 解决源码和二进制切换的问题,现有binary插件均不支持
|
65
|
+
- [x] 支持不同环境(Debug、Release)编译时链接不同环境的framework
|
66
|
+
- [x] 记录组件的hash(git提交)值,用户校验二进制的源码组件的版本。这个值在podfile.lock文件中
|
67
|
+
- [x] 两次install去校验checksum值,确保源码和二进制是对应版本,checksum值校验通过才支持binary
|
68
|
+
- [x] 添加是否从header_search_path中查找framework的header(为了兼容"" <> 这种方式引用头文件的问题)
|
69
|
+
- [x] 插件支持编译为framework
|
70
|
+
- [x] prebuild流程添加到pod的install流程中,形成闭环,使用二进制的时候,发现没有对应的二进制文件,那么可以预编译
|
71
|
+
- [x] 添加`pod jxedt options`命令,输出配置文件详细介绍
|
72
|
+
|
73
|
+
- [ ] 添加`pod jxedt binary`命令,支持命令行打包framework
|
74
|
+
- [ ] 支持配置git地址做编译结果缓存
|
75
|
+
- [ ] 支持缓存的fetch和push
|
76
|
+
- [ ] 支持多线程下载
|
77
|
+
|
78
|
+
## 已知问题
|
79
|
+
1. 不支持framework中有xib文件,如果pod仓库中有xib文件且不在bundle中,需要设置:binary=>false
|
80
|
+
2. 不支持多个target依赖同一个pod时,target的platform版本不一致的情况
|
81
|
+
3. 不支持同一个pod,多个target且使用了不同的subspec
|
82
|
+
4. framework_header_search_enabled不支持使用`#if __has_include(<FrameworkA/Header.h>)`方式设置的组件,如果有会出现重复定义的错误。如YYImage、YYWebImage等
|
83
|
+
|
84
|
+
## 感谢
|
85
|
+
|
86
|
+
感谢[cocoapods-binary](https://github.com/leavez/cocoapods-binary)和[cocoapods-binary-cache](https://github.com/grab/cocoapods-binary-cache)的作者,因为看了他们的源码之后受到了启发。
|
@@ -0,0 +1,303 @@
|
|
1
|
+
require_relative 'helper/podfile_options'
|
2
|
+
require_relative 'helper/names'
|
3
|
+
|
4
|
+
|
5
|
+
# NOTE:
|
6
|
+
# This file will only be loaded on normal pod install step
|
7
|
+
# so there's no need to check is_prebuild_stage
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
# Provide a special "download" process for prebuilded pods.
|
12
|
+
#
|
13
|
+
# As the frameworks is already exsited in local folder. We
|
14
|
+
# just create a symlink to the original target folder.
|
15
|
+
#
|
16
|
+
module Pod
|
17
|
+
class Installer
|
18
|
+
class PodSourceInstaller
|
19
|
+
|
20
|
+
def install_for_prebuild!(standard_sanbox)
|
21
|
+
check_sandbox = Jxedt::Sandbox.from_sandbox(standard_sanbox)
|
22
|
+
target_names = check_sandbox.existed_target_names(self.name)
|
23
|
+
|
24
|
+
def walk(path, &action)
|
25
|
+
return unless path.exist?
|
26
|
+
path.children.each do |child|
|
27
|
+
result = action.call(child, &action)
|
28
|
+
if child.directory?
|
29
|
+
walk(child, &action) if result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def make_link(source, target)
|
34
|
+
source = Pathname.new(source)
|
35
|
+
target = Pathname.new(target)
|
36
|
+
target.parent.mkpath unless target.parent.exist?
|
37
|
+
relative_source = source.relative_path_from(target.parent)
|
38
|
+
FileUtils.ln_sf(relative_source, target)
|
39
|
+
end
|
40
|
+
def mirror_with_symlink(source, basefolder, target_folder)
|
41
|
+
relative_path = source.relative_path_from(basefolder)
|
42
|
+
match_configuration = Jxedt.config.support_configurations.join('|')
|
43
|
+
if relative_path.to_s =~ /^(#{match_configuration})\/.*/
|
44
|
+
new_relative_path = relative_path.to_s.gsub!(/^(#{match_configuration})/) { |match| "#{Jxedt.config.xcconfig_configuration_alias}-#{match}" }
|
45
|
+
target = Pathname.new("#{target_folder}/#{new_relative_path}")
|
46
|
+
make_link(source, target)
|
47
|
+
else
|
48
|
+
target = Pathname.new("#{target_folder}/#{relative_path}")
|
49
|
+
make_link(source, target)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
target_names.each do |name|
|
54
|
+
|
55
|
+
# symbol link copy all substructure
|
56
|
+
real_file_folder = check_sandbox.framework_folder_path_for_target_name(name)
|
57
|
+
|
58
|
+
# If have only one platform, just place int the root folder of this pod.
|
59
|
+
# If have multiple paths, we use a sperated folder to store different
|
60
|
+
# platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
|
61
|
+
|
62
|
+
target_folder = standard_sanbox.pod_dir(self.name) + "_Prebuild"
|
63
|
+
target_folder.rmtree if target_folder.exist?
|
64
|
+
target_folder.mkpath
|
65
|
+
|
66
|
+
|
67
|
+
walk(real_file_folder) do |child|
|
68
|
+
source = child
|
69
|
+
# only make symlink to file and `.framework` folder
|
70
|
+
if child.directory? and [".framework", ".xcframework", ".bundle", ".dSYM"].include? child.extname
|
71
|
+
mirror_with_symlink(source, real_file_folder, target_folder)
|
72
|
+
next false # return false means don't go deeper
|
73
|
+
elsif child.file?
|
74
|
+
mirror_with_symlink(source, real_file_folder, target_folder) if child.extname != '.checksum'
|
75
|
+
next true
|
76
|
+
else
|
77
|
+
next true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end # of for each
|
81
|
+
|
82
|
+
end # of method
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# Let cocoapods use the prebuild framework files in install process.
|
90
|
+
#
|
91
|
+
# the code only effect the second pod install process.
|
92
|
+
#
|
93
|
+
module Pod
|
94
|
+
class Installer
|
95
|
+
# Modify specification to use only the prebuild framework after analyzing
|
96
|
+
old_method2 = instance_method(:resolve_dependencies)
|
97
|
+
define_method(:resolve_dependencies) do
|
98
|
+
# call original
|
99
|
+
old_method2.bind(self).()
|
100
|
+
# ...
|
101
|
+
# ...
|
102
|
+
# ...
|
103
|
+
# after finishing the very complex orginal function
|
104
|
+
|
105
|
+
# check the pods
|
106
|
+
# Although we have did it in prebuild stage, it's not sufficient.
|
107
|
+
# Same pod may appear in another target in form of source code.
|
108
|
+
# Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
|
109
|
+
# self.validate_every_pod_only_have_one_form
|
110
|
+
|
111
|
+
# prepare
|
112
|
+
cache = []
|
113
|
+
|
114
|
+
def add_vendered_framework(spec, platform, added_framework_file_path)
|
115
|
+
if spec.attributes_hash[platform] == nil
|
116
|
+
spec.attributes_hash[platform] = {}
|
117
|
+
end
|
118
|
+
vendored_frameworks = spec.attributes_hash[platform]["vendored_frameworks"] || []
|
119
|
+
vendored_frameworks = [vendored_frameworks] if vendored_frameworks.kind_of?(String)
|
120
|
+
vendored_frameworks += [added_framework_file_path] unless added_framework_file_path.nil?
|
121
|
+
spec.attributes_hash[platform]["vendored_frameworks"] = vendored_frameworks
|
122
|
+
end
|
123
|
+
def empty_source_files(spec)
|
124
|
+
spec.attributes_hash["source_files"] = []
|
125
|
+
spec.attributes_hash["public_header_files"] = []
|
126
|
+
spec.attributes_hash["private_header_files"] = []
|
127
|
+
["ios", "watchos", "tvos", "osx"].each do |plat|
|
128
|
+
if spec.attributes_hash[plat] != nil
|
129
|
+
spec.attributes_hash[plat]["source_files"] = []
|
130
|
+
spec.attributes_hash[plat]["public_header_files"] = []
|
131
|
+
spec.attributes_hash[plat]["private_header_files"] = []
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
check_sandbox = Jxedt::Sandbox.from_sandbox(self.sandbox)
|
137
|
+
|
138
|
+
specs = self.analysis_result.specifications
|
139
|
+
prebuilt_specs = (specs.select do |spec|
|
140
|
+
# rmtree
|
141
|
+
target_prebuild_files = self.sandbox.root + spec.root.name + "_Prebuild"
|
142
|
+
target_prebuild_files.rmtree if target_prebuild_files.exist?
|
143
|
+
|
144
|
+
self.prebuild_pod_names.include? spec.root.name
|
145
|
+
end)
|
146
|
+
|
147
|
+
checked_specs = {}
|
148
|
+
prebuilt_specs.each do |spec|
|
149
|
+
checked_specs[spec.root.name] = [] if checked_specs[spec.root.name].nil?
|
150
|
+
checked_specs[spec.root.name] << spec
|
151
|
+
|
152
|
+
# Use the prebuild framworks as vendered frameworks
|
153
|
+
# get_corresponding_targets
|
154
|
+
targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
|
155
|
+
targets.each do |target|
|
156
|
+
# the framework_file_path rule is decided when `install_for_prebuild`,
|
157
|
+
# as to compitable with older version and be less wordy.
|
158
|
+
check_sandbox.prebuild_vendored_frameworks(spec.root.name).each do |frame_file_path|
|
159
|
+
framework_file_path = "_Prebuild/" + frame_file_path
|
160
|
+
framework_file_path = nil if checked_specs[spec.root.name].size > 1 # spec.root.name相同的只添加一次framework文件
|
161
|
+
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
# Clean the source files
|
165
|
+
# we just add the prebuilt framework to specific platform and set no source files
|
166
|
+
# for all platform, so it doesn't support the sence that 'a pod perbuild for one
|
167
|
+
# platform and not for another platform.'
|
168
|
+
empty_source_files(spec)
|
169
|
+
|
170
|
+
# to remove the resurce bundle target.
|
171
|
+
# When specify the "resource_bundles" in podspec, xcode will generate a bundle
|
172
|
+
# target after pod install. But the bundle have already built when the prebuit
|
173
|
+
# phase and saved in the framework folder. We will treat it as a normal resource
|
174
|
+
# file.
|
175
|
+
# https://github.com/leavez/cocoapods-binary/issues/29
|
176
|
+
if spec.attributes_hash["resource_bundles"]
|
177
|
+
# bundle_names = spec.attributes_hash["resource_bundles"].keys
|
178
|
+
spec.attributes_hash["resource_bundles"] = nil
|
179
|
+
spec.attributes_hash["resources"] ||= []
|
180
|
+
resources = spec.attributes_hash["resources"] || []
|
181
|
+
resources = [resources] if resources.kind_of?(String)
|
182
|
+
spec.attributes_hash["resources"] = resources
|
183
|
+
# spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
|
184
|
+
prebuild_bundles = check_sandbox.prebuild_bundles(spec.root.name).each.map { |bundle_path| "_Prebuild/" + bundle_path }
|
185
|
+
prebuild_bundles = [] if checked_specs[spec.root.name].size > 1 # spec.root.name相同的只添加一次bundle文件
|
186
|
+
spec.attributes_hash["resources"] += prebuild_bundles
|
187
|
+
end
|
188
|
+
|
189
|
+
# to avoid the warning of missing license
|
190
|
+
spec.attributes_hash["license"] = {}
|
191
|
+
spec.attributes_hash["preserve_paths"] = "**/*"
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
# Override the download step to skip download and prepare file in target folder
|
199
|
+
old_method = instance_method(:install_source_of_pod)
|
200
|
+
define_method(:install_source_of_pod) do |pod_name|
|
201
|
+
|
202
|
+
# copy from original
|
203
|
+
pod_installer = create_pod_installer(pod_name)
|
204
|
+
# \copy from original
|
205
|
+
|
206
|
+
# copy from original
|
207
|
+
pod_installer.install!
|
208
|
+
# \copy from original
|
209
|
+
|
210
|
+
if self.prebuild_pod_names.include? pod_name
|
211
|
+
pod_installer.install_for_prebuild!(self.sandbox)
|
212
|
+
end
|
213
|
+
|
214
|
+
# copy from original
|
215
|
+
@installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
|
216
|
+
# \copy from original
|
217
|
+
end
|
218
|
+
|
219
|
+
alias_method :old_create_pod_installer, :create_pod_installer
|
220
|
+
def create_pod_installer(pod_name)
|
221
|
+
pod_installer = old_create_pod_installer(pod_name)
|
222
|
+
|
223
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
224
|
+
unless pods_to_install.include?(pod_name)
|
225
|
+
pod_installer.install_for_prebuild!(self.sandbox) if self.prebuild_pod_names.include? pod_name
|
226
|
+
end
|
227
|
+
pod_installer
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# A fix in embeded frameworks script.
|
233
|
+
#
|
234
|
+
# The framework file in pod target folder is a symblink. The EmbedFrameworksScript use `readlink`
|
235
|
+
# to read the read path. As the symlink is a relative symlink, readlink cannot handle it well. So
|
236
|
+
# we override the `readlink` to a fixed version.
|
237
|
+
#
|
238
|
+
module Pod
|
239
|
+
module Generator
|
240
|
+
class EmbedFrameworksScript
|
241
|
+
|
242
|
+
old_method = instance_method(:script)
|
243
|
+
define_method(:script) do
|
244
|
+
|
245
|
+
script = old_method.bind(self).()
|
246
|
+
patch = <<-SH.strip_heredoc
|
247
|
+
#!/bin/sh
|
248
|
+
|
249
|
+
# ---- this is added by cocoapods-binary ---
|
250
|
+
# Readlink cannot handle relative symlink well, so we override it to a new one
|
251
|
+
# If the path isn't an absolute path, we add a realtive prefix.
|
252
|
+
old_read_link=`which readlink`
|
253
|
+
readlink () {
|
254
|
+
path=`$old_read_link "$1"`;
|
255
|
+
if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
|
256
|
+
echo $path;
|
257
|
+
else
|
258
|
+
echo "`dirname $1`/$path";
|
259
|
+
fi
|
260
|
+
}
|
261
|
+
# ---
|
262
|
+
SH
|
263
|
+
|
264
|
+
# patch the rsync for copy dSYM symlink
|
265
|
+
script = script.gsub "rsync --delete", "rsync --copy-links --delete"
|
266
|
+
|
267
|
+
patch + script
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
module Pod
|
274
|
+
module Generator
|
275
|
+
class CopyXCFrameworksScript
|
276
|
+
|
277
|
+
alias_method :old_install_xcframework_args, :install_xcframework_args
|
278
|
+
def install_xcframework_args(xcframework, slices)
|
279
|
+
args = old_install_xcframework_args(xcframework, slices)
|
280
|
+
xcconfig_configuration_alias = Jxedt.config.xcconfig_configuration_alias
|
281
|
+
match_configuration = Jxedt.config.support_configurations.join('|')
|
282
|
+
args.gsub!(/#{xcconfig_configuration_alias}-(#{match_configuration})/, "#{xcconfig_configuration_alias}-${CONFIGURATION}")
|
283
|
+
args
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
module Pod
|
290
|
+
module Generator
|
291
|
+
class CopyResourcesScript
|
292
|
+
|
293
|
+
alias_method :old_script, :script
|
294
|
+
def script
|
295
|
+
script = old_script
|
296
|
+
xcconfig_configuration_alias = Jxedt.config.xcconfig_configuration_alias
|
297
|
+
match_configuration = Jxedt.config.support_configurations.join('|')
|
298
|
+
script.gsub!(/#{xcconfig_configuration_alias}-(#{match_configuration})/, "#{xcconfig_configuration_alias}-${CONFIGURATION}")
|
299
|
+
script
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module Jxedt
|
2
|
+
def self.config
|
3
|
+
Jxedt::Config.instance
|
4
|
+
end
|
5
|
+
|
6
|
+
class Config
|
7
|
+
attr_accessor :dsl_config
|
8
|
+
|
9
|
+
APPLICABLE_DSL_CONFIG = {
|
10
|
+
:all_binary => '全部组件允许使用二进制。默认为false',
|
11
|
+
:binary_dir => "framework的保存路径,相对于'Pods/Pods.xcodeproj'的相对路径。默认为'../_Prebuild'",
|
12
|
+
:binary_switch => "二进制开关,关闭则不hook pre_install过程。默认为true",
|
13
|
+
:prebuild_job => "开启编译任务,设置为false则不触发编译。默认为true",
|
14
|
+
:dev_pods_enabled => "Development Pods是否支持binary。默认为false",
|
15
|
+
:excluded_pods => "排除binary的pods",
|
16
|
+
:xcconfig_configuration_alias => "xcconfig文件中configuration的别名,configurations设置为多个值的时候会用到,用于搜索替换。一般不需要设置,有默认值为'cocoapods-jxedt-binary'",
|
17
|
+
:framework_header_search_enabled => "设置开启binary的framework是否配置framework的HEADER_SEARCH_PATH,兼容头文件引用的问题。默认为false",
|
18
|
+
:silent_build => "静默编译。默认true",
|
19
|
+
:configurations => "支持的configuration配置,可以写字符串'Debug'或'Release',也可以写多个'['Debug', 'Release']'。默认为'Release'",
|
20
|
+
:xcframework => "编译结果是否为xcframework。默认false",
|
21
|
+
:clean_build => "编译的时候是否clean。默认true",
|
22
|
+
:bitcode_enabled => "开启bitcode。默认false",
|
23
|
+
:device_build_enabled => "编译真机。默认true",
|
24
|
+
:simulator_build_enabled => "编译模拟器。默认false",
|
25
|
+
:disable_dsym => "禁止编译dsym产物。默认true",
|
26
|
+
:build_log_path => "编译的log输出路径",
|
27
|
+
:build_args => "编译的配置。了解xcodebuild命令的可以配置编译参数,例如配置 ARCHS='arm64 armv7'",
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
def initialize()
|
31
|
+
@dsl_config = {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.instance
|
35
|
+
@instance ||= new()
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_dsl_config
|
39
|
+
inapplicable_options = @dsl_config.keys - APPLICABLE_DSL_CONFIG.keys
|
40
|
+
return if inapplicable_options.empty?
|
41
|
+
|
42
|
+
message = <<~HEREDOC
|
43
|
+
[WARNING] The following options (in `config_cocoapods_util`) are not correct: #{inapplicable_options}.
|
44
|
+
Available options: #{APPLICABLE_DSL_CONFIG}.
|
45
|
+
HEREDOC
|
46
|
+
|
47
|
+
Pod::UI.puts message.yellow
|
48
|
+
end
|
49
|
+
|
50
|
+
def all_binary_enabled?
|
51
|
+
@dsl_config[:all_binary] || false
|
52
|
+
end
|
53
|
+
|
54
|
+
def binary_switch?
|
55
|
+
@dsl_config[:binary_switch] || @dsl_config[:binary_switch].nil?
|
56
|
+
end
|
57
|
+
|
58
|
+
def prebuild_job?
|
59
|
+
@dsl_config[:prebuild_job] || @dsl_config[:prebuild_job].nil?
|
60
|
+
end
|
61
|
+
|
62
|
+
def dev_pods_enabled?
|
63
|
+
@dsl_config[:dev_pods_enabled] || false
|
64
|
+
end
|
65
|
+
|
66
|
+
def excluded_pods
|
67
|
+
@dsl_config[:excluded_pods] || []
|
68
|
+
end
|
69
|
+
|
70
|
+
def framework_header_search_enabled?
|
71
|
+
@dsl_config[:framework_header_search_enabled] || false
|
72
|
+
end
|
73
|
+
|
74
|
+
def binary_dir
|
75
|
+
@dsl_config[:binary_dir] || '../_Prebuild'
|
76
|
+
end
|
77
|
+
|
78
|
+
def xcconfig_configuration_alias
|
79
|
+
@val ||= begin
|
80
|
+
val = @dsl_config[:xcconfig_configuration_alias]
|
81
|
+
val = "cocoapods-jxedt-binary" if val.nil? || val.empty?
|
82
|
+
val
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def silent_build?
|
87
|
+
@dsl_config[:silent_build] || @dsl_config[:silent_build].nil?
|
88
|
+
end
|
89
|
+
|
90
|
+
def xcframework?
|
91
|
+
@dsl_config[:xcframework] || false
|
92
|
+
end
|
93
|
+
|
94
|
+
def clean_build?
|
95
|
+
@dsl_config[:clean_build] || @dsl_config[:clean_build].nil?
|
96
|
+
end
|
97
|
+
|
98
|
+
def bitcode_enabled?
|
99
|
+
@dsl_config[:bitcode_enabled] || false
|
100
|
+
end
|
101
|
+
|
102
|
+
def disable_dsym?
|
103
|
+
@dsl_config[:disable_dsym] || @dsl_config[:disable_dsym].nil?
|
104
|
+
end
|
105
|
+
|
106
|
+
def device_build_enabled?
|
107
|
+
@dsl_config[:device_build_enabled] || @dsl_config[:device_build_enabled].nil?
|
108
|
+
end
|
109
|
+
|
110
|
+
def simulator_build_enabled?
|
111
|
+
@dsl_config[:simulator_build_enabled] || false
|
112
|
+
end
|
113
|
+
|
114
|
+
def build_log_path
|
115
|
+
@dsl_config[:build_log_path]
|
116
|
+
end
|
117
|
+
|
118
|
+
def build_args
|
119
|
+
@args ||= begin
|
120
|
+
args = @dsl_config[:build_args] || {}
|
121
|
+
args[:default] ||= ["ONLY_ACTIVE_ARCH=NO", "BUILD_LIBRARY_FOR_DISTRIBUTION=YES"]
|
122
|
+
args[:device] ||= [] # ["ARCHS='arm64 armv7 armv7s'", "ONLY_ACTIVE_ARCH=NO"]
|
123
|
+
args[:simulator] ||= [] # ["ARCHS='arm64 x86_64 i386'", "ONLY_ACTIVE_ARCH=NO"]
|
124
|
+
args
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def support_configurations
|
129
|
+
@configurations ||= begin
|
130
|
+
configurations = []
|
131
|
+
user_config = @dsl_config[:configurations]
|
132
|
+
configurations << user_config if user_config.is_a?(String)
|
133
|
+
configurations += user_config if user_config.is_a?(Array)
|
134
|
+
configurations = ["Release"] if configurations.empty?
|
135
|
+
configurations
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# ABOUT NAMES
|
2
|
+
#
|
3
|
+
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
|
4
|
+
# - root_spec.name (spec.root_name, targe.pod_name):
|
5
|
+
# aka "pod_name"
|
6
|
+
# the name we use in podfile. the concept.
|
7
|
+
#
|
8
|
+
# - target.name:
|
9
|
+
# aka "target_name"
|
10
|
+
# the name of the final target in xcode project. the final real thing.
|
11
|
+
#
|
12
|
+
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
|
13
|
+
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
|
14
|
+
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Tool to transform Pod_name to target efficiently
|
18
|
+
module Pod
|
19
|
+
def self.fast_get_targets_for_pod_name(pod_name, targets, cache)
|
20
|
+
pod_name_to_targets_hash = nil
|
21
|
+
if cache.empty?
|
22
|
+
pod_name_to_targets_hash = targets.reduce({}) do |sum, target|
|
23
|
+
array = sum[target.pod_name] || []
|
24
|
+
array << target
|
25
|
+
sum[target.pod_name] = array
|
26
|
+
sum
|
27
|
+
end
|
28
|
+
cache << pod_name_to_targets_hash
|
29
|
+
else
|
30
|
+
pod_name_to_targets_hash = cache.first
|
31
|
+
end
|
32
|
+
|
33
|
+
pod_name_to_targets_hash[pod_name] || []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# Target:
|
43
|
+
|
44
|
+
# def pod_name
|
45
|
+
# root_spec.name
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def name
|
49
|
+
# pod_name + #{scope_suffix}
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def product_module_name
|
53
|
+
# root_spec.module_name
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def framework_name
|
57
|
+
# "#{product_module_name}.framework"
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def product_name
|
61
|
+
# if requires_frameworks?
|
62
|
+
# framework_name
|
63
|
+
# else
|
64
|
+
# static_library_name
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
|
68
|
+
# def product_basename
|
69
|
+
# if requires_frameworks?
|
70
|
+
# product_module_name
|
71
|
+
# else
|
72
|
+
# label
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
|
76
|
+
# def framework_name
|
77
|
+
# "#{product_module_name}.framework"
|
78
|
+
# end
|