cocoapods-tj 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,177 @@
1
+
2
+
3
+
4
+ require 'cocoapods-tj/native/podfile'
5
+ require 'cocoapods/command/gen'
6
+ require 'cocoapods/generate'
7
+ require 'cocoapods-tj/helpers/framework_builder'
8
+ require 'cocoapods-tj/helpers/library_builder'
9
+ require 'cocoapods-tj/config/config_builder'
10
+
11
+ module CBin
12
+ class LocalBuild
13
+ class Helper
14
+ include Pod
15
+ #class var
16
+ @@build_defines = ""
17
+ #Debug下还待完成
18
+ def initialize(spec,
19
+ platform,
20
+ framework_output,
21
+ zip,
22
+ clean,
23
+ target_name,
24
+ local_build_dir_name,
25
+ local_build_dir)
26
+ @spec = spec
27
+ @target_name = target_name
28
+ @platform = platform
29
+
30
+ @framework_output = framework_output
31
+ @zip = zip
32
+ @local_build_dir_name = local_build_dir_name
33
+ @local_build_dir = local_build_dir
34
+ @clean = clean
35
+ @framework_path
36
+ @is_library = !is_framework
37
+ end
38
+
39
+ def build
40
+ UI.section("Building static framework #{@spec}") do
41
+
42
+ build_static_framework
43
+ if @is_library
44
+ build_static_library
45
+ zip_static_framework if @zip &&= @framework_output
46
+ zip_static_library
47
+ else
48
+ zip_static_framework
49
+ end
50
+
51
+ clean_workspace if @clean
52
+ end
53
+
54
+ end
55
+
56
+ def build_static_framework
57
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
58
+ Dir.chdir(workspace_directory) do
59
+ builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir, @is_library, frameWork_dir)
60
+ @framework_path = builder.create
61
+ end
62
+ end
63
+
64
+ def build_static_library
65
+ source_dir = zip_dir
66
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
67
+ Dir.chdir(workspace_directory) do
68
+ builder = CBin::LocalLibrary::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path)
69
+ builder.build
70
+ end
71
+ end
72
+
73
+ def zip_static_framework
74
+ Dir.chdir(zip_dir) do
75
+ # output_name = "#{framework_name}.zip"
76
+ output_name = File.join(zip_dir, framework_name_zip)
77
+ unless File.exist?(framework_name)
78
+ UI.warn "没有需要压缩的 framework 文件:#{framework_name}"
79
+ end
80
+
81
+ UI.puts "Compressing #{framework_name} into #{output_name}"
82
+ `zip --symlinks -r #{output_name} #{framework_name}`
83
+
84
+ end
85
+ end
86
+
87
+ def zip_static_library
88
+ Dir.chdir(zip_dir) do
89
+ output_library = "#{library_name}.zip"
90
+ unless File.exist?(library_name)
91
+ raise Informative, "没有需要压缩的 library 文件:#{library_name}"
92
+ end
93
+
94
+ UI.puts "Compressing #{library_name} into #{output_library}"
95
+
96
+ `zip --symlinks -r #{output_library} #{library_name}`
97
+ end
98
+
99
+ end
100
+
101
+
102
+ def clean_workspace
103
+ UI.puts 'Cleaning workspace'
104
+
105
+ FileUtils.rm_rf(gen_name)
106
+ Dir.chdir(zip_dir) do
107
+ FileUtils.rm_rf(framework_name) if @zip
108
+ FileUtils.rm_rf(library_name)
109
+ FileUtils.rm_rf(framework_name) unless @framework_output
110
+ FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
111
+ end
112
+ end
113
+
114
+ def framework_name
115
+ CBin::Config::Builder.instance.framework_name(@spec)
116
+ end
117
+
118
+ def framework_name_zip
119
+ CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
120
+ end
121
+
122
+ def library_name
123
+ CBin::Config::Builder.instance.library_name(@spec)
124
+ end
125
+
126
+ def workspace_directory
127
+ @local_build_dir
128
+ end
129
+
130
+ def zip_dir
131
+ CBin::Config::Builder.instance.zip_dir
132
+ end
133
+
134
+ def gen_name
135
+ CBin::Config::Builder.instance.gen_name
136
+ end
137
+
138
+ def is_library
139
+ File.exist?(File.join(@local_build_dir, "lib#{@spec.name}.a"))
140
+ end
141
+
142
+ # 使用了user_framework 会有#{@spec.name}.framework
143
+ # 未使用的 需要判断文件
144
+ def is_framework
145
+ res = File.exist?(File.join(@local_build_dir, "#{@spec.name}.framework"))
146
+ unless res
147
+ res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}","Swift Compatibility Header"))
148
+ end
149
+ res
150
+ end
151
+
152
+ def frameWork_dir
153
+ dir = File.join(@local_build_dir, "#{@spec.name}.framework")
154
+ unless File.exist?(dir)
155
+ dir = File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}")
156
+ end
157
+ dir
158
+ end
159
+
160
+ def spec_file
161
+ @spec_file ||= begin
162
+ if @podspec
163
+ find_spec_file(@podspec)
164
+ else
165
+ if code_spec_files.empty?
166
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
167
+ end
168
+
169
+ spec_file = code_spec_files.first
170
+ spec_file
171
+ end
172
+ end
173
+ end
174
+
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,85 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ module CBin
6
+ class LocalFramework
7
+ attr_reader :headers_path
8
+ attr_reader :module_map_path
9
+ attr_reader :resources_path
10
+ attr_reader :root_path
11
+ attr_reader :versions_path
12
+ attr_reader :swift_module_path
13
+ attr_reader :fwk_path
14
+
15
+ def initialize(name, platform, local_build_dir)
16
+ @name = name
17
+ @platform = platform
18
+ @local_build_dir = local_build_dir
19
+ end
20
+
21
+ def make
22
+ make_root
23
+ make_framework
24
+ make_headers
25
+ make_resources
26
+ make_current_version
27
+ end
28
+
29
+ def delete_resources
30
+ Pathname.new(@resources_path).rmtree
31
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
32
+ end
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
49
+ private
50
+
51
+ def make_current_version
52
+ current_version_path = @versions_path + Pathname.new('../Current')
53
+ `ln -sf A #{current_version_path}`
54
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
55
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
56
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
57
+ end
58
+
59
+ def make_framework
60
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
61
+ FileUtils.remove_dir(@fwk_path) if @fwk_path.exist?
62
+ @fwk_path.mkdir unless @fwk_path.exist?
63
+
64
+ @module_map_path = @fwk_path + Pathname.new('Modules')
65
+ @versions_path = @fwk_path + Pathname.new('Versions/A')
66
+ @fwk_path.exist?
67
+ @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
68
+ end
69
+
70
+ def make_headers
71
+ @headers_path = @versions_path + Pathname.new('Headers')
72
+ @headers_path.mkpath unless @headers_path.exist?
73
+ end
74
+
75
+ def make_resources
76
+ @resources_path = @versions_path + Pathname.new('Resources')
77
+ @resources_path.mkpath unless @resources_path.exist?
78
+ end
79
+
80
+ def make_root
81
+ @root_path = Pathname.new(File.join(@local_build_dir, @platform))
82
+ @root_path.mkpath unless @root_path.exist?
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,226 @@
1
+
2
+
3
+
4
+ require 'cocoapods-tj/helpers/local/local_framework'
5
+ require 'English'
6
+ require 'cocoapods-tj/config/config_builder'
7
+ require 'shellwords'
8
+
9
+ module CBin
10
+ class LocalFramework
11
+ class Builder
12
+ include Pod
13
+ #Debug下还待完成
14
+ def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir, is_library = true, framework_BuildProductsPath = "")
15
+ @spec = spec
16
+ @file_accessor = file_accessor
17
+ @platform = platform
18
+ @local_build_dir_name = local_build_dir_name
19
+ @local_build_dir = local_build_dir
20
+ @is_library = is_library
21
+ @framework_BuildProductsPath = framework_BuildProductsPath
22
+ end
23
+
24
+ def create
25
+ begin
26
+ #如果是.a 文件, 或者 swift下,是.a文件的
27
+ if @is_library || (!@is_library && @framework_BuildProductsPath != framework_name)
28
+
29
+ UI.section("Building static library #{@spec}") do
30
+ output = framework.versions_path + Pathname.new(@spec.name)
31
+ build_static_library_for_ios(output)
32
+ res = copy_headers
33
+ # maybe fails for copy_headers
34
+ if res
35
+ copy_resources
36
+ cp_to_source_dir
37
+ else
38
+ FileUtils.remove_dir(framework.fwk_path) if File.exist?(framework.fwk_path)
39
+ return nil
40
+ end
41
+ end
42
+
43
+ else
44
+ UI.section("Building static framework #{@spec}") do
45
+ output = File.join(CBin::Config::Builder.instance.zip_dir,"#{@spec.name}.framework")
46
+ build_static_framework_for_ios(output)
47
+ end
48
+ end
49
+
50
+ rescue StandardError
51
+ UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本组装失败 ."
52
+ end
53
+
54
+ framework
55
+ end
56
+
57
+ private
58
+
59
+ def cp_to_source_dir
60
+ # 删除Versions 软链接
61
+ framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec)
62
+
63
+ target_dir = File.join(CBin::Config::Builder.instance.root_dir,CBin::Config::Builder.instance.framework_file(@spec))
64
+ FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
65
+
66
+ zip_dir = CBin::Config::Builder.instance.zip_dir
67
+ FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
68
+
69
+ `cp -fa #{@platform}/#{CBin::Config::Builder.instance.framework_name(@spec)} #{target_dir}`
70
+ end
71
+
72
+
73
+ def copy_headers
74
+ #by slj 如果没有头文件,去 "Headers/Public"拿
75
+ # if public_headers.empty?
76
+ Dir.chdir(File.join(Pod::Config.instance.installation_root,'Pods')) do
77
+
78
+ if File.exist?("./Headers/Public/#{@spec.name}")
79
+ #走 podsepc中的public_headers
80
+ public_headers = Array.new
81
+
82
+ Dir.chdir("./Headers/Public/#{@spec.name}") do
83
+ headers = Dir.glob('*.h')
84
+ headers.each do |h|
85
+ public_headers << Pathname.new(File.join(Dir.pwd,h))
86
+ end
87
+ end
88
+
89
+ UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
90
+
91
+ public_headers.each do |h|
92
+ `ditto #{h} #{framework.headers_path}/#{h.basename}`
93
+ end
94
+
95
+ # If custom 'module_map' is specified add it to the framework distribution
96
+ # otherwise check if a header exists that is equal to 'spec.name', if so
97
+ # create a default 'module_map' one using it.
98
+ if !@spec.module_map.nil?
99
+ module_map_file = @file_accessor.module_map
100
+ if Pathname(module_map_file).exist?
101
+ module_map = File.read(module_map_file)
102
+ end
103
+ elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
104
+ module_map = <<-MAP
105
+ framework module #{@spec.name} {
106
+ umbrella header "#{@spec.name}-umbrella.h"
107
+
108
+ export *
109
+ module * { export * }
110
+ }
111
+ MAP
112
+ end
113
+
114
+ unless module_map.nil?
115
+ UI.message "Writing module map #{module_map}"
116
+ unless framework.module_map_path.exist?
117
+ framework.module_map_path.mkpath
118
+ end
119
+ File.write("#{framework.module_map_path}/module.modulemap", module_map)
120
+
121
+ # unless framework.swift_module_path.exist?
122
+ # framework.swift_module_path.mkpath
123
+ # end
124
+ # DO BuildProductsPath swiftModule拷贝到 framework.swift_module_path
125
+ swiftmodule_path = File.join(@framework_BuildProductsPath, "#{@spec.name}.swiftmodule")
126
+ if File.directory?(swiftmodule_path)
127
+ FileUtils.cp_r("#{swiftmodule_path}/.", framework.swift_module_path)
128
+ end
129
+ swift_Compatibility_Header = "#{@framework_BuildProductsPath}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
130
+ FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header)
131
+ info_plist_file = File.join(File.dirname(File.dirname(__FILE__)),"info.plist")
132
+ FileUtils.cp(info_plist_file,framework.fwk_path)
133
+ end
134
+ else
135
+ UI.warn "== Headers/Public/#{@spec.name} no exist"
136
+ return false
137
+ end
138
+
139
+ end
140
+ return true
141
+ end
142
+
143
+ def copy_resources
144
+
145
+
146
+ Dir.chdir(Pod::Config.instance.sandbox_root) do
147
+
148
+ bundles = Dir.glob('./build/*.bundle')
149
+
150
+ bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
151
+ consumer = spec.consumer(@platform)
152
+ consumer.resource_bundles.keys +
153
+ consumer.resources.map do |r|
154
+ File.basename(r, '.bundle') if File.extname(r) == 'bundle'
155
+ end
156
+ end.compact.uniq
157
+
158
+ bundles.select! do |bundle|
159
+ bundle_name = File.basename(bundle, '.bundle')
160
+ bundle_names.include?(bundle_name)
161
+ end
162
+
163
+ if bundles.count > 0
164
+ UI.message "Copying bundle files #{bundles}"
165
+ bundle_files = bundles.join(' ')
166
+ `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
167
+ end
168
+
169
+ real_source_dir = @spec.name
170
+ resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
171
+ expand_paths(real_source_dir, spec.consumer(@platform).resources)
172
+ end.compact.uniq
173
+
174
+ if (resources.count == 0 || (resources.count == 1 && resources[0].count == 0)) && bundles.count == 0
175
+ framework.delete_resources
176
+ return
177
+ end
178
+
179
+ if resources.count > 0
180
+ #把 路径转义。 避免空格情况下拷贝失败
181
+ escape_resource = []
182
+ resources.each do |source|
183
+ escape_resource << Shellwords.join(source)
184
+ end
185
+ UI.message "Copying resources #{escape_resource}"
186
+ `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
187
+ end
188
+
189
+ end
190
+
191
+ end
192
+
193
+
194
+ def build_static_library_for_ios(output)
195
+ `cp -rp #{library_name} #{output}`
196
+ end
197
+
198
+ def build_static_framework_for_ios(output)
199
+ FileUtils.cp_r(framework_name, output)
200
+ end
201
+
202
+ def library_name
203
+ File.join(@local_build_dir, "lib#{@spec.name}.a")
204
+ end
205
+
206
+ def framework_name
207
+ File.join(@local_build_dir, "#{@spec.name}.framework")
208
+ end
209
+
210
+ def expand_paths(source_dir, path_specs)
211
+ path_specs.map do |path_spec|
212
+ Dir.glob(File.join(source_dir, path_spec))
213
+ end
214
+ end
215
+
216
+ def framework
217
+ @framework ||= begin
218
+ framework = CBin::LocalFramework.new(@spec.name, @platform.name.to_s,@local_build_dir)
219
+ framework.make
220
+ framework
221
+ end
222
+ end
223
+
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,91 @@
1
+
2
+
3
+
4
+
5
+ require 'cocoapods-tj/helpers/framework.rb'
6
+ require 'cocoapods-tj/helpers/library.rb'
7
+
8
+ require 'English'
9
+
10
+ module CBin
11
+ class LocalLibrary
12
+ class Builder
13
+ include Pod
14
+
15
+ def initialize(spec, file_accessor, platform, source_dir,framework_path)
16
+ @spec = spec
17
+ @source_dir = source_dir
18
+ @file_accessor = file_accessor
19
+ @platform = platform
20
+ @framework = framework_path
21
+ @source_files = "#{@source_dir}/#{library.name_path}"
22
+ @source_zip_file = "#{@source_files}.zip"
23
+ end
24
+
25
+ def build
26
+ UI.section("Building static library #{@spec}") do
27
+
28
+ clean_source_dir
29
+
30
+ copy_headers
31
+ copy_library
32
+ copy_resources
33
+
34
+ cp_to_source_dir
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def clean_source_dir
41
+ FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
42
+ FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
43
+ end
44
+
45
+ def cp_to_source_dir
46
+ target_dir = library.versions_path
47
+ dest_file = "#{@source_dir}/#{library.name_path}"
48
+ FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
49
+
50
+ `cp -fa #{target_dir} #{dest_file}/`
51
+ end
52
+
53
+ def copy_headers
54
+ FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
55
+ end
56
+
57
+ def copy_library
58
+ src_file = "#{framework.versions_path}/#{@spec.name}"
59
+ unless File.exist?(src_file)
60
+ raise Informative, "framework没有文件:#{src_file}"
61
+ end
62
+
63
+ dest_file = "#{library.versions_path}/#{@spec.name}"
64
+ rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
65
+ FileUtils.cp_r(src_file,dest_file)
66
+ File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
67
+ end
68
+
69
+ def copy_resources
70
+ FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
71
+ end
72
+
73
+
74
+ def framework
75
+ @framework ||= begin
76
+ framework = Framework.new(@spec.name, @platform.name.to_s)
77
+ framework.make
78
+ framework
79
+ end
80
+ end
81
+
82
+ def library
83
+ @library ||= begin
84
+ library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
85
+ library.make
86
+ library
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,32 @@
1
+
2
+
3
+ require 'cocoapods-tj/native/sources_manager.rb'
4
+
5
+ module CBin
6
+ module SourcesHelper
7
+ def sources_manager
8
+ Pod::Config.instance.sources_manager
9
+ end
10
+
11
+ def binary_source
12
+ sources_manager.binary_source
13
+ end
14
+
15
+ def code_source
16
+ sources_manager.code_source
17
+ end
18
+
19
+ def valid_sources(code_dependencies = false)
20
+ sources = [code_source]
21
+ unless code_dependencies
22
+ sources << binary_source
23
+ sources.reverse!
24
+ end
25
+ sources
26
+ end
27
+
28
+ def sources_option(code_dependencies, additional_sources)
29
+ (valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
30
+ end
31
+ end
32
+ end