cocoapods-bb-bin 0.1.0
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 +7 -0
- data/LICENSE.txt +19 -0
- data/README.md +68 -0
- data/lib/cocoapods-bb-bin/command/bin/archive.rb +234 -0
- data/lib/cocoapods-bb-bin/command/bin/auto.rb +226 -0
- data/lib/cocoapods-bb-bin/command/bin/code.rb +295 -0
- data/lib/cocoapods-bb-bin/command/bin/dup.rb +78 -0
- data/lib/cocoapods-bb-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-bb-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-bb-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-bb-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-bb-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-bb-bin/command/bin.rb +59 -0
- data/lib/cocoapods-bb-bin/command.rb +2 -0
- data/lib/cocoapods-bb-bin/config/config.rb +136 -0
- data/lib/cocoapods-bb-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/config/config_builder.rb +234 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key.rb +102 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/gem_version.rb +10 -0
- data/lib/cocoapods-bb-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-bb-bin/helpers/build_helper.rb +217 -0
- data/lib/cocoapods-bb-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-bb-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-bb-bin/helpers/framework_builder.rb +446 -0
- data/lib/cocoapods-bb-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-bb-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-bb-bin/helpers/sources_helper.rb +36 -0
- data/lib/cocoapods-bb-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-bb-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers/spec_source_creator.rb +227 -0
- data/lib/cocoapods-bb-bin/helpers/upload_helper.rb +96 -0
- data/lib/cocoapods-bb-bin/helpers/xcframework_builder.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers.rb +5 -0
- data/lib/cocoapods-bb-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-bb-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-bb-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-bb-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-bb-bin/native/installer.rb +135 -0
- data/lib/cocoapods-bb-bin/native/linter.rb +26 -0
- data/lib/cocoapods-bb-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-bb-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-bb-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-bb-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-bb-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-bb-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-bb-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-bb-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-bb-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-bb-bin/native/source.rb +35 -0
- data/lib/cocoapods-bb-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-bb-bin/native/specification.rb +31 -0
- data/lib/cocoapods-bb-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-bb-bin/native/validator.rb +40 -0
- data/lib/cocoapods-bb-bin/native.rb +23 -0
- data/lib/cocoapods-bb-bin/source_provider_hook.rb +66 -0
- data/lib/cocoapods-bb-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +51 -0
- metadata +200 -0
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class Config
|
6
|
+
class Builder
|
7
|
+
|
8
|
+
include Pod
|
9
|
+
|
10
|
+
def self.instance
|
11
|
+
@instance ||= new
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
load_build_config
|
16
|
+
# clean
|
17
|
+
end
|
18
|
+
|
19
|
+
# 加载配置项
|
20
|
+
def load_build_config
|
21
|
+
@white_pod_list = []
|
22
|
+
@ignore_git_list = []
|
23
|
+
project_root = Pod::Config.instance.project_root
|
24
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
25
|
+
|
26
|
+
if File.exist?(path)
|
27
|
+
config = JSON.parse(File.read(path))
|
28
|
+
@white_pod_list = config['archive-white-pod-list']
|
29
|
+
UI.warn "====== archive-white-pod-list = #{@white_pod_list}" if @white_pod_list
|
30
|
+
@ignore_git_list = config['ignore-git-list']
|
31
|
+
UI.warn "====== ignore_git_list = #{@ignore_git_list}" if @ignore_git_list
|
32
|
+
@ignore_http_list = config['ignore-http-list']
|
33
|
+
|
34
|
+
@xcode_build_name = config['xcode_build_path']
|
35
|
+
@root_dir = config['root_dir'] unless config['root_dir'].nil?
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def clean
|
41
|
+
#清除之前的缓存
|
42
|
+
FileUtils.rm_rf(Dir.glob("#{zip_dir}/*")) if File.exist?(zip_dir)
|
43
|
+
FileUtils.rm_rf(Dir.glob("#{binary_json_dir}/*")) if File.exist?(binary_json_dir)
|
44
|
+
FileUtils.rm_rf(Dir.glob("#{local_psec_dir}/*")) if File.exist?(local_psec_dir)
|
45
|
+
end
|
46
|
+
|
47
|
+
# 制作二进制打包 工程目录
|
48
|
+
def gen_name
|
49
|
+
'bin-archive'
|
50
|
+
end
|
51
|
+
|
52
|
+
# 制作二进制打包 工程目录
|
53
|
+
def gen_dir
|
54
|
+
@gen_dir ||= begin
|
55
|
+
dir = File.join(root_dir,gen_name)
|
56
|
+
Dir.mkdir(dir) unless File.exist?dir
|
57
|
+
Pathname.new(dir)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def xcframework_name(spec)
|
62
|
+
"#{spec.name}.xcframework"
|
63
|
+
end
|
64
|
+
|
65
|
+
def xcframework_name_version(spec)
|
66
|
+
"#{spec.name}.xcframework_#{spec.version}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def xcframework_zip_file(spec)
|
70
|
+
File.join(zip_dir_name, xcframework_name_version(spec))
|
71
|
+
end
|
72
|
+
|
73
|
+
def xcframework_file(spec)
|
74
|
+
File.join(zip_dir_name, xcframework_name(spec))
|
75
|
+
end
|
76
|
+
|
77
|
+
def framework_name(spec)
|
78
|
+
"#{spec.name}.framework"
|
79
|
+
end
|
80
|
+
|
81
|
+
def framework_name_version(spec)
|
82
|
+
"#{spec.name}.framework_#{spec.version}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def framework_zip_file(spec)
|
86
|
+
File.join(zip_dir_name, framework_name_version(spec))
|
87
|
+
end
|
88
|
+
|
89
|
+
def framework_file(spec)
|
90
|
+
File.join(zip_dir_name, framework_name(spec))
|
91
|
+
end
|
92
|
+
|
93
|
+
def library_name(spec)
|
94
|
+
library_name_version(spec.name, spec.version)
|
95
|
+
end
|
96
|
+
|
97
|
+
def library_name_version(name,version)
|
98
|
+
"bin_#{name}_#{version}"
|
99
|
+
end
|
100
|
+
def library_file(spec)
|
101
|
+
File.join(zip_dir_name, library_name(spec))
|
102
|
+
end
|
103
|
+
|
104
|
+
def zip_dir_name
|
105
|
+
"bin-zip"
|
106
|
+
end
|
107
|
+
|
108
|
+
def zip_dir
|
109
|
+
@zip_dir ||= begin
|
110
|
+
dir = File.join(root_dir,zip_dir_name)
|
111
|
+
Dir.mkdir(dir) unless File.exist?dir
|
112
|
+
Pathname.new(dir)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
#本地
|
117
|
+
def local_spec_dir_name
|
118
|
+
"bin-spec"
|
119
|
+
end
|
120
|
+
|
121
|
+
def local_psec_dir
|
122
|
+
@local_psec_dir ||= begin
|
123
|
+
dir = File.join(root_dir,local_spec_dir_name)
|
124
|
+
Dir.mkdir(dir) unless File.exist?dir
|
125
|
+
Pathname.new(dir)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def binary_json_dir_name
|
130
|
+
"bin-json"
|
131
|
+
end
|
132
|
+
|
133
|
+
def binary_json_dir
|
134
|
+
@binary_json_dir ||= begin
|
135
|
+
dir = File.join(root_dir,binary_json_dir_name)
|
136
|
+
Dir.mkdir(dir) unless File.exist?dir
|
137
|
+
Pathname.new(dir)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
#编译target名,如 seeyou
|
144
|
+
def target_name
|
145
|
+
@target_name ||= begin
|
146
|
+
target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s
|
147
|
+
target_name_str[5,target_name_str.length]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
#编译缓存文件目录,如Xcodebuild的编译缓存目录
|
152
|
+
# 如果有配置, 配置完整路径,会使用
|
153
|
+
def xcode_build_name
|
154
|
+
@xcode_build_name ||= begin
|
155
|
+
project_root = Pod::Config.instance.project_root
|
156
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
157
|
+
|
158
|
+
if File.exist?(path)
|
159
|
+
config = JSON.parse(File.read(path))
|
160
|
+
@xcode_build_name = config['xcode_build_path']
|
161
|
+
end
|
162
|
+
#默认值,在美柚上使用默认
|
163
|
+
if @xcode_build_name.nil? || Dir.exist?(@xcode_build_name)
|
164
|
+
@xcode_build_name = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/"
|
165
|
+
end
|
166
|
+
puts @xcode_build_name
|
167
|
+
@xcode_build_name
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
#完整的xcodebuild 输出路径
|
173
|
+
def xcode_build_dir
|
174
|
+
@xcode_build_dir ||= begin
|
175
|
+
temp_xcode_build_name = xcode_build_name
|
176
|
+
if File.exist?(temp_xcode_build_name)
|
177
|
+
Pathname.new(temp_xcode_build_name)
|
178
|
+
else
|
179
|
+
dir = File.join(root_dir,xcode_build_name)
|
180
|
+
Pathname.new(dir)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
#完整的xcodebuild BuildProductsPath输出路径,
|
185
|
+
def xcode_BuildProductsPath_dir
|
186
|
+
@xcode_BuildProductsPath_dir ||= begin
|
187
|
+
temp_xcode_BuildProductsPath_dir = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/BuildProductsPath/"
|
188
|
+
full_path = File.join(root_dir, temp_xcode_BuildProductsPath_dir)
|
189
|
+
|
190
|
+
if (File.exist?(full_path))
|
191
|
+
Dir.chdir(full_path) do
|
192
|
+
iphoneos = Dir.glob('*-iphoneos')
|
193
|
+
if iphoneos.length > 0
|
194
|
+
full_path = File.join(full_path,iphoneos.first)
|
195
|
+
else
|
196
|
+
UI.warn "====== 找不到 *-iphoneos @xcode_BuildProductsPath_dir = #{@xcode_BuildProductsPath_dir}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
Pathname.new(full_path)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
#处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,"#{basename}-build-temp"
|
206
|
+
def root_dir
|
207
|
+
@root_dir ||= begin
|
208
|
+
basename = File.basename(Pod::Config.instance.installation_root)
|
209
|
+
parent_dir = File.dirname(Pod::Config.instance.installation_root)
|
210
|
+
# root_name = File.join(parent_dir,"#{basename}-build-temp")
|
211
|
+
# Dir.mkdir(root_name) unless File.exist?root_name
|
212
|
+
root_name = File.join(parent_dir,"/build/#{basename}") # 统一修改build目录
|
213
|
+
FileUtils.mkdir_p(root_name) unless File.exists?(root_name) # require 'fileutils'
|
214
|
+
Pathname.new(root_name)
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
#制作二进制 白名单
|
220
|
+
def white_pod_list
|
221
|
+
@white_pod_list
|
222
|
+
end
|
223
|
+
#忽略制作二进制组件的 git
|
224
|
+
def ignore_git_list
|
225
|
+
@ignore_git_list
|
226
|
+
end
|
227
|
+
|
228
|
+
def ignore_http_list
|
229
|
+
@ignore_http_list
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-bb-bin/native/podfile'
|
3
|
+
require 'cocoapods-bb-bin/native/podfile_env'
|
4
|
+
require 'cocoapods/generate'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
class Config_Hot_Key
|
8
|
+
|
9
|
+
def config_file
|
10
|
+
config_file_with_hot_key_index(hot_key_index)
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_hash
|
14
|
+
{
|
15
|
+
'hot_key_index' => { description: '快捷键', default: '1', selection: %w[1 2 3...] },
|
16
|
+
'hot_key_dir' => { description: '快捷键执行目录', default: '' },
|
17
|
+
'hot_key_cmd' => { description: '快捷键执行命令', default: 'pod bin update --no-repo-update' }
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_file_with_hot_key_index(hot_key_index)
|
22
|
+
file = config_file_whith_hot_key_index(hot_key_index)
|
23
|
+
raise "\n===== #{hot_key_index} 参数有误,请检查%w[1 2 3...]===" unless (hot_key_index.to_i).is_a?(Integer)
|
24
|
+
File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def hot_key_index
|
28
|
+
@hot_key_index = 1 if @hot_key_index.is_a?(NilClass)
|
29
|
+
@hot_key_index
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_hot_key_index(hot_key_index)
|
33
|
+
@hot_key_index = hot_key_index
|
34
|
+
end
|
35
|
+
|
36
|
+
def config_file_whith_hot_key_index(hot_key_index)
|
37
|
+
"hot_key_#{hot_key_index}.yml"
|
38
|
+
end
|
39
|
+
|
40
|
+
def sync_config(config)
|
41
|
+
File.open(config_file_with_hot_key_index(config['hot_key_index']), 'w+') do |f|
|
42
|
+
f.write(config.to_yaml)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_config
|
47
|
+
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def load_config
|
53
|
+
file = config_file
|
54
|
+
if (!file.nil?) && File.exist?(config_file)
|
55
|
+
YAML.load_file(config_file)
|
56
|
+
else
|
57
|
+
default_config
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def config
|
62
|
+
@config ||= begin
|
63
|
+
@config = OpenStruct.new load_config
|
64
|
+
validate!
|
65
|
+
@config
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def validate!
|
70
|
+
template_hash.each do |k, v|
|
71
|
+
selection = v[:selection]
|
72
|
+
next if !selection || selection.empty?
|
73
|
+
|
74
|
+
config_value = @config.send(k)
|
75
|
+
next unless config_value
|
76
|
+
unless selection.include?(config_value)
|
77
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def respond_to_missing?(method, include_private = false)
|
83
|
+
config.respond_to?(method) || super
|
84
|
+
end
|
85
|
+
|
86
|
+
def method_missing(method, *args, &block)
|
87
|
+
if config.respond_to?(method)
|
88
|
+
config.send(method, *args)
|
89
|
+
elsif template_hash.keys.include?(method.to_s)
|
90
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
91
|
+
else
|
92
|
+
super
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.config_hot_key
|
98
|
+
@config_hot_key ||= Config_Hot_Key.new
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-bb-bin/config/config_hot_key'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class Config_Hot_Key
|
6
|
+
class Asker
|
7
|
+
def show_prompt
|
8
|
+
print ' > '.green
|
9
|
+
end
|
10
|
+
|
11
|
+
def ask_with_answer(question, pre_answer, selection)
|
12
|
+
print "\n#{question}\n"
|
13
|
+
|
14
|
+
print_selection_info = lambda {
|
15
|
+
print "可选值:[ #{selection.join(' / ')} ]\n" if selection
|
16
|
+
}
|
17
|
+
print_selection_info.call
|
18
|
+
print "旧值:#{pre_answer}\n" unless pre_answer.nil?
|
19
|
+
|
20
|
+
answer = ''
|
21
|
+
loop do
|
22
|
+
show_prompt
|
23
|
+
answer = STDIN.gets.chomp.strip
|
24
|
+
|
25
|
+
if answer == '' && !pre_answer.nil?
|
26
|
+
answer = pre_answer
|
27
|
+
print answer.yellow
|
28
|
+
print "\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
next if answer.empty?
|
32
|
+
break if !selection || selection.include?(answer)
|
33
|
+
|
34
|
+
print_selection_info.call
|
35
|
+
end
|
36
|
+
|
37
|
+
answer
|
38
|
+
end
|
39
|
+
|
40
|
+
def wellcome_message
|
41
|
+
print <<~EOF
|
42
|
+
|
43
|
+
开始设置快捷键 pod bin imy.
|
44
|
+
所有的信息都会保存在 #{CBin.config_hot_key.config_file} 文件中.
|
45
|
+
%w[hot_key.yaml]
|
46
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
|
47
|
+
|
48
|
+
#{CBin.config_hot_key.default_config.to_yaml}
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
def done_message
|
53
|
+
print "\n设置完成.\n".green
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
Binary file
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
require 'cocoapods-bb-bin/native/podfile'
|
4
|
+
require 'cocoapods/command/gen'
|
5
|
+
require 'cocoapods/generate'
|
6
|
+
require 'cocoapods-bb-bin/helpers/framework_builder'
|
7
|
+
require 'cocoapods-bb-bin/helpers/xcframework_builder'
|
8
|
+
require 'cocoapods-bb-bin/helpers/library_builder'
|
9
|
+
require 'cocoapods-bb-bin/config/config_builder'
|
10
|
+
|
11
|
+
module CBin
|
12
|
+
class Build
|
13
|
+
class Helper
|
14
|
+
include Pod
|
15
|
+
#class var
|
16
|
+
@@build_defines = ""
|
17
|
+
#Debug下还待完成
|
18
|
+
def initialize(spec,
|
19
|
+
platform,
|
20
|
+
framework_output,
|
21
|
+
xcframework_output,
|
22
|
+
spec_sources,
|
23
|
+
zip,
|
24
|
+
rootSpec,
|
25
|
+
skip_archive = false,
|
26
|
+
build_model="Release")
|
27
|
+
@spec = spec
|
28
|
+
@platform = platform
|
29
|
+
@build_model = build_model
|
30
|
+
@rootSpec = rootSpec
|
31
|
+
@isRootSpec = rootSpec.name == spec.name
|
32
|
+
@skip_archive = skip_archive
|
33
|
+
@framework_output = framework_output
|
34
|
+
@xcframework_output = xcframework_output
|
35
|
+
@spec_sources = spec_sources
|
36
|
+
@zip = zip
|
37
|
+
|
38
|
+
@framework_path
|
39
|
+
|
40
|
+
UI.puts "build initialize...#{spec}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# build framework
|
44
|
+
def build
|
45
|
+
UI.section("Building static framework #{@spec}") do
|
46
|
+
# 生成静态库支持xcframework
|
47
|
+
has_xcframework = is_build_xcframework
|
48
|
+
if has_xcframework == true
|
49
|
+
UI.puts "build static xcframework"
|
50
|
+
build_static_xcframework
|
51
|
+
unless @skip_archive
|
52
|
+
zip_static_xcframework
|
53
|
+
end
|
54
|
+
else
|
55
|
+
UI.puts "build static framework"
|
56
|
+
build_static_framework
|
57
|
+
unless @skip_archive
|
58
|
+
unless CBin::Build::Utils.is_framework(@spec)
|
59
|
+
build_static_library
|
60
|
+
zip_static_library
|
61
|
+
else
|
62
|
+
zip_static_framework
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
# 是否编译xcframework库
|
71
|
+
def is_build_xcframework
|
72
|
+
if @xcframework_output == true
|
73
|
+
return true
|
74
|
+
end
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
# build xcframework
|
78
|
+
def build_static_xcframework
|
79
|
+
source_dir = Dir.pwd
|
80
|
+
UI.puts "xcframework source_dir=#{source_dir}"
|
81
|
+
builder = CBin::XCFramework::XCBuilder.new(@spec, @spec_sources)
|
82
|
+
builder.build
|
83
|
+
end
|
84
|
+
|
85
|
+
# build framework
|
86
|
+
def build_static_framework
|
87
|
+
source_dir = Dir.pwd
|
88
|
+
file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
|
89
|
+
Dir.chdir(workspace_directory) do
|
90
|
+
builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir, @isRootSpec, @build_model )
|
91
|
+
@@build_defines = builder.build if @isRootSpec
|
92
|
+
begin
|
93
|
+
@framework_path = builder.lipo_build(@@build_defines) unless @skip_archive
|
94
|
+
rescue
|
95
|
+
@skip_archive = true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def build_static_library
|
101
|
+
source_dir = zip_dir
|
102
|
+
file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
|
103
|
+
Dir.chdir(workspace_directory) do
|
104
|
+
builder = CBin::Library::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path)
|
105
|
+
builder.build
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def zip_static_xcframework
|
110
|
+
Dir.chdir(zip_dir) do
|
111
|
+
output_name = File.join(zip_dir, xcframework_name_zip)
|
112
|
+
unless File.exist?(xcframework_name)
|
113
|
+
UI.puts "没有需要压缩的 xcframework 文件:#{xcframework_name}"
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
UI.puts "Compressing #{xcframework_name} into #{output_name}"
|
118
|
+
`zip --symlinks -r #{output_name} #{xcframework_name} && rm -rf #{xcframework_name}` # xcframework进行zip压缩 & 删除源文件
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def zip_static_framework
|
123
|
+
Dir.chdir(File.join(workspace_directory,@framework_path.root_path)) do
|
124
|
+
output_name = File.join(zip_dir, framework_name_zip)
|
125
|
+
unless File.exist?(framework_name)
|
126
|
+
UI.puts "没有需要压缩的 framework 文件:#{framework_name}"
|
127
|
+
return
|
128
|
+
end
|
129
|
+
|
130
|
+
UI.puts "Compressing #{framework_name} into #{output_name}"
|
131
|
+
`zip --symlinks -r #{output_name} #{framework_name}`
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def zip_static_library
|
136
|
+
Dir.chdir(zip_dir) do
|
137
|
+
output_library = "#{library_name}.zip"
|
138
|
+
unless File.exist?(library_name)
|
139
|
+
raise Informative, "没有需要压缩的 library 文件:#{library_name}"
|
140
|
+
end
|
141
|
+
|
142
|
+
UI.puts "Compressing #{library_name} into #{output_library}"
|
143
|
+
|
144
|
+
`zip --symlinks -r #{output_library} #{library_name}`
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def clean_workspace
|
151
|
+
UI.puts 'Cleaning workspace'
|
152
|
+
|
153
|
+
FileUtils.rm_rf(gen_name)
|
154
|
+
Dir.chdir(zip_dir) do
|
155
|
+
# framework
|
156
|
+
FileUtils.rm_rf(framework_name) if @zip
|
157
|
+
FileUtils.rm_rf(library_name)
|
158
|
+
FileUtils.rm_rf(framework_name) unless @framework_output
|
159
|
+
FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
|
160
|
+
# xcframework
|
161
|
+
FileUtils.rm_rf(xcframework_name) if @zip
|
162
|
+
FileUtils.rm_rf(xcframework_name) unless @framework_output
|
163
|
+
FileUtils.rm_rf("#{xcframework_name}.zip") unless @framework_output
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def xcframework_name
|
168
|
+
CBin::Config::Builder.instance.xcframework_name(@spec)
|
169
|
+
end
|
170
|
+
|
171
|
+
def xcframework_name_zip
|
172
|
+
CBin::Config::Builder.instance.xcframework_name_version(@spec) + ".zip"
|
173
|
+
end
|
174
|
+
|
175
|
+
def framework_name
|
176
|
+
CBin::Config::Builder.instance.framework_name(@spec)
|
177
|
+
end
|
178
|
+
|
179
|
+
def framework_name_zip
|
180
|
+
CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
|
181
|
+
end
|
182
|
+
|
183
|
+
def library_name
|
184
|
+
CBin::Config::Builder.instance.library_name(@spec)
|
185
|
+
end
|
186
|
+
|
187
|
+
def workspace_directory
|
188
|
+
File.expand_path("#{gen_name}/#{@rootSpec.name}")
|
189
|
+
end
|
190
|
+
|
191
|
+
def zip_dir
|
192
|
+
CBin::Config::Builder.instance.zip_dir
|
193
|
+
end
|
194
|
+
|
195
|
+
def gen_name
|
196
|
+
CBin::Config::Builder.instance.gen_dir
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
def spec_file
|
201
|
+
@spec_file ||= begin
|
202
|
+
if @podspec
|
203
|
+
find_spec_file(@podspec)
|
204
|
+
else
|
205
|
+
if code_spec_files.empty?
|
206
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
207
|
+
end
|
208
|
+
|
209
|
+
spec_file = code_spec_files.first
|
210
|
+
spec_file
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-bb-bin/config/config'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class Build
|
6
|
+
|
7
|
+
class Utils
|
8
|
+
|
9
|
+
def Utils.is_framework(spec)
|
10
|
+
if Utils.uses_frameworks?
|
11
|
+
return true
|
12
|
+
end
|
13
|
+
|
14
|
+
return Utils.is_swift_module(spec)
|
15
|
+
end
|
16
|
+
|
17
|
+
def Utils.is_swift_module(spec)
|
18
|
+
|
19
|
+
is_framework = false
|
20
|
+
dir = File.join(CBin::Config::Builder.instance.gen_dir, CBin::Config::Builder.instance.target_name)
|
21
|
+
#auto 走这里
|
22
|
+
if File.exist?(dir)
|
23
|
+
Dir.chdir(dir) do
|
24
|
+
public_headers = Array.new
|
25
|
+
spec_header_dir = "./Headers/Public/#{spec.name}"
|
26
|
+
|
27
|
+
unless File.exist?(spec_header_dir)
|
28
|
+
spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
|
29
|
+
end
|
30
|
+
return false unless File.exist?(spec_header_dir)
|
31
|
+
|
32
|
+
is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if $ARGV[1] == "local"
|
37
|
+
is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_build_dir, "#{spec.name}.framework"))
|
38
|
+
unless is_framework
|
39
|
+
is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header"))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
is_framework
|
44
|
+
end
|
45
|
+
|
46
|
+
def Utils.uses_frameworks?
|
47
|
+
uses_frameworks = false
|
48
|
+
Pod::Config.instance.podfile.target_definitions.each do |key,value|
|
49
|
+
if key != "Pods"
|
50
|
+
uses_frameworks = value.uses_frameworks?
|
51
|
+
if uses_frameworks
|
52
|
+
break ;
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
return uses_frameworks
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|