- Remove the TOOL without NAME defined and its definition in ARCH_build.opt
[mirror_edk2.git] / Tools / Python / buildgen / FrameworkElement.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2007, Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 """Framework Element Classes
13
14 TODO
15 """
16
17 ################################################################################
18 ##
19 ## Element class: base class for representing framework elements
20 ##
21 ################################################################################
22 class Element:
23 def __init__(self, **kwargs):
24 """(Name, GuidValue, Version, Path, Dir, Archs, Usage, Features, Signature)"""
25 ## The path and directory where the information of the element comes from
26 self.Path = "."
27 self.Dir = "."
28
29 ## Element name, guid and version
30 self.Name = ""
31 self.GuidValue = ""
32 self.Version = ""
33
34 ## The element supported architecture
35 self.Archs = []
36
37 ## Indiciate how the element is used
38 self.Usage = "ALWAYS_CONSUMED"
39
40 ## Indicate what kind of features this element is bound
41 self.Features = []
42
43 ## Element signature, used to check the its integerity
44 self.Signature = 0
45
46 def __str__(self):
47 return self.Name + "-" + self.Version + " " + " [" + self.GuidValue + "]"
48
49 def __eq__(self, other):
50 if not isinstance(other, Element):
51 return False
52
53 if self.GuidValue != other.GuidValue:
54 return False
55
56 if self.Version != other.Version:
57 return False
58
59 return True
60
61 def __hash__(self):
62 return hash(self.GuidValue + self.Version)
63
64 ################################################################################
65 ##
66 ## ToolOption: build tool option
67 ##
68 ################################################################################
69 class ToolOption(Element):
70
71 def __init__(self, **kwargs):
72 """Prefix, Value, Tool, Toolchains, Families, Targets"""
73 Element.__init__(self)
74
75 self.Prefix = "/"
76 self.Value = ""
77 self.Tool = ""
78 self.Toolchains = ""
79 self.Families = "MSFT"
80 self.Targets = "DEBUG"
81
82 ################################################################################
83 ##
84 ## BuildTool: build tool
85 ##
86 ################################################################################
87 class BuildTool(Element):
88 def __init__(self, **kwargs):
89 """Options, Toolchains, Families, Targets"""
90 Element.__init__(self)
91
92 self.Options = []
93 self.Toolchains = []
94 self.Families = []
95 self.Targets = []
96
97 ################################################################################
98 ##
99 ## SourceFile: files in a module for build
100 ##
101 ################################################################################
102 class SourceFile(Element):
103 def __init__(self, **kwargs):
104 """BaseName, Ext, Type, Toolchains, Families, Targets"""
105 Element.__init__(self)
106
107 self.BaseName = ""
108 self.Ext = ""
109 self.Type = ""
110 self.Toolchains = []
111 self.Families = []
112 self.Targets = []
113
114 ################################################################################
115 ##
116 ## IncludeFile: header file
117 ##
118 ################################################################################
119 class IncludeFile(SourceFile):
120 def __init__(self, **kwargs):
121 """Type, Package, ModuleType"""
122 SourceFile.__init__(self)
123
124 self.Type = "HeaderFile"
125 self.Package = ""
126 self.ModuleType = ""
127
128 ################################################################################
129 ##
130 ## IncludePath:
131 ##
132 ################################################################################
133 class IncludePath(IncludeFile):
134 pass
135
136 ################################################################################
137 ##
138 ## LibraryInterface: library class interface
139 ##
140 ################################################################################
141 class LibraryInterface(Element):
142 def __init__(self, **kwargs):
143 """Package, FavoriteInstance, Instances, ModuleTypes, Consumers"""
144 Element.__init__(self)
145
146 self.Package = ""
147 self.FavoriteInstance = ""
148 self.Instances = []
149 self.ModuleTypes = []
150 self.Consumers = []
151
152 def __eq__(self, other):
153 if not isinstance(other, LibraryInterface):
154 return False
155 return self.Name == other.Name
156
157 def __hash__(self):
158 return hash(self.Name)
159
160 ################################################################################
161 ##
162 ## LibraryClass: library class
163 ##
164 ################################################################################
165 class LibraryClass(Element):
166 def __init__(self, **kwargs):
167 """
168 ()
169 """
170 Element.__init__(self)
171
172 self.Interface = ""
173 self.FavoriteInstance = ""
174
175 def __eq__(self, other):
176 if not isinstance(other, LibraryClass):
177 return False
178 return self.Name == other.Name
179
180 def __hash__(self):
181 return hash(self.Name)
182
183 ################################################################################
184 ##
185 ## Guid:
186 ##
187 ################################################################################
188 class Guid(Element):
189 def __init__(self, **kwargs):
190 """CName, Types, ModuleTypes"""
191 Element.__init__(self)
192
193 self.CName = ""
194 self.Types = []
195 self.ModuleTypes= []
196
197 ################################################################################
198 ##
199 ## Protocol:
200 ##
201 ################################################################################
202 class Protocol(Guid):
203 pass
204
205 ################################################################################
206 ##
207 ## ProtocolNotify:
208 ##
209 ################################################################################
210 class ProtocolNotify(Protocol):
211 pass
212
213 ################################################################################
214 ##
215 ## Ppi:
216 ##
217 ################################################################################
218 class Ppi(Guid):
219 pass
220
221 ################################################################################
222 ##
223 ## PpiNotify:
224 ##
225 ################################################################################
226 class PpiNotify(Ppi):
227 pass
228
229 ################################################################################
230 ##
231 ## Extern:
232 ##
233 ################################################################################
234 class Extern(Element):
235 def __init__(self, **kwargs):
236 """Specifications, ModuleEntryPoints, ModuleUnloadImages, Constructors, Destructors, DriverBindings, ComponentNames, DriverConfigs, DriverDiags, SetVirtualAddressMapCallBacks, ExitBootServicesCallBacks"""
237 Element.__init__(self)
238
239 self.Specifications = []
240 self.ModuleEntryPoints = []
241 self.ModuleUnloadImages = []
242 self.Constructors = []
243 self.Destructors = []
244 self.DriverBindings = []
245 self.ComponentNames = []
246 self.DriverConfigs = []
247 self.DriverDiags = []
248 self.SetVirtualAddressMapCallBacks = []
249 self.ExitBootServicesCallBacks = []
250
251 ################################################################################
252 ##
253 ## Sku:
254 ##
255 ################################################################################
256 class Sku(Element):
257 def __init__(self, **kwargs):
258 """Id, Value"""
259 Element.__init__(self)
260
261 self.Id = 0
262 self.Value = ""
263
264 ################################################################################
265 ##
266 ## Pcd:
267 ##
268 ################################################################################
269 class Pcd(Element):
270 def __init__(self, **kwargs):
271 """Types, CName, Value, Token, TokenSpace, DatumType, Sku, ModuleTypes"""
272 Element.__init__(self)
273
274 self.Types = []
275 self.CName = ""
276 self.Value = ""
277 self.Token = ""
278 self.TokenSpace = ""
279 self.DatumType = ""
280 self.Default = ""
281 self.Sku = ""
282 self.ModuleTypes= []
283
284 ################################################################################
285 ##
286 ## Module: framework module
287 ##
288 ################################################################################
289 class Module(Element):
290 def __init__(self, **kwargs):
291 """Workspace, Package, Type, BaseName, FileBaseName, IsLibrary, PcdIsDriver,
292 NeedsFlashMap_h, SourceFiles, IncludePaths, IncludeFiles, NonProcessedFiles,
293 LibraryClasses, Guids, Protocols, Ppis, Externs, Pcds,
294 UserExtensions, BuildOptions, Environment
295 """
296 Element.__init__(self)
297
298 self.Workspace = ""
299 self.Package = ""
300 self.Type = ""
301 self.BaseName = ""
302 self.FileBaseName = ""
303 self.IsLibrary = False
304 self.IsBinary = False
305 self.PcdIsDriver = False
306 self.NeedsFlashMap_h = False
307 self.SourceFiles = {} # arch -> {file type -> [source file list]}
308 self.IncludePaths = {} # arch -> [path list]
309 self.IncludeFiles = {}
310
311 self.NonProcessedFiles = []
312 self.LibraryClasses = {} # arch -> [library class list]
313
314 self.Guids = {} # arch -> [guid object list]
315 self.Protocols = {} # arch -> []
316 self.Ppis = {} # arch -> []
317
318 self.Externs = {} # arch -> []
319 self.Pcds = {} # arch -> []
320
321 self.UserExtensions = {} # identifier -> ...
322 self.BuildOptions = {} # (toolchain, target, arch, toolcode, "FLAGS") -> flag
323 self.Environment = {}
324
325 def __eq__(self, other):
326 if not isinstance(other, Module):
327 return False
328
329 if self.GuidValue != other.GuidValue:
330 return False
331
332 if self.Version != other.Version:
333 return False
334
335 if self.Package != other.Package:
336 return False
337
338 return True
339
340 def __hash__(self):
341 return hash(self.GuidValue + self.Version + hash(self.Package))
342
343 ################################################################################
344 ##
345 ## PlatformModule: module for build
346 ##
347 ################################################################################
348 class PlatformModule(Element):
349 def __init__(self, **kwargs):
350 """Workspace, Platform, Module, Libraries, Pcds, FfsLayouts, FvBindings
351 BuildOptions, BuildType, BuildFile, BuildPath, Sections, FfsFile, Environment
352 """
353 Element.__init__(self)
354 self.Workspace = ""
355 self.Platform = ""
356 self.Module = ""
357 self.Libraries = []
358 self.Pcds = []
359 self.FfsLayouts = []
360 self.FvBindings = []
361 self.BuildOptions = {}
362
363 self.BuildType = "efi" ## efi or lib
364 self.BuildFile = "build.xml"
365 self.BuildPath = "${MODULE_BUILD_DIR}"
366 self.Sections = []
367 self.FfsFile = ""
368
369 self.Environment = {} # name/value pairs
370
371 def __eq__(self, other):
372 if not isinstance(other, PlatformModule):
373 if not isinstance(other, Module):
374 return False
375 elif self.Module != other:
376 return False
377 elif self.Module != other.Module:
378 return False
379
380 return True
381
382 def __hash__(self):
383 return hash(self.Module)
384
385 ################################################################################
386 ##
387 ## Package: framework package
388 ##
389 ################################################################################
390 class Package(Element):
391 def __init__(self, **kwargs):
392 """Workspace, ReadOnly, Repackage, Modules, PackageIncludes, StandardIncludes,
393 LibraryInterfaces, Guids, Protocols, Ppis, Pcds, Environment
394 """
395 Element.__init__(self)
396
397 self.Workspace = ""
398 self.ReadOnly = True
399 self.Repackage = True
400 self.Modules = []
401 self.PackageIncludes = {} # module type -> [include file list]
402 self.StandardIncludes = []
403 self.LibraryInterfaces = {} # class name -> include file
404 self.Guids = {} # cname -> guid object
405 self.Protocols = {} # cname -> protocol object
406 self.Ppis = {} # cname -> ppi object
407 self.Pcds = {} # token -> pcd object
408
409 self.Environment = {}
410
411 ################################################################################
412 ##
413 ## PackageDependency:
414 ##
415 ################################################################################
416 class PackageDependency(Element):
417 def __init__(self, **kwargs):
418 """Package"""
419 Element.__init__(self)
420
421 self.Package = ""
422
423 ################################################################################
424 ##
425 ## Platform:
426 ##
427 ################################################################################
428 class Platform(Element):
429 def __init__(self, **kwargs):
430 """Targets, OutputPath, Images, Modules, DynamicPcds, Fvs, Libraries
431 BuildFile, BuildPath, BuildOptions, UserExtensions
432 """
433 Element.__init__(self)
434
435 self.Targets = []
436 self.OutputPath = ""
437 self.Images = []
438 self.Modules = {} # arch -> [module list]
439 self.DynamicPcds = []
440 self.FfsLayouts = {}
441 self.Fvs = {}
442
443 self.Libraries = {} # arch -> [library instance]
444 self.BuildFile = "build.xml"
445 self.BuildPath = "${PLATFORM_BUILD_DIR}"
446 self.BuildOptions = {}
447 self.UserExtensions = {}
448
449 self.Environment = {} # name/value pairs
450
451 ################################################################################
452 ##
453 ## Workspace:
454 ##
455 ################################################################################
456 class Workspace(Element):
457 def __init__(self, **kwargs):
458 """Packages, Platforms, Fars, Modules, PlatformIndex, PackageIndex"""
459 Element.__init__(self)
460
461 self.Packages = []
462 self.Platforms = []
463 self.Fars = []
464 self.Modules = []
465
466 ## "GUID" : {guid : {version : platform}}
467 ## "PATH" : {path : platform}
468 ## "NAME" : {name : [platform]}
469 self.PlatformXref = {
470 "GUID" : {},
471 "PATH" : {},
472 "NAME" : {},
473 }
474 ## "GUID" : {guid : {version : package}}
475 ## "PATH" : {path : package}
476 ## "NAME" : {name : package}
477 self.PackageXref = {
478 "GUID" : {},
479 "PATH" : {},
480 "NAME" : {},
481 }
482 ## "GUID" : {guid : {version : [module]}}
483 ## "PATH" : {path : module}
484 ## "NAME" : {name : module}
485 self.ModuleXref = {
486 "GUID" : {},
487 "PATH" : {},
488 "NAME" : {},
489 }
490 ## "NAME" : {name : [library interface]}
491 ## "PATH" : {path : library interface}
492 self.LibraryInterfaceXref = {
493 "PATH" : {},
494 "NAME" : {},
495 }
496 ## TODO
497 self.FarIndex = {}
498
499 # from target.txt
500 self.TargetConfig = {}
501 # from tools_def.txt
502 self.ToolConfig = {}
503
504 self.ActivePlatform = ""
505 self.ActiveToolchain = ""
506 self.ActiveFamilies = []
507 self.ActiveModules = []
508 self.ActiveTargets = []
509 self.ActiveArchs = []
510
511 self.IndividualModuleBuild = False
512 self.MultiThreadBuild = False
513 self.ThreadCount = "2"
514
515 self.Environment = {}
516
517 ################################################################################
518 ##
519 ## For test:
520 ##
521 ################################################################################
522 if __name__ == "__main__":
523 pass