-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmakefileapi.py
304 lines (223 loc) · 7.62 KB
/
cmakefileapi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# SPDX-License-Identifier: Apache-2.0
from enum import Enum
class Codemodel:
def __init__(self):
super(Codemodel, self).__init__()
self.paths_source = ""
self.paths_build = ""
self.configurations = []
def __repr__(self):
return f"Codemodel: source {self.paths_source}, build {self.paths_build}"
# A member of the codemodel configurations array
class Config:
def __init__(self):
super(Config, self).__init__()
self.name = ""
self.directories = []
self.projects = []
self.configTargets = []
def __repr__(self):
if self.name == "":
return f"Config: [no name]"
else:
return f"Config: {self.name}"
# A member of the configuration.directories array
class ConfigDir:
def __init__(self):
super(ConfigDir, self).__init__()
self.source = ""
self.build = ""
self.parentIndex = -1
self.childIndexes = []
self.projectIndex = -1
self.targetIndexes = []
self.minimumCMakeVersion = ""
self.hasInstallRule = False
# actual items, calculated from indices after loading
self.parent = None
self.children = []
self.project = None
self.targets = []
def __repr__(self):
return f"ConfigDir: source {self.source}, build {self.build}"
# A member of the configuration.projects array
class ConfigProject:
def __init__(self):
super(ConfigProject, self).__init__()
self.name = ""
self.parentIndex = -1
self.childIndexes = []
self.directoryIndexes = []
self.targetIndexes = []
# actual items, calculated from indices after loading
self.parent = None
self.children = []
self.directories = []
self.targets = []
def __repr__(self):
return f"ConfigProject: {self.name}"
# A member of the configuration.configTargets array
class ConfigTarget:
def __init__(self):
super(ConfigTarget, self).__init__()
self.name = ""
self.id = ""
self.directoryIndex = -1
self.projectIndex = -1
self.jsonFile = ""
# actual target data, loaded from self.jsonFile
self.target = None
# actual items, calculated from indices after loading
self.directory = None
self.project = None
def __repr__(self):
return f"ConfigTarget: {self.name}"
# The available values for Target.type
class TargetType(Enum):
UNKNOWN = 0
EXECUTABLE = 1
STATIC_LIBRARY = 2
SHARED_LIBRARY = 3
MODULE_LIBRARY = 4
OBJECT_LIBRARY = 5
UTILITY = 6
# A member of the target.install_destinations array
class TargetInstallDestination:
def __init__(self):
super(TargetInstallDestination, self).__init__()
self.path = ""
self.backtrace = -1
def __repr__(self):
return f"TargetInstallDestination: {self.path}"
# A member of the target.link_commandFragments and
# archive_commandFragments array
class TargetCommandFragment:
def __init__(self):
super(TargetCommandFragment, self).__init__()
self.fragment = ""
self.role = ""
def __repr__(self):
return f"TargetCommandFragment: {self.fragment}"
# A member of the target.dependencies array
class TargetDependency:
def __init__(self):
super(TargetDependency, self).__init__()
self.id = ""
self.backtrace = -1
def __repr__(self):
return f"TargetDependency: {self.id}"
# A member of the target.sources array
class TargetSource:
def __init__(self):
super(TargetSource, self).__init__()
self.path = ""
self.compileGroupIndex = -1
self.sourceGroupIndex = -1
self.isGenerated = False
self.backtrace = -1
# actual items, calculated from indices after loading
self.compileGroup = None
self.sourceGroup = None
def __repr__(self):
return f"TargetSource: {self.path}"
# A member of the target.sourceGroups array
class TargetSourceGroup:
def __init__(self):
super(TargetSourceGroup, self).__init__()
self.name = ""
self.sourceIndexes = []
# actual items, calculated from indices after loading
self.sources = []
def __repr__(self):
return f"TargetSourceGroup: {self.name}"
# A member of the target.compileGroups.includes array
class TargetCompileGroupInclude:
def __init__(self):
super(TargetCompileGroupInclude, self).__init__()
self.path = ""
self.isSystem = False
self.backtrace = -1
def __repr__(self):
return f"TargetCompileGroupInclude: {self.path}"
# A member of the target.compileGroups.precompileHeaders array
class TargetCompileGroupPrecompileHeader:
def __init__(self):
super(TargetCompileGroupPrecompileHeader, self).__init__()
self.header = ""
self.backtrace = -1
def __repr__(self):
return f"TargetCompileGroupPrecompileHeader: {self.header}"
# A member of the target.compileGroups.defines array
class TargetCompileGroupDefine:
def __init__(self):
super(TargetCompileGroupDefine, self).__init__()
self.define = ""
self.backtrace = -1
def __repr__(self):
return f"TargetCompileGroupDefine: {self.define}"
# A member of the target.compileGroups array
class TargetCompileGroup:
def __init__(self):
super(TargetCompileGroup, self).__init__()
self.sourceIndexes = []
self.language = ""
self.compileCommandFragments = []
self.includes = []
self.precompileHeaders = []
self.defines = []
self.sysroot = ""
# actual items, calculated from indices after loading
self.sources = []
def __repr__(self):
return f"TargetCompileGroup: {self.sources}"
# A member of the target.backtraceGraph_nodes array
class TargetBacktraceGraphNode:
def __init__(self):
super(TargetBacktraceGraphNode, self).__init__()
self.file = -1
self.line = -1
self.command = -1
self.parent = -1
def __repr__(self):
return f"TargetBacktraceGraphNode: {self.command}"
# Actual data in config.target.target, loaded from
# config.target.jsonFile
class Target:
def __init__(self):
super(Target, self).__init__()
self.name = ""
self.id = ""
self.type = TargetType.UNKNOWN
self.backtrace = -1
self.folder = ""
self.paths_source = ""
self.paths_build = ""
self.nameOnDisk = ""
self.artifacts = []
self.isGeneratorProvided = False
# only if install rule is present
self.install_prefix = ""
self.install_destinations = []
# only for executables and shared library targets that link into
# a runtime binary
self.link_language = ""
self.link_commandFragments = []
self.link_lto = False
self.link_sysroot = ""
# only for static library targets
self.archive_commandFragments = []
self.archive_lto = False
# only if the target depends on other targets
self.dependencies = []
# corresponds to target's source files
self.sources = []
# only if sources are grouped together by source_group() or by default
self.sourceGroups = []
# only if target has sources that compile
self.compileGroups = []
# graph of backtraces referenced from elsewhere
self.backtraceGraph_nodes = []
self.backtraceGraph_commands = []
self.backtraceGraph_files = []
def __repr__(self):
return f"Target: {self.name}"