BaseTools: skip updating temporary variable.
[mirror_edk2.git] / BaseTools / Source / Python / CommonDataClass / CommonClass.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to define common items of class object\r
3#\r
82a6a960 4# Copyright (c) 2007 - 2015, 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
14#\r
15# Generate help text\r
16#\r
17def GenerateHelpText(Text, Lang):\r
18 if Text:\r
19 Ht = HelpTextClass()\r
20 Ht.Lang = Lang\r
21 Ht.String = Text\r
22 \r
23 return Ht\r
24 \r
25 return None\r
26\r
27## CommonClass\r
28#\r
29# This class defined common items used in Module/Platform/Package files\r
30# \r
31# @param object: Inherited from object class\r
32# @param Usage: Input value for Usage, default is [] \r
33# @param FeatureFlag: Input value for FeatureFalg, default is ''\r
34# @param SupArchList: Input value for SupArchList, default is []\r
35# @param HelpText: Input value for HelpText, default is ''\r
36#\r
37# @var Usage: To store value for Usage, selection scope is in below list\r
38# ALWAYS_CONSUMED | SOMETIMES_CONSUMED | ALWAYS_PRODUCED | SOMETIMES_PRODUCED | TO_START | BY_START | PRIVATE\r
39# @var FeatureFlag: To store value for FeatureFlag\r
40# @var SupArchList: To store value for SupArchList, selection scope is in below list\r
4afd3d04 41# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64\r
30fdf114
LG
42# @var HelpText: To store value for HelpText\r
43#\r
44class CommonClass(object):\r
45 def __init__(self, Usage = None, FeatureFlag = '', SupArchList = None, HelpText = ''):\r
46 self.Usage = Usage\r
4231a819 47 if self.Usage is None:\r
30fdf114
LG
48 self.Usage = []\r
49 self.FeatureFlag = FeatureFlag\r
50 self.SupArchList = SupArchList\r
4231a819 51 if self.SupArchList is None:\r
30fdf114
LG
52 self.SupArchList = []\r
53 self.HelpText = HelpText\r
54 self.HelpTextList = []\r
55\r
08dd311f 56## CommonHeaderClass\r
30fdf114
LG
57#\r
58# This class defined common items used in Module/Platform/Package files\r
59# \r
60# @param object: Inherited from object class\r
61#\r
62# @var Abstract: To store value for Abstract\r
63# @var Description: To store value for Description\r
64# @var Copyright: To store value for Copyright\r
65# @var License: To store value for License\r
66# @var Specification: To store value for Specification\r
67#\r
68class CommonHeaderClass(object):\r
69 def __init__(self):\r
70 self.Abstract = ''\r
71 self.Description = ''\r
72 self.Copyright = ''\r
73 self.License = ''\r
74 self.Specification = {}\r
75\r
76## HelpTextClass\r
77#\r
78# This class defined HelpText item used in PKG file\r
79# \r
80# @param object: Inherited from object class\r
81#\r
82# @var Lang: To store value for Lang\r
83# @var String: To store value for String\r
84#\r
85class HelpTextClass(object):\r
86 def __init__(self):\r
87 self.Lang = ''\r
88 self.String = ''\r
89 \r
90## DefineClass\r
91#\r
92# This class defined item DEFINE used in Module/Platform/Package files\r
93#\r
94# @param object: Inherited from object class\r
95#\r
96# @var Define: To store value for Define, it is a set structure as\r
97# { (DefineName, Arch) : DefineValue, ... }\r
98#\r
99class DefineClass(object):\r
100 def __init__(self):\r
101 self.Define = {}\r
102\r
103## ClonedRecordClass\r
104#\r
105# This class defined ClonedRecord items used in Module/Platform/Package files\r
106# \r
107# @param object: Inherited from object class\r
108#\r
109# @var Id: To store value for Id\r
110# @var FarGuid: To store value for FarGuid\r
111# @var PackageGuid: To store value for PackageGuid\r
112# @var PackageVersion: To store value for PackageVersion\r
113# @var ModuleGuid: To store value for ModuleGuid\r
114# @var ModuleVersion: To store value for ModuleVersion\r
115#\r
116class ClonedRecordClass(object):\r
117 def __init__(self):\r
118 self.Id = 0\r
119 self.FarGuid = ''\r
120 self.PackageGuid = ''\r
121 self.PackageVersion = ''\r
122 self.ModuleGuid = ''\r
123 self.ModuleVersion = ''\r
124\r
125## IdentificationClass\r
126#\r
127# This class defined Identification items used in Module/Platform/Package files\r
128# \r
129# @param object: Inherited from object class\r
130#\r
131# @var Name: To store value for Name\r
132# ModuleName(Inf) / PackageName(Dec) / PlatformName(Dsc)\r
133# @var Guid: To store value for Guid\r
134# @var Version: To store value for Version\r
135# @var FileName: To store value for FileName\r
136# @var FullPath: To store value for FullPath\r
137#\r
138class IdentificationClass(object):\r
139 def __init__(self):\r
140 self.Name = ''\r
141 self.BaseName = ''\r
142 self.Guid = ''\r
143 self.Version = ''\r
144 self.FileName = ''\r
145 self.FullPath = ''\r
146 self.RelaPath = ''\r
147 self.PackagePath = ''\r
148 self.ModulePath = ''\r
149 self.CombinePath = ''\r
150\r
151## IncludeStatementClass\r
152#\r
153# This class defined IncludeFiles item used in Module/Platform/Package files\r
154# \r
155# @param object: Inherited from object class\r
156#\r
157# @var IncludeFiles: To store value for IncludeFiles\r
158# It is a set structure as { IncludeFile : [Arch1, Arch2, ...], ... }\r
159#\r
160class IncludeStatementClass(object):\r
161 def __init__(self):\r
162 self.IncludeFiles = {} \r
163\r
164## GuidProtocolPpiCommonClass\r
165#\r
166# This class defined Guid, Protocol and Ppi like items used in Module/Platform/Package files\r
167# \r
168# @param CommonClass: Inherited from CommonClass class\r
169#\r
170# @var Name: To store value for Name\r
171# @var CName: To store value for CName\r
172# @var Guid: To store value for Guid\r
173# @var Notify: To store value for Notify\r
174# @var GuidTypeList: To store value for GuidTypeList, selection scope is in below list\r
175# DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID\r
176# @var SupModuleList: To store value for SupModuleList, selection scope is in below list\r
96f73940 177# BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE\r
30fdf114
LG
178#\r
179class GuidProtocolPpiCommonClass(CommonClass):\r
180 def __init__(self):\r
181 self.Name = ''\r
182 self.CName = ''\r
183 self.Guid = ''\r
184 self.VariableName = ''\r
185 self.Notify = False\r
186 self.GuidTypeList = []\r
187 self.GuidTypeLists = []\r
188 self.SupModuleList = [] \r
189 CommonClass.__init__(self)\r
190\r
191## LibraryClassClass\r
192#\r
193# This class defined Library item used in Module/Platform/Package files\r
194# \r
195# @param CommonClass: Inherited from CommonClass class\r
196# @param DefineClass: Inherited from DefineClass class\r
197#\r
198# @var LibraryClass: To store value for LibraryClass\r
199# @var IncludeHeader: To store value for IncludeHeader\r
200# @var RecommendedInstanceVersion: To store value for RecommendedInstanceVersion\r
201# @var RecommendedInstanceGuid: To store value for RecommendedInstanceGuid\r
202# @var RecommendedInstance: To store value for RecommendedInstance, selection scope is in below list\r
203# DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID\r
204# @var SupModuleList: To store value for SupModuleList, selection scope is in below list\r
96f73940 205# BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE\r
30fdf114
LG
206#\r
207class LibraryClassClass(CommonClass, DefineClass):\r
208 def __init__(self):\r
209 self.LibraryClass = ''\r
210 self.IncludeHeader = ''\r
211 self.RecommendedInstanceVersion = ''\r
212 self.RecommendedInstanceGuid = ''\r
213 self.RecommendedInstance = ''\r
214 self.SupModuleList = []\r
215 CommonClass.__init__(self)\r
216 DefineClass.__init__(self)\r
217\r
218## GuidClass\r
219#\r
220# This class defined Guid item used in Module/Platform/Package files\r
221# \r
222# @param GuidProtocolPpiCommonClass: Inherited from GuidProtocolPpiCommonClass class\r
223#\r
224class GuidClass(GuidProtocolPpiCommonClass):\r
225 def __init__(self):\r
226 GuidProtocolPpiCommonClass.__init__(self)\r
227\r
228## ProtocolClass\r
229#\r
230# This class defined Protocol item used in Module/Platform/Package files\r
231# \r
232# @param GuidProtocolPpiCommonClass: Inherited from GuidProtocolPpiCommonClass class\r
233#\r
234class ProtocolClass(GuidProtocolPpiCommonClass):\r
235 def __init__(self):\r
236 GuidProtocolPpiCommonClass.__init__(self)\r
237\r
238## PpiClass\r
239#\r
240# This class defined Ppi item used in Module/Platform/Package files\r
241# \r
242# @param GuidProtocolPpiCommonClass: Inherited from GuidProtocolPpiCommonClass class\r
243#\r
244class PpiClass(GuidProtocolPpiCommonClass): \r
245 def __init__(self):\r
246 GuidProtocolPpiCommonClass.__init__(self)\r
247\r
248## SkuInfoClass\r
249#\r
250# This class defined SkuInfo item used in Module/Platform/Package files\r
251# \r
252# @param object: Inherited from object class\r
253# @param SkuIdName: Input value for SkuIdName, default is ''\r
254# @param SkuId: Input value for SkuId, default is ''\r
255# @param VariableName: Input value for VariableName, default is ''\r
256# @param VariableGuid: Input value for VariableGuid, default is ''\r
257# @param VariableOffset: Input value for VariableOffset, default is ''\r
258# @param HiiDefaultValue: Input value for HiiDefaultValue, default is ''\r
259# @param VpdOffset: Input value for VpdOffset, default is ''\r
260# @param DefaultValue: Input value for DefaultValue, default is ''\r
261#\r
262# @var SkuIdName: To store value for SkuIdName\r
263# @var SkuId: To store value for SkuId\r
264# @var VariableName: To store value for VariableName\r
265# @var VariableGuid: To store value for VariableGuid\r
266# @var VariableOffset: To store value for VariableOffset\r
267# @var HiiDefaultValue: To store value for HiiDefaultValue\r
268# @var VpdOffset: To store value for VpdOffset\r
269# @var DefaultValue: To store value for DefaultValue\r
270#\r
271class SkuInfoClass(object):\r
272 def __init__(self, SkuIdName = '', SkuId = '', VariableName = '', VariableGuid = '', VariableOffset = '', \r
8518bf0b 273 HiiDefaultValue = '', VpdOffset = '', DefaultValue = '', VariableGuidValue = '', VariableAttribute = '', DefaultStore = None):\r
30fdf114
LG
274 self.SkuIdName = SkuIdName\r
275 self.SkuId = SkuId\r
276 \r
277 #\r
278 # Used by Hii\r
279 #\r
8518bf0b
LG
280 if DefaultStore is None:\r
281 DefaultStore = {}\r
30fdf114
LG
282 self.VariableName = VariableName\r
283 self.VariableGuid = VariableGuid\r
284 self.VariableGuidValue = VariableGuidValue\r
285 self.VariableOffset = VariableOffset\r
286 self.HiiDefaultValue = HiiDefaultValue\r
82a6a960 287 self.VariableAttribute = VariableAttribute\r
8518bf0b 288 self.DefaultStoreDict = DefaultStore\r
30fdf114
LG
289 \r
290 #\r
291 # Used by Vpd\r
292 #\r
293 self.VpdOffset = VpdOffset\r
294 \r
295 #\r
296 # Used by Default\r
297 #\r
298 self.DefaultValue = DefaultValue\r
299 \r
300 ## Convert the class to a string\r
301 #\r
302 # Convert each member of the class to string\r
303 # Organize to a signle line format string\r
304 #\r
305 # @retval Rtn Formatted String\r
306 #\r
307 def __str__(self):\r
08dd311f 308 Rtn = 'SkuId = ' + str(self.SkuId) + "," + \\r
30fdf114
LG
309 'SkuIdName = ' + str(self.SkuIdName) + "," + \\r
310 'VariableName = ' + str(self.VariableName) + "," + \\r
311 'VariableGuid = ' + str(self.VariableGuid) + "," + \\r
312 'VariableOffset = ' + str(self.VariableOffset) + "," + \\r
313 'HiiDefaultValue = ' + str(self.HiiDefaultValue) + "," + \\r
314 'VpdOffset = ' + str(self.VpdOffset) + "," + \\r
315 'DefaultValue = ' + str(self.DefaultValue) + ","\r
316 return Rtn\r
317## PcdErrorClass\r
318#\r
319#\r
320#\r
321class PcdErrorClass(object):\r
322 def __init__(self):\r
323 self.ValidValueList = ''\r
324 self.ValidValueListLang = ''\r
325 self.ValidValueRange = ''\r
326 self.Expression = ''\r
327 self.ErrorNumber = ''\r
328 self.ErrorMessage = []\r
329\r
330## PcdClass\r
331#\r
332# This class defined Pcd item used in Module/Platform/Package files\r
333# \r
334# @param CommonClass: Inherited from CommonClass class\r
335# @param CName: Input value for CName, default is ''\r
336# @param Token: Input value for Token, default is ''\r
337# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default is ''\r
338# @param DatumType: Input value for DatumType, default is ''\r
339# @param MaxDatumSize: Input value for MaxDatumSize, default is ''\r
340# @param DefaultValue: Input value for DefaultValue, default is ''\r
341# @param ItemType: Input value for ItemType, default is ''\r
342# @param ValidUsage: Input value for ValidUsage, default is []\r
343# @param SkuInfoList: Input value for SkuInfoList, default is {}\r
344# @param SupModuleList: Input value for SupModuleList, default is []\r
345#\r
346# @var CName: To store value for CName\r
347# @var Token: To store value for Token\r
348# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName\r
349# @var DatumType: To store value for DatumType, selection scope is in below list\r
350# UINT8 | UINT16 | UINT32 | UINT64 | VOID* | BOOLEAN \r
351# @var MaxDatumSize: To store value for MaxDatumSize\r
352# @var DefaultValue: To store value for DefaultValue\r
353# @var ItemType: To store value for ItemType, selection scope is in below list\r
354# FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX\r
355# @var ValidUsage: To store value for ValidUsage, selection scope is in below list\r
356# FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX\r
357# @var SkuInfoList: To store value for SkuInfoList\r
358# It is a set structure as { [SkuIdName] : SkuInfoClass } \r
359# @var SupModuleList: To store value for SupModuleList, selection scope is in below list\r
96f73940 360# BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE\r
30fdf114
LG
361#\r
362class PcdClass(CommonClass):\r
363 def __init__(self, CName = '', Token = '', TokenSpaceGuidCName = '', DatumType = '', MaxDatumSize = '', DefaultValue = '', ItemType = '', ValidUsage = None, SkuInfoList = None, SupModuleList = None):\r
364 self.CName = CName\r
365 self.Token = Token\r
366 self.TokenSpaceGuidCName = TokenSpaceGuidCName\r
367 self.DatumType = DatumType\r
368 self.MaxDatumSize = MaxDatumSize\r
369 self.DefaultValue = DefaultValue\r
370 self.ItemType = ItemType\r
371 self.ValidUsage = ValidUsage\r
372 self.PcdItemType = ''\r
373 self.TokenSpaceGuidValue = ''\r
374 self.PcdUsage = ''\r
375 self.PcdCName = ''\r
376 self.Value = ''\r
377 self.Offset = ''\r
4231a819 378 if self.ValidUsage is None:\r
30fdf114
LG
379 self.ValidUsage = []\r
380 self.SkuInfoList = SkuInfoList\r
4231a819 381 if self.SkuInfoList is None:\r
30fdf114
LG
382 self.SkuInfoList = {}\r
383 self.SupModuleList = SupModuleList\r
4231a819 384 if self.SupModuleList is None:\r
30fdf114
LG
385 self.SupModuleList = []\r
386 CommonClass.__init__(self)\r
387 self.PcdErrors = []\r
388\r
389## BuildOptionClass\r
390#\r
391# This class defined BuildOption item used in Module/Platform/Package files\r
392# \r
393# @param IncludeStatementClass: Inherited from IncludeStatementClass class\r
394# @param ToolChainFamily: Input value for ToolChainFamily, default is ''\r
395# @param ToolChain: Input value for ToolChain, default is ''\r
396# @param Option: Input value for Option, default is ''\r
397#\r
398# @var Statement: To store value for Statement\r
399# It is a string in a special format as "Family:Target_TagName_Tarch_ToolCode_FLAGS = String"\r
400# @var ToolChainFamily: To store value for ToolChainFamily\r
401# @var ToolChain: To store value for ToolChain\r
402# @var Option: To store value for Option\r
403# @var BuildTarget: To store value for BuildTarget\r
404# @var TagName: To store value for TagName\r
405# @var ToolCode: To store value for ToolCode\r
406# @var SupArchList: To store value for SupArchList, selection scope is in below list\r
4afd3d04 407# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64\r
30fdf114
LG
408#\r
409class BuildOptionClass(IncludeStatementClass):\r
410 def __init__(self, ToolChainFamily = '', ToolChain = '', Option = ''):\r
411 IncludeStatementClass.__init__(self)\r
412 self.Statement = '' \r
413 self.ToolChainFamily = ToolChainFamily\r
414 self.ToolChain = ToolChain\r
415 self.Option = Option\r
416 self.BuildTarget = ''\r
417 self.TagName = ''\r
418 self.ToolCode = ''\r
419 self.SupArchList = []\r
420\r
421## IncludeClass\r
422#\r
423# This class defined Include item used in Module/Platform/Package files\r
424# \r
425# @param CommonClass: Inherited from CommonClass class\r
426#\r
427# @var FilePath: To store value for FilePath\r
428# @var ModuleType: To store value for ModuleType\r
429# @var Comment: To store value for Comment\r
430#\r
431class IncludeClass(CommonClass):\r
432 def __init__(self):\r
433 self.FilePath = ''\r
434 self.ModuleType = ''\r
435 self.SupModuleList = []\r
436 self.Comment = ''\r
437 CommonClass.__init__(self) \r
438\r
439## FileClass\r
440#\r
441#\r
442class FileClass(CommonClass):\r
443 def __init__(self):\r
444 self.Filename = ''\r
445 self.Executable = ''\r
446 self.Family = ''\r
447 self.FileType = ''\r
448 CommonClass.__init__(self)\r
449 \r
450\r
451## MiscFileClass\r
452#\r
453#\r
454class MiscFileClass(CommonHeaderClass):\r
455 def __init__(self):\r
456 CommonHeaderClass.__init__(self)\r
457 self.Name = ''\r
458 self.Files = []\r
459 \r
460\r
461## UserExtensionsClass\r
462#\r
463# This class defined UserExtensions item used in Module/Platform/Package files\r
464# \r
465# @param object: Inherited from object class\r
466#\r
467# @var UserID: To store value for UserID\r
468# @var Identifier: To store value for Identifier\r
469# @var Content: To store value for Content\r
470# \r
471class UserExtensionsClass(object):\r
472 def __init__(self):\r
473 self.UserID = ''\r
474 self.Identifier = 0\r
475 self.Content = ''\r
476 self.Defines = []\r
477 self.BuildOptions = []\r