Class: Pod::Command::Binary::Source
Instance Method Summary
collapse
#verify_binaryfile_exists!
Constructor Details
#initialize(argv) ⇒ Source
Returns a new instance of Source.
19
20
21
22
23
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 19
def initialize(argv)
@name = argv.shift_argument
@config = Pod::Config.instance
super
end
|
Instance Method Details
#add ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 35
def add
name = @name
lib_file = get_lib_path(name)
unless File.exist?(lib_file)
raise "file not found: #{lib_file}"
end
UI.puts "Binary path: #{lib_file}".green
target_path = download_source(name)
link(lib_file,target_path,name)
end
|
#check(lib_file, dir, basename) ⇒ Object
100
101
102
103
104
105
106
107
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 100
def check(lib_file,dir,basename)
file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
if File.exist?(file)
raise "#{file} 不存在 请检测代码源是否正确~"
end
UI.puts "link successfully!".green
UI.puts "view linked source at path: #{dir}".green
end
|
#download_source(name) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 48
def download_source(name)
target_path = File.join(source_root, name)
UI.puts "Source path: #{target_path}".green
FileUtils.rm_rf(target_path)
verify_podfile_exists!
installer = installer_for_config
installer.repo_update = repo_update?(:default => false)
installer.update = false
installer.deployment = false
installer.clean_install = false
installer.prepare
installer.resolve_dependencies
root_specs = installer.analysis_result.specifications.map(&:root).uniq
spec = root_specs.select { |s| s.name == name}.first
download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
target_path
end
|
#get_lib_path(name) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 109
def get_lib_path(name)
dir = Pathname.new(File.join(Pathname.pwd, "Pods", name, "#{name}.framework"))
lib_name = "#{name}"
lib_path = File.join(dir, lib_name)
lib_path
end
|
#link(lib_file, target_path, basename) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 70
def link(lib_file,target_path,basename)
dir = (`dwarfdump "#{lib_file}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2 `)
sub_path = "#{basename}/bin-archive/#{basename}"
dir = dir.gsub(sub_path, "").chomp
unless File.exist?(dir)
begin
FileUtils.mkdir_p(dir)
rescue SystemCallError
array = dir.split('/')
if array.length > 3
root_path = '/' + array[1] + '/' + array[2]
unless File.exist?(root_path)
raise "由于权限不足,请手动创建#{root_path} 后重试"
end
end
end
end
if Pathname.new(lib_file).extname == ".a"
FileUtils.rm_rf(File.join(dir,basename))
`ln -s #{target_path} #{dir}`
else
FileUtils.rm_rf(File.join(dir,basename))
`ln -s #{target_path} #{dir}/#{basename}`
end
check(lib_file,dir,basename)
end
|
#run ⇒ Object
30
31
32
33
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 30
def run
require 'cocoapods-aries-binary/command/source/source_spec_repo'
add
end
|
#validate! ⇒ Object
25
26
27
28
|
# File 'lib/cocoapods-aries-binary/command/source.rb', line 25
def validate!
super
help! 'Sourcing needs a pod name.' unless @name
end
|