]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Workspace/BuildClassObject.py
2 # This file is used to define each component of the build database
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 import Common
.LongFilePathOs
as os
16 from Common
.Misc
import sdict
17 from Common
.Misc
import RealPath2
18 from Common
.BuildToolError
import *
22 # This Class is used for PcdObject
24 # @param object: Inherited from object class
25 # @param Name: Input value for Name of Pcd, default is None
26 # @param Guid: Input value for Guid of Pcd, default is None
27 # @param Type: Input value for Type of Pcd, default is None
28 # @param DatumType: Input value for DatumType of Pcd, default is None
29 # @param Value: Input value for Value of Pcd, default is None
30 # @param Token: Input value for Token of Pcd, default is None
31 # @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None
32 # @param SkuInfoList: Input value for SkuInfoList of Pcd, default is {}
33 # @param IsOverrided: Input value for IsOverrided of Pcd, default is False
34 # @param GuidValue: Input value for TokenSpaceGuidValue of Pcd, default is None
36 # @var TokenCName: To store value for TokenCName
37 # @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName
38 # @var Type: To store value for Type
39 # @var DatumType: To store value for DatumType
40 # @var TokenValue: To store value for TokenValue
41 # @var MaxDatumSize: To store value for MaxDatumSize
42 # @var SkuInfoList: To store value for SkuInfoList
43 # @var IsOverrided: To store value for IsOverrided
44 # @var Phase: To store value for Phase, default is "DXE"
46 class PcdClassObject(object):
47 def __init__(self
, Name
= None, Guid
= None, Type
= None, DatumType
= None, Value
= None, Token
= None, MaxDatumSize
= None, SkuInfoList
= {}, IsOverrided
= False, GuidValue
= None, validateranges
= [], validlists
= [], expressions
= [], IsDsc
= False):
48 self
.TokenCName
= Name
49 self
.TokenSpaceGuidCName
= Guid
50 self
.TokenSpaceGuidValue
= GuidValue
52 self
.DatumType
= DatumType
53 self
.DefaultValue
= Value
54 self
.TokenValue
= Token
55 self
.MaxDatumSize
= MaxDatumSize
56 self
.SkuInfoList
= SkuInfoList
59 self
.IsOverrided
= IsOverrided
60 self
.IsFromBinaryInf
= False
61 self
.IsFromDsc
= False
62 self
.validateranges
= validateranges
63 self
.validlists
= validlists
64 self
.expressions
= expressions
65 self
.DscDefaultValue
= None
67 self
.DscDefaultValue
= Value
69 ## Convert the class to a string
71 # Convert each member of the class to string
72 # Organize to a signle line format string
74 # @retval Rtn Formatted String
77 Rtn
= '\tTokenCName=' + str(self
.TokenCName
) + ', ' + \
78 'TokenSpaceGuidCName=' + str(self
.TokenSpaceGuidCName
) + ', ' + \
79 'Type=' + str(self
.Type
) + ', ' + \
80 'DatumType=' + str(self
.DatumType
) + ', ' + \
81 'DefaultValue=' + str(self
.DefaultValue
) + ', ' + \
82 'TokenValue=' + str(self
.TokenValue
) + ', ' + \
83 'MaxDatumSize=' + str(self
.MaxDatumSize
) + ', '
84 for Item
in self
.SkuInfoList
.values():
85 Rtn
= Rtn
+ 'SkuId=' + Item
.SkuId
+ ', ' + 'SkuIdName=' + Item
.SkuIdName
86 Rtn
= Rtn
+ ', IsOverrided=' + str(self
.IsOverrided
)
90 ## Override __eq__ function
92 # Check whether pcds are the same
94 # @retval False The two pcds are different
95 # @retval True The two pcds are the same
97 def __eq__(self
, Other
):
98 return Other
and self
.TokenCName
== Other
.TokenCName
and self
.TokenSpaceGuidCName
== Other
.TokenSpaceGuidCName
100 ## Override __hash__ function
102 # Use (TokenCName, TokenSpaceGuidCName) as key in hash table
104 # @retval truple() Key for hash table
107 return hash((self
.TokenCName
, self
.TokenSpaceGuidCName
))
109 ## LibraryClassObject
111 # This Class defines LibraryClassObject used in BuildDatabase
113 # @param object: Inherited from object class
114 # @param Name: Input value for LibraryClassName, default is None
115 # @param SupModList: Input value for SupModList, default is []
116 # @param Type: Input value for Type, default is None
118 # @var LibraryClass: To store value for LibraryClass
119 # @var SupModList: To store value for SupModList
120 # @var Type: To store value for Type
122 class LibraryClassObject(object):
123 def __init__(self
, Name
= None, SupModList
= [], Type
= None):
124 self
.LibraryClass
= Name
125 self
.SupModList
= SupModList
127 self
.SupModList
= CleanString(Type
).split(DataType
.TAB_SPACE_SPLIT
)
129 ## ModuleBuildClassObject
131 # This Class defines ModuleBuildClass
133 # @param object: Inherited from object class
135 # @var MetaFile: To store value for module meta file path
136 # @var BaseName: To store value for BaseName
137 # @var ModuleType: To store value for ModuleType
138 # @var Guid: To store value for Guid
139 # @var Version: To store value for Version
140 # @var PcdIsDriver: To store value for PcdIsDriver
141 # @var BinaryModule: To store value for BinaryModule
142 # @var CustomMakefile: To store value for CustomMakefile
143 # @var Specification: To store value for Specification
144 # @var Shadow To store value for Shadow
145 # @var LibraryClass: To store value for LibraryClass, it is a list structure as
146 # [ LibraryClassObject, ...]
147 # @var ModuleEntryPointList: To store value for ModuleEntryPointList
148 # @var ModuleUnloadImageList: To store value for ModuleUnloadImageList
149 # @var ConstructorList: To store value for ConstructorList
150 # @var DestructorList: To store value for DestructorList
151 # @var Binaries: To store value for Binaries, it is a list structure as
152 # [ ModuleBinaryClassObject, ...]
153 # @var Sources: To store value for Sources, it is a list structure as
154 # [ ModuleSourceFilesClassObject, ... ]
155 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
156 # { [LibraryClassName, ModuleType] : LibraryClassInfFile }
157 # @var Protocols: To store value for Protocols, it is a list structure as
158 # [ ProtocolName, ... ]
159 # @var Ppis: To store value for Ppis, it is a list structure as
161 # @var Guids: To store value for Guids, it is a list structure as
163 # @var Includes: To store value for Includes, it is a list structure as
164 # [ IncludePath, ... ]
165 # @var Packages: To store value for Packages, it is a list structure as
166 # [ DecFileName, ... ]
167 # @var Pcds: To store value for Pcds, it is a set structure as
168 # { [(PcdCName, PcdGuidCName)] : PcdClassObject}
169 # @var BuildOptions: To store value for BuildOptions, it is a set structure as
170 # { [BuildOptionKey] : BuildOptionValue}
171 # @var Depex: To store value for Depex
173 class ModuleBuildClassObject(object):
175 self
.AutoGenVersion
= 0
181 self
.PcdIsDriver
= ''
182 self
.BinaryModule
= ''
184 self
.SourceOverridePath
= ''
185 self
.CustomMakefile
= {}
186 self
.Specification
= {}
187 self
.LibraryClass
= []
188 self
.ModuleEntryPointList
= []
189 self
.ModuleUnloadImageList
= []
190 self
.ConstructorList
= []
191 self
.DestructorList
= []
195 self
.LibraryClasses
= sdict()
203 self
.BuildOptions
= {}
206 ## Convert the class to a string
208 # Convert member MetaFile of the class to a string
210 # @retval string Formatted String
213 return str(self
.MetaFile
)
215 ## Override __eq__ function
217 # Check whether ModuleBuildClassObjects are the same
219 # @retval False The two ModuleBuildClassObjects are different
220 # @retval True The two ModuleBuildClassObjects are the same
222 def __eq__(self
, Other
):
223 return self
.MetaFile
== Other
225 ## Override __hash__ function
227 # Use MetaFile as key in hash table
229 # @retval string Key for hash table
232 return hash(self
.MetaFile
)
234 ## PackageBuildClassObject
236 # This Class defines PackageBuildClass
238 # @param object: Inherited from object class
240 # @var MetaFile: To store value for package meta file path
241 # @var PackageName: To store value for PackageName
242 # @var Guid: To store value for Guid
243 # @var Version: To store value for Version
244 # @var Protocols: To store value for Protocols, it is a set structure as
245 # { [ProtocolName] : Protocol Guid, ... }
246 # @var Ppis: To store value for Ppis, it is a set structure as
247 # { [PpiName] : Ppi Guid, ... }
248 # @var Guids: To store value for Guids, it is a set structure as
249 # { [GuidName] : Guid, ... }
250 # @var Includes: To store value for Includes, it is a list structure as
251 # [ IncludePath, ... ]
252 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
253 # { [LibraryClassName] : LibraryClassInfFile }
254 # @var Pcds: To store value for Pcds, it is a set structure as
255 # { [(PcdCName, PcdGuidCName)] : PcdClassObject}
257 class PackageBuildClassObject(object):
260 self
.PackageName
= ''
268 self
.LibraryClasses
= {}
271 ## Convert the class to a string
273 # Convert member MetaFile of the class to a string
275 # @retval string Formatted String
278 return str(self
.MetaFile
)
280 ## Override __eq__ function
282 # Check whether PackageBuildClassObjects are the same
284 # @retval False The two PackageBuildClassObjects are different
285 # @retval True The two PackageBuildClassObjects are the same
287 def __eq__(self
, Other
):
288 return self
.MetaFile
== Other
290 ## Override __hash__ function
292 # Use MetaFile as key in hash table
294 # @retval string Key for hash table
297 return hash(self
.MetaFile
)
299 ## PlatformBuildClassObject
301 # This Class defines PlatformBuildClass
303 # @param object: Inherited from object class
305 # @var MetaFile: To store value for platform meta-file path
306 # @var PlatformName: To store value for PlatformName
307 # @var Guid: To store value for Guid
308 # @var Version: To store value for Version
309 # @var DscSpecification: To store value for DscSpecification
310 # @var OutputDirectory: To store value for OutputDirectory
311 # @var FlashDefinition: To store value for FlashDefinition
312 # @var BuildNumber: To store value for BuildNumber
313 # @var MakefileName: To store value for MakefileName
314 # @var SkuIds: To store value for SkuIds, it is a set structure as
315 # { 'SkuName' : SkuId, '!include' : includefilename, ...}
316 # @var Modules: To store value for Modules, it is a list structure as
317 # [ InfFileName, ... ]
318 # @var Libraries: To store value for Libraries, it is a list structure as
319 # [ InfFileName, ... ]
320 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
321 # { (LibraryClassName, ModuleType) : LibraryClassInfFile }
322 # @var Pcds: To store value for Pcds, it is a set structure as
323 # { [(PcdCName, PcdGuidCName)] : PcdClassObject }
324 # @var BuildOptions: To store value for BuildOptions, it is a set structure as
325 # { [BuildOptionKey] : BuildOptionValue }
327 class PlatformBuildClassObject(object):
330 self
.PlatformName
= ''
333 self
.DscSpecification
= ''
334 self
.OutputDirectory
= ''
335 self
.FlashDefinition
= ''
336 self
.BuildNumber
= ''
337 self
.MakefileName
= ''
341 self
.LibraryInstances
= []
342 self
.LibraryClasses
= {}
345 self
.BuildOptions
= {}
347 ## Convert the class to a string
349 # Convert member MetaFile of the class to a string
351 # @retval string Formatted String
354 return str(self
.MetaFile
)
356 ## Override __eq__ function
358 # Check whether PlatformBuildClassObjects are the same
360 # @retval False The two PlatformBuildClassObjects are different
361 # @retval True The two PlatformBuildClassObjects are the same
363 def __eq__(self
, Other
):
364 return self
.MetaFile
== Other
366 ## Override __hash__ function
368 # Use MetaFile as key in hash table
370 # @retval string Key for hash table
373 return hash(self
.MetaFile
)