cocoapods-tj 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +1 -0
  4. data/lib/cocoapods-tj/command/bin/archive.rb +203 -0
  5. data/lib/cocoapods-tj/command/bin/auto.rb +189 -0
  6. data/lib/cocoapods-tj/command/bin/code.rb +198 -0
  7. data/lib/cocoapods-tj/command/bin/imy.rb +45 -0
  8. data/lib/cocoapods-tj/command/bin/init.rb +65 -0
  9. data/lib/cocoapods-tj/command/bin/initHotKey.rb +66 -0
  10. data/lib/cocoapods-tj/command/bin/install.rb +41 -0
  11. data/lib/cocoapods-tj/command/bin/lib/lint.rb +66 -0
  12. data/lib/cocoapods-tj/command/bin/local.rb +142 -0
  13. data/lib/cocoapods-tj/command/bin/repo/update.rb +42 -0
  14. data/lib/cocoapods-tj/command/bin/spec/create.rb +68 -0
  15. data/lib/cocoapods-tj/command/bin/spec/push.rb +114 -0
  16. data/lib/cocoapods-tj/command/bin/update.rb +144 -0
  17. data/lib/cocoapods-tj/command/bin.rb +42 -0
  18. data/lib/cocoapods-tj/command.rb +2 -0
  19. data/lib/cocoapods-tj/config/config.rb +129 -0
  20. data/lib/cocoapods-tj/config/config_asker.rb +49 -0
  21. data/lib/cocoapods-tj/config/config_builder.rb +201 -0
  22. data/lib/cocoapods-tj/config/config_hot_key.rb +102 -0
  23. data/lib/cocoapods-tj/config/config_hot_key_asker.rb +48 -0
  24. data/lib/cocoapods-tj/gem_version.rb +10 -0
  25. data/lib/cocoapods-tj/helpers/Info.plist +0 -0
  26. data/lib/cocoapods-tj/helpers/build_helper.rb +154 -0
  27. data/lib/cocoapods-tj/helpers/build_utils.rb +62 -0
  28. data/lib/cocoapods-tj/helpers/framework.rb +79 -0
  29. data/lib/cocoapods-tj/helpers/framework_builder.rb +391 -0
  30. data/lib/cocoapods-tj/helpers/library.rb +54 -0
  31. data/lib/cocoapods-tj/helpers/library_builder.rb +89 -0
  32. data/lib/cocoapods-tj/helpers/local/loca_llibrary.rb +57 -0
  33. data/lib/cocoapods-tj/helpers/local/local_build_helper.rb +177 -0
  34. data/lib/cocoapods-tj/helpers/local/local_framework.rb +85 -0
  35. data/lib/cocoapods-tj/helpers/local/local_framework_builder.rb +226 -0
  36. data/lib/cocoapods-tj/helpers/local/local_library_builder.rb +91 -0
  37. data/lib/cocoapods-tj/helpers/sources_helper.rb +32 -0
  38. data/lib/cocoapods-tj/helpers/spec_creator.rb +150 -0
  39. data/lib/cocoapods-tj/helpers/spec_files_helper.rb +73 -0
  40. data/lib/cocoapods-tj/helpers/spec_source_creator.rb +189 -0
  41. data/lib/cocoapods-tj/helpers/upload_helper.rb +81 -0
  42. data/lib/cocoapods-tj/helpers.rb +5 -0
  43. data/lib/cocoapods-tj/native/acknowledgements.rb +26 -0
  44. data/lib/cocoapods-tj/native/analyzer.rb +29 -0
  45. data/lib/cocoapods-tj/native/file_accessor.rb +20 -0
  46. data/lib/cocoapods-tj/native/installation_options.rb +21 -0
  47. data/lib/cocoapods-tj/native/installer.rb +106 -0
  48. data/lib/cocoapods-tj/native/linter.rb +26 -0
  49. data/lib/cocoapods-tj/native/path_source.rb +29 -0
  50. data/lib/cocoapods-tj/native/pod_source_installer.rb +18 -0
  51. data/lib/cocoapods-tj/native/pod_target_installer.rb +81 -0
  52. data/lib/cocoapods-tj/native/podfile.rb +91 -0
  53. data/lib/cocoapods-tj/native/podfile_env.rb +37 -0
  54. data/lib/cocoapods-tj/native/podfile_generator.rb +135 -0
  55. data/lib/cocoapods-tj/native/podspec_finder.rb +23 -0
  56. data/lib/cocoapods-tj/native/resolver.rb +202 -0
  57. data/lib/cocoapods-tj/native/sandbox_analyzer.rb +11 -0
  58. data/lib/cocoapods-tj/native/source.rb +35 -0
  59. data/lib/cocoapods-tj/native/sources_manager.rb +18 -0
  60. data/lib/cocoapods-tj/native/specification.rb +10 -0
  61. data/lib/cocoapods-tj/native/target_validator.rb +41 -0
  62. data/lib/cocoapods-tj/native/validator.rb +40 -0
  63. data/lib/cocoapods-tj/native.rb +23 -0
  64. data/lib/cocoapods-tj/source_provider_hook.rb +50 -0
  65. data/lib/cocoapods-tj.rb +2 -0
  66. data/lib/cocoapods_plugin.rb +3 -0
  67. data/spec/command/bin_spec.rb +12 -0
  68. data/spec/spec_helper.rb +50 -0
  69. metadata +182 -0
