cocoapods-imy-bin 0.2.9.1 → 0.3.0.11
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 +5 -5
- data/lib/cocoapods-imy-bin/command/bin/archive.rb +41 -4
- data/lib/cocoapods-imy-bin/command/bin/auto.rb +7 -5
- data/lib/cocoapods-imy-bin/command/bin/local.rb +16 -7
- data/lib/cocoapods-imy-bin/config/config_builder.rb +39 -2
- data/lib/cocoapods-imy-bin/gem_version.rb +1 -1
- data/lib/cocoapods-imy-bin/helpers.rb +1 -0
- data/lib/cocoapods-imy-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-imy-bin/helpers/build_helper.rb +15 -7
- data/lib/cocoapods-imy-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-imy-bin/helpers/framework.rb +25 -2
- data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +145 -44
- data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +38 -6
- data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +20 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +91 -38
- data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +65 -8
- data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +8 -3
- data/lib/cocoapods-imy-bin/native.rb +4 -0
- data/lib/cocoapods-imy-bin/native/analyzer.rb +2 -0
- data/lib/cocoapods-imy-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-imy-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-imy-bin/native/podfile_generator.rb +11 -2
- data/lib/cocoapods-imy-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-imy-bin/native/validator.rb +1 -38
- metadata +9 -3
@@ -4,6 +4,7 @@ require 'cocoapods-imy-bin/helpers/framework.rb'
|
|
4
4
|
require 'English'
|
5
5
|
require 'cocoapods-imy-bin/config/config_builder'
|
6
6
|
require 'shellwords'
|
7
|
+
require 'cocoapods-imy-bin/helpers/build_utils'
|
7
8
|
|
8
9
|
module CBin
|
9
10
|
class Framework
|
@@ -38,26 +39,54 @@ module CBin
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def lipo_build(defines)
|
41
|
-
UI.section("Building static Library #{@spec}") do
|
42
|
-
# defines = compile
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
if CBin::Build::Utils.is_swift_module(@spec) || !CBin::Build::Utils.uses_frameworks?
|
44
|
+
UI.section("Building static Library #{@spec}") do
|
45
|
+
# defines = compile
|
46
46
|
|
47
|
-
|
47
|
+
# build_sim_libraries(defines)
|
48
|
+
output = framework.versions_path + Pathname.new(@spec.name)
|
48
49
|
|
49
|
-
|
50
|
-
copy_license
|
51
|
-
copy_resources
|
50
|
+
build_static_library_for_ios(output)
|
52
51
|
|
53
|
-
|
52
|
+
copy_headers
|
53
|
+
copy_license
|
54
|
+
copy_resources
|
55
|
+
|
56
|
+
cp_to_source_dir
|
57
|
+
end
|
58
|
+
else
|
59
|
+
# begin
|
60
|
+
UI.section("Building framework #{@spec}") do
|
61
|
+
# defines = compile
|
62
|
+
|
63
|
+
# build_sim_libraries(defines)
|
64
|
+
output = framework.fwk_path + Pathname.new(@spec.name)
|
65
|
+
|
66
|
+
copy_static_framework_dir_for_ios
|
67
|
+
|
68
|
+
build_static_framework_machO_for_ios(output)
|
69
|
+
|
70
|
+
# copy_license
|
71
|
+
copy_framework_resources
|
72
|
+
|
73
|
+
#cp_to_source_dir#
|
74
|
+
|
75
|
+
# rescue Object => exception
|
76
|
+
# UI.puts exception
|
77
|
+
# end
|
78
|
+
end
|
54
79
|
end
|
80
|
+
|
55
81
|
framework
|
56
82
|
end
|
57
83
|
|
58
84
|
private
|
59
85
|
|
60
86
|
def cp_to_source_dir
|
87
|
+
# 删除Versions 软链接
|
88
|
+
framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec)
|
89
|
+
|
61
90
|
framework_name = "#{@spec.name}.framework"
|
62
91
|
target_dir = File.join(CBin::Config::Builder.instance.zip_dir,framework_name)
|
63
92
|
FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
|
@@ -92,33 +121,21 @@ module CBin
|
|
92
121
|
def build_static_library_for_ios(output)
|
93
122
|
UI.message "Building ios libraries with archs #{ios_architectures}"
|
94
123
|
static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
# end
|
124
|
+
|
125
|
+
ios_architectures.map do |arch|
|
126
|
+
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
|
127
|
+
end
|
128
|
+
ios_architectures_sim do |arch|
|
129
|
+
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
|
130
|
+
end
|
103
131
|
|
104
132
|
build_path = Pathname("build")
|
105
133
|
build_path.mkpath unless build_path.exist?
|
106
134
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
# else
|
113
|
-
# libs = ios_architectures.map do |arch|
|
114
|
-
# library = "build/package-#{@spec.name}-#{arch}.a"
|
115
|
-
# # libtool -arch_only arm64 -static -o build/package-armv64.a build/libIMYFoundation.a build-simulator/libIMYFoundation.a
|
116
|
-
# # 从liBFoundation.a 文件中,提取出 arm64 架构的文件,命名为build/package-armv64.a
|
117
|
-
# UI.message "libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}"
|
118
|
-
# `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
|
119
|
-
# library
|
120
|
-
# end
|
121
|
-
# end
|
135
|
+
libs = (ios_architectures + ios_architectures_sim) .map do |arch|
|
136
|
+
library = "build-#{arch}/lib#{@spec.name}.a"
|
137
|
+
library
|
138
|
+
end
|
122
139
|
|
123
140
|
UI.message "lipo -create -output #{output} #{libs.join(' ')}"
|
124
141
|
`lipo -create -output #{output} #{libs.join(' ')}`
|
@@ -182,11 +199,11 @@ module CBin
|
|
182
199
|
def target_name
|
183
200
|
#区分多平台,如配置了多平台,会带上平台的名字
|
184
201
|
# 如libwebp-iOS
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
202
|
+
if @spec.available_platforms.count > 1
|
203
|
+
"#{@spec.name}-#{Platform.string_name(@spec.consumer(@platform).platform_name)}"
|
204
|
+
else
|
205
|
+
@spec.name
|
206
|
+
end
|
190
207
|
end
|
191
208
|
|
192
209
|
def xcodebuild(defines = '', args = '', build_dir = 'build', build_model = 'Debug')
|
@@ -244,10 +261,10 @@ module CBin
|
|
244
261
|
if Pathname(module_map_file).exist?
|
245
262
|
module_map = File.read(module_map_file)
|
246
263
|
end
|
247
|
-
elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
|
264
|
+
elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
|
248
265
|
module_map = <<-MAP
|
249
266
|
framework module #{@spec.name} {
|
250
|
-
umbrella header "#{@spec.name}.h"
|
267
|
+
umbrella header "#{@spec.name}-umbrella.h"
|
251
268
|
|
252
269
|
export *
|
253
270
|
module * { export * }
|
@@ -261,9 +278,29 @@ module CBin
|
|
261
278
|
framework.module_map_path.mkpath
|
262
279
|
end
|
263
280
|
File.write("#{framework.module_map_path}/module.modulemap", module_map)
|
281
|
+
|
282
|
+
# unless framework.swift_module_path.exist?
|
283
|
+
# framework.swift_module_path.mkpath
|
284
|
+
# end
|
285
|
+
# todo 所有架构的swiftModule拷贝到 framework.swift_module_path
|
286
|
+
archs = ios_architectures + ios_architectures_sim
|
287
|
+
archs.map do |arch|
|
288
|
+
swift_module = "build-#{arch}/#{@spec.name}.swiftmodule"
|
289
|
+
if File.directory?(swift_module)
|
290
|
+
FileUtils.cp_r("#{swift_module}/.", framework.swift_module_path)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
swift_Compatibility_Header = "build-#{archs.first}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
|
294
|
+
FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header)
|
295
|
+
info_plist_file = File.join(File.dirname(__FILE__),"info.plist")
|
296
|
+
FileUtils.cp(info_plist_file,framework.fwk_path)
|
264
297
|
end
|
265
298
|
end
|
266
299
|
|
300
|
+
def copy_swift_header
|
301
|
+
|
302
|
+
end
|
303
|
+
|
267
304
|
def copy_license
|
268
305
|
UI.message 'Copying license'
|
269
306
|
license_file = @spec.license[:file] || 'LICENSE'
|
@@ -296,13 +333,18 @@ module CBin
|
|
296
333
|
`cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
|
297
334
|
end
|
298
335
|
|
299
|
-
|
300
|
-
unless
|
301
|
-
spec_source_dir = File.join(Dir.pwd,"
|
336
|
+
real_source_dir = @source_dir
|
337
|
+
unless @isRootSpec
|
338
|
+
spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
|
339
|
+
unless File.exist?(spec_source_dir)
|
340
|
+
spec_source_dir = File.join(Dir.pwd,"Pods/#{@spec.name}")
|
341
|
+
end
|
342
|
+
raise "copy_resources #{spec_source_dir} no exist " unless File.exist?(spec_source_dir)
|
343
|
+
|
344
|
+
spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
|
345
|
+
real_source_dir = spec_source_dir
|
302
346
|
end
|
303
|
-
raise "copy_resources #{spec_source_dir} no exist " unless File.exist?(spec_source_dir)
|
304
347
|
|
305
|
-
real_source_dir = @isRootSpec ? @source_dir : spec_source_dir
|
306
348
|
resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
307
349
|
expand_paths(real_source_dir, spec.consumer(@platform).resources)
|
308
350
|
end.compact.uniq
|
@@ -329,6 +371,65 @@ module CBin
|
|
329
371
|
end
|
330
372
|
end
|
331
373
|
|
374
|
+
#---------------------------------swift--------------------------------------#
|
375
|
+
# lipo -create .a
|
376
|
+
def build_static_framework_machO_for_ios(output)
|
377
|
+
UI.message "Building ios framework with archs #{ios_architectures}"
|
378
|
+
|
379
|
+
static_libs = static_libs_in_sandbox('build') + @vendored_libraries
|
380
|
+
ios_architectures.map do |arch|
|
381
|
+
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
|
382
|
+
end
|
383
|
+
|
384
|
+
ios_architectures_sim do |arch|
|
385
|
+
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
|
386
|
+
end
|
387
|
+
|
388
|
+
build_path = Pathname("build")
|
389
|
+
build_path.mkpath unless build_path.exist?
|
390
|
+
|
391
|
+
libs = (ios_architectures + ios_architectures_sim) .map do |arch|
|
392
|
+
library = "build-#{arch}/#{@spec.name}.framework/#{@spec.name}"
|
393
|
+
library
|
394
|
+
end
|
395
|
+
|
396
|
+
UI.message "lipo -create -output #{output} #{libs.join(' ')}"
|
397
|
+
`lipo -create -output #{output} #{libs.join(' ')}`
|
398
|
+
end
|
399
|
+
|
400
|
+
def copy_static_framework_dir_for_ios
|
401
|
+
|
402
|
+
archs = ios_architectures + ios_architectures_sim
|
403
|
+
framework_dir = "build-#{ios_architectures_sim.first}/#{@spec.name}.framework"
|
404
|
+
framework_dir = "build-#{ios_architectures.first}/#{@spec.name}.framework" unless File.exist?(framework_dir)
|
405
|
+
unless File.exist?(framework_dir)
|
406
|
+
raise "#{framework_dir} path no exist"
|
407
|
+
end
|
408
|
+
File.join(Dir.pwd, "build-#{ios_architectures_sim.first}/#{@spec.name}.framework")
|
409
|
+
FileUtils.cp_r(framework_dir, framework.root_path)
|
410
|
+
|
411
|
+
# todo 所有架构的swiftModule拷贝到 framework.swift_module_path
|
412
|
+
archs.map do |arch|
|
413
|
+
swift_module = "build-#{arch}/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule"
|
414
|
+
if File.directory?(swift_module)
|
415
|
+
FileUtils.cp_r("#{swift_module}/.", framework.swift_module_path)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
# 删除Versions 软链接
|
420
|
+
framework.remove_current_version
|
421
|
+
end
|
422
|
+
|
423
|
+
def copy_framework_resources
|
424
|
+
resources = Dir.glob("#{framework.fwk_path + Pathname.new('Resources')}/*")
|
425
|
+
if resources.count == 0
|
426
|
+
framework.delete_resources
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
|
431
|
+
#---------------------------------getter and setter--------------------------------------#
|
432
|
+
|
332
433
|
def framework
|
333
434
|
@framework ||= begin
|
334
435
|
framework = Framework.new(@spec.name, @platform.name.to_s)
|
@@ -34,15 +34,20 @@ module CBin
|
|
34
34
|
@local_build_dir = local_build_dir
|
35
35
|
@clean = clean
|
36
36
|
@framework_path
|
37
|
+
@is_library = !is_framework
|
37
38
|
end
|
38
39
|
|
39
40
|
def build
|
40
41
|
UI.section("Building static framework #{@spec}") do
|
41
42
|
|
42
43
|
build_static_framework
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
if @is_library
|
45
|
+
build_static_library
|
46
|
+
zip_static_framework if @zip &&= @framework_output
|
47
|
+
zip_static_library
|
48
|
+
else
|
49
|
+
zip_static_framework
|
50
|
+
end
|
46
51
|
|
47
52
|
clean_workspace if @clean
|
48
53
|
end
|
@@ -52,7 +57,7 @@ module CBin
|
|
52
57
|
def build_static_framework
|
53
58
|
file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
|
54
59
|
Dir.chdir(workspace_directory) do
|
55
|
-
builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir)
|
60
|
+
builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir, @is_library, frameWork_dir)
|
56
61
|
@framework_path = builder.create
|
57
62
|
end
|
58
63
|
end
|
@@ -68,9 +73,10 @@ module CBin
|
|
68
73
|
|
69
74
|
def zip_static_framework
|
70
75
|
Dir.chdir(zip_dir) do
|
71
|
-
output_name = "#{framework_name}.zip"
|
76
|
+
# output_name = "#{framework_name}.zip"
|
77
|
+
output_name = File.join(zip_dir, framework_name_zip)
|
72
78
|
unless File.exist?(framework_name)
|
73
|
-
|
79
|
+
UI.warn "没有需要压缩的 framework 文件:#{framework_name}"
|
74
80
|
end
|
75
81
|
|
76
82
|
UI.puts "Compressing #{framework_name} into #{output_name}"
|
@@ -110,6 +116,10 @@ module CBin
|
|
110
116
|
CBin::Config::Builder.instance.framework_name(@spec)
|
111
117
|
end
|
112
118
|
|
119
|
+
def framework_name_zip
|
120
|
+
CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
|
121
|
+
end
|
122
|
+
|
113
123
|
def library_name
|
114
124
|
CBin::Config::Builder.instance.library_name(@spec)
|
115
125
|
end
|
@@ -126,6 +136,28 @@ module CBin
|
|
126
136
|
CBin::Config::Builder.instance.gen_name
|
127
137
|
end
|
128
138
|
|
139
|
+
def is_library
|
140
|
+
File.exist?(File.join(@local_build_dir, "lib#{@spec.name}.a"))
|
141
|
+
end
|
142
|
+
|
143
|
+
# 使用了user_framework 会有#{@spec.name}.framework
|
144
|
+
# 未使用的 需要判断文件
|
145
|
+
def is_framework
|
146
|
+
res = File.exist?(File.join(@local_build_dir, "#{@spec.name}.framework"))
|
147
|
+
unless res
|
148
|
+
res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}","Swift Compatibility Header"))
|
149
|
+
end
|
150
|
+
res
|
151
|
+
end
|
152
|
+
|
153
|
+
def frameWork_dir
|
154
|
+
dir = File.join(@local_build_dir, "#{@spec.name}.framework")
|
155
|
+
unless File.exist?(dir)
|
156
|
+
dir = File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}")
|
157
|
+
end
|
158
|
+
dir
|
159
|
+
end
|
160
|
+
|
129
161
|
def spec_file
|
130
162
|
@spec_file ||= begin
|
131
163
|
if @podspec
|
@@ -9,6 +9,8 @@ module CBin
|
|
9
9
|
attr_reader :resources_path
|
10
10
|
attr_reader :root_path
|
11
11
|
attr_reader :versions_path
|
12
|
+
attr_reader :swift_module_path
|
13
|
+
attr_reader :fwk_path
|
12
14
|
|
13
15
|
def initialize(name, platform, local_build_dir)
|
14
16
|
@name = name
|
@@ -29,6 +31,21 @@ module CBin
|
|
29
31
|
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
30
32
|
end
|
31
33
|
|
34
|
+
def remove_current_version
|
35
|
+
FileUtils.rm_f(File.join(@fwk_path,@name))
|
36
|
+
FileUtils.rm_f(File.join(@fwk_path,"Headers"))
|
37
|
+
FileUtils.rm_f(File.join(@fwk_path,"Resources"))
|
38
|
+
|
39
|
+
FileUtils.cp_r("#{@versions_path}/.", @fwk_path)
|
40
|
+
# FileUtils.remove_dir(@versions_path)
|
41
|
+
FileUtils.remove_dir("#{@fwk_path}/Versions")
|
42
|
+
|
43
|
+
# current_version_path = @versions_path + Pathname.new('../Current')
|
44
|
+
# `ln -sf A #{current_version_path}`
|
45
|
+
# `ln -sf Versions/Current/Headers #{@fwk_path}/`
|
46
|
+
# `ln -sf Versions/Current/Resources #{@fwk_path}/`
|
47
|
+
# `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
|
48
|
+
end
|
32
49
|
private
|
33
50
|
|
34
51
|
def make_current_version
|
@@ -41,10 +58,13 @@ module CBin
|
|
41
58
|
|
42
59
|
def make_framework
|
43
60
|
@fwk_path = @root_path + Pathname.new(@name + '.framework')
|
61
|
+
FileUtils.remove_dir(@fwk_path) if @fwk_path.exist?
|
44
62
|
@fwk_path.mkdir unless @fwk_path.exist?
|
45
63
|
|
46
64
|
@module_map_path = @fwk_path + Pathname.new('Modules')
|
47
65
|
@versions_path = @fwk_path + Pathname.new('Versions/A')
|
66
|
+
@fwk_path.exist?
|
67
|
+
@swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
|
48
68
|
end
|
49
69
|
|
50
70
|
def make_headers
|
@@ -12,31 +12,55 @@ module CBin
|
|
12
12
|
class Builder
|
13
13
|
include Pod
|
14
14
|
#Debug下还待完成
|
15
|
-
def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir)
|
15
|
+
def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir, is_library = true, framework_BuildProductsPath = "")
|
16
16
|
@spec = spec
|
17
17
|
@file_accessor = file_accessor
|
18
18
|
@platform = platform
|
19
19
|
@local_build_dir_name = local_build_dir_name
|
20
20
|
@local_build_dir = local_build_dir
|
21
|
+
@is_library = is_library
|
22
|
+
@framework_BuildProductsPath = framework_BuildProductsPath
|
21
23
|
end
|
22
24
|
|
23
25
|
def create
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
begin
|
27
|
+
#如果是.a 文件, 或者 swift下,是.a文件的
|
28
|
+
if @is_library || (!@is_library && @framework_BuildProductsPath != framework_name)
|
29
|
+
|
30
|
+
UI.section("Building static library #{@spec}") do
|
31
|
+
output = framework.versions_path + Pathname.new(@spec.name)
|
32
|
+
build_static_library_for_ios(output)
|
33
|
+
res = copy_headers
|
34
|
+
# maybe fails for copy_headers
|
35
|
+
if res
|
36
|
+
copy_resources
|
37
|
+
cp_to_source_dir
|
38
|
+
else
|
39
|
+
FileUtils.remove_dir(framework.fwk_path) if File.exist?(framework.fwk_path)
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
end
|
28
43
|
|
29
|
-
|
30
|
-
|
44
|
+
else
|
45
|
+
UI.section("Building static framework #{@spec}") do
|
46
|
+
output = File.join(CBin::Config::Builder.instance.zip_dir,"#{@spec.name}.framework")
|
47
|
+
build_static_framework_for_ios(output)
|
48
|
+
end
|
49
|
+
end
|
31
50
|
|
32
|
-
|
51
|
+
rescue StandardError
|
52
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本组装失败 ."
|
33
53
|
end
|
54
|
+
|
34
55
|
framework
|
35
56
|
end
|
36
57
|
|
37
58
|
private
|
38
59
|
|
39
60
|
def cp_to_source_dir
|
61
|
+
# 删除Versions 软链接
|
62
|
+
framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec)
|
63
|
+
|
40
64
|
target_dir = File.join(CBin::Config::Builder.instance.root_dir,CBin::Config::Builder.instance.framework_file(@spec))
|
41
65
|
FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
|
42
66
|
|
@@ -46,58 +70,80 @@ module CBin
|
|
46
70
|
`cp -fa #{@platform}/#{CBin::Config::Builder.instance.framework_name(@spec)} #{target_dir}`
|
47
71
|
end
|
48
72
|
|
73
|
+
|
49
74
|
def copy_headers
|
50
75
|
#by slj 如果没有头文件,去 "Headers/Public"拿
|
51
76
|
# if public_headers.empty?
|
52
77
|
Dir.chdir(File.join(Pod::Config.instance.installation_root,'Pods')) do
|
53
78
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
headers = Dir.glob('*.h')
|
58
|
-
headers.each do |h|
|
59
|
-
public_headers << Pathname.new(File.join(Dir.pwd,h))
|
60
|
-
end
|
61
|
-
end
|
79
|
+
if File.exist?("./Headers/Public/#{@spec.name}")
|
80
|
+
#走 podsepc中的public_headers
|
81
|
+
public_headers = Array.new
|
62
82
|
|
63
|
-
|
83
|
+
Dir.chdir("./Headers/Public/#{@spec.name}") do
|
84
|
+
headers = Dir.glob('*.h')
|
85
|
+
headers.each do |h|
|
86
|
+
public_headers << Pathname.new(File.join(Dir.pwd,h))
|
87
|
+
end
|
88
|
+
end
|
64
89
|
|
65
|
-
|
66
|
-
`ditto #{h} #{framework.headers_path}/#{h.basename}`
|
67
|
-
end
|
90
|
+
UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
|
68
91
|
|
69
|
-
|
70
|
-
|
71
|
-
# create a default 'module_map' one using it.
|
72
|
-
if !@spec.module_map.nil?
|
73
|
-
module_map_file = @file_accessor.module_map
|
74
|
-
if Pathname(module_map_file).exist?
|
75
|
-
module_map = File.read(module_map_file)
|
92
|
+
public_headers.each do |h|
|
93
|
+
`ditto #{h} #{framework.headers_path}/#{h.basename}`
|
76
94
|
end
|
77
|
-
|
78
|
-
module_map
|
95
|
+
|
96
|
+
# If custom 'module_map' is specified add it to the framework distribution
|
97
|
+
# otherwise check if a header exists that is equal to 'spec.name', if so
|
98
|
+
# create a default 'module_map' one using it.
|
99
|
+
if !@spec.module_map.nil?
|
100
|
+
module_map_file = @file_accessor.module_map
|
101
|
+
if Pathname(module_map_file).exist?
|
102
|
+
module_map = File.read(module_map_file)
|
103
|
+
end
|
104
|
+
elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
|
105
|
+
module_map = <<-MAP
|
79
106
|
framework module #{@spec.name} {
|
80
|
-
umbrella header "#{@spec.name}.h"
|
107
|
+
umbrella header "#{@spec.name}-umbrella.h"
|
81
108
|
|
82
109
|
export *
|
83
110
|
module * { export * }
|
84
111
|
}
|
85
|
-
|
86
|
-
|
112
|
+
MAP
|
113
|
+
end
|
87
114
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
115
|
+
unless module_map.nil?
|
116
|
+
UI.message "Writing module map #{module_map}"
|
117
|
+
unless framework.module_map_path.exist?
|
118
|
+
framework.module_map_path.mkpath
|
119
|
+
end
|
120
|
+
File.write("#{framework.module_map_path}/module.modulemap", module_map)
|
121
|
+
|
122
|
+
# unless framework.swift_module_path.exist?
|
123
|
+
# framework.swift_module_path.mkpath
|
124
|
+
# end
|
125
|
+
# DO BuildProductsPath swiftModule拷贝到 framework.swift_module_path
|
126
|
+
swiftmodule_path = File.join(@framework_BuildProductsPath, "#{@spec.name}.swiftmodule")
|
127
|
+
if File.directory?(swiftmodule_path)
|
128
|
+
FileUtils.cp_r("#{swiftmodule_path}/.", framework.swift_module_path)
|
129
|
+
end
|
130
|
+
swift_Compatibility_Header = "#{@framework_BuildProductsPath}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
|
131
|
+
FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header)
|
132
|
+
info_plist_file = File.join(File.dirname(File.dirname(__FILE__)),"info.plist")
|
133
|
+
FileUtils.cp(info_plist_file,framework.fwk_path)
|
92
134
|
end
|
93
|
-
|
135
|
+
else
|
136
|
+
UI.warn "== Headers/Public/#{@spec.name} no exist"
|
137
|
+
return false
|
94
138
|
end
|
95
139
|
|
96
140
|
end
|
141
|
+
return true
|
97
142
|
end
|
98
143
|
|
99
144
|
def copy_resources
|
100
145
|
|
146
|
+
|
101
147
|
Dir.chdir(Pod::Config.instance.sandbox_root) do
|
102
148
|
|
103
149
|
bundles = Dir.glob('./build/*.bundle')
|
@@ -126,7 +172,7 @@ module CBin
|
|
126
172
|
expand_paths(real_source_dir, spec.consumer(@platform).resources)
|
127
173
|
end.compact.uniq
|
128
174
|
|
129
|
-
if resources.count == 0 && bundles.count == 0
|
175
|
+
if (resources.count == 0 || (resources.count == 1 && resources[0].count == 0)) && bundles.count == 0
|
130
176
|
framework.delete_resources
|
131
177
|
return
|
132
178
|
end
|
@@ -150,10 +196,17 @@ module CBin
|
|
150
196
|
`cp -rp #{library_name} #{output}`
|
151
197
|
end
|
152
198
|
|
199
|
+
def build_static_framework_for_ios(output)
|
200
|
+
FileUtils.cp_r(framework_name, output)
|
201
|
+
end
|
202
|
+
|
153
203
|
def library_name
|
154
204
|
File.join(@local_build_dir, "lib#{@spec.name}.a")
|
155
205
|
end
|
156
206
|
|
207
|
+
def framework_name
|
208
|
+
File.join(@local_build_dir, "#{@spec.name}.framework")
|
209
|
+
end
|
157
210
|
|
158
211
|
def expand_paths(source_dir, path_specs)
|
159
212
|
path_specs.map do |path_spec|
|