cocoapods-tj 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -0
- data/lib/cocoapods-tj/command/bin/archive.rb +203 -0
- data/lib/cocoapods-tj/command/bin/auto.rb +189 -0
- data/lib/cocoapods-tj/command/bin/code.rb +198 -0
- data/lib/cocoapods-tj/command/bin/imy.rb +45 -0
- data/lib/cocoapods-tj/command/bin/init.rb +65 -0
- data/lib/cocoapods-tj/command/bin/initHotKey.rb +66 -0
- data/lib/cocoapods-tj/command/bin/install.rb +41 -0
- data/lib/cocoapods-tj/command/bin/lib/lint.rb +66 -0
- data/lib/cocoapods-tj/command/bin/local.rb +142 -0
- data/lib/cocoapods-tj/command/bin/repo/update.rb +42 -0
- data/lib/cocoapods-tj/command/bin/spec/create.rb +68 -0
- data/lib/cocoapods-tj/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-tj/command/bin/update.rb +144 -0
- data/lib/cocoapods-tj/command/bin.rb +42 -0
- data/lib/cocoapods-tj/command.rb +2 -0
- data/lib/cocoapods-tj/config/config.rb +129 -0
- data/lib/cocoapods-tj/config/config_asker.rb +49 -0
- data/lib/cocoapods-tj/config/config_builder.rb +201 -0
- data/lib/cocoapods-tj/config/config_hot_key.rb +102 -0
- data/lib/cocoapods-tj/config/config_hot_key_asker.rb +48 -0
- data/lib/cocoapods-tj/gem_version.rb +10 -0
- data/lib/cocoapods-tj/helpers/Info.plist +0 -0
- data/lib/cocoapods-tj/helpers/build_helper.rb +154 -0
- data/lib/cocoapods-tj/helpers/build_utils.rb +62 -0
- data/lib/cocoapods-tj/helpers/framework.rb +79 -0
- data/lib/cocoapods-tj/helpers/framework_builder.rb +391 -0
- data/lib/cocoapods-tj/helpers/library.rb +54 -0
- data/lib/cocoapods-tj/helpers/library_builder.rb +89 -0
- data/lib/cocoapods-tj/helpers/local/loca_llibrary.rb +57 -0
- data/lib/cocoapods-tj/helpers/local/local_build_helper.rb +177 -0
- data/lib/cocoapods-tj/helpers/local/local_framework.rb +85 -0
- data/lib/cocoapods-tj/helpers/local/local_framework_builder.rb +226 -0
- data/lib/cocoapods-tj/helpers/local/local_library_builder.rb +91 -0
- data/lib/cocoapods-tj/helpers/sources_helper.rb +32 -0
- data/lib/cocoapods-tj/helpers/spec_creator.rb +150 -0
- data/lib/cocoapods-tj/helpers/spec_files_helper.rb +73 -0
- data/lib/cocoapods-tj/helpers/spec_source_creator.rb +189 -0
- data/lib/cocoapods-tj/helpers/upload_helper.rb +81 -0
- data/lib/cocoapods-tj/helpers.rb +5 -0
- data/lib/cocoapods-tj/native/acknowledgements.rb +26 -0
- data/lib/cocoapods-tj/native/analyzer.rb +29 -0
- data/lib/cocoapods-tj/native/file_accessor.rb +20 -0
- data/lib/cocoapods-tj/native/installation_options.rb +21 -0
- data/lib/cocoapods-tj/native/installer.rb +106 -0
- data/lib/cocoapods-tj/native/linter.rb +26 -0
- data/lib/cocoapods-tj/native/path_source.rb +29 -0
- data/lib/cocoapods-tj/native/pod_source_installer.rb +18 -0
- data/lib/cocoapods-tj/native/pod_target_installer.rb +81 -0
- data/lib/cocoapods-tj/native/podfile.rb +91 -0
- data/lib/cocoapods-tj/native/podfile_env.rb +37 -0
- data/lib/cocoapods-tj/native/podfile_generator.rb +135 -0
- data/lib/cocoapods-tj/native/podspec_finder.rb +23 -0
- data/lib/cocoapods-tj/native/resolver.rb +202 -0
- data/lib/cocoapods-tj/native/sandbox_analyzer.rb +11 -0
- data/lib/cocoapods-tj/native/source.rb +35 -0
- data/lib/cocoapods-tj/native/sources_manager.rb +18 -0
- data/lib/cocoapods-tj/native/specification.rb +10 -0
- data/lib/cocoapods-tj/native/target_validator.rb +41 -0
- data/lib/cocoapods-tj/native/validator.rb +40 -0
- data/lib/cocoapods-tj/native.rb +23 -0
- data/lib/cocoapods-tj/source_provider_hook.rb +50 -0
- data/lib/cocoapods-tj.rb +2 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2ab57722083f35a7c6fb6b12987b7d84088d4c65cb431d8604f3d16a0126759a
|
4
|
+
data.tar.gz: 027cb025549caa0d801abf6f6f2215834e5ca300869315ce3b2c288582a7863a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 833e4b77cbf4b231d3a08f69d46abb2f9119d06f7d7d39b5e4c0bce3a19290da7091307b177adb611844134551cb4544c79017432b7db7270d90bec3907cc950
|
7
|
+
data.tar.gz: a5e0253ed36d971578c898210404c6f8ac929dbe2ba7cf4037f4341928ab2bc3a3f17d8408da0b8b4755b27e4597661006f1e0503bdcd6e62450461e9bd329f1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'cocoapods-tj/native/podfile'
|
2
|
+
require 'cocoapods/command/gen'
|
3
|
+
require 'cocoapods/generate'
|
4
|
+
require 'cocoapods-tj/helpers/framework_builder'
|
5
|
+
require 'cocoapods-tj/helpers/library_builder'
|
6
|
+
require 'cocoapods-tj/helpers/build_helper'
|
7
|
+
require 'cocoapods-tj/helpers/spec_source_creator'
|
8
|
+
require 'cocoapods-tj/config/config_builder'
|
9
|
+
require 'cocoapods-tj/command/bin/lib/lint'
|
10
|
+
require 'xcodeproj'
|
11
|
+
|
12
|
+
module Pod
|
13
|
+
class Command
|
14
|
+
class Bin < Command
|
15
|
+
class Archive < Bin
|
16
|
+
|
17
|
+
@@missing_binary_specs = []
|
18
|
+
|
19
|
+
self.summary = ''
|
20
|
+
self.description = <<-DESC
|
21
|
+
|
22
|
+
DESC
|
23
|
+
|
24
|
+
def self.options
|
25
|
+
[
|
26
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
27
|
+
['--code-dependencies', '使用源码依赖'],
|
28
|
+
['--no-clean', '保留构建中间产物'],
|
29
|
+
['--sources', '私有源地址,多个用分号区分'],
|
30
|
+
['--framework-output', '输出framework文件'],
|
31
|
+
['--no-zip', '不压缩静态库 为 zip'],
|
32
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
33
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
34
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
35
|
+
end
|
36
|
+
|
37
|
+
self.arguments = [
|
38
|
+
CLAide::Argument.new('NAME.podspec', false)
|
39
|
+
]
|
40
|
+
|
41
|
+
def initialize(argv)
|
42
|
+
@env = argv.option('env') || 'dev'
|
43
|
+
CBin.config.set_configuration_env(@env)
|
44
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
45
|
+
@framework_output = argv.flag?('framework-output', false )
|
46
|
+
@clean = argv.flag?('no-clean', false)
|
47
|
+
@zip = argv.flag?('zip', true)
|
48
|
+
@all_make = argv.flag?('all-make', false )
|
49
|
+
@sources = argv.option('sources') || []
|
50
|
+
@platform = Platform.new(:ios)
|
51
|
+
|
52
|
+
@config = argv.option('configuration', 'Release')
|
53
|
+
|
54
|
+
@framework_path
|
55
|
+
super
|
56
|
+
|
57
|
+
@additional_args = argv.remainder!
|
58
|
+
@build_finshed = false
|
59
|
+
end
|
60
|
+
|
61
|
+
def run
|
62
|
+
CBin::Config::Builder.instance.clean
|
63
|
+
|
64
|
+
@spec = Specification.from_file(spec_file)
|
65
|
+
generate_project
|
66
|
+
|
67
|
+
swift_pods_buildsetting
|
68
|
+
|
69
|
+
build_root_spec
|
70
|
+
|
71
|
+
sources_sepc = Array.new
|
72
|
+
sources_sepc << @spec
|
73
|
+
sources_sepc.concat(build_dependencies) if @all_make
|
74
|
+
|
75
|
+
sources_sepc
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_root_spec
|
79
|
+
builder = CBin::Build::Helper.new(@spec,
|
80
|
+
@platform,
|
81
|
+
@framework_output,
|
82
|
+
@zip,
|
83
|
+
@spec,
|
84
|
+
CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
|
85
|
+
@config)
|
86
|
+
builder.build
|
87
|
+
builder.clean_workspace if @clean && !@all_make
|
88
|
+
end
|
89
|
+
|
90
|
+
def build_dependencies
|
91
|
+
@build_finshed = true
|
92
|
+
sources_sepc = []
|
93
|
+
@@missing_binary_specs.uniq.each do |spec|
|
94
|
+
next if spec.name.include?('/')
|
95
|
+
next if spec.name == @spec.name
|
96
|
+
next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
|
97
|
+
if spec.source[:git] && spec.source[:git]
|
98
|
+
spec_git = spec.source[:git]
|
99
|
+
spec_git_res = false
|
100
|
+
CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
101
|
+
spec_git_res = spec_git.include?(ignore_git)
|
102
|
+
break if spec_git_res
|
103
|
+
end
|
104
|
+
next if spec_git_res
|
105
|
+
end
|
106
|
+
next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
107
|
+
next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
108
|
+
sources_sepc << spec
|
109
|
+
end
|
110
|
+
|
111
|
+
fail_build_specs = []
|
112
|
+
sources_sepc.uniq.each do |spec|
|
113
|
+
begin
|
114
|
+
builder = CBin::Build::Helper.new(spec,
|
115
|
+
@platform,
|
116
|
+
@framework_output,
|
117
|
+
@zip,
|
118
|
+
@spec,
|
119
|
+
false ,
|
120
|
+
@config)
|
121
|
+
builder.build
|
122
|
+
rescue Object => exception
|
123
|
+
UI.puts exception
|
124
|
+
fail_build_specs << spec
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
if fail_build_specs.any?
|
129
|
+
fail_build_specs.uniq.each do |spec|
|
130
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
|
131
|
+
end
|
132
|
+
end
|
133
|
+
sources_sepc - fail_build_specs
|
134
|
+
end
|
135
|
+
|
136
|
+
def Archive.missing_binary_specs(missing_binary_specs)
|
137
|
+
@@missing_binary_specs = missing_binary_specs unless @build_finshed
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def generate_project
|
143
|
+
Podfile.execute_with_bin_plugin do
|
144
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
145
|
+
argvs = [
|
146
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
147
|
+
"--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
|
148
|
+
'--clean',
|
149
|
+
"--verbose",
|
150
|
+
*@additional_args
|
151
|
+
]
|
152
|
+
|
153
|
+
if File.exist?(Pod::Config.instance.podfile_path)
|
154
|
+
argvs += ['--use-podfile']
|
155
|
+
end
|
156
|
+
|
157
|
+
unless CBin::Build::Utils.uses_frameworks?
|
158
|
+
argvs += ['--use-libraries']
|
159
|
+
end
|
160
|
+
|
161
|
+
argvs << spec_file if spec_file
|
162
|
+
|
163
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
164
|
+
gen.validate!
|
165
|
+
gen.run
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def swift_pods_buildsetting
|
171
|
+
worksppace_path = File.expand_path("#{CBin::Config::Builder.instance.gen_dir}/#{@spec.name}")
|
172
|
+
path = File.join(worksppace_path, "Pods.xcodeproj")
|
173
|
+
path = File.join(worksppace_path, "Pods/Pods.xcodeproj") unless File.exist?(path)
|
174
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
175
|
+
project = Xcodeproj::Project.open(path)
|
176
|
+
project.build_configurations.each do |x|
|
177
|
+
x.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true #设置生成swift inter
|
178
|
+
end
|
179
|
+
project.save
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def spec_file
|
184
|
+
@spec_file ||= begin
|
185
|
+
if @podspec
|
186
|
+
find_spec_file(@podspec)
|
187
|
+
else
|
188
|
+
if code_spec_files.empty?
|
189
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
190
|
+
end
|
191
|
+
|
192
|
+
spec_file = code_spec_files.first
|
193
|
+
spec_file
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-tj/command/bin/auto'
|
3
|
+
require 'cocoapods-tj/helpers/upload_helper'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Bin < Command
|
8
|
+
class Auto < Bin
|
9
|
+
self.summary = '打开 workspace 工程.'
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('NAME.podspec', false)
|
13
|
+
]
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--code-dependencies', '使用源码依赖'],
|
17
|
+
['--allow-prerelease', '允许使用 prerelease 的版本'],
|
18
|
+
['--no-clean', '保留构建中间产物'],
|
19
|
+
['--framework-output', '输出framework文件'],
|
20
|
+
['--no-zip', '不压缩静态 framework 为 zip'],
|
21
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
22
|
+
['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
|
23
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
24
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(argv)
|
28
|
+
|
29
|
+
@env = argv.option('env') || 'dev'
|
30
|
+
CBin.config.set_configuration_env(@env)
|
31
|
+
|
32
|
+
@podspec = argv.shift_argument || find_podspec
|
33
|
+
@specification = Specification.from_file(@podspec)
|
34
|
+
|
35
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
36
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
37
|
+
@framework_output = argv.flag?('framework-output', false )
|
38
|
+
@clean = argv.flag?('clean', true)
|
39
|
+
@zip = argv.flag?('zip', true)
|
40
|
+
@all_make = argv.flag?('all-make', false )
|
41
|
+
@verbose = argv.flag?('verbose',true)
|
42
|
+
|
43
|
+
@config = argv.option('configuration', 'Debug')
|
44
|
+
@additional_args = argv.remainder!
|
45
|
+
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def run
|
50
|
+
|
51
|
+
unless @podspec
|
52
|
+
raise Informative, "未找到 podspec文件"
|
53
|
+
end
|
54
|
+
sources_sepc = run_archive
|
55
|
+
|
56
|
+
fail_push_specs = []
|
57
|
+
sources_sepc.uniq.each do |spec|
|
58
|
+
begin
|
59
|
+
fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
|
60
|
+
rescue Object => exception
|
61
|
+
UI.puts exception
|
62
|
+
fail_push_specs << spec
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if fail_push_specs.any?
|
67
|
+
fail_push_specs.uniq.each do |spec|
|
68
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
success_specs = sources_sepc - fail_push_specs
|
73
|
+
if success_specs.any?
|
74
|
+
auto_success = ""
|
75
|
+
success_specs.uniq.each do |spec|
|
76
|
+
auto_success += "#{spec.name} | #{spec.version}\n"
|
77
|
+
end
|
78
|
+
puts auto_success
|
79
|
+
ENV['auto_success'] = auto_success
|
80
|
+
end
|
81
|
+
UI.section("\nUpdating Spec Repositories\n".yellow) do
|
82
|
+
Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def run_archive
|
89
|
+
argvs = [
|
90
|
+
"--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
|
91
|
+
@additional_args
|
92
|
+
]
|
93
|
+
|
94
|
+
argvs << spec_file if spec_file
|
95
|
+
argvs.delete(Array.new)
|
96
|
+
|
97
|
+
unless @clean
|
98
|
+
argvs += ['--no-clean']
|
99
|
+
end
|
100
|
+
if @code_dependencies
|
101
|
+
argvs += ['--code-dependencies']
|
102
|
+
end
|
103
|
+
if @verbose
|
104
|
+
argvs += ['--verbose']
|
105
|
+
end
|
106
|
+
if @allow_prerelease
|
107
|
+
argvs += ['--allow-prerelease']
|
108
|
+
end
|
109
|
+
if @framework_output
|
110
|
+
argvs += ['--framework-output']
|
111
|
+
end
|
112
|
+
if @all_make
|
113
|
+
argvs += ['--all-make']
|
114
|
+
end
|
115
|
+
if @env
|
116
|
+
argvs += ["--env=#{@env}"]
|
117
|
+
end
|
118
|
+
argvs += ["--configuration=#{@config}"]
|
119
|
+
|
120
|
+
archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
|
121
|
+
archive.validate!
|
122
|
+
sources_sepc = archive.run
|
123
|
+
sources_sepc
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
def code_podsepc_extname
|
128
|
+
'.podsepc'
|
129
|
+
end
|
130
|
+
|
131
|
+
def binary_podsepc_json
|
132
|
+
"#{@specification.name}.binary.podspec.json"
|
133
|
+
end
|
134
|
+
|
135
|
+
def binary_template_podsepc
|
136
|
+
"#{@specification.name}.binary-template.podspec"
|
137
|
+
end
|
138
|
+
|
139
|
+
def template_spec_file
|
140
|
+
@template_spec_file ||= begin
|
141
|
+
if @template_podspec
|
142
|
+
find_spec_file(@template_podspec)
|
143
|
+
else
|
144
|
+
binary_template_spec_file
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def spec_file
|
150
|
+
@spec_file ||= begin
|
151
|
+
if @podspec
|
152
|
+
find_spec_file(@podspec) || @podspec
|
153
|
+
else
|
154
|
+
if code_spec_files.empty?
|
155
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
156
|
+
end
|
157
|
+
|
158
|
+
spec_file = if @binary
|
159
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
160
|
+
if template_spec_file
|
161
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
162
|
+
end
|
163
|
+
create_binary_spec_file(code_spec, template_spec)
|
164
|
+
else
|
165
|
+
code_spec_files.first
|
166
|
+
end
|
167
|
+
spec_file
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def find_podspec
|
173
|
+
Pathname.pwd.children.each do |child|
|
174
|
+
puts child
|
175
|
+
if File.file?(child)
|
176
|
+
if child.extname == '.podspec'
|
177
|
+
name = File.basename(child)
|
178
|
+
unless name.include?("binary-template")
|
179
|
+
return name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class Bin < Command
|
5
|
+
class Code < Bin
|
6
|
+
self.summary = ''
|
7
|
+
|
8
|
+
self.description = <<-DESC
|
9
|
+
|
10
|
+
DESC
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('NAME', false)
|
14
|
+
]
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--all-clean', '删除所有已经下载的源码'],
|
18
|
+
['--clean', '删除所有指定下载的源码'],
|
19
|
+
['--list', '展示所有一级下载的源码以及其大小'],
|
20
|
+
['--source', '源码路径,本地路径,会去自动链接本地源码']
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@codeSource = argv.option('source') || nil
|
26
|
+
@names = argv.arguments! unless argv.arguments.empty?
|
27
|
+
@list = argv.flag?('list', false )
|
28
|
+
@all_clean = argv.flag?('all-clean', false )
|
29
|
+
@clean = argv.flag?('clean', false )
|
30
|
+
|
31
|
+
@config = Pod::Config.instance
|
32
|
+
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def run
|
38
|
+
|
39
|
+
podfile_lock = File.join(Pathname.pwd,"Podfile.lock")
|
40
|
+
raise "podfile.lock,不存在,请先pod install/update" unless File.exist?(podfile_lock)
|
41
|
+
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock) )
|
42
|
+
|
43
|
+
if @list
|
44
|
+
list
|
45
|
+
elsif @clean
|
46
|
+
clean
|
47
|
+
elsif @all_clean
|
48
|
+
all_clean
|
49
|
+
elsif @names
|
50
|
+
add
|
51
|
+
end
|
52
|
+
|
53
|
+
if @list && @clean && @names
|
54
|
+
raise "请选择您要执行的命令。"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def add
|
60
|
+
if @names == nil
|
61
|
+
raise "请输入要调试组件名,多个组件名称用空格分隔"
|
62
|
+
end
|
63
|
+
|
64
|
+
@names.each do |name|
|
65
|
+
lib_file = get_lib_path(name)
|
66
|
+
unless File.exist?(lib_file)
|
67
|
+
raise "找不到 #{lib_file}"
|
68
|
+
end
|
69
|
+
UI.puts "#{lib_file}"
|
70
|
+
|
71
|
+
target_path = @codeSource || download_source(name)
|
72
|
+
|
73
|
+
link(lib_file,target_path,name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def download_source(name)
|
78
|
+
target_path = File.join(source_root, name)
|
79
|
+
UI.puts target_path
|
80
|
+
FileUtils.rm_rf(target_path)
|
81
|
+
|
82
|
+
find_dependency = find_dependency(name)
|
83
|
+
|
84
|
+
spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
|
85
|
+
|
86
|
+
download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
|
87
|
+
Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
|
88
|
+
|
89
|
+
target_path
|
90
|
+
end
|
91
|
+
|
92
|
+
def find_dependency (name)
|
93
|
+
find_dependency = nil
|
94
|
+
@config.podfile.dependencies.each do |dependency|
|
95
|
+
if dependency.root_name.downcase == name.downcase
|
96
|
+
find_dependency = dependency
|
97
|
+
break
|
98
|
+
end
|
99
|
+
end
|
100
|
+
find_dependency
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def fetch_external_source(dependency ,podfile , lockfile, sandbox,use_lockfile_options)
|
105
|
+
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
|
106
|
+
source.fetch(sandbox)
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
def link(lib_file,target_path,basename)
|
112
|
+
dir = (`dwarfdump "#{lib_file}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2 `)
|
113
|
+
sub_path = "#{basename}/bin-archive/#{basename}"
|
114
|
+
dir = dir.gsub(sub_path, "").chomp
|
115
|
+
|
116
|
+
unless File.exist?(dir)
|
117
|
+
begin
|
118
|
+
FileUtils.mkdir_p(dir)
|
119
|
+
rescue SystemCallError
|
120
|
+
array = dir.split('/')
|
121
|
+
if array.length > 3
|
122
|
+
root_path = '/' + array[1] + '/' + array[2]
|
123
|
+
unless File.exist?(root_path)
|
124
|
+
raise "由于权限不足,请手动创建#{root_path} 后重试"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if Pathname.new(lib_file).extname == ".a"
|
131
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
132
|
+
`ln -s #{target_path} #{dir}`
|
133
|
+
else
|
134
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
135
|
+
`ln -s #{target_path} #{dir}/#{basename}`
|
136
|
+
end
|
137
|
+
|
138
|
+
check(lib_file,dir,basename)
|
139
|
+
end
|
140
|
+
|
141
|
+
def check(lib_file,dir,basename)
|
142
|
+
file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
|
143
|
+
if File.exist?(file)
|
144
|
+
raise "#{file} 不存在 请检测代码源是否正确~"
|
145
|
+
end
|
146
|
+
UI.puts "link successfully!"
|
147
|
+
UI.puts "view linked source at path: #{dir}"
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_lib_path(name)
|
151
|
+
dir = Pathname.new(File.join(Pathname.pwd,"Pods",name))
|
152
|
+
lib_name = "lib#{name}.a"
|
153
|
+
lib_path = File.join(dir,lib_name)
|
154
|
+
|
155
|
+
unless File.exist?(lib_path)
|
156
|
+
lib_path = File.join(dir.children.first,lib_name)
|
157
|
+
end
|
158
|
+
|
159
|
+
lib_path
|
160
|
+
end
|
161
|
+
|
162
|
+
def list
|
163
|
+
Dir.entries(source_root).each do |sub|
|
164
|
+
UI.puts "- #{sub}" unless sub.include?('.')
|
165
|
+
end
|
166
|
+
UI.puts "加载完成"
|
167
|
+
end
|
168
|
+
|
169
|
+
def all_clean
|
170
|
+
FileUtils.rm_rf(source_root) if File.directory?(source_root)
|
171
|
+
UI.puts "清理完成 #{source_root}"
|
172
|
+
end
|
173
|
+
|
174
|
+
def clean
|
175
|
+
raise "请输入要删除的组件库" if @names.nil?
|
176
|
+
@names.each do |name|
|
177
|
+
full_path = File.join(source_root,name)
|
178
|
+
if File.directory?(full_path)
|
179
|
+
FileUtils.rm_rf(full_path)
|
180
|
+
else
|
181
|
+
UI.puts "找不到 #{full_path}".yellow
|
182
|
+
end
|
183
|
+
end
|
184
|
+
UI.puts "清理完成 #{@names.to_s}"
|
185
|
+
end
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
def source_root
|
190
|
+
dir = File.join(@config.cache_root,"Source")
|
191
|
+
FileUtils.mkdir_p(dir) unless File.exist? dir
|
192
|
+
dir
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'cocoapods-tj/config/config_hot_key_asker'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Imy < Bin
|
7
|
+
self.summary = ''
|
8
|
+
self.description = <<-DESC
|
9
|
+
|
10
|
+
DESC
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('1', false)
|
14
|
+
]
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
].concat(super)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
@hot_key = argv.shift_argument || '1'
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
CBin.config_hot_key.set_hot_key_index(@hot_key)
|
28
|
+
UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
|
29
|
+
|
30
|
+
if Dir.exist?(CBin.config_hot_key.hot_key_dir)
|
31
|
+
Dir.chdir(CBin.config_hot_key.hot_key_dir) do
|
32
|
+
UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
|
33
|
+
system CBin.config_hot_key.hot_key_cmd
|
34
|
+
end
|
35
|
+
else
|
36
|
+
raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|