fastlane-plugin-analyze_ios_linkmap 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7e26083cb69298f9af1dec82d0f015bb595454ee6bdcaeae84f121ff9a61c6
|
4
|
+
data.tar.gz: 28119251fdc69243ba162aecbd19774589df4cac1ad32402235c8cf9dc96de97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76607c8979fd32f427a7d2e6f35936cf68bf98f1acb5e94f1a7c985e9143356891f442eba0ccb512c3f16bb4dc72abf9b22545f7e2e5419d9e04dbbbb6cb87f
|
7
|
+
data.tar.gz: 0a7888ee701c27db2f3643f5e2a2ee372ff212a3552561d8b8b39888fd5360fcd76e447ff2fff7b1ad5d554c2873835994eadd124b9079801e8683ee7ed39e6c
|
data/README.md
CHANGED
@@ -26,8 +26,8 @@ lane :test do
|
|
26
26
|
analyze_ios_linkmap(
|
27
27
|
filepath: '/Users/xiongzenghui/collect_rubygems/fastlane-plugins/fastlane-plugin-analyze_ios_linkmap/spec/demo-LinkMap.txt'
|
28
28
|
)
|
29
|
-
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::
|
30
|
-
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::
|
29
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_HASH]
|
30
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_JSON]
|
31
31
|
|
32
32
|
# eg2:
|
33
33
|
analyze_ios_linkmap(
|
@@ -5,16 +5,23 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
module ShatedValues
|
7
7
|
ANALYZE_IOS_LINKMAP_SEARCH_SYMBOL = :ANALYZE_IOS_LINKMAP_SEARCH_SYMBOL
|
8
|
-
|
9
|
-
|
8
|
+
ANALYZE_IOS_LINKMAP_PARSED_HASH = :ANALYZE_IOS_LINKMAP_PARSED_HASH
|
9
|
+
ANALYZE_IOS_LINKMAP_PARSED_JSON = :ANALYZE_IOS_LINKMAP_PARSED_JSON
|
10
|
+
ANALYZE_IOS_LINKMAP_PARSED_MERGE_HASH = :ANALYZE_IOS_LINKMAP_PARSED_MERGE_HASH
|
11
|
+
ANALYZE_IOS_LINKMAP_PARSED_MERGE_JSON = :ANALYZE_IOS_LINKMAP_PARSED_MERGE_JSON
|
10
12
|
end
|
11
13
|
|
12
14
|
class AnalyzeIosLinkmapAction < Action
|
13
15
|
def self.run(params)
|
14
16
|
filepath = params[:filepath]
|
15
17
|
search_symbol = params[:search_symbol]
|
18
|
+
all_symbols = params[:all_symbols] || false
|
19
|
+
merge_by_pod = params[:merge_by_pod] || false
|
16
20
|
|
17
|
-
parser = Fastlane::Helper::LinkMap::Parser.new(
|
21
|
+
parser = Fastlane::Helper::LinkMap::Parser.new({
|
22
|
+
filepath: filepath,
|
23
|
+
all_symbols: all_symbols
|
24
|
+
})
|
18
25
|
|
19
26
|
if search_symbol
|
20
27
|
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_SEARCH_SYMBOL] = []
|
@@ -33,8 +40,13 @@ module Fastlane
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
36
|
-
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::
|
37
|
-
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::
|
43
|
+
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_HASH] = parser.pretty_hash
|
44
|
+
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_JSON] = parser.pretty_json
|
45
|
+
|
46
|
+
if merge_by_pod
|
47
|
+
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_MERGE_HASH] = parser.pretty_merge_by_pod_hash
|
48
|
+
Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_MERGE_JSON] = parser.pretty_merge_by_pod_json
|
49
|
+
end
|
38
50
|
end
|
39
51
|
|
40
52
|
def self.available_options
|
@@ -51,10 +63,44 @@ module Fastlane
|
|
51
63
|
key: :search_symbol,
|
52
64
|
description: "search your give symbol in linkmap.txt from what library",
|
53
65
|
optional: true
|
66
|
+
),
|
67
|
+
FastlaneCore::ConfigItem.new(
|
68
|
+
key: :all_symbols,
|
69
|
+
description: "print all symbol size ???",
|
70
|
+
optional: true
|
71
|
+
),
|
72
|
+
FastlaneCore::ConfigItem.new(
|
73
|
+
key: :merge_by_pod,
|
74
|
+
description: "merge linkmap parsed hash by pod name ???",
|
75
|
+
optional: true
|
76
|
+
)
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.example_code
|
81
|
+
[
|
82
|
+
'analyze_ios_linkmap(filepath: "/path/to/linkmap.txt")
|
83
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_HASH]
|
84
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_JSON]',
|
85
|
+
'analyze_ios_linkmap(
|
86
|
+
filepath: "/path/to/linkmap.txt",
|
87
|
+
search_symbol: "TDATEvo"
|
88
|
+
)
|
89
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_SEARCH_SYMBOL]'
|
90
|
+
'analyze_ios_linkmap(
|
91
|
+
filepath: "/path/to/linkmap.txt",
|
92
|
+
all_symbols: false,
|
93
|
+
merge_by_pod: true
|
54
94
|
)
|
95
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_MERGE_HASH]
|
96
|
+
pp Fastlane::Actions.lane_context[Fastlane::Actions::ShatedValues::ANALYZE_IOS_LINKMAP_PARSED_MERGE_JSON]'
|
55
97
|
]
|
56
98
|
end
|
57
99
|
|
100
|
+
def self.return_value
|
101
|
+
# If your method provides a return value, you can describe here what it does
|
102
|
+
end
|
103
|
+
|
58
104
|
def self.description
|
59
105
|
"iOS parse linkmap.txt to ruby Hash or JSON"
|
60
106
|
end
|
@@ -63,10 +109,6 @@ module Fastlane
|
|
63
109
|
["xiongzenghui"]
|
64
110
|
end
|
65
111
|
|
66
|
-
def self.return_value
|
67
|
-
# If your method provides a return value, you can describe here what it does
|
68
|
-
end
|
69
|
-
|
70
112
|
def self.details
|
71
113
|
"iOS parse linkmap.txt to ruby Hash"
|
72
114
|
end
|
@@ -70,8 +70,12 @@ module Fastlane
|
|
70
70
|
class Parser
|
71
71
|
attr_accessor(:object_map, :library_map, :section_map, :segment_map)
|
72
72
|
|
73
|
-
def initialize(
|
74
|
-
@filepath = filepath
|
73
|
+
def initialize(options)
|
74
|
+
@filepath = options[:filepath]
|
75
|
+
@all_symbols = options[:all_symbols]
|
76
|
+
|
77
|
+
UI.user_error!("❌ #{@filepath} not pass") unless @filepath
|
78
|
+
UI.user_error!("❌ #{@filepath} not exist") unless File.exist?(@filepath)
|
75
79
|
|
76
80
|
@object_map = {}
|
77
81
|
@library_map = {}
|
@@ -81,6 +85,116 @@ module Fastlane
|
|
81
85
|
parse
|
82
86
|
end
|
83
87
|
|
88
|
+
def pretty_json
|
89
|
+
JSON.pretty_generate(pretty_hash)
|
90
|
+
end
|
91
|
+
|
92
|
+
def pretty_hash
|
93
|
+
return @result if @result
|
94
|
+
|
95
|
+
# sort object_map[i].ObjectFile.symbols
|
96
|
+
@object_map.each do |ofid, object|
|
97
|
+
next unless object.symbols
|
98
|
+
|
99
|
+
object.symbols.sort! do |sym1, sym2|
|
100
|
+
sym2[:size] <=> sym1[:size]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# 计算 linkmap.txt 所有的 symbol 总大小
|
105
|
+
total_size = @library_map.values.map(&:size).inject(:+)
|
106
|
+
total_dead_size = @library_map.values.map(&:dead_symbol_size).inject(:+)
|
107
|
+
|
108
|
+
# sort object_map[i]
|
109
|
+
library_map_values = @library_map.values.sort do |a, b|
|
110
|
+
b.size <=> a.size
|
111
|
+
end
|
112
|
+
library_map_values.compact!
|
113
|
+
|
114
|
+
library_maps = library_map_values.map do |lib|
|
115
|
+
pod_name = lib.name
|
116
|
+
unless lib.pod_name.empty?
|
117
|
+
pod_name = lib.pod_name
|
118
|
+
end
|
119
|
+
|
120
|
+
if @all_symbols
|
121
|
+
{
|
122
|
+
library: lib.name,
|
123
|
+
pod: pod_name,
|
124
|
+
total: lib.size,
|
125
|
+
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.size),
|
126
|
+
total_dead: lib.dead_symbol_size,
|
127
|
+
format_total_dead: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.dead_symbol_size),
|
128
|
+
objects: lib.object_file_ids.map do |object_file_id|
|
129
|
+
# Struct.new(:file_id, :object, :library, :framework, :symbols, :size, :dead_symbol_size)
|
130
|
+
object_file = @object_map[object_file_id]
|
131
|
+
if object_file
|
132
|
+
{
|
133
|
+
object: object_file.object,
|
134
|
+
symbols: object_file.symbols.map do |symb|
|
135
|
+
{
|
136
|
+
name: symb.name,
|
137
|
+
total: symb.size,
|
138
|
+
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(symb.size),
|
139
|
+
}
|
140
|
+
end
|
141
|
+
}
|
142
|
+
else
|
143
|
+
nil
|
144
|
+
end
|
145
|
+
end
|
146
|
+
}
|
147
|
+
else
|
148
|
+
{
|
149
|
+
library: lib.name,
|
150
|
+
pod: pod_name,
|
151
|
+
total: lib.size,
|
152
|
+
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.size),
|
153
|
+
total_dead: lib.dead_symbol_size,
|
154
|
+
format_total_dead: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.dead_symbol_size)
|
155
|
+
}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
@result = {
|
160
|
+
total_count: library_maps.count,
|
161
|
+
total_size: total_size,
|
162
|
+
format_total_size: Fastlane::Helper::LinkMap::FileHelper.format_size(total_size),
|
163
|
+
total_dead_size: total_dead_size,
|
164
|
+
format_total_dead_size: Fastlane::Helper::LinkMap::FileHelper.format_size(total_dead_size),
|
165
|
+
librarys: library_maps
|
166
|
+
}
|
167
|
+
|
168
|
+
@result
|
169
|
+
end
|
170
|
+
|
171
|
+
def pretty_merge_by_pod_hash
|
172
|
+
return @merge_by_pod_result if @merge_by_pod_result
|
173
|
+
|
174
|
+
@merge_by_pod_result = {
|
175
|
+
total_count: pretty_hash[:total_count],
|
176
|
+
total_size: pretty_hash[:total_size],
|
177
|
+
format_total_size: pretty_hash[:format_total_size],
|
178
|
+
total_dead_size: pretty_hash[:total_dead_size],
|
179
|
+
format_total_dead_size: pretty_hash[:format_total_dead_size]
|
180
|
+
}
|
181
|
+
|
182
|
+
pods = Hash.new
|
183
|
+
pretty_hash[:librarys].each do |lib|
|
184
|
+
apod_librarys = pods[lib[:pod]]
|
185
|
+
apod_librarys ||= Array.new
|
186
|
+
apod_librarys << lib
|
187
|
+
pods[lib[:pod]] = apod_librarys
|
188
|
+
end
|
189
|
+
@merge_by_pod_result[:pods] = pods
|
190
|
+
|
191
|
+
@merge_by_pod_result
|
192
|
+
end
|
193
|
+
|
194
|
+
def pretty_merge_by_pod_json
|
195
|
+
JSON.pretty_generate(pretty_merge_by_pod_hash)
|
196
|
+
end
|
197
|
+
|
84
198
|
def parse
|
85
199
|
# 读取 Linkmap.txt 【每一行】进行解析
|
86
200
|
File.foreach(@filepath).with_index do |line, line_num|
|
@@ -373,91 +487,6 @@ module Fastlane
|
|
373
487
|
@library_map[object_file.library].dead_symbol_size += size
|
374
488
|
end
|
375
489
|
end
|
376
|
-
|
377
|
-
def pretty_json
|
378
|
-
result = pretty_hash
|
379
|
-
unless result
|
380
|
-
UI.user_error!("❌ LinkMap parsed failed!")
|
381
|
-
end
|
382
|
-
JSON.pretty_generate(result)
|
383
|
-
end
|
384
|
-
|
385
|
-
def pretty_hash
|
386
|
-
UI.user_error!("❌ #{@filepath} not pass") unless @filepath
|
387
|
-
UI.user_error!("❌ #{@filepath} not exist") unless File.exist?(@filepath)
|
388
|
-
|
389
|
-
result
|
390
|
-
end
|
391
|
-
|
392
|
-
def result
|
393
|
-
# 1. cache
|
394
|
-
return @result if @result
|
395
|
-
|
396
|
-
# 2. sort object_map[i].ObjectFile.symbols
|
397
|
-
@object_map.each do |ofid, object|
|
398
|
-
next unless object.symbols
|
399
|
-
|
400
|
-
object.symbols.sort! do |sym1, sym2|
|
401
|
-
sym2[:size] <=> sym1[:size]
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
# 3. linkmap.txt 所有的 symbol 总大小
|
406
|
-
total_size = @library_map.values.map(&:size).inject(:+)
|
407
|
-
total_dead_size = @library_map.values.map(&:dead_symbol_size).inject(:+)
|
408
|
-
|
409
|
-
# 4.
|
410
|
-
library_map_values = @library_map.values.sort do |a, b|
|
411
|
-
b.size <=> a.size
|
412
|
-
end
|
413
|
-
library_map_values.compact!
|
414
|
-
|
415
|
-
# 5.
|
416
|
-
library_maps = library_map_values.map do |lib|
|
417
|
-
pod_name = lib.name
|
418
|
-
unless lib.pod_name.empty?
|
419
|
-
pod_name = lib.pod_name
|
420
|
-
end
|
421
|
-
# pp "pod_name=#{pod_name}"
|
422
|
-
|
423
|
-
{
|
424
|
-
library: lib.name,
|
425
|
-
pod: pod_name,
|
426
|
-
total: lib.size,
|
427
|
-
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.size),
|
428
|
-
total_dead: lib.dead_symbol_size,
|
429
|
-
format_total_dead: Fastlane::Helper::LinkMap::FileHelper.format_size(lib.dead_symbol_size),
|
430
|
-
objects: lib.object_file_ids.map do |object_file_id|
|
431
|
-
# Struct.new(:file_id, :object, :library, :framework, :symbols, :size, :dead_symbol_size)
|
432
|
-
object_file = @object_map[object_file_id]
|
433
|
-
if object_file
|
434
|
-
{
|
435
|
-
object: object_file.object,
|
436
|
-
symbols: object_file.symbols.map do |symb|
|
437
|
-
{
|
438
|
-
name: symb.name,
|
439
|
-
total: symb.size,
|
440
|
-
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(symb.size),
|
441
|
-
}
|
442
|
-
end
|
443
|
-
}
|
444
|
-
else
|
445
|
-
nil
|
446
|
-
end
|
447
|
-
end
|
448
|
-
}
|
449
|
-
end
|
450
|
-
|
451
|
-
# 6.
|
452
|
-
@result = {
|
453
|
-
total: total_size,
|
454
|
-
format_total: Fastlane::Helper::LinkMap::FileHelper.format_size(total_size),
|
455
|
-
total_dead: total_dead_size,
|
456
|
-
format_total_dead: Fastlane::Helper::LinkMap::FileHelper.format_size(total_dead_size),
|
457
|
-
librarys: library_maps
|
458
|
-
}
|
459
|
-
@result
|
460
|
-
end
|
461
490
|
end
|
462
491
|
end
|
463
492
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-analyze_ios_linkmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiongzenghui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.0.
|
171
|
+
rubygems_version: 3.0.4
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: iOS parse linkmap.txt to ruby Hash
|