cocoapods-xp-binary-debug 0.0.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/.gitignore +3 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-xp-binary-debug.gemspec +23 -0
- data/lib/cocoapods-xp-binary-debug/command/debug.rb +245 -0
- data/lib/cocoapods-xp-binary-debug/command.rb +1 -0
- data/lib/cocoapods-xp-binary-debug/gem_version.rb +3 -0
- data/lib/cocoapods-xp-binary-debug.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/debug_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e3ad1bd6a7105cc2a0e2c0f1db38c1cc639840ba861d5923cec9cf37b1cc34e
|
4
|
+
data.tar.gz: 9ee82a967bfb21475f678cc23c2fb197320a98a45f28ca0d94f55ae5db65541a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d228d3cfab9989bc33633cbf7a4db59a9776d7adf4177aa1c5eb7e7e6428c12fdd05619f217fdc3bb241887930fa46644b8f88d84645a476a217ac504724cc8a
|
7
|
+
data.tar.gz: c2174078e14ac7bab87e341a9a6dbe7afe832608f2c86665a8dcfd17adc6ba306498aad7765a15a3b5e93ae94bb4e453e23e46892adfc099b86a350f954343e6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2022 林俊炳 <linjb@xiaopeng.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-xp-binary-debug/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-xp-binary-debug'
|
8
|
+
spec.version = CocoapodsXpBinaryDebug::VERSION
|
9
|
+
spec.authors = ['林俊炳']
|
10
|
+
spec.email = ['linjb@xiaopeng.com']
|
11
|
+
spec.description = %q{A short description of cocoapods-xp-binary-debug.}
|
12
|
+
spec.summary = %q{A longer description of cocoapods-xp-binary-debug.}
|
13
|
+
spec.homepage = 'https://github.com/EXAMPLE/cocoapods-xp-binary-debug'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
4
|
+
# to the 'pod' command.
|
5
|
+
#
|
6
|
+
# You can also create subcommands of existing or new commands. Say you
|
7
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
8
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
9
|
+
# to change.
|
10
|
+
#
|
11
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
12
|
+
# the class to exist in the the Pod::Command::List namespace
|
13
|
+
# - change this class to extend from `List` instead of `Command`. This
|
14
|
+
# tells the plugin system that it is a subcommand of `list`.
|
15
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
16
|
+
#
|
17
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
18
|
+
# in the `plugins.json` file, once your plugin is released.
|
19
|
+
#
|
20
|
+
class Debug < Command
|
21
|
+
self.summary = '通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。'
|
22
|
+
|
23
|
+
self.description = <<-DESC
|
24
|
+
通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。
|
25
|
+
在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
|
26
|
+
DESC
|
27
|
+
|
28
|
+
self.arguments = [
|
29
|
+
CLAide::Argument.new('NAME', false)
|
30
|
+
]
|
31
|
+
def self.options
|
32
|
+
[
|
33
|
+
['--all-clean', '删除所有已经下载的源码'],
|
34
|
+
['--clean', '删除所有指定下载的源码'],
|
35
|
+
['--list', '展示所有一级下载的源码以及其大小'],
|
36
|
+
['--source', '源码路径,本地路径,会去自动链接本地源码']
|
37
|
+
]
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(argv)
|
41
|
+
@codeSource = argv.option('source') || nil
|
42
|
+
@names = argv.arguments! unless argv.arguments.empty?
|
43
|
+
@list = argv.flag?('list', false )
|
44
|
+
@all_clean = argv.flag?('all-clean', false )
|
45
|
+
@clean = argv.flag?('clean', false )
|
46
|
+
|
47
|
+
@config = Pod::Config.instance
|
48
|
+
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def run
|
54
|
+
|
55
|
+
podfile_lock = File.join(Pathname.pwd,"Podfile.lock")
|
56
|
+
raise "podfile.lock,不存在,请先pod install/update" unless File.exist?(podfile_lock)
|
57
|
+
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock) )
|
58
|
+
|
59
|
+
if @list
|
60
|
+
list
|
61
|
+
elsif @clean
|
62
|
+
clean
|
63
|
+
elsif @all_clean
|
64
|
+
all_clean
|
65
|
+
elsif @names
|
66
|
+
add
|
67
|
+
end
|
68
|
+
|
69
|
+
if @list && @clean && @names
|
70
|
+
raise "请选择您要执行的命令。"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#==========================begin add ==============
|
75
|
+
|
76
|
+
def add
|
77
|
+
if @names == nil
|
78
|
+
raise "请输入要调试组件名,多个组件名称用空格分隔"
|
79
|
+
end
|
80
|
+
|
81
|
+
@names.each do |name|
|
82
|
+
lib_file = get_lib_path(name)
|
83
|
+
unless File.exist?(lib_file)
|
84
|
+
raise "找不到 #{lib_file}"
|
85
|
+
end
|
86
|
+
UI.puts "#{lib_file}"
|
87
|
+
|
88
|
+
target_path = @codeSource || download_source(name)
|
89
|
+
|
90
|
+
link(lib_file,target_path,name)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
#下载源码到本地
|
95
|
+
def download_source(name)
|
96
|
+
target_path = File.join(source_root, name)
|
97
|
+
UI.puts target_path
|
98
|
+
FileUtils.rm_rf(target_path)
|
99
|
+
|
100
|
+
find_dependency = find_dependency(name)
|
101
|
+
|
102
|
+
spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
|
103
|
+
|
104
|
+
download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
|
105
|
+
Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
|
106
|
+
|
107
|
+
target_path
|
108
|
+
end
|
109
|
+
|
110
|
+
#找出依赖
|
111
|
+
def find_dependency (name)
|
112
|
+
find_dependency = nil
|
113
|
+
@config.podfile.dependencies.each do |dependency|
|
114
|
+
if dependency.root_name.downcase == name.downcase
|
115
|
+
find_dependency = dependency
|
116
|
+
break
|
117
|
+
end
|
118
|
+
end
|
119
|
+
find_dependency
|
120
|
+
end
|
121
|
+
|
122
|
+
# 获取external_source 下的仓库
|
123
|
+
# @return spec
|
124
|
+
def fetch_external_source(dependency ,podfile , lockfile, sandbox,use_lockfile_options)
|
125
|
+
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
|
126
|
+
source.fetch(sandbox)
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
#==========================link begin ==============
|
131
|
+
|
132
|
+
#链接,.a文件位置, 源码目录,工程名=IMYFoundation
|
133
|
+
def link(lib_file,target_path,basename)
|
134
|
+
dir = (`dwarfdump "#{lib_file}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2 `)
|
135
|
+
sub_path = "#{basename}/bin-archive/#{basename}"
|
136
|
+
dir = dir.gsub(sub_path, "").chomp
|
137
|
+
# UI.puts "dir = #{dir}"
|
138
|
+
|
139
|
+
unless File.exist?(dir)
|
140
|
+
# UI.puts "不存在 = #{dir}"
|
141
|
+
begin
|
142
|
+
FileUtils.mkdir_p(dir)
|
143
|
+
rescue SystemCallError
|
144
|
+
#判断用户目录是否存在
|
145
|
+
array = dir.split('/')
|
146
|
+
if array.length > 3
|
147
|
+
root_path = '/' + array[1] + '/' + array[2]
|
148
|
+
unless File.exist?(root_path)
|
149
|
+
raise "由于权限不足,请手动创建#{root_path} 后重试"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
if Pathname.new(lib_file).extname == ".a"
|
156
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
157
|
+
`ln -s #{target_path} #{dir}`
|
158
|
+
else
|
159
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
160
|
+
`ln -s #{target_path} #{dir}/#{basename}`
|
161
|
+
end
|
162
|
+
|
163
|
+
check(lib_file,dir,basename)
|
164
|
+
end
|
165
|
+
|
166
|
+
def check(lib_file,dir,basename)
|
167
|
+
file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
|
168
|
+
if File.exist?(file)
|
169
|
+
raise "#{file} 不存在 请检测代码源是否正确~"
|
170
|
+
end
|
171
|
+
UI.puts "link successfully!"
|
172
|
+
UI.puts "view linked source at path: #{dir}"
|
173
|
+
end
|
174
|
+
|
175
|
+
def get_lib_path(name)
|
176
|
+
dir = Pathname.new(File.join(Pathname.pwd,"Pods",name))
|
177
|
+
lib_name = "lib#{name}.a"
|
178
|
+
lib_path = File.join(dir,lib_name)
|
179
|
+
|
180
|
+
unless File.exist?(lib_path)
|
181
|
+
lib_path = File.join(dir.children.first,lib_name)
|
182
|
+
end
|
183
|
+
|
184
|
+
lib_path
|
185
|
+
end
|
186
|
+
|
187
|
+
#源码地址
|
188
|
+
# def get_gitlib_iOS_path(name)
|
189
|
+
# "git@gitlab.xxx.com:iOS/#{name}.git"
|
190
|
+
# end
|
191
|
+
#要转换的地址,Github-iOS默认都是静态库
|
192
|
+
# def git_gitlib_iOS_path
|
193
|
+
# 'git@gitlab.xxx.com:Github-iOS/'
|
194
|
+
# end
|
195
|
+
|
196
|
+
|
197
|
+
#要转换的地址,Github-iOS默认都是静态库
|
198
|
+
# def http_gitlib_GitHub_iOS_path
|
199
|
+
# 'https://gitlab.xxx.com/Github-iOS/'
|
200
|
+
# end
|
201
|
+
|
202
|
+
#要转换的地址,iOS默认都是静态库
|
203
|
+
# def http_gitlib_iOS_path
|
204
|
+
# 'https://gitlab.xxx.com/iOS/'
|
205
|
+
# end
|
206
|
+
|
207
|
+
#==========================list begin ==============
|
208
|
+
|
209
|
+
def list
|
210
|
+
Dir.entries(source_root).each do |sub|
|
211
|
+
UI.puts "- #{sub}" unless sub.include?('.')
|
212
|
+
end
|
213
|
+
UI.puts "加载完成"
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
#==========================clean begin ==============
|
218
|
+
def all_clean
|
219
|
+
FileUtils.rm_rf(source_root) if File.directory?(source_root)
|
220
|
+
UI.puts "清理完成 #{source_root}"
|
221
|
+
end
|
222
|
+
|
223
|
+
def clean
|
224
|
+
raise "请输入要删除的组件库" if @names.nil?
|
225
|
+
@names.each do |name|
|
226
|
+
full_path = File.join(source_root,name)
|
227
|
+
if File.directory?(full_path)
|
228
|
+
FileUtils.rm_rf(full_path)
|
229
|
+
else
|
230
|
+
UI.puts "找不到 #{full_path}".yellow
|
231
|
+
end
|
232
|
+
end
|
233
|
+
UI.puts "清理完成 #{@names.to_s}"
|
234
|
+
end
|
235
|
+
|
236
|
+
private
|
237
|
+
|
238
|
+
def source_root
|
239
|
+
dir = File.join(@config.cache_root,"Source")
|
240
|
+
FileUtils.mkdir_p(dir) unless File.exist? dir
|
241
|
+
dir
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-xp-binary-debug/command/debug'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-xp-binary-debug/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-xp-binary-debug/command'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-xp-binary-debug
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 林俊炳
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A short description of cocoapods-xp-binary-debug.
|
42
|
+
email:
|
43
|
+
- linjb@xiaopeng.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- cocoapods-xp-binary-debug.gemspec
|
54
|
+
- lib/cocoapods-xp-binary-debug.rb
|
55
|
+
- lib/cocoapods-xp-binary-debug/command.rb
|
56
|
+
- lib/cocoapods-xp-binary-debug/command/debug.rb
|
57
|
+
- lib/cocoapods-xp-binary-debug/gem_version.rb
|
58
|
+
- lib/cocoapods_plugin.rb
|
59
|
+
- spec/command/debug_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/EXAMPLE/cocoapods-xp-binary-debug
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.0.3.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A longer description of cocoapods-xp-binary-debug.
|
84
|
+
test_files:
|
85
|
+
- spec/command/debug_spec.rb
|
86
|
+
- spec/spec_helper.rb
|