cocoapods-vbbuildsource 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 583106b2fcf0d5b22a0fd75d64be82462a83906f09f8a5bd02c86ccc6ce3fd06
4
+ data.tar.gz: 819bc37d0bc7ed3a8c650e6ace66fca9a97ea1467023c0be70ffd9288e4d2981
5
+ SHA512:
6
+ metadata.gz: ee0fca905427587e05f35d6ba910b30a0c44562d45ba827bad66a4cc7ef4878ad68fea25519f5e46ba0000c5fdf463b904d5b9ec6440d540337e2eba1905c0af
7
+ data.tar.gz: c17e79c9b8ba2b767ac8d0cb076075a7a9d2ecff3925d0782cc3658cd643febb5b0ca884e4c2f27dd35977fc51a5657ad9427fd88d1ef9240d99b1499a7b35df
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-vbbuildsource.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods', '1.10.0'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 faliu <faliu@tencent.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
@@ -0,0 +1,11 @@
1
+ # cocoapods-vbbuildsource
2
+
3
+ A description of cocoapods-vbbuildsource.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-vbbuildsource
8
+
9
+ ## Usage
10
+
11
+ $ pod spec vbbuildsource POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -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-vbbuildsource/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-vbbuildsource'
8
+ spec.version = CocoapodsVbbuildsource::VERSION
9
+ spec.authors = ['faliu']
10
+ spec.email = ['faliu@tencent.com']
11
+ spec.description = %q{A short description of cocoapods-vbbuildsource.}
12
+ spec.summary = %q{A longer description of cocoapods-vbbuildsource.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-vbbuildsource'
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,156 @@
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 Vbbuildsource < Command
21
+ self.summary = 'Short description of cocoapods-vbbuildsource.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-vbbuildsource.
25
+ DESC
26
+
27
+ self.arguments = 'NAME'
28
+
29
+ def self.options
30
+ [
31
+ ['--clean-module', '删除模式,用于删除已经下载好源文件的组件'],
32
+ ]
33
+ end
34
+
35
+ def initialize(argv)
36
+ @module_name = argv.shift_argument
37
+ @clean_module = argv.flag?('clean-module', false)
38
+ super
39
+ end
40
+
41
+ def validate!
42
+ super
43
+ help! 'A module_name name is required.' unless @module_name
44
+ end
45
+
46
+ def run
47
+ @installer = installer_for_config
48
+ @installer.resolve_dependencies
49
+
50
+ pod_target = find_pod_target @installer
51
+
52
+ help! "该pod库 #{@module_name} 未找到" unless pod_target
53
+
54
+ framework_file_path = pod_target.all_files.first
55
+
56
+ framework_file_path = Pathname.new(framework_file_path) if framework_file_path.is_a? String
57
+
58
+ help! "该pod库 #{@module_name} 不是一个framework" unless pod_target.all_files.count == 1 and framework_file_path.extname.end_with? 'framework'
59
+
60
+ binary_build_path = find_binary_build_path framework_file_path
61
+
62
+ module_source_path = download_source_code_file binary_build_path
63
+
64
+ puts "#{@module_name} 库源文件 路径为 #{module_source_path}"
65
+ puts "---------完成库#{@module_name} 文件切换为源码,请刷新xcode(切换页面或者单步调试一下)---------"
66
+ end
67
+
68
+ def find_pod_target installer
69
+ pod_target_list = installer.pod_targets
70
+ pod_target = nil
71
+ pod_target_list.each do |target|
72
+ if target.pod_name == @module_name then
73
+ pod_target = target
74
+ break
75
+ end
76
+ end
77
+ pod_target
78
+ end
79
+
80
+ def find_binary_build_path framework_file_path
81
+
82
+ binary_file_path = find_binary_file_in_framework framework_file_path
83
+ help! "未找到库 #{@module_name} 的二进制文件" unless binary_file_path
84
+ # 找到framework里面的某一个.h头文件的 DW_AT_decl_file 字段
85
+ first_head_file = find_first_head_file_in_framework framework_file_path
86
+ binary_build_path_string = `dwarfdump #{binary_file_path.to_path} | grep #{File.basename(first_head_file)} | grep 'DW_AT_decl_file'`.gsub!(/\s/, '')
87
+ binary_build_path_list = binary_build_path_string.split('DW_AT_decl_file').delete_if(&:empty?).uniq
88
+ # 删掉所有的括号引号
89
+ binary_build_path_list = binary_build_path_list.each { |item| item.gsub!('("','').gsub!('")', '') }
90
+ puts '这个库格式格式有异常。可能解析不成功,请将这个例子报告给 faliu' unless binary_build_path_list.count >= 1
91
+
92
+ binary_build_path = binary_build_path_list.first
93
+ end
94
+
95
+ def download_source_code_file head_file_path
96
+ pod_spec = nil
97
+ @installer.analysis_result.specifications.each do |spec|
98
+ if spec.name == @module_name then
99
+ pod_spec = spec
100
+ break
101
+ end
102
+ end
103
+ version = pod_spec.version.version
104
+ help! '该库版本不符合二进制版本识别规则' unless version_is_binary version
105
+ version = source_code_version version
106
+ module_spec = Pod::Specification::Set::LazySpecification.new(pod_spec.name, Pod::Version.new(version), pod_spec.spec_source)
107
+ module_request = Downloader::Request.new(:spec => module_spec)
108
+
109
+ source_file_dir = find_spec_source_file_path module_spec
110
+ source_path = File.dirname(head_file_path).split(source_file_dir).first
111
+ puts "开始创建目录:#{source_path}"
112
+ `sudo mkdir -p #{source_path}` unless File.exists?(source_path)
113
+ `sudo chmod 777 #{File.split(source_path).first}`
114
+ puts "创建目录成功#{source_path}"
115
+ download_result = Downloader.download(module_request, source_path, :can_cache => true)
116
+ source_path
117
+
118
+ end
119
+
120
+ private
121
+ # 找到二进制文件。
122
+ def find_binary_file_in_framework framework_file_path
123
+ return nil unless framework_file_path.extname.end_with? '.framework'
124
+ return Pathname.new("#{framework_file_path.to_path}/#{framework_file_path.basename.to_path.gsub!('.framework', '')}")
125
+ end
126
+
127
+ def find_first_head_file_in_framework(framework_file_path, end_name='.h')
128
+ framework_file_path.children.collect do |child|
129
+ if child.file? && child.extname.end_with?(end_name)
130
+ return child
131
+ elsif child.directory?
132
+ filePath = find_first_head_file_in_framework child
133
+ return filePath if filePath
134
+ end
135
+ end
136
+ return nil
137
+ end
138
+
139
+ def version_is_binary version
140
+ return true if version.end_with? '-bin'
141
+ return true if version.end_with? '-xc'
142
+ end
143
+ def source_code_version version
144
+ return version.gsub!('-bin', '') if version.end_with? '-bin'
145
+ return version.gsub!('-xc', '') if version.end_with? 'xc'
146
+ help! '该库版本不符合二进制版本识别规则'
147
+ end
148
+ def find_spec_source_file_path specification
149
+ source_path = specification.specification.attributes_hash['source_files']
150
+ dir_list = source_path.split('/')
151
+ help! "源码路径错误 #{source_path}" unless dir_list.count >= 2
152
+ return "/#{dir_list.first}/#{dir_list[1]}"
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-vbbuildsource/command/vbbuildsource'
@@ -0,0 +1,3 @@
1
+ module CocoapodsVbbuildsource
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-vbbuildsource/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-vbbuildsource/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Vbbuildsource do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ vbbuildsource }).should.be.instance_of Command::Vbbuildsource
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -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-vbbuildsource
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - faliu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-30 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-vbbuildsource.
42
+ email:
43
+ - faliu@tencent.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-vbbuildsource.gemspec
54
+ - lib/cocoapods-vbbuildsource.rb
55
+ - lib/cocoapods-vbbuildsource/command.rb
56
+ - lib/cocoapods-vbbuildsource/command/vbbuildsource.rb
57
+ - lib/cocoapods-vbbuildsource/gem_version.rb
58
+ - lib/cocoapods_plugin.rb
59
+ - spec/command/vbbuildsource_spec.rb
60
+ - spec/spec_helper.rb
61
+ homepage: https://github.com/EXAMPLE/cocoapods-vbbuildsource
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.9
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: A longer description of cocoapods-vbbuildsource.
84
+ test_files:
85
+ - spec/command/vbbuildsource_spec.rb
86
+ - spec/spec_helper.rb