@@ -0,0 +1,391 @@
1
+
2
+ require 'cocoapods-tj/helpers/framework.rb'
3
+ require 'English'
4
+ require 'cocoapods-tj/config/config_builder'
5
+ require 'shellwords'
6
+ require 'cocoapods-tj/helpers/build_utils'
7
+
8
+ module CBin
9
+ class Framework
10
+ class Builder
11
+ include Pod
12
+ def initialize(spec, file_accessor, platform, source_dir, isRootSpec = true, build_model="Debug")
13
+ @spec = spec
14
+ @source_dir = source_dir
15
+ @file_accessor = file_accessor
16
+ @platform = platform
17
+ @build_model = build_model
18
+ @isRootSpec = isRootSpec
19
+ vendored_static_frameworks = file_accessor.vendored_static_frameworks.map do |framework|
20
+ path = framework
21
+ extn = File.extname path
22
+ if extn.downcase == '.framework'
23
+ path = File.join(path,File.basename(path, extn))
24
+ end
25
+ path
26
+ end
27
+
28
+ @vendored_libraries = (vendored_static_frameworks + file_accessor.vendored_static_libraries).map(&:to_s)
29
+ end
30
+
31
+ def build
32
+ defines = compile
33
+ build_sim_libraries(defines)
34
+
35
+ defines
36
+ end
37
+
38
+ def lipo_build(defines)
39
+
40
+ if CBin::Build::Utils.is_swift_module(@spec) || !CBin::Build::Utils.uses_frameworks?
41
+ UI.section("Building static Library #{@spec}") do
42
+
43
+ output = framework.versions_path + Pathname.new(@spec.name)
44
+
45
+ build_static_library_for_ios(output)
46
+
47
+ copy_headers
48
+ copy_license
49
+ copy_resources
50
+
51
+ cp_to_source_dir
52
+ end
53
+ else
54
+ UI.section("Building framework #{@spec}") do
55
+
56
+ output = framework.fwk_path + Pathname.new(@spec.name)
57
+
58
+ copy_static_framework_dir_for_ios
59
+
60
+ build_static_framework_machO_for_ios(output)
61
+
62
+ copy_framework_resources
63
+
64
+
65
+ end
66
+ end
67
+
68
+ framework
69
+ end
70
+
71
+ private
72
+
73
+ def cp_to_source_dir
74
+ framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec)
75
+
76
+ framework_name = "#{@spec.name}.framework"
77
+ target_dir = File.join(CBin::Config::Builder.instance.zip_dir,framework_name)
78
+ FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
79
+
80
+ zip_dir = CBin::Config::Builder.instance.zip_dir
81
+ FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
82
+
83
+ `cp -fa #{@platform}/#{framework_name} #{target_dir}`
84
+ end
85
+
86
+ def build_sim_libraries(defines)
87
+ UI.message 'Building simulator libraries'
88
+
89
+ archs = ios_architectures_sim
90
+ archs.map do |arch|
91
+ xcodebuild(defines, "-sdk iphonesimulator ARCHS=\'#{arch}\' ", "build-#{arch}",@build_model)
92
+ end
93
+
94
+ end
95
+
96
+
97
+ def static_libs_in_sandbox(build_dir = 'build')
98
+ file = Dir.glob("#{build_dir}/lib#{target_name}.a")
99
+ unless file
100
+ UI.warn "file no find = #{build_dir}/lib#{target_name}.a"
101
+ end
102
+ file
103
+ end
104
+
105
+ def build_static_library_for_ios(output)
106
+ UI.message "Building ios libraries with archs #{ios_architectures}"
107
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
108
+
109
+ ios_architectures.map do |arch|
110
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
111
+ end
112
+ ios_architectures_sim do |arch|
113
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
114
+ end
115
+
116
+ build_path = Pathname("build")
117
+ build_path.mkpath unless build_path.exist?
118
+
119
+ libs = (ios_architectures + ios_architectures_sim) .map do |arch|
120
+ library = "build-#{arch}/lib#{@spec.name}.a"
121
+ library
122
+ end
123
+
124
+ UI.message "lipo -create -output #{output} #{libs.join(' ')}"
125
+ `lipo -create -output #{output} #{libs.join(' ')}`
126
+ end
127
+
128
+ def ios_build_options
129
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
130
+ end
131
+
132
+ def ios_architectures
133
+
134
+ archs = %w[arm64 armv7]
135
+
136
+ archs
137
+ end
138
+
139
+ def ios_architectures_sim
140
+
141
+ archs = %w[x86_64]
142
+ # TODO 处理是否需要 i386
143
+ archs
144
+ end
145
+
146
+ def compile
147
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited)'"
148
+ defines += ' '
149
+ defines += @spec.consumer(@platform).compiler_flags.join(' ')
150
+
151
+ options = ios_build_options
152
+ archs = ios_architectures
153
+ archs.map do |arch|
154
+ xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
155
+ end
156
+
157
+
158
+ defines
159
+ end
160
+
161
+ def is_debug_model
162
+ @build_model == "Debug"
163
+ end
164
+
165
+ def target_name
166
+
167
+ if @spec.available_platforms.count > 1
168
+ "#{@spec.name}-#{Platform.string_name(@spec.consumer(@platform).platform_name)}"
169
+ else
170
+ @spec.name
171
+ end
172
+ end
173
+
174
+ def xcodebuild(defines = '', args = '', build_dir = 'build', build_model = 'Debug')
175
+
176
+ unless File.exist?("Pods.xcodeproj") #cocoapods-generate v2.0.0
177
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{build_model} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
178
+ else
179
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
180
+ end
181
+
182
+ UI.message "command = #{command}"
183
+ output = `#{command}`.lines.to_a
184
+
185
+ if $CHILD_STATUS.exitstatus != 0
186
+ raise <<~EOF
187
+ Build command failed: #{command}
188
+ Output:
189
+ #{output.map { |line| " #{line}" }.join}
190
+ EOF
191
+
192
+ Process.exit
193
+ end
194
+ end
195
+
196
+ def copy_headers
197
+ public_headers = Array.new
198
+
199
+ spec_header_dir = "./Headers/Public/#{@spec.name}"
200
+ unless File.exist?(spec_header_dir)
201
+ spec_header_dir = "./Pods/Headers/Public/#{@spec.name}"
202
+ end
203
+ raise "copy_headers #{spec_header_dir} no exist " unless File.exist?(spec_header_dir)
204
+ Dir.chdir(spec_header_dir) do
205
+ headers = Dir.glob('*.h')
206
+ headers.each do |h|
207
+ public_headers << Pathname.new(File.join(Dir.pwd,h))
208
+ end
209
+ end
210
+ # end
211
+
212
+
213
+ public_headers.each do |h|
214
+ `ditto #{h} #{framework.headers_path}/#{h.basename}`
215
+ end
216
+
217
+ if !@spec.module_map.nil?
218
+ module_map_file = @file_accessor.module_map
219
+ if Pathname(module_map_file).exist?
220
+ module_map = File.read(module_map_file)
221
+ end
222
+ elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
223
+ module_map = <<-MAP
224
+ framework module #{@spec.name} {
225
+ umbrella header "#{@spec.name}-umbrella.h"
226
+
227
+ export *
228
+ module * { export * }
229
+ }
230
+ MAP
231
+ end
232
+
233
+ unless module_map.nil?
234
+ UI.message "Writing module map #{module_map}"
235
+ unless framework.module_map_path.exist?
236
+ framework.module_map_path.mkpath
237
+ end
238
+ File.write("#{framework.module_map_path}/module.modulemap", module_map)
239
+
240
+ archs = ios_architectures + ios_architectures_sim
241
+ archs.map do |arch|
242
+ swift_module = "build-#{arch}/#{@spec.name}.swiftmodule"
243
+ if File.directory?(swift_module)
244
+ FileUtils.cp_r("#{swift_module}/.", framework.swift_module_path)
245
+ end
246
+ end
247
+ swift_Compatibility_Header = "build-#{archs.first}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
248
+ FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header)
249
+ info_plist_file = File.join(File.dirname(__FILE__),"info.plist")
250
+ FileUtils.cp(info_plist_file,framework.fwk_path)
251
+ end
252
+ end
253
+
254
+ def copy_swift_header
255
+
256
+ end
257
+
258
+ def copy_license
259
+ license_file = @spec.license[:file] || 'LICENSE'
260
+ `cp "#{license_file}" .` if Pathname(license_file).exist?
261
+ end
262
+
263
+ def copy_resources
264
+ resource_dir = './build/*.bundle'
265
+ resource_dir = './build-armv7/*.bundle' if File.exist?('./build-armv7')
266
+ resource_dir = './build-arm64/*.bundle' if File.exist?('./build-arm64')
267
+
268
+ bundles = Dir.glob(resource_dir)
269
+
270
+ bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
271
+ consumer = spec.consumer(@platform)
272
+ consumer.resource_bundles.keys +
273
+ consumer.resources.map do |r|
274
+ File.basename(r, '.bundle') if File.extname(r) == 'bundle'
275
+ end
276
+ end.compact.uniq
277
+
278
+ bundles.select! do |bundle|
279
+ bundle_name = File.basename(bundle, '.bundle')
280
+ bundle_names.include?(bundle_name)
281
+ end
282
+
283
+ if bundles.count > 0
284
+ UI.message "Copying bundle files #{bundles}"
285
+ bundle_files = bundles.join(' ')
286
+ `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
287
+ end
288
+
289
+ real_source_dir = @source_dir
290
+ unless @isRootSpec
291
+ spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
292
+ unless File.exist?(spec_source_dir)
293
+ spec_source_dir = File.join(Dir.pwd,"Pods/#{@spec.name}")
294
+ end
295
+ raise "copy_resources #{spec_source_dir} no exist " unless File.exist?(spec_source_dir)
296
+
297
+ spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
298
+ real_source_dir = spec_source_dir
299
+ end
300
+
301
+ resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
302
+ expand_paths(real_source_dir, spec.consumer(@platform).resources)
303
+ end.compact.uniq
304
+
305
+ if resources.count == 0 && bundles.count == 0
306
+ framework.delete_resources
307
+ return
308
+ end
309
+
310
+ if resources.count > 0
311
+ escape_resource = []
312
+ resources.each do |source|
313
+ escape_resource << Shellwords.join(source)
314
+ end
315
+ UI.message "Copying resources #{escape_resource}"
316
+ `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
317
+ end
318
+ end
319
+
320
+ def expand_paths(source_dir, path_specs)
321
+ path_specs.map do |path_spec|
322
+ Dir.glob(File.join(source_dir, path_spec))
323
+ end
324
+ end
325
+
326
+ def build_static_framework_machO_for_ios(output)
327
+ UI.message "Building ios framework with archs #{ios_architectures}"
328
+
329
+ static_libs = static_libs_in_sandbox('build') + @vendored_libraries
330
+ ios_architectures.map do |arch|
331
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
332
+ end
333
+
334
+ ios_architectures_sim do |arch|
335
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
336
+ end
337
+
338
+ build_path = Pathname("build")
339
+ build_path.mkpath unless build_path.exist?
340
+
341
+ libs = (ios_architectures + ios_architectures_sim) .map do |arch|
342
+ library = "build-#{arch}/#{@spec.name}.framework/#{@spec.name}"
343
+ library
344
+ end
345
+
346
+ UI.message "lipo -create -output #{output} #{libs.join(' ')}"
347
+ `lipo -create -output #{output} #{libs.join(' ')}`
348
+ end
349
+
350
+ def copy_static_framework_dir_for_ios
351
+
352
+ archs = ios_architectures + ios_architectures_sim
353
+ framework_dir = "build-#{ios_architectures_sim.first}/#{@spec.name}.framework"
354
+ framework_dir = "build-#{ios_architectures.first}/#{@spec.name}.framework" unless File.exist?(framework_dir)
355
+ unless File.exist?(framework_dir)
356
+ raise "#{framework_dir} path no exist"
357
+ end
358
+ File.join(Dir.pwd, "build-#{ios_architectures_sim.first}/#{@spec.name}.framework")
359
+ FileUtils.cp_r(framework_dir, framework.root_path)
360
+
361
+ archs.map do |arch|
362
+ swift_module = "build-#{arch}/#{@spec.name}.framework/Modules/#{@spec.name}.swiftmodule"
363
+ if File.directory?(swift_module)
364
+ FileUtils.cp_r("#{swift_module}/.", framework.swift_module_path)
365
+ end
366
+ end
367
+
368
+ framework.remove_current_version
369
+ end
370
+
371
+ def copy_framework_resources
372
+ resources = Dir.glob("#{framework.fwk_path + Pathname.new('Resources')}/*")
373
+ if resources.count == 0
374
+ framework.delete_resources
375
+ end
376
+ end
377
+
378
+
379
+
380
+ def framework
381
+ @framework ||= begin
382
+ framework = Framework.new(@spec.name, @platform.name.to_s)
383
+ framework.make
384
+ framework
385
+ end
386
+ end
387
+
388
+
389
+ end
390
+ end
391
+ 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,89 @@
1
+
2
+
3
+ require 'cocoapods-tj/helpers/framework.rb'
4
+ require 'cocoapods-tj/helpers/library.rb'
5
+
6
+ require 'English'
7
+
8
+ module CBin
9
+ class Library
10
+ class Builder
11
+ include Pod
12
+
13
+ def initialize(spec, file_accessor, platform, source_dir,framework_path)
14
+ @spec = spec
15
+ @source_dir = source_dir
16
+ @file_accessor = file_accessor
17
+ @platform = platform
18
+ @framework = framework_path
19
+ @source_files = "#{@source_dir}/#{library.name_path}"
20
+ @source_zip_file = "#{@source_files}.zip"
21
+ end
22
+
23
+ def build
24
+ UI.section("Building static library #{@spec}") do
25
+
26
+ clean_source_dir
27
+
28
+ copy_headers
29
+ copy_library
30
+ copy_resources
31
+
32
+ cp_to_source_dir
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def clean_source_dir
39
+ FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
40
+ FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
41
+ end
42
+
43
+ def cp_to_source_dir
44
+ target_dir = library.versions_path
45
+ dest_file = "#{@source_dir}/#{library.name_path}"
46
+ FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
47
+
48
+ `cp -fa #{target_dir} #{dest_file}/`
49
+ end
50
+
51
+ def copy_headers
52
+ FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
53
+ end
54
+
55
+ def copy_library
56
+ src_file = "#{framework.versions_path}/#{@spec.name}"
57
+ unless File.exist?(src_file)
58
+ raise Informative, "framework没有文件:#{src_file}"
59
+ end
60
+
61
+ dest_file = "#{library.versions_path}/#{@spec.name}"
62
+ rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
63
+ FileUtils.cp_r(src_file,dest_file)
64
+ File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
65
+ end
66
+
67
+ def copy_resources
68
+ FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
69
+ end
70
+
71
+
72
+ def framework
73
+ @framework ||= begin
74
+ framework = Framework.new(@spec.name, @platform.name.to_s)
75
+ framework.make
76
+ framework
77
+ end
78
+ end
79
+
80
+ def library
81
+ @library ||= begin
82
+ library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
83
+ library.make
84
+ library
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,57 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+ require 'cocoapods-tj/config/config_builder'
5
+
6
+ module CBin
7
+ class LocalLibrary
8
+ attr_reader :headers_path
9
+ attr_reader :resources_path
10
+ attr_reader :root_path
11
+ attr_reader :versions_path
12
+ attr_reader :name_path
13
+
14
+ def initialize(name, platform, version)
15
+ @name = name
16
+ @platform = platform
17
+ @version = version
18
+ end
19
+
20
+ def make
21
+ make_root
22
+ make_library
23
+ make_headers
24
+ make_resources
25
+ end
26
+
27
+ def delete_resources
28
+ Pathname.new(@resources_path).rmtree
29
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
30
+ end
31
+
32
+ private
33
+
34
+ def make_library
35
+ @name_path = CBin::Config::Builder.instance.library_name_version(@name, @version)
36
+ @fwk_path = @root_path + Pathname.new(@name_path)
37
+ @fwk_path.mkdir unless @fwk_path.exist?
38
+
39
+ @versions_path = @fwk_path
40
+ end
41
+
42
+ def make_headers
43
+ @headers_path = @versions_path + Pathname.new('Headers')
44
+ # @headers_path.mkpath unless @headers_path.exist?
45
+ end
46
+
47
+ def make_resources
48
+ @resources_path = @versions_path + Pathname.new('Resources')
49
+ # @resources_path.mkpath unless @resources_path.exist?
50
+ end
51
+
52
+ def make_root
53
+ @root_path = Pathname.new(@platform)
54
+ @root_path.mkpath unless @root_path.exist?
55
+ end
56
+ end
57
+ end