BaseTools: Enable structure pcd in FDF file
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / BuildClassObject.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to define each component of the build database\r
3#\r
c33081c9 4# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
30fdf114
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
1be2ed90 14import Common.LongFilePathOs as os\r
30fdf114 15\r
6e6d767e 16from collections import OrderedDict\r
30fdf114
LG
17from Common.Misc import RealPath2\r
18from Common.BuildToolError import *\r
8518bf0b 19from Common.DataType import *\r
ae7b6df8 20import collections\r
30fdf114
LG
21\r
22## PcdClassObject\r
23#\r
24# This Class is used for PcdObject\r
25#\r
26# @param object: Inherited from object class\r
27# @param Name: Input value for Name of Pcd, default is None\r
28# @param Guid: Input value for Guid of Pcd, default is None\r
29# @param Type: Input value for Type of Pcd, default is None\r
30# @param DatumType: Input value for DatumType of Pcd, default is None\r
31# @param Value: Input value for Value of Pcd, default is None\r
32# @param Token: Input value for Token of Pcd, default is None\r
33# @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None\r
34# @param SkuInfoList: Input value for SkuInfoList of Pcd, default is {}\r
35# @param IsOverrided: Input value for IsOverrided of Pcd, default is False\r
e56468c0 36# @param GuidValue: Input value for TokenSpaceGuidValue of Pcd, default is None\r
30fdf114
LG
37#\r
38# @var TokenCName: To store value for TokenCName\r
39# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName\r
40# @var Type: To store value for Type\r
41# @var DatumType: To store value for DatumType\r
42# @var TokenValue: To store value for TokenValue\r
43# @var MaxDatumSize: To store value for MaxDatumSize\r
44# @var SkuInfoList: To store value for SkuInfoList\r
45# @var IsOverrided: To store value for IsOverrided\r
46# @var Phase: To store value for Phase, default is "DXE"\r
47#\r
48class PcdClassObject(object):\r
cc71d8b7 49 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):\r
30fdf114
LG
50 self.TokenCName = Name\r
51 self.TokenSpaceGuidCName = Guid\r
52 self.TokenSpaceGuidValue = GuidValue\r
53 self.Type = Type\r
54 self.DatumType = DatumType\r
55 self.DefaultValue = Value\r
56 self.TokenValue = Token\r
57 self.MaxDatumSize = MaxDatumSize\r
c33081c9 58 self.MaxSizeUserSet = None\r
30fdf114
LG
59 self.SkuInfoList = SkuInfoList\r
60 self.Phase = "DXE"\r
61 self.Pending = False\r
e56468c0 62 self.IsOverrided = IsOverrided\r
a0a2cd1e
FB
63 self.IsFromBinaryInf = False\r
64 self.IsFromDsc = False\r
82a6a960
BF
65 self.validateranges = validateranges\r
66 self.validlists = validlists\r
67 self.expressions = expressions\r
cc71d8b7 68 self.DscDefaultValue = None\r
f3b31433 69 self.DscRawValue = None\r
cc71d8b7
YZ
70 if IsDsc:\r
71 self.DscDefaultValue = Value\r
0f228f19 72 self.PcdValueFromComm = ""\r
543f5ac3
B
73 self.PcdValueFromFdf = ""\r
74 self.DefinitionPosition = ("","")\r
9904222d 75\r
5565a8c4
CJ
76 ## Get the maximum number of bytes\r
77 def GetPcdMaxSize(self):\r
78 if self.DatumType in TAB_PCD_NUMERIC_TYPES:\r
79 return MAX_SIZE_TYPE[self.DatumType]\r
80\r
ccaa7754 81 MaxSize = int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0\r
543f5ac3
B
82 if self.PcdValueFromFdf:\r
83 if self.PcdValueFromFdf.startswith("{") and self.PcdValueFromFdf.endswith("}"):\r
84 MaxSize = max([len(self.PcdValueFromFdf.split(",")),MaxSize])\r
85 elif self.PcdValueFromFdf.startswith("\"") or self.PcdValueFromFdf.startswith("\'"):\r
86 MaxSize = max([len(self.PcdValueFromFdf)-2+1,MaxSize])\r
87 elif self.PcdValueFromFdf.startswith("L\""):\r
88 MaxSize = max([2*(len(self.PcdValueFromFdf)-3+1),MaxSize])\r
89 else:\r
90 MaxSize = max([len(self.PcdValueFromFdf),MaxSize])\r
91\r
5565a8c4
CJ
92 if self.PcdValueFromComm:\r
93 if self.PcdValueFromComm.startswith("{") and self.PcdValueFromComm.endswith("}"):\r
ccaa7754 94 return max([len(self.PcdValueFromComm.split(",")), MaxSize])\r
5565a8c4 95 elif self.PcdValueFromComm.startswith("\"") or self.PcdValueFromComm.startswith("\'"):\r
ccaa7754 96 return max([len(self.PcdValueFromComm)-2+1, MaxSize])\r
5565a8c4 97 elif self.PcdValueFromComm.startswith("L\""):\r
ccaa7754 98 return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize])\r
5565a8c4 99 else:\r
ccaa7754 100 return max([len(self.PcdValueFromComm), MaxSize])\r
5565a8c4
CJ
101 return MaxSize\r
102\r
103 ## Get the number of bytes\r
104 def GetPcdSize(self):\r
105 if self.DatumType in TAB_PCD_NUMERIC_TYPES:\r
106 return MAX_SIZE_TYPE[self.DatumType]\r
107 if not self.DefaultValue:\r
108 return 1\r
109 elif self.DefaultValue[0] == 'L':\r
110 return (len(self.DefaultValue) - 2) * 2\r
111 elif self.DefaultValue[0] == '{':\r
112 return len(self.DefaultValue.split(','))\r
113 else:\r
114 return len(self.DefaultValue) - 1\r
115\r
116\r
30fdf114
LG
117 ## Convert the class to a string\r
118 #\r
119 # Convert each member of the class to string\r
120 # Organize to a signle line format string\r
121 #\r
122 # @retval Rtn Formatted String\r
123 #\r
124 def __str__(self):\r
125 Rtn = '\tTokenCName=' + str(self.TokenCName) + ', ' + \\r
126 'TokenSpaceGuidCName=' + str(self.TokenSpaceGuidCName) + ', ' + \\r
127 'Type=' + str(self.Type) + ', ' + \\r
128 'DatumType=' + str(self.DatumType) + ', ' + \\r
129 'DefaultValue=' + str(self.DefaultValue) + ', ' + \\r
130 'TokenValue=' + str(self.TokenValue) + ', ' + \\r
131 'MaxDatumSize=' + str(self.MaxDatumSize) + ', '\r
132 for Item in self.SkuInfoList.values():\r
133 Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName\r
e56468c0 134 Rtn = Rtn + ', IsOverrided=' + str(self.IsOverrided)\r
30fdf114
LG
135\r
136 return Rtn\r
137\r
138 ## Override __eq__ function\r
139 #\r
140 # Check whether pcds are the same\r
141 #\r
142 # @retval False The two pcds are different\r
143 # @retval True The two pcds are the same\r
144 #\r
145 def __eq__(self, Other):\r
146 return Other and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName\r
147\r
148 ## Override __hash__ function\r
149 #\r
150 # Use (TokenCName, TokenSpaceGuidCName) as key in hash table\r
151 #\r
152 # @retval truple() Key for hash table\r
153 #\r
154 def __hash__(self):\r
155 return hash((self.TokenCName, self.TokenSpaceGuidCName))\r
156\r
ae7b6df8 157class StructurePcd(PcdClassObject):\r
9904222d 158 def __init__(self, StructuredPcdIncludeFile=None, Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList=None, IsOverrided=False, GuidValue=None, validateranges=None, validlists=None, expressions=None,default_store = TAB_DEFAULT_STORES_DEFAULT):\r
8ac64c5b
CJ
159 if SkuInfoList is None:\r
160 SkuInfoList = {}\r
161 if validateranges is None:\r
162 validateranges = []\r
163 if validlists is None:\r
164 validlists = []\r
165 if expressions is None:\r
166 expressions = []\r
167 if Packages is None:\r
168 Packages = []\r
ae7b6df8 169 super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions)\r
81add864 170 self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile\r
ae7b6df8 171 self.PackageDecs = Packages\r
8518bf0b 172 self.DefaultStoreName = [default_store]\r
817e3669 173 self.DefaultValues = collections.OrderedDict()\r
ae7b6df8 174 self.PcdMode = None\r
817e3669 175 self.SkuOverrideValues = collections.OrderedDict()\r
ae7b6df8 176 self.FlexibleFieldName = None\r
e651d06c 177 self.StructName = None\r
6a103440
FB
178 self.PcdDefineLineNo = 0\r
179 self.PkgPath = ""\r
06140766 180 self.DefaultValueFromDec = ""\r
88252a90 181 self.ValueChain = set()\r
817e3669 182 self.PcdFieldValueFromComm = collections.OrderedDict()\r
543f5ac3 183 self.PcdFieldValueFromFdf = collections.OrderedDict()\r
ae7b6df8
LG
184 def __repr__(self):\r
185 return self.TypeName\r
186\r
187 def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0):\r
34952f49
LG
188 if FieldName in self.DefaultValues:\r
189 del self.DefaultValues[FieldName]\r
ae7b6df8
LG
190 self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo]\r
191 return self.DefaultValues[FieldName]\r
192\r
ccaa7754 193 def SetDecDefaultValue(self, DefaultValue):\r
06140766 194 self.DefaultValueFromDec = DefaultValue\r
8518bf0b 195 def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):\r
ae7b6df8 196 if SkuName not in self.SkuOverrideValues:\r
817e3669 197 self.SkuOverrideValues[SkuName] = collections.OrderedDict()\r
8518bf0b 198 if DefaultStoreName not in self.SkuOverrideValues[SkuName]:\r
817e3669 199 self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict()\r
8518bf0b
LG
200 if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName]:\r
201 del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName]\r
202 self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] = [Value.strip(), FileName, LineNo]\r
203 return self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName]\r
ae7b6df8
LG
204\r
205 def SetPcdMode (self, PcdMode):\r
206 self.PcdMode = PcdMode\r
207\r
208 def SetFlexibleFieldName (self, FlexibleFieldName):\r
209 self.FlexibleFieldName = FlexibleFieldName\r
210\r
211 def copy(self, PcdObject):\r
212 self.TokenCName = PcdObject.TokenCName if PcdObject.TokenCName else self.TokenCName\r
213 self.TokenSpaceGuidCName = PcdObject.TokenSpaceGuidCName if PcdObject.TokenSpaceGuidCName else PcdObject.TokenSpaceGuidCName\r
214 self.TokenSpaceGuidValue = PcdObject.TokenSpaceGuidValue if PcdObject.TokenSpaceGuidValue else self.TokenSpaceGuidValue\r
215 self.Type = PcdObject.Type if PcdObject.Type else self.Type\r
216 self.DatumType = PcdObject.DatumType if PcdObject.DatumType else self.DatumType\r
217 self.DefaultValue = PcdObject.DefaultValue if PcdObject.DefaultValue else self.DefaultValue\r
218 self.TokenValue = PcdObject.TokenValue if PcdObject.TokenValue else self.TokenValue\r
219 self.MaxDatumSize = PcdObject.MaxDatumSize if PcdObject.MaxDatumSize else self.MaxDatumSize\r
220 self.SkuInfoList = PcdObject.SkuInfoList if PcdObject.SkuInfoList else self.SkuInfoList\r
221 self.Phase = PcdObject.Phase if PcdObject.Phase else self.Phase\r
222 self.Pending = PcdObject.Pending if PcdObject.Pending else self.Pending\r
223 self.IsOverrided = PcdObject.IsOverrided if PcdObject.IsOverrided else self.IsOverrided\r
224 self.IsFromBinaryInf = PcdObject.IsFromBinaryInf if PcdObject.IsFromBinaryInf else self.IsFromBinaryInf\r
225 self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc\r
226 self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges\r
227 self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists\r
228 self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions\r
f3b31433 229 self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue\r
0f228f19 230 self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm\r
543f5ac3 231 self.PcdValueFromFdf = PcdObject.PcdValueFromFdf if PcdObject.PcdValueFromFdf else self.PcdValueFromFdf\r
065a7d40 232 self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition\r
0d1f5b2b 233 if isinstance(PcdObject, StructurePcd):\r
ae7b6df8
LG
234 self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile\r
235 self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs\r
236 self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues\r
237 self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode\r
238 self.DefaultFromDSC=None\r
06140766 239 self.DefaultValueFromDec = PcdObject.DefaultValueFromDec if PcdObject.DefaultValueFromDec else self.DefaultValueFromDec\r
65eff519 240 self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues\r
ae7b6df8 241 self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName\r
e651d06c 242 self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName\r
6a103440
FB
243 self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo\r
244 self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath\r
f3b31433 245 self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain\r
b854e2bf 246 self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm\r
543f5ac3 247 self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf\r
ae7b6df8 248\r
30fdf114
LG
249## LibraryClassObject\r
250#\r
251# This Class defines LibraryClassObject used in BuildDatabase\r
252#\r
253# @param object: Inherited from object class\r
254# @param Name: Input value for LibraryClassName, default is None\r
255# @param SupModList: Input value for SupModList, default is []\r
256# @param Type: Input value for Type, default is None\r
257#\r
258# @var LibraryClass: To store value for LibraryClass\r
259# @var SupModList: To store value for SupModList\r
260# @var Type: To store value for Type\r
261#\r
262class LibraryClassObject(object):\r
263 def __init__(self, Name = None, SupModList = [], Type = None):\r
264 self.LibraryClass = Name\r
265 self.SupModList = SupModList\r
4231a819 266 if Type is not None:\r
30fdf114
LG
267 self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)\r
268\r
269## ModuleBuildClassObject\r
270#\r
271# This Class defines ModuleBuildClass\r
272#\r
273# @param object: Inherited from object class\r
274#\r
275# @var MetaFile: To store value for module meta file path\r
276# @var BaseName: To store value for BaseName\r
277# @var ModuleType: To store value for ModuleType\r
278# @var Guid: To store value for Guid\r
279# @var Version: To store value for Version\r
280# @var PcdIsDriver: To store value for PcdIsDriver\r
281# @var BinaryModule: To store value for BinaryModule\r
282# @var CustomMakefile: To store value for CustomMakefile\r
283# @var Specification: To store value for Specification\r
284# @var Shadow To store value for Shadow\r
285# @var LibraryClass: To store value for LibraryClass, it is a list structure as\r
286# [ LibraryClassObject, ...]\r
287# @var ModuleEntryPointList: To store value for ModuleEntryPointList\r
288# @var ModuleUnloadImageList: To store value for ModuleUnloadImageList\r
289# @var ConstructorList: To store value for ConstructorList\r
290# @var DestructorList: To store value for DestructorList\r
291# @var Binaries: To store value for Binaries, it is a list structure as\r
292# [ ModuleBinaryClassObject, ...]\r
293# @var Sources: To store value for Sources, it is a list structure as\r
294# [ ModuleSourceFilesClassObject, ... ]\r
295# @var LibraryClasses: To store value for LibraryClasses, it is a set structure as\r
296# { [LibraryClassName, ModuleType] : LibraryClassInfFile }\r
297# @var Protocols: To store value for Protocols, it is a list structure as\r
298# [ ProtocolName, ... ]\r
299# @var Ppis: To store value for Ppis, it is a list structure as\r
300# [ PpiName, ... ]\r
301# @var Guids: To store value for Guids, it is a list structure as\r
302# [ GuidName, ... ]\r
303# @var Includes: To store value for Includes, it is a list structure as\r
304# [ IncludePath, ... ]\r
305# @var Packages: To store value for Packages, it is a list structure as\r
306# [ DecFileName, ... ]\r
307# @var Pcds: To store value for Pcds, it is a set structure as\r
308# { [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
309# @var BuildOptions: To store value for BuildOptions, it is a set structure as\r
310# { [BuildOptionKey] : BuildOptionValue}\r
311# @var Depex: To store value for Depex\r
312#\r
313class ModuleBuildClassObject(object):\r
314 def __init__(self):\r
315 self.AutoGenVersion = 0\r
316 self.MetaFile = ''\r
317 self.BaseName = ''\r
318 self.ModuleType = ''\r
319 self.Guid = ''\r
320 self.Version = ''\r
321 self.PcdIsDriver = ''\r
322 self.BinaryModule = ''\r
323 self.Shadow = ''\r
324 self.SourceOverridePath = ''\r
325 self.CustomMakefile = {}\r
326 self.Specification = {}\r
327 self.LibraryClass = []\r
328 self.ModuleEntryPointList = []\r
329 self.ModuleUnloadImageList = []\r
330 self.ConstructorList = []\r
331 self.DestructorList = []\r
332\r
333 self.Binaries = []\r
334 self.Sources = []\r
6e6d767e 335 self.LibraryClasses = OrderedDict()\r
30fdf114
LG
336 self.Libraries = []\r
337 self.Protocols = []\r
338 self.Ppis = []\r
339 self.Guids = []\r
340 self.Includes = []\r
341 self.Packages = []\r
342 self.Pcds = {}\r
343 self.BuildOptions = {}\r
344 self.Depex = {}\r
345\r
346 ## Convert the class to a string\r
347 #\r
348 # Convert member MetaFile of the class to a string\r
349 #\r
350 # @retval string Formatted String\r
351 #\r
352 def __str__(self):\r
353 return str(self.MetaFile)\r
354\r
355 ## Override __eq__ function\r
356 #\r
357 # Check whether ModuleBuildClassObjects are the same\r
358 #\r
359 # @retval False The two ModuleBuildClassObjects are different\r
360 # @retval True The two ModuleBuildClassObjects are the same\r
361 #\r
362 def __eq__(self, Other):\r
363 return self.MetaFile == Other\r
364\r
365 ## Override __hash__ function\r
366 #\r
367 # Use MetaFile as key in hash table\r
368 #\r
369 # @retval string Key for hash table\r
370 #\r
371 def __hash__(self):\r
372 return hash(self.MetaFile)\r
373\r
374## PackageBuildClassObject\r
375#\r
376# This Class defines PackageBuildClass\r
377#\r
378# @param object: Inherited from object class\r
379#\r
380# @var MetaFile: To store value for package meta file path\r
381# @var PackageName: To store value for PackageName\r
382# @var Guid: To store value for Guid\r
383# @var Version: To store value for Version\r
384# @var Protocols: To store value for Protocols, it is a set structure as\r
385# { [ProtocolName] : Protocol Guid, ... }\r
386# @var Ppis: To store value for Ppis, it is a set structure as\r
387# { [PpiName] : Ppi Guid, ... }\r
388# @var Guids: To store value for Guids, it is a set structure as\r
389# { [GuidName] : Guid, ... }\r
390# @var Includes: To store value for Includes, it is a list structure as\r
391# [ IncludePath, ... ]\r
392# @var LibraryClasses: To store value for LibraryClasses, it is a set structure as\r
393# { [LibraryClassName] : LibraryClassInfFile }\r
394# @var Pcds: To store value for Pcds, it is a set structure as\r
395# { [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
396#\r
397class PackageBuildClassObject(object):\r
398 def __init__(self):\r
399 self.MetaFile = ''\r
400 self.PackageName = ''\r
401 self.Guid = ''\r
402 self.Version = ''\r
403\r
404 self.Protocols = {}\r
405 self.Ppis = {}\r
406 self.Guids = {}\r
407 self.Includes = []\r
408 self.LibraryClasses = {}\r
409 self.Pcds = {}\r
410\r
411 ## Convert the class to a string\r
412 #\r
413 # Convert member MetaFile of the class to a string\r
414 #\r
415 # @retval string Formatted String\r
416 #\r
417 def __str__(self):\r
418 return str(self.MetaFile)\r
419\r
420 ## Override __eq__ function\r
421 #\r
422 # Check whether PackageBuildClassObjects are the same\r
423 #\r
424 # @retval False The two PackageBuildClassObjects are different\r
425 # @retval True The two PackageBuildClassObjects are the same\r
426 #\r
427 def __eq__(self, Other):\r
428 return self.MetaFile == Other\r
429\r
430 ## Override __hash__ function\r
431 #\r
432 # Use MetaFile as key in hash table\r
433 #\r
434 # @retval string Key for hash table\r
435 #\r
436 def __hash__(self):\r
437 return hash(self.MetaFile)\r
438\r
439## PlatformBuildClassObject\r
440#\r
441# This Class defines PlatformBuildClass\r
442#\r
443# @param object: Inherited from object class\r
444#\r
445# @var MetaFile: To store value for platform meta-file path\r
446# @var PlatformName: To store value for PlatformName\r
447# @var Guid: To store value for Guid\r
448# @var Version: To store value for Version\r
449# @var DscSpecification: To store value for DscSpecification\r
450# @var OutputDirectory: To store value for OutputDirectory\r
451# @var FlashDefinition: To store value for FlashDefinition\r
452# @var BuildNumber: To store value for BuildNumber\r
453# @var MakefileName: To store value for MakefileName\r
454# @var SkuIds: To store value for SkuIds, it is a set structure as\r
455# { 'SkuName' : SkuId, '!include' : includefilename, ...}\r
456# @var Modules: To store value for Modules, it is a list structure as\r
457# [ InfFileName, ... ]\r
458# @var Libraries: To store value for Libraries, it is a list structure as\r
459# [ InfFileName, ... ]\r
460# @var LibraryClasses: To store value for LibraryClasses, it is a set structure as\r
461# { (LibraryClassName, ModuleType) : LibraryClassInfFile }\r
462# @var Pcds: To store value for Pcds, it is a set structure as\r
463# { [(PcdCName, PcdGuidCName)] : PcdClassObject }\r
464# @var BuildOptions: To store value for BuildOptions, it is a set structure as\r
465# { [BuildOptionKey] : BuildOptionValue }\r
466#\r
467class PlatformBuildClassObject(object):\r
468 def __init__(self):\r
469 self.MetaFile = ''\r
470 self.PlatformName = ''\r
471 self.Guid = ''\r
472 self.Version = ''\r
473 self.DscSpecification = ''\r
474 self.OutputDirectory = ''\r
475 self.FlashDefinition = ''\r
476 self.BuildNumber = ''\r
477 self.MakefileName = ''\r
478\r
479 self.SkuIds = {}\r
480 self.Modules = []\r
481 self.LibraryInstances = []\r
482 self.LibraryClasses = {}\r
483 self.Libraries = {}\r
484 self.Pcds = {}\r
485 self.BuildOptions = {}\r
486\r
487 ## Convert the class to a string\r
488 #\r
489 # Convert member MetaFile of the class to a string\r
490 #\r
491 # @retval string Formatted String\r
492 #\r
493 def __str__(self):\r
494 return str(self.MetaFile)\r
495\r
496 ## Override __eq__ function\r
497 #\r
498 # Check whether PlatformBuildClassObjects are the same\r
499 #\r
500 # @retval False The two PlatformBuildClassObjects are different\r
501 # @retval True The two PlatformBuildClassObjects are the same\r
502 #\r
503 def __eq__(self, Other):\r
504 return self.MetaFile == Other\r
505\r
506 ## Override __hash__ function\r
507 #\r
508 # Use MetaFile as key in hash table\r
509 #\r
510 # @retval string Key for hash table\r
511 #\r
512 def __hash__(self):\r
513 return hash(self.MetaFile)\r