BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[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
47 if self.Usage == None:\r
48 self.Usage = []\r
49 self.FeatureFlag = FeatureFlag\r
50 self.SupArchList = SupArchList\r
51 if self.SupArchList == None:\r
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
b303ea72 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\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
b303ea72 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\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
82a6a960 273 HiiDefaultValue = '', VpdOffset = '', DefaultValue = '', VariableGuidValue = '', VariableAttribute = ''):\r
30fdf114
LG
274 self.SkuIdName = SkuIdName\r
275 self.SkuId = SkuId\r
276 \r
277 #\r
278 # Used by Hii\r
279 #\r
280 self.VariableName = VariableName\r
281 self.VariableGuid = VariableGuid\r
282 self.VariableGuidValue = VariableGuidValue\r
283 self.VariableOffset = VariableOffset\r
284 self.HiiDefaultValue = HiiDefaultValue\r
82a6a960 285 self.VariableAttribute = VariableAttribute\r
30fdf114
LG
286 \r
287 #\r
288 # Used by Vpd\r
289 #\r
290 self.VpdOffset = VpdOffset\r
291 \r
292 #\r
293 # Used by Default\r
294 #\r
295 self.DefaultValue = DefaultValue\r
296 \r
297 ## Convert the class to a string\r
298 #\r
299 # Convert each member of the class to string\r
300 # Organize to a signle line format string\r
301 #\r
302 # @retval Rtn Formatted String\r
303 #\r
304 def __str__(self):\r
08dd311f 305 Rtn = 'SkuId = ' + str(self.SkuId) + "," + \\r
30fdf114
LG
306 'SkuIdName = ' + str(self.SkuIdName) + "," + \\r
307 'VariableName = ' + str(self.VariableName) + "," + \\r
308 'VariableGuid = ' + str(self.VariableGuid) + "," + \\r
309 'VariableOffset = ' + str(self.VariableOffset) + "," + \\r
310 'HiiDefaultValue = ' + str(self.HiiDefaultValue) + "," + \\r
311 'VpdOffset = ' + str(self.VpdOffset) + "," + \\r
312 'DefaultValue = ' + str(self.DefaultValue) + ","\r
313 return Rtn\r
314## PcdErrorClass\r
315#\r
316#\r
317#\r
318class PcdErrorClass(object):\r
319 def __init__(self):\r
320 self.ValidValueList = ''\r
321 self.ValidValueListLang = ''\r
322 self.ValidValueRange = ''\r
323 self.Expression = ''\r
324 self.ErrorNumber = ''\r
325 self.ErrorMessage = []\r
326\r
327## PcdClass\r
328#\r
329# This class defined Pcd item used in Module/Platform/Package files\r
330# \r
331# @param CommonClass: Inherited from CommonClass class\r
332# @param CName: Input value for CName, default is ''\r
333# @param Token: Input value for Token, default is ''\r
334# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default is ''\r
335# @param DatumType: Input value for DatumType, default is ''\r
336# @param MaxDatumSize: Input value for MaxDatumSize, default is ''\r
337# @param DefaultValue: Input value for DefaultValue, default is ''\r
338# @param ItemType: Input value for ItemType, default is ''\r
339# @param ValidUsage: Input value for ValidUsage, default is []\r
340# @param SkuInfoList: Input value for SkuInfoList, default is {}\r
341# @param SupModuleList: Input value for SupModuleList, default is []\r
342#\r
343# @var CName: To store value for CName\r
344# @var Token: To store value for Token\r
345# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName\r
346# @var DatumType: To store value for DatumType, selection scope is in below list\r
347# UINT8 | UINT16 | UINT32 | UINT64 | VOID* | BOOLEAN \r
348# @var MaxDatumSize: To store value for MaxDatumSize\r
349# @var DefaultValue: To store value for DefaultValue\r
350# @var ItemType: To store value for ItemType, selection scope is in below list\r
351# FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX\r
352# @var ValidUsage: To store value for ValidUsage, selection scope is in below list\r
353# FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX\r
354# @var SkuInfoList: To store value for SkuInfoList\r
355# It is a set structure as { [SkuIdName] : SkuInfoClass } \r
356# @var SupModuleList: To store value for SupModuleList, selection scope is in below list\r
b303ea72 357# 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\r
30fdf114
LG
358#\r
359class PcdClass(CommonClass):\r
360 def __init__(self, CName = '', Token = '', TokenSpaceGuidCName = '', DatumType = '', MaxDatumSize = '', DefaultValue = '', ItemType = '', ValidUsage = None, SkuInfoList = None, SupModuleList = None):\r
361 self.CName = CName\r
362 self.Token = Token\r
363 self.TokenSpaceGuidCName = TokenSpaceGuidCName\r
364 self.DatumType = DatumType\r
365 self.MaxDatumSize = MaxDatumSize\r
366 self.DefaultValue = DefaultValue\r
367 self.ItemType = ItemType\r
368 self.ValidUsage = ValidUsage\r
369 self.PcdItemType = ''\r
370 self.TokenSpaceGuidValue = ''\r
371 self.PcdUsage = ''\r
372 self.PcdCName = ''\r
373 self.Value = ''\r
374 self.Offset = ''\r
375 if self.ValidUsage == None:\r
376 self.ValidUsage = []\r
377 self.SkuInfoList = SkuInfoList\r
378 if self.SkuInfoList == None:\r
379 self.SkuInfoList = {}\r
380 self.SupModuleList = SupModuleList\r
381 if self.SupModuleList == None:\r
382 self.SupModuleList = []\r
383 CommonClass.__init__(self)\r
384 self.PcdErrors = []\r
385\r
386## BuildOptionClass\r
387#\r
388# This class defined BuildOption item used in Module/Platform/Package files\r
389# \r
390# @param IncludeStatementClass: Inherited from IncludeStatementClass class\r
391# @param ToolChainFamily: Input value for ToolChainFamily, default is ''\r
392# @param ToolChain: Input value for ToolChain, default is ''\r
393# @param Option: Input value for Option, default is ''\r
394#\r
395# @var Statement: To store value for Statement\r
396# It is a string in a special format as "Family:Target_TagName_Tarch_ToolCode_FLAGS = String"\r
397# @var ToolChainFamily: To store value for ToolChainFamily\r
398# @var ToolChain: To store value for ToolChain\r
399# @var Option: To store value for Option\r
400# @var BuildTarget: To store value for BuildTarget\r
401# @var TagName: To store value for TagName\r
402# @var ToolCode: To store value for ToolCode\r
403# @var SupArchList: To store value for SupArchList, selection scope is in below list\r
4afd3d04 404# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64\r
30fdf114
LG
405#\r
406class BuildOptionClass(IncludeStatementClass):\r
407 def __init__(self, ToolChainFamily = '', ToolChain = '', Option = ''):\r
408 IncludeStatementClass.__init__(self)\r
409 self.Statement = '' \r
410 self.ToolChainFamily = ToolChainFamily\r
411 self.ToolChain = ToolChain\r
412 self.Option = Option\r
413 self.BuildTarget = ''\r
414 self.TagName = ''\r
415 self.ToolCode = ''\r
416 self.SupArchList = []\r
417\r
418## IncludeClass\r
419#\r
420# This class defined Include item used in Module/Platform/Package files\r
421# \r
422# @param CommonClass: Inherited from CommonClass class\r
423#\r
424# @var FilePath: To store value for FilePath\r
425# @var ModuleType: To store value for ModuleType\r
426# @var Comment: To store value for Comment\r
427#\r
428class IncludeClass(CommonClass):\r
429 def __init__(self):\r
430 self.FilePath = ''\r
431 self.ModuleType = ''\r
432 self.SupModuleList = []\r
433 self.Comment = ''\r
434 CommonClass.__init__(self) \r
435\r
436## FileClass\r
437#\r
438#\r
439class FileClass(CommonClass):\r
440 def __init__(self):\r
441 self.Filename = ''\r
442 self.Executable = ''\r
443 self.Family = ''\r
444 self.FileType = ''\r
445 CommonClass.__init__(self)\r
446 \r
447\r
448## MiscFileClass\r
449#\r
450#\r
451class MiscFileClass(CommonHeaderClass):\r
452 def __init__(self):\r
453 CommonHeaderClass.__init__(self)\r
454 self.Name = ''\r
455 self.Files = []\r
456 \r
457\r
458## UserExtensionsClass\r
459#\r
460# This class defined UserExtensions item used in Module/Platform/Package files\r
461# \r
462# @param object: Inherited from object class\r
463#\r
464# @var UserID: To store value for UserID\r
465# @var Identifier: To store value for Identifier\r
466# @var Content: To store value for Content\r
467# \r
468class UserExtensionsClass(object):\r
469 def __init__(self):\r
470 self.UserID = ''\r
471 self.Identifier = 0\r
472 self.Content = ''\r
473 self.Defines = []\r
474 self.BuildOptions = []\r