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