cocoapods-imy-bin 0.2.1
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 +22 -0
- data/README.md +541 -0
- data/lib/cocoapods-imy-bin.rb +2 -0
- data/lib/cocoapods-imy-bin/command.rb +2 -0
- data/lib/cocoapods-imy-bin/command/bin.rb +60 -0
- data/lib/cocoapods-imy-bin/command/bin/archive.rb +184 -0
- data/lib/cocoapods-imy-bin/command/bin/auto.rb +188 -0
- data/lib/cocoapods-imy-bin/command/bin/code.rb +237 -0
- data/lib/cocoapods-imy-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-imy-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-imy-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-imy-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-imy-bin/command/bin/local.rb +156 -0
- data/lib/cocoapods-imy-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-imy-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-imy-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-imy-bin/command/bin/update.rb +148 -0
- data/lib/cocoapods-imy-bin/config/config.rb +137 -0
- data/lib/cocoapods-imy-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-imy-bin/config/config_builder.rb +179 -0
- data/lib/cocoapods-imy-bin/config/config_hot_key.rb +103 -0
- data/lib/cocoapods-imy-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-imy-bin/gem_version.rb +10 -0
- data/lib/cocoapods-imy-bin/helpers.rb +4 -0
- data/lib/cocoapods-imy-bin/helpers/build_helper.rb +150 -0
- data/lib/cocoapods-imy-bin/helpers/framework.rb +62 -0
- data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +307 -0
- data/lib/cocoapods-imy-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-imy-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +57 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +146 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +65 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +174 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +92 -0
- data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +33 -0
- data/lib/cocoapods-imy-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-imy-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +171 -0
- data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +84 -0
- data/lib/cocoapods-imy-bin/native.rb +19 -0
- data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-imy-bin/native/analyzer.rb +53 -0
- data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-imy-bin/native/installer.rb +115 -0
- data/lib/cocoapods-imy-bin/native/linter.rb +26 -0
- data/lib/cocoapods-imy-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-imy-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-imy-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-imy-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-imy-bin/native/podfile_generator.rb +190 -0
- data/lib/cocoapods-imy-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-imy-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-imy-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-imy-bin/native/source.rb +35 -0
- data/lib/cocoapods-imy-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-imy-bin/native/specification.rb +31 -0
- data/lib/cocoapods-imy-bin/native/validator.rb +77 -0
- data/lib/cocoapods-imy-bin/source_provider_hook.rb +54 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +180 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Framework
|
5
|
+
attr_reader :headers_path
|
6
|
+
attr_reader :module_map_path
|
7
|
+
attr_reader :resources_path
|
8
|
+
attr_reader :root_path
|
9
|
+
attr_reader :versions_path
|
10
|
+
|
11
|
+
def initialize(name, platform)
|
12
|
+
@name = name
|
13
|
+
@platform = platform
|
14
|
+
end
|
15
|
+
|
16
|
+
def make
|
17
|
+
make_root
|
18
|
+
make_framework
|
19
|
+
make_headers
|
20
|
+
make_resources
|
21
|
+
make_current_version
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_resources
|
25
|
+
Pathname.new(@resources_path).rmtree
|
26
|
+
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def make_current_version
|
32
|
+
current_version_path = @versions_path + Pathname.new('../Current')
|
33
|
+
`ln -sf A #{current_version_path}`
|
34
|
+
`ln -sf Versions/Current/Headers #{@fwk_path}/`
|
35
|
+
`ln -sf Versions/Current/Resources #{@fwk_path}/`
|
36
|
+
`ln -sf Versions/Current/#{@name} #{@fwk_path}/`
|
37
|
+
end
|
38
|
+
|
39
|
+
def make_framework
|
40
|
+
@fwk_path = @root_path + Pathname.new(@name + '.framework')
|
41
|
+
@fwk_path.mkdir unless @fwk_path.exist?
|
42
|
+
|
43
|
+
@module_map_path = @fwk_path + Pathname.new('Modules')
|
44
|
+
@versions_path = @fwk_path + Pathname.new('Versions/A')
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_headers
|
48
|
+
@headers_path = @versions_path + Pathname.new('Headers')
|
49
|
+
@headers_path.mkpath unless @headers_path.exist?
|
50
|
+
end
|
51
|
+
|
52
|
+
def make_resources
|
53
|
+
@resources_path = @versions_path + Pathname.new('Resources')
|
54
|
+
@resources_path.mkpath unless @resources_path.exist?
|
55
|
+
end
|
56
|
+
|
57
|
+
def make_root
|
58
|
+
@root_path = Pathname.new(@platform)
|
59
|
+
@root_path.mkpath unless @root_path.exist?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,307 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
require 'cocoapods-imy-bin/helpers/framework.rb'
|
4
|
+
require 'English'
|
5
|
+
require 'cocoapods-imy-bin/config/config_builder'
|
6
|
+
require 'shellwords'
|
7
|
+
|
8
|
+
module CBin
|
9
|
+
class Framework
|
10
|
+
class Builder
|
11
|
+
include Pod
|
12
|
+
#Debug下还待完成
|
13
|
+
def initialize(spec, file_accessor, platform, source_dir, isRootSpec = true, build_model="Release")
|
14
|
+
@spec = spec
|
15
|
+
@source_dir = source_dir
|
16
|
+
@file_accessor = file_accessor
|
17
|
+
@platform = platform
|
18
|
+
@build_model = build_model
|
19
|
+
@isRootSpec = isRootSpec
|
20
|
+
#vendored_static_frameworks 只有 xx.framework 需要拼接为 xx.framework/xx by slj
|
21
|
+
vendored_static_frameworks = file_accessor.vendored_static_frameworks.map do |framework|
|
22
|
+
path = framework
|
23
|
+
extn = File.extname path
|
24
|
+
if extn.downcase == '.framework'
|
25
|
+
path = File.join(path,File.basename(path, extn))
|
26
|
+
end
|
27
|
+
path
|
28
|
+
end
|
29
|
+
|
30
|
+
@vendored_libraries = (vendored_static_frameworks + file_accessor.vendored_static_libraries).map(&:to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
def build
|
34
|
+
defines = compile
|
35
|
+
build_sim_libraries(defines)
|
36
|
+
|
37
|
+
defines
|
38
|
+
end
|
39
|
+
|
40
|
+
def lipo_build(defines)
|
41
|
+
UI.section("Building static framework #{@spec}") do
|
42
|
+
# defines = compile
|
43
|
+
|
44
|
+
# build_sim_libraries(defines)
|
45
|
+
output = framework.versions_path + Pathname.new(@spec.name)
|
46
|
+
|
47
|
+
build_static_library_for_ios(output)
|
48
|
+
|
49
|
+
copy_headers
|
50
|
+
copy_license
|
51
|
+
copy_resources
|
52
|
+
|
53
|
+
cp_to_source_dir
|
54
|
+
end
|
55
|
+
framework
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def cp_to_source_dir
|
61
|
+
framework_name = "#{@spec.name}.framework"
|
62
|
+
target_dir = File.join(CBin::Config::Builder.instance.zip_dir,framework_name)
|
63
|
+
FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
|
64
|
+
|
65
|
+
zip_dir = CBin::Config::Builder.instance.zip_dir
|
66
|
+
FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
|
67
|
+
|
68
|
+
`cp -fa #{@platform}/#{framework_name} #{target_dir}`
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_sim_libraries(defines)
|
72
|
+
UI.message 'Building simulator libraries'
|
73
|
+
|
74
|
+
if is_debug_model
|
75
|
+
# archs = %w[i386 x86_64]
|
76
|
+
archs = %w[x86_64]
|
77
|
+
archs.map do |arch|
|
78
|
+
xcodebuild(defines, "-sdk iphonesimulator ARCHS=\'#{arch}\' ", "build-#{arch}","Debug")
|
79
|
+
end
|
80
|
+
else
|
81
|
+
xcodebuild(defines, "-sdk iphonesimulator ", 'build-simulator')
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
def copy_headers
|
87
|
+
#走 podsepc中的public_headers
|
88
|
+
public_headers = Array.new
|
89
|
+
|
90
|
+
#by slj 如果没有头文件,去 "Headers/Public"拿
|
91
|
+
# if public_headers.empty?
|
92
|
+
Dir.chdir("./Headers/Public/#{@spec.name}") do
|
93
|
+
headers = Dir.glob('*.h')
|
94
|
+
headers.each do |h|
|
95
|
+
public_headers << Pathname.new(File.join(Dir.pwd,h))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
# end
|
99
|
+
|
100
|
+
# UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
|
101
|
+
|
102
|
+
public_headers.each do |h|
|
103
|
+
`ditto #{h} #{framework.headers_path}/#{h.basename}`
|
104
|
+
end
|
105
|
+
|
106
|
+
# If custom 'module_map' is specified add it to the framework distribution
|
107
|
+
# otherwise check if a header exists that is equal to 'spec.name', if so
|
108
|
+
# create a default 'module_map' one using it.
|
109
|
+
if !@spec.module_map.nil?
|
110
|
+
module_map_file = @file_accessor.module_map
|
111
|
+
if Pathname(module_map_file).exist?
|
112
|
+
module_map = File.read(module_map_file)
|
113
|
+
end
|
114
|
+
elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
|
115
|
+
module_map = <<-MAP
|
116
|
+
framework module #{@spec.name} {
|
117
|
+
umbrella header "#{@spec.name}.h"
|
118
|
+
|
119
|
+
export *
|
120
|
+
module * { export * }
|
121
|
+
}
|
122
|
+
MAP
|
123
|
+
end
|
124
|
+
|
125
|
+
unless module_map.nil?
|
126
|
+
UI.message "Writing module map #{module_map}"
|
127
|
+
unless framework.module_map_path.exist?
|
128
|
+
framework.module_map_path.mkpath
|
129
|
+
end
|
130
|
+
File.write("#{framework.module_map_path}/module.modulemap", module_map)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def copy_license
|
135
|
+
UI.message 'Copying license'
|
136
|
+
license_file = @spec.license[:file] || 'LICENSE'
|
137
|
+
`cp "#{license_file}" .` if Pathname(license_file).exist?
|
138
|
+
end
|
139
|
+
|
140
|
+
def copy_resources
|
141
|
+
|
142
|
+
bundles = Dir.glob('./build/*.bundle')
|
143
|
+
|
144
|
+
bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
145
|
+
consumer = spec.consumer(@platform)
|
146
|
+
consumer.resource_bundles.keys +
|
147
|
+
consumer.resources.map do |r|
|
148
|
+
File.basename(r, '.bundle') if File.extname(r) == 'bundle'
|
149
|
+
end
|
150
|
+
end.compact.uniq
|
151
|
+
|
152
|
+
bundles.select! do |bundle|
|
153
|
+
bundle_name = File.basename(bundle, '.bundle')
|
154
|
+
bundle_names.include?(bundle_name)
|
155
|
+
end
|
156
|
+
|
157
|
+
if bundles.count > 0
|
158
|
+
UI.message "Copying bundle files #{bundles}"
|
159
|
+
bundle_files = bundles.join(' ')
|
160
|
+
`cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
|
161
|
+
end
|
162
|
+
|
163
|
+
real_source_dir = @isRootSpec ? @source_dir : Pathname.new(File.join(Dir.pwd,"#{@spec.name}"))
|
164
|
+
resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
165
|
+
expand_paths(real_source_dir, spec.consumer(@platform).resources)
|
166
|
+
end.compact.uniq
|
167
|
+
|
168
|
+
if resources.count == 0 && bundles.count == 0
|
169
|
+
framework.delete_resources
|
170
|
+
return
|
171
|
+
end
|
172
|
+
|
173
|
+
if resources.count > 0
|
174
|
+
#把 路径转义。 避免空格情况下拷贝失败
|
175
|
+
escape_resource = []
|
176
|
+
resources.each do |source|
|
177
|
+
escape_resource << Shellwords.join(source)
|
178
|
+
end
|
179
|
+
UI.message "Copying resources #{escape_resource}"
|
180
|
+
`cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def static_libs_in_sandbox(build_dir = 'build')
|
185
|
+
file = Dir.glob("#{build_dir}/lib#{target_name}.a")
|
186
|
+
unless file
|
187
|
+
UI.warn "file no find = #{build_dir}/lib#{target_name}.a"
|
188
|
+
end
|
189
|
+
file
|
190
|
+
end
|
191
|
+
|
192
|
+
def build_static_library_for_ios(output)
|
193
|
+
UI.message "Building ios libraries with archs #{ios_architectures}"
|
194
|
+
static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
|
195
|
+
if is_debug_model
|
196
|
+
ios_architectures.map do |arch|
|
197
|
+
static_libs += static_libs_in_sandbox("build-#{arch}") + static_libs_in_sandbox('build-simulator') + @vendored_libraries
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
build_path = Pathname("build")
|
202
|
+
build_path.mkpath unless build_path.exist?
|
203
|
+
|
204
|
+
libs = ios_architectures.map do |arch|
|
205
|
+
library = "build/package-#{@spec.name}-#{arch}.a"
|
206
|
+
# libtool -arch_only arm64 -static -o build/package-armv64.a build/libIMYFoundation.a build-simulator/libIMYFoundation.a
|
207
|
+
# 从liBFoundation.a 文件中,提取出 arm64 架构的文件,命名为build/package-armv64.a
|
208
|
+
UI.message "libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}"
|
209
|
+
`libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
|
210
|
+
library
|
211
|
+
end
|
212
|
+
UI.message "lipo -create -output #{output} #{libs.join(' ')}"
|
213
|
+
`lipo -create -output #{output} #{libs.join(' ')}`
|
214
|
+
end
|
215
|
+
|
216
|
+
def ios_build_options
|
217
|
+
"ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
|
218
|
+
end
|
219
|
+
|
220
|
+
def ios_architectures
|
221
|
+
# >armv7
|
222
|
+
# iPhone4
|
223
|
+
# iPhone4S
|
224
|
+
# >armv7s 去掉
|
225
|
+
# iPhone5
|
226
|
+
# iPhone5C
|
227
|
+
# >arm64
|
228
|
+
# iPhone5S(以上)
|
229
|
+
# >i386
|
230
|
+
# iphone5,iphone5s以下的模拟器
|
231
|
+
# >x86_64
|
232
|
+
# iphone6以上的模拟器
|
233
|
+
archs = %w[x86_64 arm64 armv7]
|
234
|
+
# archs = %w[x86_64 arm64 armv7s i386]
|
235
|
+
@vendored_libraries.each do |library|
|
236
|
+
archs = `lipo -info #{library}`.split & archs
|
237
|
+
end
|
238
|
+
archs
|
239
|
+
end
|
240
|
+
|
241
|
+
def compile
|
242
|
+
defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited)'"
|
243
|
+
defines += ' '
|
244
|
+
defines += @spec.consumer(@platform).compiler_flags.join(' ')
|
245
|
+
|
246
|
+
options = ios_build_options
|
247
|
+
if is_debug_model
|
248
|
+
archs = %w[arm64 armv7]
|
249
|
+
# archs = %w[arm64 armv7 armv7s]
|
250
|
+
archs.map do |arch|
|
251
|
+
xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
|
252
|
+
end
|
253
|
+
else
|
254
|
+
xcodebuild(defines,options)
|
255
|
+
end
|
256
|
+
|
257
|
+
defines
|
258
|
+
end
|
259
|
+
|
260
|
+
def is_debug_model
|
261
|
+
@build_model == "Debug"
|
262
|
+
end
|
263
|
+
|
264
|
+
def target_name
|
265
|
+
#区分多平台,如配置了多平台,会带上平台的名字
|
266
|
+
# 如libwebp-iOS
|
267
|
+
# if @spec.available_platforms.count > 1
|
268
|
+
# "#{@spec.name}-#{Platform.string_name(@spec.consumer(@platform).platform_name)}"
|
269
|
+
# else
|
270
|
+
@spec.name
|
271
|
+
# end
|
272
|
+
end
|
273
|
+
|
274
|
+
def xcodebuild(defines = '', args = '', build_dir = 'build',build_model = 'Release')
|
275
|
+
#xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(inherited)' ARCHS='x86_64 arm64 armv7 armv7s i386' OTHER_CFLAGS='-fembed-bitcode -Qunused-arguments' CONFIGURATION_BUILD_DIR=build clean build -configuration Debug -target IMYTCP -project ./Pods.xcodeproj 2>&1
|
276
|
+
# xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(inherited)' -sdk iphoneos CONFIGURATION_BUILD_DIR=build-simulator clean build -configuration Release -target IMYFoundation -project ./Pods/Pods.xcodeproj 2>&1
|
277
|
+
command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
|
278
|
+
UI.message "command = #{command}"
|
279
|
+
output = `#{command}`.lines.to_a
|
280
|
+
|
281
|
+
if $CHILD_STATUS.exitstatus != 0
|
282
|
+
raise <<~EOF
|
283
|
+
Build command failed: #{command}
|
284
|
+
Output:
|
285
|
+
#{output.map { |line| " #{line}" }.join}
|
286
|
+
EOF
|
287
|
+
|
288
|
+
Process.exit
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def expand_paths(source_dir, path_specs)
|
293
|
+
path_specs.map do |path_spec|
|
294
|
+
Dir.glob(File.join(source_dir, path_spec))
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def framework
|
299
|
+
@framework ||= begin
|
300
|
+
framework = Framework.new(@spec.name, @platform.name.to_s)
|
301
|
+
framework.make
|
302
|
+
framework
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Library
|
5
|
+
attr_reader :headers_path
|
6
|
+
attr_reader :resources_path
|
7
|
+
attr_reader :root_path
|
8
|
+
attr_reader :versions_path
|
9
|
+
attr_reader :name_path
|
10
|
+
|
11
|
+
def initialize(name, platform, version)
|
12
|
+
@name = name
|
13
|
+
@platform = platform
|
14
|
+
@version = version
|
15
|
+
end
|
16
|
+
|
17
|
+
def make
|
18
|
+
make_root
|
19
|
+
make_library
|
20
|
+
make_headers
|
21
|
+
make_resources
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_resources
|
25
|
+
Pathname.new(@resources_path).rmtree
|
26
|
+
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def make_library
|
32
|
+
@name_path = CBin::Config::Builder.instance.library_name_version(@name,@version)
|
33
|
+
@fwk_path = @root_path + Pathname.new(@name_path)
|
34
|
+
@fwk_path.mkdir unless @fwk_path.exist?
|
35
|
+
|
36
|
+
@versions_path = @fwk_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def make_headers
|
40
|
+
@headers_path = @versions_path + Pathname.new('Headers')
|
41
|
+
# @headers_path.mkpath unless @headers_path.exist?
|
42
|
+
end
|
43
|
+
|
44
|
+
def make_resources
|
45
|
+
@resources_path = @versions_path + Pathname.new('Resources')
|
46
|
+
# @resources_path.mkpath unless @resources_path.exist?
|
47
|
+
end
|
48
|
+
|
49
|
+
def make_root
|
50
|
+
@root_path = Pathname.new(@platform)
|
51
|
+
@root_path.mkpath unless @root_path.exist?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
3
|
+
|
4
|
+
require 'cocoapods-imy-bin/helpers/framework.rb'
|
5
|
+
require 'cocoapods-imy-bin/helpers/library.rb'
|
6
|
+
|
7
|
+
require 'English'
|
8
|
+
|
9
|
+
module CBin
|
10
|
+
class Library
|
11
|
+
class Builder
|
12
|
+
include Pod
|
13
|
+
|
14
|
+
def initialize(spec, file_accessor, platform, source_dir,framework_path)
|
15
|
+
@spec = spec
|
16
|
+
@source_dir = source_dir
|
17
|
+
@file_accessor = file_accessor
|
18
|
+
@platform = platform
|
19
|
+
@framework = framework_path
|
20
|
+
@source_files = "#{@source_dir}/#{library.name_path}"
|
21
|
+
@source_zip_file = "#{@source_files}.zip"
|
22
|
+
end
|
23
|
+
|
24
|
+
def build
|
25
|
+
UI.section("Building static library #{@spec}") do
|
26
|
+
|
27
|
+
clean_source_dir
|
28
|
+
|
29
|
+
copy_headers
|
30
|
+
copy_library
|
31
|
+
copy_resources
|
32
|
+
|
33
|
+
cp_to_source_dir
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def clean_source_dir
|
40
|
+
FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
|
41
|
+
FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
def cp_to_source_dir
|
45
|
+
target_dir = library.versions_path
|
46
|
+
dest_file = "#{@source_dir}/#{library.name_path}"
|
47
|
+
FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
|
48
|
+
|
49
|
+
`cp -fa #{target_dir} #{dest_file}/`
|
50
|
+
end
|
51
|
+
|
52
|
+
def copy_headers
|
53
|
+
FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
|
54
|
+
end
|
55
|
+
|
56
|
+
def copy_library
|
57
|
+
src_file = "#{framework.versions_path}/#{@spec.name}"
|
58
|
+
unless File.exist?(src_file)
|
59
|
+
raise Informative, "framework没有文件:#{src_file}"
|
60
|
+
end
|
61
|
+
|
62
|
+
dest_file = "#{library.versions_path}/#{@spec.name}"
|
63
|
+
rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
|
64
|
+
FileUtils.cp_r(src_file,dest_file)
|
65
|
+
File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
|
66
|
+
end
|
67
|
+
|
68
|
+
def copy_resources
|
69
|
+
FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def framework
|
74
|
+
@framework ||= begin
|
75
|
+
framework = Framework.new(@spec.name, @platform.name.to_s)
|
76
|
+
framework.make
|
77
|
+
framework
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def library
|
82
|
+
@library ||= begin
|
83
|
+
library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
|
84
|
+
library.make
|
85
|
+
library
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|