linkmap 0.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 (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/linkmap +5 -0
  3. data/lib/linkmap.rb +135 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 65483982ddf191a00195c9d3ffa802429f89ccfe
4
+ data.tar.gz: ca585f0610fe4a0ba9c237bd42a63111d7aa96cc
5
+ SHA512:
6
+ metadata.gz: c59b1dde441330e18cef352800e452629070ba3a5fc81e21ad796fdc541295711986992d16e405d85041d62ce12c4c8f672f4287af96519027eef62bf43b6059
7
+ data.tar.gz: 81ad75701e37342279ae0f296249c951c7f7c7a6d3c54f4bb7e1777049c73a4ac8573a42818fe9ab404b2b78afe4fb004b548d10172dbe5e30ee5b206739c9ab
data/bin/linkmap ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'linkmap'
4
+
5
+ LinkMap::Command.run(ARGV)
data/lib/linkmap.rb ADDED
@@ -0,0 +1,135 @@
1
+ #encoding=UTF-8
2
+
3
+ module LinkMap
4
+
5
+ #argv[0] == "a" anylize
6
+ #argv[0] == "c" compare
7
+
8
+ class Command
9
+ def self.run(argv)
10
+ if argv[0]=="--help"
11
+ self.help()
12
+ elsif argv[0] == "a" and argv.size>1
13
+ anylize = Anylize.new()
14
+ anylize.run(argv)
15
+ else
16
+ puts "type:linkmap --help"
17
+ end
18
+ end
19
+
20
+ def self.help()
21
+ puts "usage:\tlinkmap a exampleProject-LinkMap-normal-armv7.txt"
22
+ end
23
+
24
+ end
25
+
26
+ class Anylize
27
+
28
+ def initialize()
29
+ @reachFiles = false
30
+ @reachSymbols = false
31
+ @reachSections = false
32
+
33
+ @fileMap = Hash.new
34
+ end
35
+
36
+ def run(argv)
37
+ filename = argv[1]
38
+ if File::file?(filename)
39
+ File.open(filename, "r") do |file|
40
+ while line = file.gets
41
+ if line.include?("#") #注释行
42
+ if line.include?("# Object files:")
43
+ reachFiles = true
44
+ elsif line.include?("# Sections:")
45
+ reachSections = true
46
+ elsif line.include?("# Symbols:")
47
+ reachSymbols = true
48
+ end
49
+ else
50
+ if reachFiles and !reachSections and !reachSymbols
51
+ index = line.index("]")
52
+ if index != nil
53
+ linkFile = LinkFile.new()
54
+ key = line[0, index+1]
55
+ name = line[index+1, line.length-index-1-1]
56
+ linkFile.name = name
57
+ @fileMap.store(key, linkFile)
58
+ end
59
+ elsif reachFiles and reachSections and !reachSymbols
60
+ # puts "read sections"
61
+ else
62
+ # puts "read symbols"
63
+ array = line.force_encoding("ISO-8859-1").split("\t")
64
+ if array.size == 3
65
+ keyAndName = array[2]
66
+ size = array[1].to_i(16)
67
+ index = keyAndName.index("]")
68
+ if index != nil
69
+ key = keyAndName[0, index+1]
70
+ linkFile = @fileMap.fetch(key)
71
+ if linkFile != nil
72
+ linkFile.size = linkFile.size.to_i+size.to_i
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ fileArray = @fileMap.values
82
+ fileArray = fileArray.sort{|x,y| y.size <=> x.size}
83
+
84
+ array = filename.split("/")
85
+ destFileName = array[array.size-1]
86
+ destFileName = "analize_#{destFileName}"
87
+ array.delete_at(array.size-1)
88
+ array.push(destFileName)
89
+ destFileName = array.join("/")
90
+
91
+ if File::file?(destFileName)
92
+ File::delete(destFileName)
93
+ end
94
+ destFile = File.new(destFileName, "w");
95
+
96
+ destFile.puts "各模块体积大小"
97
+ totalSize = 0
98
+ fileArray.each do |linkFile|
99
+ array = linkFile.name.split("/")
100
+ line = array[array.size-1]
101
+ line += "\t"
102
+ line += "#{linkFile.size/1024.0}K"
103
+ # puts "#{line}"
104
+ destFile.puts line
105
+ totalSize += linkFile.size
106
+ end
107
+ destFile.puts "总体积: #{totalSize/(1024.0*1024.0)}M"
108
+
109
+ destFile.close
110
+ puts("success!")
111
+ puts("result saved in:#{destFileName}")
112
+ else
113
+ puts "\t#{argv[1]} is not a file name"
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ class LinkFile
120
+
121
+ attr_accessor :name
122
+ attr_accessor :size
123
+
124
+ @name
125
+ @size
126
+
127
+ end
128
+
129
+ # argv = ["a", "/Users/wangbin/Desktop/My/linkmap/babyShow-LinkMap-normal-armv7.txt"]
130
+ # argv = ["a", "b"]
131
+ # argv = []
132
+ # argv = ["--help"]
133
+ # LinkMap::Command.run(argv);
134
+
135
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linkmap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - siyou325
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: linkmap analyzer for ios
14
+ email: bin@siyou325.com
15
+ executables:
16
+ - linkmap
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/linkmap
21
+ - lib/linkmap.rb
22
+ homepage: https://github.com/siyou325/linkmap
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: linkmap analyzer
46
+ test_files: []