cocoapods-packager-bj 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/cocoapods_packager-bj.gemspec +20 -0
- data/lib/cocoapods-packager-bj/builder.rb +387 -0
- data/lib/cocoapods-packager-bj/framework.rb +76 -0
- data/lib/cocoapods-packager-bj/mangle.rb +32 -0
- data/lib/cocoapods-packager-bj/pod_utils.rb +248 -0
- data/lib/cocoapods-packager-bj/spec_builder.rb +63 -0
- data/lib/cocoapods-packager-bj/symbols.rb +42 -0
- data/lib/cocoapods-packager-bj/user_interface/build_failed_report.rb +15 -0
- data/lib/cocoapods_packager_bj.rb +5 -0
- data/lib/cocoapods_plugin.rb +8 -0
- data/lib/pod/command/package_bj.rb +181 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 382baa9a262ec1156fe9fc0c74f90df5dd591cf5bffdbf0a252d48c76c3f1e09
|
4
|
+
data.tar.gz: 625cdf927849414089516f0e30f0edbfde628e7e6e7f9515d0e2fb73f68052d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 721a87c1de2ba0de3b210f0215522783045c82269523867bbb9e33441d9c8bd3c7aa72f72102b078cf2e907c61aae83e7681e868dc62d64b332b1ae3acb9b903
|
7
|
+
data.tar.gz: db53922e95149f32e41498c506c8b8d36061f5e65bd4aa97bb8d4b204bb7c4dd2de17e528bc6bea735cd50351f857a47f9c1afc40d3bfa471b0b0c6e282d7903
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 A Fire Fish
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods_packager_bj.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-packager-bj'
|
8
|
+
spec.version = Pod::BJPackager::VERSION
|
9
|
+
spec.authors = ['Kyle Fuller', 'Boris Bügling']
|
10
|
+
spec.summary = 'Based on cocoapods-packager code, support swift framework, generate a framework or static library from a podspec. '
|
11
|
+
spec.homepage = 'https://github.com/Afirefish/cocoapods_packager-bj'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_dependency "cocoapods", '>= 1.1.1', '< 2.0'
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
end
|
@@ -0,0 +1,387 @@
|
|
1
|
+
module Pod
|
2
|
+
class BJBuilder
|
3
|
+
def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
|
4
|
+
@platform = platform
|
5
|
+
@static_installer = static_installer
|
6
|
+
@source_dir = source_dir
|
7
|
+
@static_sandbox_root = static_sandbox_root
|
8
|
+
@dynamic_sandbox_root = dynamic_sandbox_root
|
9
|
+
@public_headers_root = public_headers_root
|
10
|
+
@spec = spec
|
11
|
+
@embedded = embedded
|
12
|
+
@mangle = mangle
|
13
|
+
@dynamic = dynamic
|
14
|
+
@config = config
|
15
|
+
@bundle_identifier = bundle_identifier
|
16
|
+
@exclude_deps = exclude_deps
|
17
|
+
|
18
|
+
@file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
|
19
|
+
end
|
20
|
+
|
21
|
+
def build(package_type)
|
22
|
+
case package_type
|
23
|
+
when :static_library
|
24
|
+
build_static_library
|
25
|
+
when :static_framework
|
26
|
+
build_static_framework
|
27
|
+
when :dynamic_framework
|
28
|
+
build_dynamic_framework
|
29
|
+
when :module_framework
|
30
|
+
build_module_framework
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_static_library
|
35
|
+
UI.puts("Building static library #{@spec} with configuration #{@config}")
|
36
|
+
|
37
|
+
defines = compile
|
38
|
+
build_sim_libraries(defines)
|
39
|
+
|
40
|
+
platform_path = Pathname.new(@platform.name.to_s)
|
41
|
+
platform_path.mkdir unless platform_path.exist?
|
42
|
+
|
43
|
+
output = platform_path + "lib#{@spec.name}.a"
|
44
|
+
|
45
|
+
if @platform.name == :ios
|
46
|
+
build_static_library_for_ios(output)
|
47
|
+
else
|
48
|
+
build_static_library_for_mac(output)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_static_framework
|
53
|
+
UI.puts("Building static framework #{@spec} with configuration #{@config}")
|
54
|
+
|
55
|
+
defines = compile
|
56
|
+
build_sim_libraries(defines)
|
57
|
+
|
58
|
+
create_framework
|
59
|
+
output = @fwk.versions_path + Pathname.new(@spec.name)
|
60
|
+
|
61
|
+
if @platform.name == :ios
|
62
|
+
build_static_library_for_ios(output)
|
63
|
+
else
|
64
|
+
build_static_library_for_mac(output)
|
65
|
+
end
|
66
|
+
|
67
|
+
copy_headers
|
68
|
+
copy_license
|
69
|
+
copy_resources
|
70
|
+
end
|
71
|
+
|
72
|
+
def link_embedded_resources
|
73
|
+
target_path = @fwk.root_path + Pathname.new('Resources')
|
74
|
+
target_path.mkdir unless target_path.exist?
|
75
|
+
|
76
|
+
Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
|
77
|
+
resource = Pathname.new(resource).relative_path_from(target_path)
|
78
|
+
`ln -sf #{resource} #{target_path}`
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def build_dynamic_framework
|
83
|
+
UI.puts("Building dynamic framework #{@spec} with configuration #{@config}")
|
84
|
+
|
85
|
+
defines = compile
|
86
|
+
build_sim_libraries(defines)
|
87
|
+
|
88
|
+
if @bundle_identifier
|
89
|
+
defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
|
90
|
+
end
|
91
|
+
|
92
|
+
output = "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}"
|
93
|
+
|
94
|
+
clean_directory_for_dynamic_build
|
95
|
+
if @platform.name == :ios
|
96
|
+
build_dynamic_framework_for_ios(defines, output)
|
97
|
+
else
|
98
|
+
build_dynamic_framework_for_mac(defines, output)
|
99
|
+
end
|
100
|
+
|
101
|
+
copy_resources
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_dynamic_framework_for_ios(defines, output)
|
105
|
+
# Specify frameworks to link and search paths
|
106
|
+
linker_flags = static_linker_flags_in_sandbox
|
107
|
+
defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
|
108
|
+
|
109
|
+
# Build Target Dynamic Framework for both device and Simulator
|
110
|
+
device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
|
111
|
+
device_options = ios_build_options << ' -sdk iphoneos'
|
112
|
+
xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
|
113
|
+
|
114
|
+
sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
|
115
|
+
xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
|
116
|
+
|
117
|
+
# Combine architectures
|
118
|
+
`lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
|
119
|
+
|
120
|
+
FileUtils.mkdir(@platform.name.to_s)
|
121
|
+
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
|
122
|
+
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
|
123
|
+
end
|
124
|
+
|
125
|
+
def build_dynamic_framework_for_mac(defines, _output)
|
126
|
+
# Specify frameworks to link and search paths
|
127
|
+
linker_flags = static_linker_flags_in_sandbox
|
128
|
+
defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
|
129
|
+
|
130
|
+
# Build Target Dynamic Framework for osx
|
131
|
+
defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
|
132
|
+
xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
|
133
|
+
|
134
|
+
FileUtils.mkdir(@platform.name.to_s)
|
135
|
+
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
|
136
|
+
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
|
137
|
+
end
|
138
|
+
|
139
|
+
def build_sim_libraries(defines)
|
140
|
+
if @platform.name == :ios
|
141
|
+
xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def build_static_library_for_ios(output)
|
146
|
+
static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
|
147
|
+
libs = ios_architectures.map do |arch|
|
148
|
+
library = "#{@static_sandbox_root}/build/package-#{arch}.a"
|
149
|
+
`libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
|
150
|
+
library
|
151
|
+
end
|
152
|
+
|
153
|
+
`lipo -create -output #{output} #{libs.join(' ')}`
|
154
|
+
end
|
155
|
+
|
156
|
+
def build_static_library_for_mac(output)
|
157
|
+
static_libs = static_libs_in_sandbox + vendored_libraries
|
158
|
+
`libtool -static -o #{output} #{static_libs.join(' ')}`
|
159
|
+
end
|
160
|
+
|
161
|
+
def build_with_mangling(options)
|
162
|
+
UI.puts 'Mangling symbols'
|
163
|
+
defines = BJSymbols.mangle_for_pod_dependencies(@spec.name, @static_sandbox_root)
|
164
|
+
defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
|
165
|
+
|
166
|
+
UI.puts 'Building mangled framework'
|
167
|
+
xcodebuild(defines, options)
|
168
|
+
defines
|
169
|
+
end
|
170
|
+
|
171
|
+
def clean_directory_for_dynamic_build
|
172
|
+
# Remove static headers to avoid duplicate declaration conflicts
|
173
|
+
FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Public/#{@spec.name}")
|
174
|
+
FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Private/#{@spec.name}")
|
175
|
+
|
176
|
+
# Equivalent to removing derrived data
|
177
|
+
FileUtils.rm_rf('Pods/build')
|
178
|
+
end
|
179
|
+
|
180
|
+
def compile
|
181
|
+
defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
|
182
|
+
defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
|
183
|
+
|
184
|
+
if @platform.name == :ios
|
185
|
+
options = ios_build_options
|
186
|
+
end
|
187
|
+
|
188
|
+
xcodebuild(defines, options)
|
189
|
+
|
190
|
+
if @mangle
|
191
|
+
return build_with_mangling(options)
|
192
|
+
end
|
193
|
+
|
194
|
+
defines
|
195
|
+
end
|
196
|
+
|
197
|
+
def copy_headers
|
198
|
+
headers_source_root = "#{@public_headers_root}/#{@spec.name}"
|
199
|
+
|
200
|
+
Dir.glob("#{headers_source_root}/**/*.h").
|
201
|
+
each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
|
202
|
+
|
203
|
+
# If custom 'module_map' is specified add it to the framework distribution
|
204
|
+
# otherwise check if a header exists that is equal to 'spec.name', if so
|
205
|
+
# create a default 'module_map' one using it.
|
206
|
+
if !@spec.module_map.nil?
|
207
|
+
module_map_file = @file_accessors.flat_map(&:module_map).first
|
208
|
+
module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
|
209
|
+
elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
|
210
|
+
module_map = <<MAP
|
211
|
+
framework module #{@spec.name} {
|
212
|
+
umbrella header "#{@spec.name}.h"
|
213
|
+
|
214
|
+
export *
|
215
|
+
module * { export * }
|
216
|
+
}
|
217
|
+
MAP
|
218
|
+
end
|
219
|
+
|
220
|
+
unless module_map.nil?
|
221
|
+
@fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
|
222
|
+
File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def copy_license
|
227
|
+
license_file = @spec.license[:file] || 'LICENSE'
|
228
|
+
license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
|
229
|
+
FileUtils.cp(license_file, '.') if license_file.exist?
|
230
|
+
end
|
231
|
+
|
232
|
+
def copy_resources
|
233
|
+
bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
|
234
|
+
if @dynamic
|
235
|
+
resources_path = "ios/#{@spec.name}.framework"
|
236
|
+
`cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
|
237
|
+
else
|
238
|
+
`cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
|
239
|
+
resources = expand_paths(@spec.consumer(@platform).resources)
|
240
|
+
if resources.count == 0 && bundles.count == 0
|
241
|
+
@fwk.delete_resources
|
242
|
+
return
|
243
|
+
end
|
244
|
+
if resources.count > 0
|
245
|
+
`cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def create_framework
|
251
|
+
@fwk = BJFramework::BJTree.new(@spec.name, @platform.name.to_s, @embedded)
|
252
|
+
@fwk.make
|
253
|
+
end
|
254
|
+
|
255
|
+
def dependency_count
|
256
|
+
count = @spec.dependencies.count
|
257
|
+
|
258
|
+
@spec.subspecs.each do |subspec|
|
259
|
+
count += subspec.dependencies.count
|
260
|
+
end
|
261
|
+
|
262
|
+
count
|
263
|
+
end
|
264
|
+
|
265
|
+
def expand_paths(path_specs)
|
266
|
+
path_specs.map do |path_spec|
|
267
|
+
Dir.glob(File.join(@source_dir, path_spec))
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def static_libs_in_sandbox(build_dir = 'build')
|
272
|
+
if @exclude_deps
|
273
|
+
UI.puts 'Excluding dependencies'
|
274
|
+
Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
|
275
|
+
else
|
276
|
+
Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def vendored_libraries
|
281
|
+
if @vendored_libraries
|
282
|
+
@vendored_libraries
|
283
|
+
end
|
284
|
+
file_accessors = if @exclude_deps
|
285
|
+
@file_accessors
|
286
|
+
else
|
287
|
+
@static_installer.pod_targets.flat_map(&:file_accessors)
|
288
|
+
end
|
289
|
+
libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || []
|
290
|
+
libs += file_accessors.flat_map(&:vendored_static_libraries)
|
291
|
+
@vendored_libraries = libs.compact.map(&:to_s)
|
292
|
+
@vendored_libraries
|
293
|
+
end
|
294
|
+
|
295
|
+
def static_linker_flags_in_sandbox
|
296
|
+
linker_flags = static_libs_in_sandbox.map do |lib|
|
297
|
+
lib.slice!('lib')
|
298
|
+
lib_flag = lib.chomp('.a').split('/').last
|
299
|
+
"-l#{lib_flag}"
|
300
|
+
end
|
301
|
+
linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
|
302
|
+
end
|
303
|
+
|
304
|
+
def ios_build_options
|
305
|
+
"ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
|
306
|
+
end
|
307
|
+
|
308
|
+
def ios_architectures
|
309
|
+
archs = %w(x86_64 i386 arm64 armv7 armv7s)
|
310
|
+
vendored_libraries.each do |library|
|
311
|
+
archs = `lipo -info #{library}`.split & archs
|
312
|
+
end
|
313
|
+
archs
|
314
|
+
end
|
315
|
+
|
316
|
+
def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
|
317
|
+
if defined?(Pod::DONT_CODESIGN)
|
318
|
+
args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
|
319
|
+
end
|
320
|
+
|
321
|
+
command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
|
322
|
+
output = `#{command}`.lines.to_a
|
323
|
+
|
324
|
+
if $?.exitstatus != 0
|
325
|
+
puts UI::BJBuildFailedReport.report(command, output)
|
326
|
+
|
327
|
+
# Note: We use `Process.exit` here because it fires a `SystemExit`
|
328
|
+
# exception, which gives the caller a chance to clean up before the
|
329
|
+
# process terminates.
|
330
|
+
#
|
331
|
+
# See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
|
332
|
+
Process.exit
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def build_module_framework
|
337
|
+
UI.puts("Building module framework #{@spec} with configuration #{@config}")
|
338
|
+
|
339
|
+
defines = compile
|
340
|
+
build_sim_libraries(defines)
|
341
|
+
|
342
|
+
create_framework
|
343
|
+
output = @fwk.versions_path + Pathname.new(@spec.name)
|
344
|
+
|
345
|
+
build_module_framework_for_ios(output)
|
346
|
+
|
347
|
+
copy_module_headers
|
348
|
+
copy_license
|
349
|
+
copy_resources
|
350
|
+
end
|
351
|
+
|
352
|
+
def build_module_framework_for_ios(output)
|
353
|
+
`lipo #{@static_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@static_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
|
354
|
+
end
|
355
|
+
|
356
|
+
def copy_module_headers
|
357
|
+
headers_source_root = "#{@static_sandbox_root}/build/#{@spec.name}.framework/Headers"
|
358
|
+
module_map_file_root = "#{@static_sandbox_root}/build/#{@spec.name}.framework/Modules"
|
359
|
+
modules_source_root = "#{@static_sandbox_root}/build/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule"
|
360
|
+
modules_sourceinfo_root = "#{@static_sandbox_root}/build/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule/Project"
|
361
|
+
modules_sim_source_root = "#{@static_sandbox_root}/build-sim/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule"
|
362
|
+
modules_sim_sourceinfo_root = "#{@static_sandbox_root}/build-sim/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule/Project"
|
363
|
+
|
364
|
+
UI.puts("copy header && modules")
|
365
|
+
|
366
|
+
Dir.glob("#{headers_source_root}/**/*.h").
|
367
|
+
each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
|
368
|
+
|
369
|
+
Dir.glob("#{module_map_file_root}/**/*.modulemap").
|
370
|
+
each { |h| `ditto #{h} #{@fwk.module_map_path}/#{h.sub(module_map_file_root, '')}` }
|
371
|
+
|
372
|
+
Dir.glob("#{modules_source_root}/**/*.{swiftdoc,swiftinterface,swiftmodule}").
|
373
|
+
each { |h| `ditto #{h} #{@fwk.swiftmodule_path}/#{h.sub(modules_source_root, '')}` }
|
374
|
+
|
375
|
+
Dir.glob("#{modules_sourceinfo_root}/**/*.swiftsourceinfo").
|
376
|
+
each { |h| `ditto #{h} #{@fwk.swiftsourceinfo_path}/#{h.sub(modules_sourceinfo_root, '')}` }
|
377
|
+
|
378
|
+
Dir.glob("#{modules_sim_source_root}/**/*.{swiftdoc,swiftinterface,swiftmodule}").
|
379
|
+
each { |h| `ditto #{h} #{@fwk.swiftmodule_path}/#{h.sub(modules_sim_source_root, '')}` }
|
380
|
+
|
381
|
+
Dir.glob("#{modules_sim_sourceinfo_root}/**/*.swiftsourceinfo").
|
382
|
+
each { |h| `ditto #{h} #{@fwk.swiftsourceinfo_path}/#{h.sub(modules_sim_sourceinfo_root, '')}` }
|
383
|
+
|
384
|
+
end
|
385
|
+
|
386
|
+
end
|
387
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module BJFramework
|
2
|
+
class BJTree
|
3
|
+
attr_reader :headers_path
|
4
|
+
attr_reader :module_map_path
|
5
|
+
attr_reader :resources_path
|
6
|
+
attr_reader :root_path
|
7
|
+
attr_reader :versions_path
|
8
|
+
attr_reader :swiftmodule_path
|
9
|
+
attr_reader :swiftsourceinfo_path
|
10
|
+
|
11
|
+
def delete_resources
|
12
|
+
Pathname.new(@resources_path).rmtree
|
13
|
+
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(name, platform, embedded)
|
17
|
+
@name = name
|
18
|
+
@platform = platform
|
19
|
+
@embedded = embedded
|
20
|
+
end
|
21
|
+
|
22
|
+
def make
|
23
|
+
make_root
|
24
|
+
make_framework
|
25
|
+
make_headers
|
26
|
+
make_resources
|
27
|
+
make_current_version
|
28
|
+
make_modules
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def make_current_version
|
34
|
+
current_version_path = @versions_path + Pathname.new('../Current')
|
35
|
+
`ln -sf A #{current_version_path}`
|
36
|
+
`ln -sf Versions/Current/Headers #{@fwk_path}/`
|
37
|
+
`ln -sf Versions/Current/Resources #{@fwk_path}/`
|
38
|
+
`ln -sf Versions/Current/#{@name} #{@fwk_path}/`
|
39
|
+
end
|
40
|
+
|
41
|
+
def make_framework
|
42
|
+
@fwk_path = @root_path + Pathname.new(@name + '.framework')
|
43
|
+
@fwk_path.mkdir unless @fwk_path.exist?
|
44
|
+
|
45
|
+
@module_map_path = @fwk_path + Pathname.new('Modules')
|
46
|
+
@versions_path = @fwk_path + Pathname.new('Versions/A')
|
47
|
+
end
|
48
|
+
|
49
|
+
def make_headers
|
50
|
+
@headers_path = @versions_path + Pathname.new('Headers')
|
51
|
+
@headers_path.mkpath unless @headers_path.exist?
|
52
|
+
end
|
53
|
+
|
54
|
+
def make_resources
|
55
|
+
@resources_path = @versions_path + Pathname.new('Resources')
|
56
|
+
@resources_path.mkpath unless @resources_path.exist?
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_modules
|
60
|
+
@swiftmodule_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
|
61
|
+
@swiftmodule_path.mkpath unless @swiftmodule_path.exist?
|
62
|
+
@swiftsourceinfo_path = @swiftmodule_path + Pathname.new('Project')
|
63
|
+
@swiftsourceinfo_path.mkpath unless @swiftsourceinfo_path.exist?
|
64
|
+
end
|
65
|
+
|
66
|
+
def make_root
|
67
|
+
@root_path = Pathname.new(@platform)
|
68
|
+
|
69
|
+
if @embedded
|
70
|
+
@root_path += Pathname.new(@name + '.embeddedframework')
|
71
|
+
end
|
72
|
+
|
73
|
+
@root_path.mkpath unless @root_path.exist?
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BJSymbols
|
2
|
+
#
|
3
|
+
# performs symbol aliasing
|
4
|
+
#
|
5
|
+
# for each dependency:
|
6
|
+
# - determine symbols for classes and global constants
|
7
|
+
# - alias each symbol to Pod#{pod_name}_#{symbol}
|
8
|
+
# - put defines into `GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode
|
9
|
+
#
|
10
|
+
def mangle_for_pod_dependencies(pod_name, sandbox_root)
|
11
|
+
pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do |file|
|
12
|
+
file !~ /lib#{pod_name}.a$/
|
13
|
+
end
|
14
|
+
|
15
|
+
dummy_alias = alias_symbol "PodsDummy_#{pod_name}", pod_name
|
16
|
+
all_syms = [dummy_alias]
|
17
|
+
|
18
|
+
pod_libs.each do |pod_lib|
|
19
|
+
syms = BJSymbols.symbols_from_library(pod_lib)
|
20
|
+
all_syms += syms.map! { |sym| alias_symbol sym, pod_name }
|
21
|
+
end
|
22
|
+
|
23
|
+
"GCC_PREPROCESSOR_DEFINITIONS='$(inherited) #{all_syms.uniq.join(' ')}'"
|
24
|
+
end
|
25
|
+
|
26
|
+
def alias_symbol(sym, pod_name)
|
27
|
+
pod_name = pod_name.tr('-', '_')
|
28
|
+
sym + "=Pod#{pod_name}_" + sym
|
29
|
+
end
|
30
|
+
|
31
|
+
module_function :mangle_for_pod_dependencies, :alias_symbol
|
32
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class BJPackage < Command
|
4
|
+
private
|
5
|
+
|
6
|
+
def build_static_sandbox(dynamic)
|
7
|
+
static_sandbox_root = if dynamic
|
8
|
+
Pathname.new(config.sandbox_root + '/Static')
|
9
|
+
else
|
10
|
+
Pathname.new(config.sandbox_root)
|
11
|
+
end
|
12
|
+
Sandbox.new(static_sandbox_root)
|
13
|
+
end
|
14
|
+
|
15
|
+
def install_pod(platform_name, sandbox, modules)
|
16
|
+
podfile = podfile_from_spec(
|
17
|
+
@path,
|
18
|
+
@spec.name,
|
19
|
+
platform_name,
|
20
|
+
@spec.deployment_target(platform_name),
|
21
|
+
@subspecs,
|
22
|
+
@spec_sources,
|
23
|
+
modules
|
24
|
+
)
|
25
|
+
|
26
|
+
static_installer = Installer.new(sandbox, podfile)
|
27
|
+
static_installer.install!
|
28
|
+
|
29
|
+
unless static_installer.nil?
|
30
|
+
static_installer.pods_project.targets.each do |target|
|
31
|
+
target.build_configurations.each do |config|
|
32
|
+
config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
|
33
|
+
config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
static_installer.pods_project.save
|
37
|
+
end
|
38
|
+
|
39
|
+
static_installer
|
40
|
+
end
|
41
|
+
|
42
|
+
def podfile_from_spec(path, spec_name, platform_name, deployment_target, subspecs, sources, modules)
|
43
|
+
options = {}
|
44
|
+
if path
|
45
|
+
if @local
|
46
|
+
options[:path] = path
|
47
|
+
else
|
48
|
+
options[:podspec] = path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
options[:subspecs] = subspecs if subspecs
|
52
|
+
Pod::Podfile.new do
|
53
|
+
if modules
|
54
|
+
use_frameworks!
|
55
|
+
end
|
56
|
+
sources.each { |s| source s }
|
57
|
+
platform(platform_name, deployment_target)
|
58
|
+
pod(spec_name, options)
|
59
|
+
|
60
|
+
install!('cocoapods',
|
61
|
+
:integrate_targets => false,
|
62
|
+
:deterministic_uuids => false)
|
63
|
+
|
64
|
+
target('packager') do
|
65
|
+
inherit! :complete
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def binary_only?(spec)
|
71
|
+
deps = spec.dependencies.map { |dep| spec_with_name(dep.name) }
|
72
|
+
[spec, *deps].each do |specification|
|
73
|
+
%w(vendored_frameworks vendored_libraries).each do |attrib|
|
74
|
+
if specification.attributes_hash[attrib]
|
75
|
+
return true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
83
|
+
def spec_with_name(name)
|
84
|
+
return if name.nil?
|
85
|
+
|
86
|
+
set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
|
87
|
+
return nil if set.nil?
|
88
|
+
|
89
|
+
set.specification.root
|
90
|
+
end
|
91
|
+
|
92
|
+
def spec_with_path(path)
|
93
|
+
return if path.nil?
|
94
|
+
path = Pathname.new(path)
|
95
|
+
path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
|
96
|
+
return unless path.exist?
|
97
|
+
|
98
|
+
@path = path.expand_path
|
99
|
+
|
100
|
+
if @path.directory?
|
101
|
+
help! @path + ': is a directory.'
|
102
|
+
return
|
103
|
+
end
|
104
|
+
|
105
|
+
unless ['.podspec', '.json'].include? @path.extname
|
106
|
+
help! @path + ': is not a podspec.'
|
107
|
+
return
|
108
|
+
end
|
109
|
+
|
110
|
+
Specification.from_file(@path)
|
111
|
+
end
|
112
|
+
|
113
|
+
#----------------------
|
114
|
+
# Dynamic Project Setup
|
115
|
+
#----------------------
|
116
|
+
|
117
|
+
def build_dynamic_sandbox(_static_sandbox, _static_installer)
|
118
|
+
dynamic_sandbox_root = Pathname.new(config.sandbox_root + '/Dynamic')
|
119
|
+
dynamic_sandbox = Sandbox.new(dynamic_sandbox_root)
|
120
|
+
|
121
|
+
dynamic_sandbox
|
122
|
+
end
|
123
|
+
|
124
|
+
# @param [Pod::Sandbox] dynamic_sandbox
|
125
|
+
#
|
126
|
+
# @param [Pod::Sandbox] static_sandbox
|
127
|
+
#
|
128
|
+
# @param [Pod::Installer] static_installer
|
129
|
+
#
|
130
|
+
# @param [Pod::Platform] platform
|
131
|
+
#
|
132
|
+
def install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
|
133
|
+
# 1 Create a dynamic target for only the spec pod.
|
134
|
+
dynamic_target = build_dynamic_target(dynamic_sandbox, static_installer, platform)
|
135
|
+
|
136
|
+
# 2. Build a new xcodeproj in the dynamic_sandbox with only the spec pod as a target.
|
137
|
+
project = prepare_pods_project(dynamic_sandbox, dynamic_target.name, static_installer)
|
138
|
+
|
139
|
+
# 3. Copy the source directory for the dynamic framework from the static sandbox.
|
140
|
+
copy_dynamic_target(static_sandbox, dynamic_target, dynamic_sandbox)
|
141
|
+
|
142
|
+
# 4. Create the file references.
|
143
|
+
install_file_references(dynamic_sandbox, [dynamic_target], project)
|
144
|
+
|
145
|
+
# 5. Install the target.
|
146
|
+
install_library(dynamic_sandbox, dynamic_target, project)
|
147
|
+
|
148
|
+
# 6. Write the actual .xcodeproj to the dynamic sandbox.
|
149
|
+
write_pod_project(project, dynamic_sandbox)
|
150
|
+
end
|
151
|
+
|
152
|
+
# @param [Pod::Installer] static_installer
|
153
|
+
#
|
154
|
+
# @return [Pod::PodTarget]
|
155
|
+
#
|
156
|
+
def build_dynamic_target(dynamic_sandbox, static_installer, platform)
|
157
|
+
spec_targets = static_installer.pod_targets.select do |target|
|
158
|
+
target.name == @spec.name
|
159
|
+
end
|
160
|
+
static_target = spec_targets[0]
|
161
|
+
|
162
|
+
file_accessors = create_file_accessors(static_target, dynamic_sandbox)
|
163
|
+
|
164
|
+
archs = []
|
165
|
+
dynamic_target = Pod::PodTarget.new(dynamic_sandbox, true, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)
|
166
|
+
dynamic_target
|
167
|
+
end
|
168
|
+
|
169
|
+
# @param [Pod::Sandbox] dynamic_sandbox
|
170
|
+
#
|
171
|
+
# @param [String] spec_name
|
172
|
+
#
|
173
|
+
# @param [Pod::Installer] installer
|
174
|
+
#
|
175
|
+
def prepare_pods_project(dynamic_sandbox, spec_name, installer)
|
176
|
+
# Create a new pods project
|
177
|
+
pods_project = Pod::Project.new(dynamic_sandbox.project_path)
|
178
|
+
|
179
|
+
# Update build configurations
|
180
|
+
installer.analysis_result.all_user_build_configurations.each do |name, type|
|
181
|
+
pods_project.add_build_configuration(name, type)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Add the pod group for only the dynamic framework
|
185
|
+
local = dynamic_sandbox.local?(spec_name)
|
186
|
+
path = dynamic_sandbox.pod_dir(spec_name)
|
187
|
+
was_absolute = dynamic_sandbox.local_path_was_absolute?(spec_name)
|
188
|
+
pods_project.add_pod_group(spec_name, path, local, was_absolute)
|
189
|
+
pods_project
|
190
|
+
end
|
191
|
+
|
192
|
+
def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
|
193
|
+
command = "cp -a #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
|
194
|
+
`#{command}`
|
195
|
+
end
|
196
|
+
|
197
|
+
def create_file_accessors(target, dynamic_sandbox)
|
198
|
+
pod_root = dynamic_sandbox.pod_dir(target.root_spec.name)
|
199
|
+
|
200
|
+
path_list = Sandbox::PathList.new(pod_root)
|
201
|
+
target.specs.map do |spec|
|
202
|
+
Sandbox::FileAccessor.new(path_list, spec.consumer(target.platform))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def install_file_references(dynamic_sandbox, pod_targets, pods_project)
|
207
|
+
installer = Pod::Installer::Xcode::PodsProjectGenerator::FileReferencesInstaller.new(dynamic_sandbox, pod_targets, pods_project)
|
208
|
+
installer.install!
|
209
|
+
end
|
210
|
+
|
211
|
+
def install_library(dynamic_sandbox, dynamic_target, project)
|
212
|
+
return if dynamic_target.target_definitions.flat_map(&:dependencies).empty?
|
213
|
+
target_installer = Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.new(dynamic_sandbox, project, dynamic_target)
|
214
|
+
result = target_installer.install!
|
215
|
+
native_target = result.native_target
|
216
|
+
|
217
|
+
# Installs System Frameworks
|
218
|
+
if dynamic_target.should_build?
|
219
|
+
dynamic_target.file_accessors.each do |file_accessor|
|
220
|
+
file_accessor.spec_consumer.frameworks.each do |framework|
|
221
|
+
native_target.add_system_framework(framework)
|
222
|
+
end
|
223
|
+
file_accessor.spec_consumer.libraries.each do |library|
|
224
|
+
native_target.add_system_library(library)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def write_pod_project(dynamic_project, dynamic_sandbox)
|
231
|
+
UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
|
232
|
+
dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
|
233
|
+
dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
|
234
|
+
dynamic_project.sort(:groups_position => :below)
|
235
|
+
dynamic_project.recreate_user_schemes(false)
|
236
|
+
|
237
|
+
# Edit search paths so that we can find our dependency headers
|
238
|
+
dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
|
239
|
+
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
|
240
|
+
config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
|
241
|
+
config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
|
242
|
+
end
|
243
|
+
dynamic_project.save
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Pod
|
2
|
+
class BJSpecBuilder
|
3
|
+
def initialize(spec, source, embedded, dynamic)
|
4
|
+
@spec = spec
|
5
|
+
@source = source.nil? ? '{ :path => \'.\' }' : source
|
6
|
+
@embedded = embedded
|
7
|
+
@dynamic = dynamic
|
8
|
+
end
|
9
|
+
|
10
|
+
def framework_path
|
11
|
+
if @embedded
|
12
|
+
@spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
|
13
|
+
else
|
14
|
+
@spec.name + '.framework'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def spec_platform(platform)
|
19
|
+
fwk_base = platform.name.to_s + '/' + framework_path
|
20
|
+
spec = <<RB
|
21
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
22
|
+
s.#{platform.name}.vendored_framework = '#{fwk_base}'
|
23
|
+
RB
|
24
|
+
|
25
|
+
%w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
|
26
|
+
attributes_hash = @spec.attributes_hash[platform.name.to_s]
|
27
|
+
next if attributes_hash.nil?
|
28
|
+
value = attributes_hash[attribute]
|
29
|
+
next if value.nil?
|
30
|
+
|
31
|
+
value = "'#{value}'" if value.class == String
|
32
|
+
spec += " s.#{platform.name}.#{attribute} = #{value}\n"
|
33
|
+
end
|
34
|
+
spec
|
35
|
+
end
|
36
|
+
|
37
|
+
def spec_metadata
|
38
|
+
spec = spec_header
|
39
|
+
spec
|
40
|
+
end
|
41
|
+
|
42
|
+
def spec_close
|
43
|
+
"end\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def spec_header
|
49
|
+
spec = "Pod::Spec.new do |s|\n"
|
50
|
+
|
51
|
+
%w(name version summary license authors homepage description social_media_url
|
52
|
+
docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
|
53
|
+
deployment_target xcconfig).each do |attribute|
|
54
|
+
value = @spec.attributes_hash[attribute]
|
55
|
+
next if value.nil?
|
56
|
+
value = value.dump if value.class == String
|
57
|
+
spec += " s.#{attribute} = #{value}\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
spec + " s.source = #{@source}\n\n"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module BJSymbols
|
2
|
+
def symbols_from_library(library)
|
3
|
+
syms = `nm -defined-only -extern-only #{library}`.split("\n")
|
4
|
+
result = classes_from_symbols(syms)
|
5
|
+
result += constants_from_symbols(syms)
|
6
|
+
|
7
|
+
result.select do |e|
|
8
|
+
case e
|
9
|
+
when 'llvm.cmdline', 'llvm.embedded.module', '__clang_at_available_requires_core_foundation_framework'
|
10
|
+
false
|
11
|
+
else
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module_function :symbols_from_library
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def classes_from_symbols(syms)
|
22
|
+
classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
|
23
|
+
classes = classes.uniq
|
24
|
+
classes.map! { |klass| klass.gsub(/^.*\$_/, '') }
|
25
|
+
end
|
26
|
+
|
27
|
+
def constants_from_symbols(syms)
|
28
|
+
consts = syms.select { |const| const[/ S /] }
|
29
|
+
consts = consts.select { |const| const !~ /OBJC|\.eh/ }
|
30
|
+
consts = consts.uniq
|
31
|
+
consts = consts.map! { |const| const.gsub(/^.* _/, '') }
|
32
|
+
|
33
|
+
other_consts = syms.select { |const| const[/ T /] }
|
34
|
+
other_consts = other_consts.uniq
|
35
|
+
other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }
|
36
|
+
|
37
|
+
consts + other_consts
|
38
|
+
end
|
39
|
+
|
40
|
+
module_function :classes_from_symbols
|
41
|
+
module_function :constants_from_symbols
|
42
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'pod/command/package_bj'
|
2
|
+
require 'cocoapods-packager-bj/user_interface/build_failed_report'
|
3
|
+
require 'cocoapods-packager-bj/builder'
|
4
|
+
require 'cocoapods-packager-bj/framework'
|
5
|
+
require 'cocoapods-packager-bj/mangle'
|
6
|
+
require 'cocoapods-packager-bj/pod_utils'
|
7
|
+
require 'cocoapods-packager-bj/spec_builder'
|
8
|
+
require 'cocoapods-packager-bj/symbols'
|
@@ -0,0 +1,181 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class BJPackage < Command
|
5
|
+
self.summary = 'Package a podspec into a static library.'
|
6
|
+
self.arguments = [
|
7
|
+
CLAide::Argument.new('NAME', true),
|
8
|
+
CLAide::Argument.new('SOURCE', false)
|
9
|
+
]
|
10
|
+
|
11
|
+
def self.options
|
12
|
+
[
|
13
|
+
['--force', 'Overwrite existing files.'],
|
14
|
+
['--no-mangle', 'Do not mangle symbols of depedendant Pods.'],
|
15
|
+
['--embedded', 'Generate embedded frameworks.'],
|
16
|
+
['--library', 'Generate static libraries.'],
|
17
|
+
['--dynamic', 'Generate dynamic framework.'],
|
18
|
+
['--modules', 'Generate static swift framework use modules.'],
|
19
|
+
['--local', 'Use local state rather than published versions.'],
|
20
|
+
['--bundle-identifier', 'Bundle identifier for dynamic framework'],
|
21
|
+
['--exclude-deps', 'Exclude symbols from dependencies.'],
|
22
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
23
|
+
['--subspecs', 'Only include the given subspecs'],
|
24
|
+
['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent ' \
|
25
|
+
'pods from (defaults to https://github.com/CocoaPods/Specs.git)']
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@embedded = argv.flag?('embedded')
|
31
|
+
@library = argv.flag?('library')
|
32
|
+
@dynamic = argv.flag?('dynamic')
|
33
|
+
@modules = argv.flag?('modules')
|
34
|
+
@local = argv.flag?('local', false)
|
35
|
+
@package_type = if @modules
|
36
|
+
:module_framework
|
37
|
+
elsif @dynamic
|
38
|
+
:dynamic_framework
|
39
|
+
elsif @library
|
40
|
+
:static_library
|
41
|
+
elsif @embedded
|
42
|
+
:static_framework
|
43
|
+
else
|
44
|
+
:static_framework
|
45
|
+
end
|
46
|
+
@force = argv.flag?('force')
|
47
|
+
@mangle = argv.flag?('mangle', true)
|
48
|
+
@bundle_identifier = argv.option('bundle-identifier', nil)
|
49
|
+
@exclude_deps = argv.flag?('exclude-deps', false)
|
50
|
+
@name = argv.shift_argument
|
51
|
+
@source = argv.shift_argument
|
52
|
+
@spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')
|
53
|
+
|
54
|
+
subspecs = argv.option('subspecs')
|
55
|
+
@subspecs = subspecs.split(',') unless subspecs.nil?
|
56
|
+
|
57
|
+
@config = argv.option('configuration', 'Release')
|
58
|
+
|
59
|
+
@source_dir = Dir.pwd
|
60
|
+
@is_spec_from_path = false
|
61
|
+
@spec = spec_with_path(@name)
|
62
|
+
@is_spec_from_path = true if @spec
|
63
|
+
@spec ||= spec_with_name(@name)
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate!
|
68
|
+
super
|
69
|
+
help! 'A podspec name or path is required.' unless @spec
|
70
|
+
help! 'podspec has binary-only depedencies, mangling not possible.' if @mangle && binary_only?(@spec)
|
71
|
+
help! '--bundle-identifier option can only be used for dynamic frameworks' if @bundle_identifier && !@dynamic
|
72
|
+
help! '--exclude-deps option can only be used for static libraries' if @exclude_deps && @dynamic
|
73
|
+
help! '--local option can only be used when a local `.podspec` path is given.' if @local && !@is_spec_from_path
|
74
|
+
end
|
75
|
+
|
76
|
+
def run
|
77
|
+
if @spec.nil?
|
78
|
+
help! "Unable to find a podspec with path or name `#{@name}`."
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
target_dir, work_dir = create_working_directory
|
83
|
+
return if target_dir.nil?
|
84
|
+
build_package
|
85
|
+
|
86
|
+
`mv "#{work_dir}" "#{target_dir}"`
|
87
|
+
Dir.chdir(@source_dir)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def build_in_sandbox(platform)
|
93
|
+
config.installation_root = Pathname.new(Dir.pwd)
|
94
|
+
config.sandbox_root = 'Pods'
|
95
|
+
|
96
|
+
static_sandbox = build_static_sandbox(@dynamic)
|
97
|
+
static_installer = install_pod(platform.name, static_sandbox, @modules)
|
98
|
+
|
99
|
+
if @dynamic
|
100
|
+
dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
|
101
|
+
install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
|
102
|
+
end
|
103
|
+
|
104
|
+
begin
|
105
|
+
perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
106
|
+
ensure # in case the build fails; see Builder#xcodebuild.
|
107
|
+
Pathname.new(config.sandbox_root).rmtree
|
108
|
+
FileUtils.rm_f('Podfile.lock')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_package
|
113
|
+
builder = BJSpecBuilder.new(@spec, @source, @embedded, @dynamic)
|
114
|
+
newspec = builder.spec_metadata
|
115
|
+
|
116
|
+
@spec.available_platforms.each do |platform|
|
117
|
+
build_in_sandbox(platform)
|
118
|
+
|
119
|
+
newspec += builder.spec_platform(platform)
|
120
|
+
end
|
121
|
+
|
122
|
+
newspec += builder.spec_close
|
123
|
+
File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) }
|
124
|
+
end
|
125
|
+
|
126
|
+
def create_target_directory
|
127
|
+
target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}"
|
128
|
+
if File.exist? target_dir
|
129
|
+
if @force
|
130
|
+
Pathname.new(target_dir).rmtree
|
131
|
+
else
|
132
|
+
UI.puts "Target directory '#{target_dir}' already exists."
|
133
|
+
return nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
target_dir
|
137
|
+
end
|
138
|
+
|
139
|
+
def create_working_directory
|
140
|
+
target_dir = create_target_directory
|
141
|
+
return if target_dir.nil?
|
142
|
+
|
143
|
+
work_dir = Dir.tmpdir + '/cocoapods-' + Array.new(8) { rand(36).to_s(36) }.join
|
144
|
+
Pathname.new(work_dir).mkdir
|
145
|
+
Dir.chdir(work_dir)
|
146
|
+
|
147
|
+
[target_dir, work_dir]
|
148
|
+
end
|
149
|
+
|
150
|
+
def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
151
|
+
static_sandbox_root = config.sandbox_root.to_s
|
152
|
+
|
153
|
+
if @dynamic
|
154
|
+
static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}"
|
155
|
+
dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}"
|
156
|
+
end
|
157
|
+
|
158
|
+
builder = Pod::BJBuilder.new(
|
159
|
+
platform,
|
160
|
+
static_installer,
|
161
|
+
@source_dir,
|
162
|
+
static_sandbox_root,
|
163
|
+
dynamic_sandbox_root,
|
164
|
+
static_sandbox.public_headers.root,
|
165
|
+
@spec,
|
166
|
+
@embedded,
|
167
|
+
@mangle,
|
168
|
+
@dynamic,
|
169
|
+
@config,
|
170
|
+
@bundle_identifier,
|
171
|
+
@exclude_deps
|
172
|
+
)
|
173
|
+
|
174
|
+
builder.build(@package_type)
|
175
|
+
|
176
|
+
return unless @embedded
|
177
|
+
builder.link_embedded_resources
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-packager-bj
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyle Fuller
|
8
|
+
- Boris Bügling
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cocoapods
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.1.1
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '2.0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.1.1
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: bundler
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
type: :development
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description:
|
63
|
+
email:
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- cocoapods_packager-bj.gemspec
|
72
|
+
- lib/cocoapods-packager-bj/builder.rb
|
73
|
+
- lib/cocoapods-packager-bj/framework.rb
|
74
|
+
- lib/cocoapods-packager-bj/mangle.rb
|
75
|
+
- lib/cocoapods-packager-bj/pod_utils.rb
|
76
|
+
- lib/cocoapods-packager-bj/spec_builder.rb
|
77
|
+
- lib/cocoapods-packager-bj/symbols.rb
|
78
|
+
- lib/cocoapods-packager-bj/user_interface/build_failed_report.rb
|
79
|
+
- lib/cocoapods_packager_bj.rb
|
80
|
+
- lib/cocoapods_plugin.rb
|
81
|
+
- lib/pod/command/package_bj.rb
|
82
|
+
homepage: https://github.com/Afirefish/cocoapods_packager-bj
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.0.3
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Based on cocoapods-packager code, support swift framework, generate a framework
|
105
|
+
or static library from a podspec.
|
106
|
+
test_files: []
|