objc-dependency-tree-generator 0.0.8 → 0.1.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.
- checksums.yaml +4 -4
- data/bin/objc_dependency_tree_generator +2 -2
- data/lib/dependency_tree.rb +119 -0
- data/lib/helpers/objc_dependency_tree_generator_helper.rb +58 -0
- data/lib/helpers/swift_primitives.rb +282 -0
- data/lib/{objc_dependencies_generator.rb → objc/objc_dependencies_generator.rb} +0 -0
- data/lib/objc_dependency_tree_generator.rb +106 -89
- data/lib/sourcekitten/sourcekitten_dependencies_generator.rb +229 -0
- data/lib/swift-ast-dump/swift_ast_dependencies_generator.rb +216 -0
- data/lib/swift-ast-dump/swift_ast_parser.rb +217 -0
- data/lib/{swift_dependencies_generator.rb → swift/swift_dependencies_generator.rb} +0 -0
- data/lib/tree_serializer.rb +64 -0
- metadata +14 -8
- data/lib/objc_dependency_tree_generator_helper.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c73066f3ea89fafce42e159f82c40ded14359a
|
4
|
+
data.tar.gz: b15c8c1482279b1c530e5c92c2b63c8f26d92c1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76970e3381b2308d142135d8c8c51ad9a494e9dede689980e79fa38ba31612518c841b4555b6ef03cfd6db8323d18e014c50f09b1d1b1bd558916f14d8c7d11c
|
7
|
+
data.tar.gz: 7975c2a09d5e6babd10e551252da690c4e4b69e4c1577948fe599153fd31e7a63356a8c644fb10972172b71b692df3e2a5991f9fc0e493cd17b4993d6ea71490
|
@@ -4,9 +4,9 @@
|
|
4
4
|
require 'objc_dependency_tree_generator'
|
5
5
|
|
6
6
|
# resolve options from command line
|
7
|
-
options =
|
7
|
+
options = DependencyTreeGenerator.parse_command_line_options
|
8
8
|
|
9
9
|
# creating generator
|
10
|
-
generator =
|
10
|
+
generator = DependencyTreeGenerator.new options
|
11
11
|
|
12
12
|
puts generator.dependencies_to_s
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module DependencyItemType
|
2
|
+
CLASS = 'class'.freeze
|
3
|
+
STRUCTURE = 'struct'.freeze
|
4
|
+
PROTOCOL = 'protocol'.freeze
|
5
|
+
UNKNOWN = 'unknown'.freeze
|
6
|
+
end
|
7
|
+
|
8
|
+
module DependencyLinkType
|
9
|
+
INHERITANCE = 'inheritance'.freeze
|
10
|
+
IVAR = 'ivar'.freeze
|
11
|
+
CALL = 'call'.freeze
|
12
|
+
PARAMETER = 'parameter'.freeze
|
13
|
+
UNKNOWN = 'unknown'.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
class DependencyTree
|
17
|
+
|
18
|
+
attr_reader :links_count
|
19
|
+
attr_reader :links
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@links_count = 0
|
23
|
+
@links = []
|
24
|
+
@registry = {}
|
25
|
+
@types_registry = {}
|
26
|
+
@links_registry = {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def add(source, dest, type = DependencyLinkType::UNKNOWN)
|
30
|
+
register source
|
31
|
+
register dest
|
32
|
+
register_link(source, dest, type)
|
33
|
+
|
34
|
+
return if connected?(source, dest)
|
35
|
+
|
36
|
+
@links_count += 1
|
37
|
+
@links += [{source: source, dest: dest}]
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def connected?(source, dest)
|
42
|
+
@links.any? {|item| item[:source] == source && item[:dest] == dest}
|
43
|
+
end
|
44
|
+
|
45
|
+
def isEmpty?
|
46
|
+
@links_count.zero?
|
47
|
+
end
|
48
|
+
|
49
|
+
def register(object, type = DependencyItemType::UNKNOWN)
|
50
|
+
@registry[object] = true
|
51
|
+
if @types_registry[object].nil? || @types_registry[object] == DependencyItemType::UNKNOWN
|
52
|
+
@types_registry[object] = type
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def isRegistered?(object)
|
57
|
+
!@registry[object].nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def type(object)
|
61
|
+
@types_registry[object]
|
62
|
+
end
|
63
|
+
|
64
|
+
def objects
|
65
|
+
@types_registry.keys
|
66
|
+
end
|
67
|
+
|
68
|
+
def link_type(source, dest)
|
69
|
+
@links_registry[link_key(source, dest)] || DependencyLinkType::UNKNOWN
|
70
|
+
end
|
71
|
+
|
72
|
+
def links_with_types
|
73
|
+
@links.map do |l|
|
74
|
+
type = link_type(l[:source], l[:dest])
|
75
|
+
l[:type] = type unless type == DependencyLinkType::UNKNOWN
|
76
|
+
l
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def filter
|
81
|
+
@types_registry.each { |item, type|
|
82
|
+
next if yield item, type
|
83
|
+
@types_registry.delete(item)
|
84
|
+
@registry.delete(item)
|
85
|
+
selected_links = @links.select { |link| link[:source] != item && link[:dest] != item }
|
86
|
+
filtered_links = @links.select { |link| link[:source] == item || link[:dest] == item }
|
87
|
+
filtered_links.each { |link| remove_link_type(link) }
|
88
|
+
@links = selected_links
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def filter_links
|
93
|
+
@links = @links.select { |link|
|
94
|
+
yield link[:source], link[:dest], link_type(link[:source], link[:dest])
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_link_type(link)
|
99
|
+
source, dest = link[:source], link[:dest]
|
100
|
+
return unless source && dest
|
101
|
+
@links_registry.delete(link_key(source, dest))
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def register_link(source, dest, type)
|
107
|
+
return unless source && dest
|
108
|
+
link_key = link_key(source, dest)
|
109
|
+
registered_link = @links_registry[link_key]
|
110
|
+
if registered_link.nil? || registered_link == DependencyLinkType::UNKNOWN
|
111
|
+
@links_registry[link_key] = type
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def link_key(source, dest)
|
116
|
+
source + '!<->!' + dest
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
def find_project_output_directory(derived_data_paths, project_prefix, project_suffix_pattern, target_names, verbose)
|
4
|
+
|
5
|
+
return nil unless derived_data_paths
|
6
|
+
|
7
|
+
# all we need is log
|
8
|
+
log = lambda { |message|
|
9
|
+
$stderr.puts message if verbose
|
10
|
+
}
|
11
|
+
|
12
|
+
paths = []
|
13
|
+
|
14
|
+
# looking for derived data
|
15
|
+
derived_data_paths.each do |derived_data_path|
|
16
|
+
IO.popen("find #{derived_data_path} -depth 1 -name \"#{project_prefix}#{project_suffix_pattern}\" -type d -exec find {} -name \"i386\" -o -name \"armv*\" -o -name \"x86_64\" -type d \\; ") { |f|
|
17
|
+
f.each do |line|
|
18
|
+
paths << line
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
log.call "There were #{paths.length} directories found"
|
24
|
+
if paths.empty?
|
25
|
+
log.call "Cannot find projects that starts with '#{project_prefix}'"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
29
|
+
filtered_by_target_paths = paths
|
30
|
+
|
31
|
+
if target_names != nil && target_names.length > 0
|
32
|
+
filtered_by_target_paths = paths.find_all { |path|
|
33
|
+
target_names.any? { |target| /#{target}[^\.]*\.build\/Objects-normal/.match path }
|
34
|
+
}
|
35
|
+
log.call "After target filtration there is #{filtered_by_target_paths.length} directories left"
|
36
|
+
if paths.empty?
|
37
|
+
log.call "Cannot find projects that starts with '#{project_prefix}'' and has target name that starts with '#{target_names}'"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
paths_sorted_by_time = filtered_by_target_paths.sort_by { |f| File.ctime(f.chomp) }
|
42
|
+
last_modified_dirs = target_names.map { |target|
|
43
|
+
filtered_by_target = filtered_by_target_paths.find_all { |path| /#{target}[^\.]*\.build\/Objects-normal/.match path }
|
44
|
+
last_modified_dir = filtered_by_target.last.chomp
|
45
|
+
log.call "Last modifications for #{target} were in\n#{last_modified_dir}\ndirectory at\n#{File.ctime(last_modified_dir)}"
|
46
|
+
last_modified_dir
|
47
|
+
}
|
48
|
+
return last_modified_dirs
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
paths_sorted_by_time = filtered_by_target_paths.sort_by { |f| File.ctime(f.chomp) }
|
53
|
+
|
54
|
+
last_modified_dir = paths_sorted_by_time.last.chomp
|
55
|
+
log.call "Last modifications were in\n#{last_modified_dir}\ndirectory at\n#{File.ctime(last_modified_dir)}"
|
56
|
+
|
57
|
+
[last_modified_dir]
|
58
|
+
end
|
@@ -0,0 +1,282 @@
|
|
1
|
+
# noinspection RubyLiteralArrayInspection
|
2
|
+
class SwiftPrimitives
|
3
|
+
@@primitive_swift_types =
|
4
|
+
Set.new([
|
5
|
+
'BOOL',
|
6
|
+
'alignofValue',
|
7
|
+
'anyGenerator',
|
8
|
+
'anyGenerator',
|
9
|
+
'assert',
|
10
|
+
'assertionFailure',
|
11
|
+
'autoclosure',
|
12
|
+
'debugPrint',
|
13
|
+
'debugPrint',
|
14
|
+
'dump',
|
15
|
+
'escaping',
|
16
|
+
'fatalError',
|
17
|
+
'getVaList',
|
18
|
+
'isUniquelyReferenced',
|
19
|
+
'isUniquelyReferencedNonObjC',
|
20
|
+
'isUniquelyReferencedNonObjC',
|
21
|
+
'max',
|
22
|
+
'max',
|
23
|
+
'min',
|
24
|
+
'abs',
|
25
|
+
'alignof',
|
26
|
+
'min',
|
27
|
+
'numericCast',
|
28
|
+
'numericCast',
|
29
|
+
'numericCast',
|
30
|
+
'numericCast',
|
31
|
+
'precondition',
|
32
|
+
'preconditionFailure',
|
33
|
+
'print',
|
34
|
+
'print',
|
35
|
+
'readLine',
|
36
|
+
'sizeof',
|
37
|
+
'sizeofValue',
|
38
|
+
'strideof',
|
39
|
+
'strideofValue',
|
40
|
+
'swap',
|
41
|
+
'throws',
|
42
|
+
'transcode',
|
43
|
+
'unsafeAddressOf',
|
44
|
+
'unsafeBitCast',
|
45
|
+
'unsafeDowncast',
|
46
|
+
'unsafeUnwrap',
|
47
|
+
'where',
|
48
|
+
'withExtendedLifetime',
|
49
|
+
'withExtendedLifetime',
|
50
|
+
'withUnsafeMutablePointer',
|
51
|
+
'withUnsafeMutablePointers',
|
52
|
+
'withUnsafeMutablePointers',
|
53
|
+
'withUnsafePointer',
|
54
|
+
'withUnsafePointers',
|
55
|
+
'withUnsafePointers',
|
56
|
+
'withVaList',
|
57
|
+
'withVaList',
|
58
|
+
'zip',
|
59
|
+
'Any',
|
60
|
+
'AnyClass',
|
61
|
+
'BooleanLiteralType',
|
62
|
+
'CBool',
|
63
|
+
'CChar',
|
64
|
+
'CChar16',
|
65
|
+
'CChar32',
|
66
|
+
'CDouble',
|
67
|
+
'CFloat',
|
68
|
+
'CInt',
|
69
|
+
'CLong',
|
70
|
+
'CLongLong',
|
71
|
+
'CShort',
|
72
|
+
'CSignedChar',
|
73
|
+
'CUnsignedChar',
|
74
|
+
'CUnsignedInt',
|
75
|
+
'CUnsignedLong',
|
76
|
+
'CUnsignedLongLong',
|
77
|
+
'CUnsignedShort',
|
78
|
+
'CWideChar',
|
79
|
+
'ExtendedGraphemeClusterType',
|
80
|
+
'Float32',
|
81
|
+
'Float64',
|
82
|
+
'FloatLiteralType',
|
83
|
+
'IntMax',
|
84
|
+
'IntegerLiteralType',
|
85
|
+
'StringLiteralType',
|
86
|
+
'UIntMax',
|
87
|
+
'UnicodeScalarType',
|
88
|
+
'Void',
|
89
|
+
'Any',
|
90
|
+
'AnyHashable',
|
91
|
+
'AnyObject',
|
92
|
+
'AnyBidirectionalCollection',
|
93
|
+
'AnyBidirectionalIndex',
|
94
|
+
'AnyForwardCollection',
|
95
|
+
'AnyForwardIndex',
|
96
|
+
'AnyRandomAccessCollection',
|
97
|
+
'AnyRandomAccessIndex',
|
98
|
+
'AnySequence',
|
99
|
+
'Array',
|
100
|
+
'ArraySlice',
|
101
|
+
'Array.Index',
|
102
|
+
'AutoreleasingUnsafeMutablePointer',
|
103
|
+
'Bool',
|
104
|
+
'COpaquePointer',
|
105
|
+
'CVaListPointer',
|
106
|
+
'Character',
|
107
|
+
'ClosedInterval',
|
108
|
+
'CollectionOfOne',
|
109
|
+
'ContiguousArray',
|
110
|
+
'Data',
|
111
|
+
'Date',
|
112
|
+
'Dictionary',
|
113
|
+
'DictionaryGenerator',
|
114
|
+
'DictionaryIndex',
|
115
|
+
'DictionaryLiteral',
|
116
|
+
'Double',
|
117
|
+
'EmptyGenerator',
|
118
|
+
'EnumerateGenerator',
|
119
|
+
'EnumerateSequence',
|
120
|
+
'Equatable',
|
121
|
+
'Error',
|
122
|
+
'FlattenBidirectionalCollection',
|
123
|
+
'FlattenBidirectionalCollectionIndex',
|
124
|
+
'FlattenCollectionIndex',
|
125
|
+
'FlattenSequence',
|
126
|
+
'Float',
|
127
|
+
'GeneratorSequence',
|
128
|
+
'HalfOpenInterval',
|
129
|
+
'IndexingGenerator',
|
130
|
+
'IndexingIterator',
|
131
|
+
'Int',
|
132
|
+
'Int1',
|
133
|
+
'Int16',
|
134
|
+
'Int32',
|
135
|
+
'Int64',
|
136
|
+
'Int8',
|
137
|
+
'JoinGenerator',
|
138
|
+
'JoinSequence',
|
139
|
+
'LazyCollection',
|
140
|
+
'LazyFilterCollection',
|
141
|
+
'LazyFilterGenerator',
|
142
|
+
'LazyFilterIndex',
|
143
|
+
'LazyFilterSequence',
|
144
|
+
'LazyMapCollection',
|
145
|
+
'LazyMapGenerator',
|
146
|
+
'LazyMapSequence',
|
147
|
+
'LazySequence',
|
148
|
+
'ManagedBufferPointer',
|
149
|
+
'Mirror',
|
150
|
+
'MutableSlice',
|
151
|
+
'Never',
|
152
|
+
'ObjectIdentifier',
|
153
|
+
'Optional',
|
154
|
+
'PermutationGenerator',
|
155
|
+
'Range',
|
156
|
+
'RangeGenerator',
|
157
|
+
'RawByte',
|
158
|
+
'Repeat',
|
159
|
+
'ReverseCollection',
|
160
|
+
'ReverseIndex',
|
161
|
+
'ReverseRandomAccessCollection',
|
162
|
+
'ReverseRandomAccessIndex',
|
163
|
+
'Self',
|
164
|
+
'Set',
|
165
|
+
'SetGenerator',
|
166
|
+
'SetIndex',
|
167
|
+
'Slice',
|
168
|
+
'StaticString',
|
169
|
+
'StrideThrough',
|
170
|
+
'StrideThroughGenerator',
|
171
|
+
'StrideTo',
|
172
|
+
'StrideToGenerator',
|
173
|
+
'String',
|
174
|
+
'String.CharacterView',
|
175
|
+
'String.CharacterView.Index',
|
176
|
+
'String.UTF16View',
|
177
|
+
'String.UTF16View.Index',
|
178
|
+
'String.UTF8View',
|
179
|
+
'String.UTF8View.Index',
|
180
|
+
'String.UnicodeScalarView',
|
181
|
+
'String.UnicodeScalarView.Generator',
|
182
|
+
'String.UnicodeScalarView.Index',
|
183
|
+
'TernaryPrecedence',
|
184
|
+
'AssignmentPrecedence',
|
185
|
+
'CastingPrecedence',
|
186
|
+
'Type',
|
187
|
+
'UInt',
|
188
|
+
'UInt16',
|
189
|
+
'UInt32',
|
190
|
+
'UInt64',
|
191
|
+
'UInt8',
|
192
|
+
'UTF16',
|
193
|
+
'UTF32',
|
194
|
+
'UTF8',
|
195
|
+
'URL',
|
196
|
+
'UnicodeScalar',
|
197
|
+
'Unmanaged',
|
198
|
+
'UnsafeBufferPointer',
|
199
|
+
'UnsafeBufferPointerGenerator',
|
200
|
+
'UnsafeMutableBufferPointer',
|
201
|
+
'UnsafeMutablePointer',
|
202
|
+
'UnsafePointer',
|
203
|
+
'Zip2Generator',
|
204
|
+
'Zip2Sequence',
|
205
|
+
#Operators
|
206
|
+
'&&',
|
207
|
+
'!',
|
208
|
+
'!=',
|
209
|
+
'||',
|
210
|
+
'/',
|
211
|
+
'*',
|
212
|
+
'==',
|
213
|
+
'===',
|
214
|
+
'?',
|
215
|
+
'??',
|
216
|
+
'>=',
|
217
|
+
'<=',
|
218
|
+
'~=',
|
219
|
+
'%',
|
220
|
+
'<',
|
221
|
+
'<',
|
222
|
+
'-',
|
223
|
+
'+',
|
224
|
+
'-=',
|
225
|
+
'+=',
|
226
|
+
'..<',
|
227
|
+
'>',
|
228
|
+
'<',
|
229
|
+
'/=',
|
230
|
+
#Globals
|
231
|
+
'floor',
|
232
|
+
'sqrt',
|
233
|
+
'abs',
|
234
|
+
'fabs',
|
235
|
+
#Foundation
|
236
|
+
'Bundle',
|
237
|
+
'CharacterSet',
|
238
|
+
'Comparable',
|
239
|
+
'FileManager',
|
240
|
+
'Foundation',
|
241
|
+
'HTTPURLResponse',
|
242
|
+
'IndexPath',
|
243
|
+
'IndexSet',
|
244
|
+
'JSONSerialization',
|
245
|
+
'Notification',
|
246
|
+
'NotificationCenter',
|
247
|
+
'Operation',
|
248
|
+
'OperationQueue',
|
249
|
+
'TimeInterval',
|
250
|
+
'Timer',
|
251
|
+
'URLRequest',
|
252
|
+
'URLCache'
|
253
|
+
]).freeze
|
254
|
+
|
255
|
+
def self.primitive_types
|
256
|
+
@@primitive_swift_types
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
def is_primitive_swift_type?(dest)
|
262
|
+
SwiftPrimitives.primitive_types.include?(dest)
|
263
|
+
end
|
264
|
+
|
265
|
+
def is_filtered_swift_type?(dest)
|
266
|
+
/(ClusterType|ScalarType|LiteralType|\.Type)$/.match(dest) != nil || /^Builtin\./.match(dest) != nil
|
267
|
+
end
|
268
|
+
|
269
|
+
def is_filtered_objc_type?(dest)
|
270
|
+
/^(dispatch_)|(DISPATCH_)/.match(dest) != nil #or /^([a-z])/.match(dest) != nil
|
271
|
+
end
|
272
|
+
|
273
|
+
def is_valid_dest?(dest, exclusion_prefixes)
|
274
|
+
return false if dest.nil?
|
275
|
+
return false unless /^(#{exclusion_prefixes})/.match(dest).nil?
|
276
|
+
return false if is_primitive_swift_type?(dest)
|
277
|
+
return false if is_filtered_swift_type?(dest)
|
278
|
+
return false if is_filtered_objc_type?(dest)
|
279
|
+
true
|
280
|
+
end
|
281
|
+
|
282
|
+
|