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
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.
12 """Framework Element Classes
17 ################################################################################
19 ## Element class: base class for representing framework elements
21 ################################################################################
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
29 ## Element name, guid and version
34 ## The element supported architecture
37 ## Indiciate how the element is used
38 self
.Usage
= "ALWAYS_CONSUMED"
40 ## Indicate what kind of features this element is bound
43 ## Element signature, used to check the its integerity
47 return self
.Name
+ "-" + self
.Version
+ " " + " [" + self
.GuidValue
+ "]"
49 def __eq__(self
, other
):
50 if not isinstance(other
, Element
):
53 if self
.GuidValue
!= other
.GuidValue
:
56 if self
.Version
!= other
.Version
:
62 return hash(self
.GuidValue
+ self
.Version
)
64 ################################################################################
66 ## ToolOption: build tool option
68 ################################################################################
69 class ToolOption(Element
):
71 def __init__(self
, **kwargs
):
72 """Prefix, Value, Tool, Toolchains, Families, Targets"""
73 Element
.__init
__(self
)
79 self
.Families
= "MSFT"
80 self
.Targets
= "DEBUG"
82 ################################################################################
84 ## BuildTool: build tool
86 ################################################################################
87 class BuildTool(Element
):
88 def __init__(self
, **kwargs
):
89 """Options, Toolchains, Families, Targets"""
90 Element
.__init
__(self
)
97 ################################################################################
99 ## SourceFile: files in a module for build
101 ################################################################################
102 class SourceFile(Element
):
103 def __init__(self
, **kwargs
):
104 """BaseName, Ext, Type, Toolchains, Families, Targets"""
105 Element
.__init
__(self
)
114 ################################################################################
116 ## IncludeFile: header file
118 ################################################################################
119 class IncludeFile(SourceFile
):
120 def __init__(self
, **kwargs
):
121 """Type, Package, ModuleType"""
122 SourceFile
.__init
__(self
)
124 self
.Type
= "HeaderFile"
128 ################################################################################
132 ################################################################################
133 class IncludePath(IncludeFile
):
136 ################################################################################
138 ## LibraryInterface: library class interface
140 ################################################################################
141 class LibraryInterface(Element
):
142 def __init__(self
, **kwargs
):
143 """Package, FavoriteInstance, Instances, ModuleTypes, Consumers"""
144 Element
.__init
__(self
)
147 self
.FavoriteInstance
= ""
149 self
.ModuleTypes
= []
152 def __eq__(self
, other
):
153 if not isinstance(other
, LibraryInterface
):
155 return self
.Name
== other
.Name
158 return hash(self
.Name
)
160 ################################################################################
162 ## LibraryClass: library class
164 ################################################################################
165 class LibraryClass(Element
):
166 def __init__(self
, **kwargs
):
170 Element
.__init
__(self
)
173 self
.FavoriteInstance
= ""
175 def __eq__(self
, other
):
176 if not isinstance(other
, LibraryClass
):
178 return self
.Name
== other
.Name
181 return hash(self
.Name
)
183 ################################################################################
187 ################################################################################
189 def __init__(self
, **kwargs
):
190 """CName, Types, ModuleTypes"""
191 Element
.__init
__(self
)
197 ################################################################################
201 ################################################################################
202 class Protocol(Guid
):
205 ################################################################################
209 ################################################################################
210 class ProtocolNotify(Protocol
):
213 ################################################################################
217 ################################################################################
221 ################################################################################
225 ################################################################################
226 class PpiNotify(Ppi
):
229 ################################################################################
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
)
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
= []
251 ################################################################################
255 ################################################################################
257 def __init__(self
, **kwargs
):
259 Element
.__init
__(self
)
264 ################################################################################
268 ################################################################################
270 def __init__(self
, **kwargs
):
271 """Types, CName, Value, Token, TokenSpace, DatumType, Sku, ModuleTypes"""
272 Element
.__init
__(self
)
284 ################################################################################
286 ## Module: framework module
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
296 Element
.__init
__(self
)
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
= {}
311 self
.NonProcessedFiles
= []
312 self
.LibraryClasses
= {} # arch -> [library class list]
314 self
.Guids
= {} # arch -> [guid object list]
315 self
.Protocols
= {} # arch -> []
316 self
.Ppis
= {} # arch -> []
318 self
.Externs
= {} # arch -> []
319 self
.Pcds
= {} # arch -> []
321 self
.UserExtensions
= {} # identifier -> ...
322 self
.BuildOptions
= {} # (toolchain, target, arch, toolcode, "FLAGS") -> flag
323 self
.Environment
= {}
325 def __eq__(self
, other
):
326 if not isinstance(other
, Module
):
329 if self
.GuidValue
!= other
.GuidValue
:
332 if self
.Version
!= other
.Version
:
335 if self
.Package
!= other
.Package
:
341 return hash(self
.GuidValue
+ self
.Version
+ hash(self
.Package
))
343 ################################################################################
345 ## PlatformModule: module for build
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
353 Element
.__init
__(self
)
361 self
.BuildOptions
= {}
363 self
.BuildType
= "efi" ## efi or lib
364 self
.BuildFile
= "build.xml"
365 self
.BuildPath
= "${MODULE_BUILD_DIR}"
369 self
.Environment
= {} # name/value pairs
371 def __eq__(self
, other
):
372 if not isinstance(other
, PlatformModule
):
373 if not isinstance(other
, Module
):
375 elif self
.Module
!= other
:
377 elif self
.Module
!= other
.Module
:
383 return hash(self
.Module
)
385 ################################################################################
387 ## Package: framework package
389 ################################################################################
390 class Package(Element
):
391 def __init__(self
, **kwargs
):
392 """Workspace, ReadOnly, Repackage, Modules, PackageIncludes, StandardIncludes,
393 LibraryInterfaces, Guids, Protocols, Ppis, Pcds, Environment
395 Element
.__init
__(self
)
399 self
.Repackage
= True
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
409 self
.Environment
= {}
411 ################################################################################
413 ## PackageDependency:
415 ################################################################################
416 class PackageDependency(Element
):
417 def __init__(self
, **kwargs
):
419 Element
.__init
__(self
)
423 ################################################################################
427 ################################################################################
428 class Platform(Element
):
429 def __init__(self
, **kwargs
):
430 """Targets, OutputPath, Images, Modules, DynamicPcds, Fvs, Libraries
431 BuildFile, BuildPath, BuildOptions, UserExtensions
433 Element
.__init
__(self
)
438 self
.Modules
= {} # arch -> [module list]
439 self
.DynamicPcds
= []
443 self
.Libraries
= {} # arch -> [library instance]
444 self
.BuildFile
= "build.xml"
445 self
.BuildPath
= "${PLATFORM_BUILD_DIR}"
446 self
.BuildOptions
= {}
447 self
.UserExtensions
= {}
449 self
.Environment
= {} # name/value pairs
451 ################################################################################
455 ################################################################################
456 class Workspace(Element
):
457 def __init__(self
, **kwargs
):
458 """Packages, Platforms, Fars, Modules, PlatformIndex, PackageIndex"""
459 Element
.__init
__(self
)
466 ## "GUID" : {guid : {version : platform}}
467 ## "PATH" : {path : platform}
468 ## "NAME" : {name : [platform]}
469 self
.PlatformXref
= {
474 ## "GUID" : {guid : {version : package}}
475 ## "PATH" : {path : package}
476 ## "NAME" : {name : package}
482 ## "GUID" : {guid : {version : [module]}}
483 ## "PATH" : {path : module}
484 ## "NAME" : {name : module}
490 ## "NAME" : {name : [library interface]}
491 ## "PATH" : {path : library interface}
492 self
.LibraryInterfaceXref
= {
500 self
.TargetConfig
= {}
504 self
.ActivePlatform
= ""
505 self
.ActiveToolchain
= ""
506 self
.ActiveFamilies
= []
507 self
.ActiveModules
= []
508 self
.ActiveTargets
= []
509 self
.ActiveArchs
= []
511 self
.IndividualModuleBuild
= False
512 self
.MultiThreadBuild
= False
513 self
.ThreadCount
= "2"
515 self
.Environment
= {}
517 ################################################################################
521 ################################################################################
522 if __name__
== "__main__":