]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Workspace/InfBuildData.py
BaseTools: Update copyright year info of DSC/DEC/INF BuilData.py file
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / InfBuildData.py
1 ## @file
2 # This file is used to create a database used by build tool
3 #
4 # Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
5 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
10 #
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #
14
15 from Common.String import *
16 from Common.DataType import *
17 from Common.Misc import *
18 from types import *
19
20 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
21 ## Module build information from INF file
22 #
23 # This class is used to retrieve information stored in database and convert them
24 # into ModuleBuildClassObject form for easier use for AutoGen.
25 #
26 class InfBuildData(ModuleBuildClassObject):
27 # dict used to convert PCD type in database to string used by build tool
28 _PCD_TYPE_STRING_ = {
29 MODEL_PCD_FIXED_AT_BUILD : "FixedAtBuild",
30 MODEL_PCD_PATCHABLE_IN_MODULE : "PatchableInModule",
31 MODEL_PCD_FEATURE_FLAG : "FeatureFlag",
32 MODEL_PCD_DYNAMIC : "Dynamic",
33 MODEL_PCD_DYNAMIC_DEFAULT : "Dynamic",
34 MODEL_PCD_DYNAMIC_HII : "DynamicHii",
35 MODEL_PCD_DYNAMIC_VPD : "DynamicVpd",
36 MODEL_PCD_DYNAMIC_EX : "DynamicEx",
37 MODEL_PCD_DYNAMIC_EX_DEFAULT : "DynamicEx",
38 MODEL_PCD_DYNAMIC_EX_HII : "DynamicExHii",
39 MODEL_PCD_DYNAMIC_EX_VPD : "DynamicExVpd",
40 }
41
42 # dict used to convert part of [Defines] to members of InfBuildData directly
43 _PROPERTY_ = {
44 #
45 # Required Fields
46 #
47 TAB_INF_DEFINES_BASE_NAME : "_BaseName",
48 TAB_INF_DEFINES_FILE_GUID : "_Guid",
49 TAB_INF_DEFINES_MODULE_TYPE : "_ModuleType",
50 #
51 # Optional Fields
52 #
53 # TAB_INF_DEFINES_INF_VERSION : "_AutoGenVersion",
54 TAB_INF_DEFINES_COMPONENT_TYPE : "_ComponentType",
55 TAB_INF_DEFINES_MAKEFILE_NAME : "_MakefileName",
56 # TAB_INF_DEFINES_CUSTOM_MAKEFILE : "_CustomMakefile",
57 TAB_INF_DEFINES_DPX_SOURCE :"_DxsFile",
58 TAB_INF_DEFINES_VERSION_NUMBER : "_Version",
59 TAB_INF_DEFINES_VERSION_STRING : "_Version",
60 TAB_INF_DEFINES_VERSION : "_Version",
61 TAB_INF_DEFINES_PCD_IS_DRIVER : "_PcdIsDriver",
62 TAB_INF_DEFINES_SHADOW : "_Shadow",
63
64 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH : "_SourceOverridePath",
65 }
66
67 # dict used to convert Component type to Module type
68 _MODULE_TYPE_ = {
69 "LIBRARY" : "BASE",
70 "SECURITY_CORE" : "SEC",
71 "PEI_CORE" : "PEI_CORE",
72 "COMBINED_PEIM_DRIVER" : "PEIM",
73 "PIC_PEIM" : "PEIM",
74 "RELOCATABLE_PEIM" : "PEIM",
75 "PE32_PEIM" : "PEIM",
76 "BS_DRIVER" : "DXE_DRIVER",
77 "RT_DRIVER" : "DXE_RUNTIME_DRIVER",
78 "SAL_RT_DRIVER" : "DXE_SAL_DRIVER",
79 "DXE_SMM_DRIVER" : "DXE_SMM_DRIVER",
80 # "SMM_DRIVER" : "DXE_SMM_DRIVER",
81 # "BS_DRIVER" : "DXE_SMM_DRIVER",
82 # "BS_DRIVER" : "UEFI_DRIVER",
83 "APPLICATION" : "UEFI_APPLICATION",
84 "LOGO" : "BASE",
85 }
86
87 # regular expression for converting XXX_FLAGS in [nmake] section to new type
88 _NMAKE_FLAG_PATTERN_ = re.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE)
89 # dict used to convert old tool name used in [nmake] section to new ones
90 _TOOL_CODE_ = {
91 "C" : "CC",
92 "LIB" : "SLINK",
93 "LINK" : "DLINK",
94 }
95
96
97 ## Constructor of DscBuildData
98 #
99 # Initialize object of DscBuildData
100 #
101 # @param FilePath The path of platform description file
102 # @param RawData The raw data of DSC file
103 # @param BuildDataBase Database used to retrieve module/package information
104 # @param Arch The target architecture
105 # @param Platform The name of platform employing this module
106 # @param Macros Macros used for replacement in DSC file
107 #
108 def __init__(self, FilePath, RawData, BuildDatabase, Arch='COMMON', Target=None, Toolchain=None):
109 self.MetaFile = FilePath
110 self._ModuleDir = FilePath.Dir
111 self._RawData = RawData
112 self._Bdb = BuildDatabase
113 self._Arch = Arch
114 self._Target = Target
115 self._Toolchain = Toolchain
116 self._Platform = 'COMMON'
117 self._SourceOverridePath = None
118 if FilePath.Key in GlobalData.gOverrideDir:
119 self._SourceOverridePath = GlobalData.gOverrideDir[FilePath.Key]
120 self._Clear()
121
122 ## XXX[key] = value
123 def __setitem__(self, key, value):
124 self.__dict__[self._PROPERTY_[key]] = value
125
126 ## value = XXX[key]
127 def __getitem__(self, key):
128 return self.__dict__[self._PROPERTY_[key]]
129
130 ## "in" test support
131 def __contains__(self, key):
132 return key in self._PROPERTY_
133
134 ## Set all internal used members of InfBuildData to None
135 def _Clear(self):
136 self._HeaderComments = None
137 self._TailComments = None
138 self._Header_ = None
139 self._AutoGenVersion = None
140 self._BaseName = None
141 self._DxsFile = None
142 self._ModuleType = None
143 self._ComponentType = None
144 self._BuildType = None
145 self._Guid = None
146 self._Version = None
147 self._PcdIsDriver = None
148 self._BinaryModule = None
149 self._Shadow = None
150 self._MakefileName = None
151 self._CustomMakefile = None
152 self._Specification = None
153 self._LibraryClass = None
154 self._ModuleEntryPointList = None
155 self._ModuleUnloadImageList = None
156 self._ConstructorList = None
157 self._DestructorList = None
158 self._Defs = None
159 self._Binaries = None
160 self._Sources = None
161 self._LibraryClasses = None
162 self._Libraries = None
163 self._Protocols = None
164 self._ProtocolComments = None
165 self._Ppis = None
166 self._PpiComments = None
167 self._Guids = None
168 self._GuidsUsedByPcd = sdict()
169 self._GuidComments = None
170 self._Includes = None
171 self._Packages = None
172 self._Pcds = None
173 self._PcdComments = None
174 self._BuildOptions = None
175 self._Depex = None
176 self._DepexExpression = None
177 self.__Macros = None
178
179 ## Get current effective macros
180 def _GetMacros(self):
181 if self.__Macros == None:
182 self.__Macros = {}
183 # EDK_GLOBAL defined macros can be applied to EDK module
184 if self.AutoGenVersion < 0x00010005:
185 self.__Macros.update(GlobalData.gEdkGlobal)
186 self.__Macros.update(GlobalData.gGlobalDefines)
187 return self.__Macros
188
189 ## Get architecture
190 def _GetArch(self):
191 return self._Arch
192
193 ## Set architecture
194 #
195 # Changing the default ARCH to another may affect all other information
196 # because all information in a platform may be ARCH-related. That's
197 # why we need to clear all internal used members, in order to cause all
198 # information to be re-retrieved.
199 #
200 # @param Value The value of ARCH
201 #
202 def _SetArch(self, Value):
203 if self._Arch == Value:
204 return
205 self._Arch = Value
206 self._Clear()
207
208 ## Return the name of platform employing this module
209 def _GetPlatform(self):
210 return self._Platform
211
212 ## Change the name of platform employing this module
213 #
214 # Changing the default name of platform to another may affect some information
215 # because they may be PLATFORM-related. That's why we need to clear all internal
216 # used members, in order to cause all information to be re-retrieved.
217 #
218 def _SetPlatform(self, Value):
219 if self._Platform == Value:
220 return
221 self._Platform = Value
222 self._Clear()
223 def _GetHeaderComments(self):
224 if not self._HeaderComments:
225 self._HeaderComments = []
226 RecordList = self._RawData[MODEL_META_DATA_HEADER_COMMENT]
227 for Record in RecordList:
228 self._HeaderComments.append(Record[0])
229 return self._HeaderComments
230 def _GetTailComments(self):
231 if not self._TailComments:
232 self._TailComments = []
233 RecordList = self._RawData[MODEL_META_DATA_TAIL_COMMENT]
234 for Record in RecordList:
235 self._TailComments.append(Record[0])
236 return self._TailComments
237 ## Retrieve all information in [Defines] section
238 #
239 # (Retriving all [Defines] information in one-shot is just to save time.)
240 #
241 def _GetHeaderInfo(self):
242 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
243 for Record in RecordList:
244 Name, Value = Record[1], ReplaceMacro(Record[2], self._Macros, False)
245 # items defined _PROPERTY_ don't need additional processing
246 if Name in self:
247 self[Name] = Value
248 if self._Defs == None:
249 self._Defs = sdict()
250 self._Defs[Name] = Value
251 self._Macros[Name] = Value
252 # some special items in [Defines] section need special treatment
253 elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
254 if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
255 Name = 'UEFI_SPECIFICATION_VERSION'
256 if self._Specification == None:
257 self._Specification = sdict()
258 self._Specification[Name] = GetHexVerValue(Value)
259 if self._Specification[Name] == None:
260 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
261 "'%s' format is not supported for %s" % (Value, Name),
262 File=self.MetaFile, Line=Record[-1])
263 elif Name == 'LIBRARY_CLASS':
264 if self._LibraryClass == None:
265 self._LibraryClass = []
266 ValueList = GetSplitValueList(Value)
267 LibraryClass = ValueList[0]
268 if len(ValueList) > 1:
269 SupModuleList = GetSplitValueList(ValueList[1], ' ')
270 else:
271 SupModuleList = SUP_MODULE_LIST
272 self._LibraryClass.append(LibraryClassObject(LibraryClass, SupModuleList))
273 elif Name == 'ENTRY_POINT':
274 if self._ModuleEntryPointList == None:
275 self._ModuleEntryPointList = []
276 self._ModuleEntryPointList.append(Value)
277 elif Name == 'UNLOAD_IMAGE':
278 if self._ModuleUnloadImageList == None:
279 self._ModuleUnloadImageList = []
280 if not Value:
281 continue
282 self._ModuleUnloadImageList.append(Value)
283 elif Name == 'CONSTRUCTOR':
284 if self._ConstructorList == None:
285 self._ConstructorList = []
286 if not Value:
287 continue
288 self._ConstructorList.append(Value)
289 elif Name == 'DESTRUCTOR':
290 if self._DestructorList == None:
291 self._DestructorList = []
292 if not Value:
293 continue
294 self._DestructorList.append(Value)
295 elif Name == TAB_INF_DEFINES_CUSTOM_MAKEFILE:
296 TokenList = GetSplitValueList(Value)
297 if self._CustomMakefile == None:
298 self._CustomMakefile = {}
299 if len(TokenList) < 2:
300 self._CustomMakefile['MSFT'] = TokenList[0]
301 self._CustomMakefile['GCC'] = TokenList[0]
302 else:
303 if TokenList[0] not in ['MSFT', 'GCC']:
304 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
305 "No supported family [%s]" % TokenList[0],
306 File=self.MetaFile, Line=Record[-1])
307 self._CustomMakefile[TokenList[0]] = TokenList[1]
308 else:
309 if self._Defs == None:
310 self._Defs = sdict()
311 self._Defs[Name] = Value
312 self._Macros[Name] = Value
313
314 #
315 # Retrieve information in sections specific to Edk.x modules
316 #
317 if self.AutoGenVersion >= 0x00010005:
318 if not self._ModuleType:
319 EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE,
320 "MODULE_TYPE is not given", File=self.MetaFile)
321 if self._ModuleType not in SUP_MODULE_LIST:
322 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
323 for Record in RecordList:
324 Name = Record[1]
325 if Name == "MODULE_TYPE":
326 LineNo = Record[6]
327 break
328 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
329 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self._ModuleType, ' '.join(l for l in SUP_MODULE_LIST)),
330 File=self.MetaFile, Line=LineNo)
331 if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
332 if self._ModuleType == SUP_MODULE_SMM_CORE:
333 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile)
334 if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
335 if self._ModuleType == SUP_MODULE_MM_CORE_STANDALONE:
336 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
337 if self._ModuleType == SUP_MODULE_MM_STANDALONE:
338 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
339 if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \
340 and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:
341 self._BuildType = 'UEFI_OPTIONROM'
342 if 'PCI_COMPRESS' in self._Defs:
343 if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
344 EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile)
345
346 elif self._Defs and 'UEFI_HII_RESOURCE_SECTION' in self._Defs \
347 and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
348 self._BuildType = 'UEFI_HII'
349 else:
350 self._BuildType = self._ModuleType.upper()
351
352 if self._DxsFile:
353 File = PathClass(NormPath(self._DxsFile), self._ModuleDir, Arch=self._Arch)
354 # check the file validation
355 ErrorCode, ErrorInfo = File.Validate(".dxs", CaseSensitive=False)
356 if ErrorCode != 0:
357 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo,
358 File=self.MetaFile, Line=LineNo)
359 if self.Sources == None:
360 self._Sources = []
361 self._Sources.append(File)
362 else:
363 if not self._ComponentType:
364 EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE,
365 "COMPONENT_TYPE is not given", File=self.MetaFile)
366 self._BuildType = self._ComponentType.upper()
367 if self._ComponentType in self._MODULE_TYPE_:
368 self._ModuleType = self._MODULE_TYPE_[self._ComponentType]
369 if self._ComponentType == 'LIBRARY':
370 self._LibraryClass = [LibraryClassObject(self._BaseName, SUP_MODULE_LIST)]
371 # make use some [nmake] section macros
372 Macros = self._Macros
373 Macros["EDK_SOURCE"] = GlobalData.gEcpSource
374 Macros['PROCESSOR'] = self._Arch
375 RecordList = self._RawData[MODEL_META_DATA_NMAKE, self._Arch, self._Platform]
376 for Name, Value, Dummy, Arch, Platform, ID, LineNo in RecordList:
377 Value = ReplaceMacro(Value, Macros, True)
378 if Name == "IMAGE_ENTRY_POINT":
379 if self._ModuleEntryPointList == None:
380 self._ModuleEntryPointList = []
381 self._ModuleEntryPointList.append(Value)
382 elif Name == "DPX_SOURCE":
383 File = PathClass(NormPath(Value), self._ModuleDir, Arch=self._Arch)
384 # check the file validation
385 ErrorCode, ErrorInfo = File.Validate(".dxs", CaseSensitive=False)
386 if ErrorCode != 0:
387 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo,
388 File=self.MetaFile, Line=LineNo)
389 if self.Sources == None:
390 self._Sources = []
391 self._Sources.append(File)
392 else:
393 ToolList = self._NMAKE_FLAG_PATTERN_.findall(Name)
394 if len(ToolList) == 0 or len(ToolList) != 1:
395 pass
396 # EdkLogger.warn("build", "Don't know how to do with macro [%s]" % Name,
397 # File=self.MetaFile, Line=LineNo)
398 else:
399 if self._BuildOptions == None:
400 self._BuildOptions = sdict()
401
402 if ToolList[0] in self._TOOL_CODE_:
403 Tool = self._TOOL_CODE_[ToolList[0]]
404 else:
405 Tool = ToolList[0]
406 ToolChain = "*_*_*_%s_FLAGS" % Tool
407 ToolChainFamily = 'MSFT' # Edk.x only support MSFT tool chain
408 # ignore not replaced macros in value
409 ValueList = GetSplitList(' ' + Value, '/D')
410 Dummy = ValueList[0]
411 for Index in range(1, len(ValueList)):
412 if ValueList[Index][-1] == '=' or ValueList[Index] == '':
413 continue
414 Dummy = Dummy + ' /D ' + ValueList[Index]
415 Value = Dummy.strip()
416 if (ToolChainFamily, ToolChain) not in self._BuildOptions:
417 self._BuildOptions[ToolChainFamily, ToolChain] = Value
418 else:
419 OptionString = self._BuildOptions[ToolChainFamily, ToolChain]
420 self._BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Value
421 # set _Header to non-None in order to avoid database re-querying
422 self._Header_ = 'DUMMY'
423
424 ## Retrieve file version
425 def _GetInfVersion(self):
426 if self._AutoGenVersion == None:
427 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
428 for Record in RecordList:
429 if Record[1] == TAB_INF_DEFINES_INF_VERSION:
430 if '.' in Record[2]:
431 ValueList = Record[2].split('.')
432 Major = '%04o' % int(ValueList[0], 0)
433 Minor = '%04o' % int(ValueList[1], 0)
434 self._AutoGenVersion = int('0x' + Major + Minor, 0)
435 else:
436 self._AutoGenVersion = int(Record[2], 0)
437 break
438 if self._AutoGenVersion == None:
439 self._AutoGenVersion = 0x00010000
440 return self._AutoGenVersion
441
442 ## Retrieve BASE_NAME
443 def _GetBaseName(self):
444 if self._BaseName == None:
445 if self._Header_ == None:
446 self._GetHeaderInfo()
447 if self._BaseName == None:
448 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BASE_NAME name", File=self.MetaFile)
449 return self._BaseName
450
451 ## Retrieve DxsFile
452 def _GetDxsFile(self):
453 if self._DxsFile == None:
454 if self._Header_ == None:
455 self._GetHeaderInfo()
456 if self._DxsFile == None:
457 self._DxsFile = ''
458 return self._DxsFile
459
460 ## Retrieve MODULE_TYPE
461 def _GetModuleType(self):
462 if self._ModuleType == None:
463 if self._Header_ == None:
464 self._GetHeaderInfo()
465 if self._ModuleType == None:
466 self._ModuleType = 'BASE'
467 if self._ModuleType not in SUP_MODULE_LIST:
468 self._ModuleType = "USER_DEFINED"
469 return self._ModuleType
470
471 ## Retrieve COMPONENT_TYPE
472 def _GetComponentType(self):
473 if self._ComponentType == None:
474 if self._Header_ == None:
475 self._GetHeaderInfo()
476 if self._ComponentType == None:
477 self._ComponentType = 'USER_DEFINED'
478 return self._ComponentType
479
480 ## Retrieve "BUILD_TYPE"
481 def _GetBuildType(self):
482 if self._BuildType == None:
483 if self._Header_ == None:
484 self._GetHeaderInfo()
485 if not self._BuildType:
486 self._BuildType = "BASE"
487 return self._BuildType
488
489 ## Retrieve file guid
490 def _GetFileGuid(self):
491 if self._Guid == None:
492 if self._Header_ == None:
493 self._GetHeaderInfo()
494 if self._Guid == None:
495 self._Guid = '00000000-0000-0000-0000-000000000000'
496 return self._Guid
497
498 ## Retrieve module version
499 def _GetVersion(self):
500 if self._Version == None:
501 if self._Header_ == None:
502 self._GetHeaderInfo()
503 if self._Version == None:
504 self._Version = '0.0'
505 return self._Version
506
507 ## Retrieve PCD_IS_DRIVER
508 def _GetPcdIsDriver(self):
509 if self._PcdIsDriver == None:
510 if self._Header_ == None:
511 self._GetHeaderInfo()
512 if self._PcdIsDriver == None:
513 self._PcdIsDriver = ''
514 return self._PcdIsDriver
515
516 ## Retrieve SHADOW
517 def _GetShadow(self):
518 if self._Shadow == None:
519 if self._Header_ == None:
520 self._GetHeaderInfo()
521 if self._Shadow != None and self._Shadow.upper() == 'TRUE':
522 self._Shadow = True
523 else:
524 self._Shadow = False
525 return self._Shadow
526
527 ## Retrieve CUSTOM_MAKEFILE
528 def _GetMakefile(self):
529 if self._CustomMakefile == None:
530 if self._Header_ == None:
531 self._GetHeaderInfo()
532 if self._CustomMakefile == None:
533 self._CustomMakefile = {}
534 return self._CustomMakefile
535
536 ## Retrieve EFI_SPECIFICATION_VERSION
537 def _GetSpec(self):
538 if self._Specification == None:
539 if self._Header_ == None:
540 self._GetHeaderInfo()
541 if self._Specification == None:
542 self._Specification = {}
543 return self._Specification
544
545 ## Retrieve LIBRARY_CLASS
546 def _GetLibraryClass(self):
547 if self._LibraryClass == None:
548 if self._Header_ == None:
549 self._GetHeaderInfo()
550 if self._LibraryClass == None:
551 self._LibraryClass = []
552 return self._LibraryClass
553
554 ## Retrieve ENTRY_POINT
555 def _GetEntryPoint(self):
556 if self._ModuleEntryPointList == None:
557 if self._Header_ == None:
558 self._GetHeaderInfo()
559 if self._ModuleEntryPointList == None:
560 self._ModuleEntryPointList = []
561 return self._ModuleEntryPointList
562
563 ## Retrieve UNLOAD_IMAGE
564 def _GetUnloadImage(self):
565 if self._ModuleUnloadImageList == None:
566 if self._Header_ == None:
567 self._GetHeaderInfo()
568 if self._ModuleUnloadImageList == None:
569 self._ModuleUnloadImageList = []
570 return self._ModuleUnloadImageList
571
572 ## Retrieve CONSTRUCTOR
573 def _GetConstructor(self):
574 if self._ConstructorList == None:
575 if self._Header_ == None:
576 self._GetHeaderInfo()
577 if self._ConstructorList == None:
578 self._ConstructorList = []
579 return self._ConstructorList
580
581 ## Retrieve DESTRUCTOR
582 def _GetDestructor(self):
583 if self._DestructorList == None:
584 if self._Header_ == None:
585 self._GetHeaderInfo()
586 if self._DestructorList == None:
587 self._DestructorList = []
588 return self._DestructorList
589
590 ## Retrieve definies other than above ones
591 def _GetDefines(self):
592 if self._Defs == None:
593 if self._Header_ == None:
594 self._GetHeaderInfo()
595 if self._Defs == None:
596 self._Defs = sdict()
597 return self._Defs
598
599 ## Retrieve binary files
600 def _GetBinaries(self):
601 if self._Binaries == None:
602 self._Binaries = []
603 RecordList = self._RawData[MODEL_EFI_BINARY_FILE, self._Arch, self._Platform]
604 Macros = self._Macros
605 Macros["EDK_SOURCE"] = GlobalData.gEcpSource
606 Macros['PROCESSOR'] = self._Arch
607 for Record in RecordList:
608 FileType = Record[0]
609 LineNo = Record[-1]
610 Target = 'COMMON'
611 FeatureFlag = []
612 if Record[2]:
613 TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
614 if TokenList:
615 Target = TokenList[0]
616 if len(TokenList) > 1:
617 FeatureFlag = Record[1:]
618
619 File = PathClass(NormPath(Record[1], Macros), self._ModuleDir, '', FileType, True, self._Arch, '', Target)
620 # check the file validation
621 ErrorCode, ErrorInfo = File.Validate()
622 if ErrorCode != 0:
623 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
624 self._Binaries.append(File)
625 return self._Binaries
626
627 ## Retrieve binary files with error check.
628 def _GetBinaryFiles(self):
629 Binaries = self._GetBinaries()
630 if GlobalData.gIgnoreSource and Binaries == []:
631 ErrorInfo = "The INF file does not contain any Binaries to use in creating the image\n"
632 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, ExtraData=ErrorInfo, File=self.MetaFile)
633
634 return Binaries
635 ## Check whether it exists the binaries with current ARCH in AsBuild INF
636 def _IsSupportedArch(self):
637 if self._GetBinaries() and not self._GetSourceFiles():
638 return True
639 else:
640 return False
641 ## Retrieve source files
642 def _GetSourceFiles(self):
643 # Ignore all source files in a binary build mode
644 if GlobalData.gIgnoreSource:
645 self._Sources = []
646 return self._Sources
647
648 if self._Sources == None:
649 self._Sources = []
650 RecordList = self._RawData[MODEL_EFI_SOURCE_FILE, self._Arch, self._Platform]
651 Macros = self._Macros
652 for Record in RecordList:
653 LineNo = Record[-1]
654 ToolChainFamily = Record[1]
655 TagName = Record[2]
656 ToolCode = Record[3]
657 FeatureFlag = Record[4]
658 if self.AutoGenVersion < 0x00010005:
659 Macros["EDK_SOURCE"] = GlobalData.gEcpSource
660 Macros['PROCESSOR'] = self._Arch
661 SourceFile = NormPath(Record[0], Macros)
662 if SourceFile[0] == os.path.sep:
663 SourceFile = mws.join(GlobalData.gWorkspace, SourceFile[1:])
664 # old module source files (Edk)
665 File = PathClass(SourceFile, self._ModuleDir, self._SourceOverridePath,
666 '', False, self._Arch, ToolChainFamily, '', TagName, ToolCode)
667 # check the file validation
668 ErrorCode, ErrorInfo = File.Validate(CaseSensitive=False)
669 if ErrorCode != 0:
670 if File.Ext.lower() == '.h':
671 EdkLogger.warn('build', 'Include file not found', ExtraData=ErrorInfo,
672 File=self.MetaFile, Line=LineNo)
673 continue
674 else:
675 EdkLogger.error('build', ErrorCode, ExtraData=File, File=self.MetaFile, Line=LineNo)
676 else:
677 File = PathClass(NormPath(Record[0], Macros), self._ModuleDir, '',
678 '', False, self._Arch, ToolChainFamily, '', TagName, ToolCode)
679 # check the file validation
680 ErrorCode, ErrorInfo = File.Validate()
681 if ErrorCode != 0:
682 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
683
684 self._Sources.append(File)
685 return self._Sources
686
687 ## Retrieve library classes employed by this module
688 def _GetLibraryClassUses(self):
689 if self._LibraryClasses == None:
690 self._LibraryClasses = sdict()
691 RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform]
692 for Record in RecordList:
693 Lib = Record[0]
694 Instance = Record[1]
695 if Instance:
696 Instance = NormPath(Instance, self._Macros)
697 self._LibraryClasses[Lib] = Instance
698 return self._LibraryClasses
699
700 ## Retrieve library names (for Edk.x style of modules)
701 def _GetLibraryNames(self):
702 if self._Libraries == None:
703 self._Libraries = []
704 RecordList = self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self._Arch, self._Platform]
705 for Record in RecordList:
706 LibraryName = ReplaceMacro(Record[0], self._Macros, False)
707 # in case of name with '.lib' extension, which is unusual in Edk.x inf
708 LibraryName = os.path.splitext(LibraryName)[0]
709 if LibraryName not in self._Libraries:
710 self._Libraries.append(LibraryName)
711 return self._Libraries
712
713 def _GetProtocolComments(self):
714 self._GetProtocols()
715 return self._ProtocolComments
716 ## Retrieve protocols consumed/produced by this module
717 def _GetProtocols(self):
718 if self._Protocols == None:
719 self._Protocols = sdict()
720 self._ProtocolComments = sdict()
721 RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
722 for Record in RecordList:
723 CName = Record[0]
724 Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)
725 if Value == None:
726 PackageList = "\n\t".join([str(P) for P in self.Packages])
727 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
728 "Value of Protocol [%s] is not found under [Protocols] section in" % CName,
729 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
730 self._Protocols[CName] = Value
731 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
732 Comments = []
733 for CmtRec in CommentRecords:
734 Comments.append(CmtRec[0])
735 self._ProtocolComments[CName] = Comments
736 return self._Protocols
737
738 def _GetPpiComments(self):
739 self._GetPpis()
740 return self._PpiComments
741 ## Retrieve PPIs consumed/produced by this module
742 def _GetPpis(self):
743 if self._Ppis == None:
744 self._Ppis = sdict()
745 self._PpiComments = sdict()
746 RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
747 for Record in RecordList:
748 CName = Record[0]
749 Value = PpiValue(CName, self.Packages, self.MetaFile.Path)
750 if Value == None:
751 PackageList = "\n\t".join([str(P) for P in self.Packages])
752 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
753 "Value of PPI [%s] is not found under [Ppis] section in " % CName,
754 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
755 self._Ppis[CName] = Value
756 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
757 Comments = []
758 for CmtRec in CommentRecords:
759 Comments.append(CmtRec[0])
760 self._PpiComments[CName] = Comments
761 return self._Ppis
762
763 def _GetGuidComments(self):
764 self._GetGuids()
765 return self._GuidComments
766 ## Retrieve GUIDs consumed/produced by this module
767 def _GetGuids(self):
768 if self._Guids == None:
769 self._Guids = sdict()
770 self._GuidComments = sdict()
771 RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]
772 for Record in RecordList:
773 CName = Record[0]
774 Value = GuidValue(CName, self.Packages, self.MetaFile.Path)
775 if Value == None:
776 PackageList = "\n\t".join([str(P) for P in self.Packages])
777 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
778 "Value of Guid [%s] is not found under [Guids] section in" % CName,
779 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
780 self._Guids[CName] = Value
781 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
782 Comments = []
783 for CmtRec in CommentRecords:
784 Comments.append(CmtRec[0])
785 self._GuidComments[CName] = Comments
786 return self._Guids
787
788 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
789 def _GetIncludes(self):
790 if self._Includes == None:
791 self._Includes = []
792 if self._SourceOverridePath:
793 self._Includes.append(self._SourceOverridePath)
794
795 Macros = self._Macros
796 if 'PROCESSOR' in GlobalData.gEdkGlobal.keys():
797 Macros['PROCESSOR'] = GlobalData.gEdkGlobal['PROCESSOR']
798 else:
799 Macros['PROCESSOR'] = self._Arch
800 RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]
801 for Record in RecordList:
802 if Record[0].find('EDK_SOURCE') > -1:
803 Macros['EDK_SOURCE'] = GlobalData.gEcpSource
804 File = NormPath(Record[0], self._Macros)
805 if File[0] == '.':
806 File = os.path.join(self._ModuleDir, File)
807 else:
808 File = os.path.join(GlobalData.gWorkspace, File)
809 File = RealPath(os.path.normpath(File))
810 if File:
811 self._Includes.append(File)
812
813 # TRICK: let compiler to choose correct header file
814 Macros['EDK_SOURCE'] = GlobalData.gEdkSource
815 File = NormPath(Record[0], self._Macros)
816 if File[0] == '.':
817 File = os.path.join(self._ModuleDir, File)
818 else:
819 File = os.path.join(GlobalData.gWorkspace, File)
820 File = RealPath(os.path.normpath(File))
821 if File:
822 self._Includes.append(File)
823 else:
824 File = NormPath(Record[0], Macros)
825 if File[0] == '.':
826 File = os.path.join(self._ModuleDir, File)
827 else:
828 File = mws.join(GlobalData.gWorkspace, File)
829 File = RealPath(os.path.normpath(File))
830 if File:
831 self._Includes.append(File)
832 if not File and Record[0].find('EFI_SOURCE') > -1:
833 # tricky to regard WorkSpace as EFI_SOURCE
834 Macros['EFI_SOURCE'] = GlobalData.gWorkspace
835 File = NormPath(Record[0], Macros)
836 if File[0] == '.':
837 File = os.path.join(self._ModuleDir, File)
838 else:
839 File = os.path.join(GlobalData.gWorkspace, File)
840 File = RealPath(os.path.normpath(File))
841 if File:
842 self._Includes.append(File)
843 return self._Includes
844
845 ## Retrieve packages this module depends on
846 def _GetPackages(self):
847 if self._Packages == None:
848 self._Packages = []
849 RecordList = self._RawData[MODEL_META_DATA_PACKAGE, self._Arch, self._Platform]
850 Macros = self._Macros
851 Macros['EDK_SOURCE'] = GlobalData.gEcpSource
852 for Record in RecordList:
853 File = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)
854 LineNo = Record[-1]
855 # check the file validation
856 ErrorCode, ErrorInfo = File.Validate('.dec')
857 if ErrorCode != 0:
858 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
859 # parse this package now. we need it to get protocol/ppi/guid value
860 Package = self._Bdb[File, self._Arch, self._Target, self._Toolchain]
861 self._Packages.append(Package)
862 return self._Packages
863
864 ## Retrieve PCD comments
865 def _GetPcdComments(self):
866 self._GetPcds()
867 return self._PcdComments
868 ## Retrieve PCDs used in this module
869 def _GetPcds(self):
870 if self._Pcds == None:
871 self._Pcds = sdict()
872 self._PcdComments = sdict()
873 self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
874 self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
875 self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
876 self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC))
877 self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
878 return self._Pcds
879
880 ## Retrieve build options specific to this module
881 def _GetBuildOptions(self):
882 if self._BuildOptions == None:
883 self._BuildOptions = sdict()
884 RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform]
885 for Record in RecordList:
886 ToolChainFamily = Record[0]
887 ToolChain = Record[1]
888 Option = Record[2]
889 if (ToolChainFamily, ToolChain) not in self._BuildOptions or Option.startswith('='):
890 self._BuildOptions[ToolChainFamily, ToolChain] = Option
891 else:
892 # concatenate the option string if they're for the same tool
893 OptionString = self._BuildOptions[ToolChainFamily, ToolChain]
894 self._BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option
895 return self._BuildOptions
896
897 ## Retrieve dependency expression
898 def _GetDepex(self):
899 if self._Depex == None:
900 self._Depex = tdict(False, 2)
901 RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
902
903 # If the module has only Binaries and no Sources, then ignore [Depex]
904 if self.Sources == None or self.Sources == []:
905 if self.Binaries != None and self.Binaries != []:
906 return self._Depex
907
908 # PEIM and DXE drivers must have a valid [Depex] section
909 if len(self.LibraryClass) == 0 and len(RecordList) == 0:
910 if self.ModuleType == 'DXE_DRIVER' or self.ModuleType == 'PEIM' or self.ModuleType == 'DXE_SMM_DRIVER' or \
911 self.ModuleType == 'DXE_SAL_DRIVER' or self.ModuleType == 'DXE_RUNTIME_DRIVER':
912 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
913 % self.ModuleType, File=self.MetaFile)
914
915 if len(RecordList) != 0 and self.ModuleType == 'USER_DEFINED':
916 for Record in RecordList:
917 if Record[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']:
918 EdkLogger.error('build', FORMAT_INVALID,
919 "'%s' module must specify the type of [Depex] section" % self.ModuleType,
920 File=self.MetaFile)
921
922 Depex = sdict()
923 for Record in RecordList:
924 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
925 Arch = Record[3]
926 ModuleType = Record[4]
927 TokenList = DepexStr.split()
928 if (Arch, ModuleType) not in Depex:
929 Depex[Arch, ModuleType] = []
930 DepexList = Depex[Arch, ModuleType]
931 for Token in TokenList:
932 if Token in DEPEX_SUPPORTED_OPCODE:
933 DepexList.append(Token)
934 elif Token.endswith(".inf"): # module file name
935 ModuleFile = os.path.normpath(Token)
936 Module = self.BuildDatabase[ModuleFile]
937 if Module == None:
938 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Module is not found in active platform",
939 ExtraData=Token, File=self.MetaFile, Line=Record[-1])
940 DepexList.append(Module.Guid)
941 else:
942 # get the GUID value now
943 Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
944 if Value == None:
945 Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
946 if Value == None:
947 Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
948 if Value == None:
949 PackageList = "\n\t".join([str(P) for P in self.Packages])
950 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
951 "Value of [%s] is not found in" % Token,
952 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
953 DepexList.append(Value)
954 for Arch, ModuleType in Depex:
955 self._Depex[Arch, ModuleType] = Depex[Arch, ModuleType]
956 return self._Depex
957
958 ## Retrieve depedency expression
959 def _GetDepexExpression(self):
960 if self._DepexExpression == None:
961 self._DepexExpression = tdict(False, 2)
962 RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
963 DepexExpression = sdict()
964 for Record in RecordList:
965 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
966 Arch = Record[3]
967 ModuleType = Record[4]
968 TokenList = DepexStr.split()
969 if (Arch, ModuleType) not in DepexExpression:
970 DepexExpression[Arch, ModuleType] = ''
971 for Token in TokenList:
972 DepexExpression[Arch, ModuleType] = DepexExpression[Arch, ModuleType] + Token.strip() + ' '
973 for Arch, ModuleType in DepexExpression:
974 self._DepexExpression[Arch, ModuleType] = DepexExpression[Arch, ModuleType]
975 return self._DepexExpression
976
977 def GetGuidsUsedByPcd(self):
978 return self._GuidsUsedByPcd
979 ## Retrieve PCD for given type
980 def _GetPcd(self, Type):
981 Pcds = sdict()
982 PcdDict = tdict(True, 4)
983 PcdList = []
984 RecordList = self._RawData[Type, self._Arch, self._Platform]
985 for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Id, LineNo in RecordList:
986 PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] = (Setting, LineNo)
987 PcdList.append((PcdCName, TokenSpaceGuid))
988 # get the guid value
989 if TokenSpaceGuid not in self.Guids:
990 Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path)
991 if Value == None:
992 PackageList = "\n\t".join([str(P) for P in self.Packages])
993 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
994 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid,
995 ExtraData=PackageList, File=self.MetaFile, Line=LineNo)
996 self.Guids[TokenSpaceGuid] = Value
997 self._GuidsUsedByPcd[TokenSpaceGuid] = Value
998 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Id]
999 Comments = []
1000 for CmtRec in CommentRecords:
1001 Comments.append(CmtRec[0])
1002 self._PcdComments[TokenSpaceGuid, PcdCName] = Comments
1003
1004 # resolve PCD type, value, datum info, etc. by getting its definition from package
1005 for PcdCName, TokenSpaceGuid in PcdList:
1006 PcdRealName = PcdCName
1007 Setting, LineNo = PcdDict[self._Arch, self.Platform, PcdCName, TokenSpaceGuid]
1008 if Setting == None:
1009 continue
1010 ValueList = AnalyzePcdData(Setting)
1011 DefaultValue = ValueList[0]
1012 Pcd = PcdClassObject(
1013 PcdCName,
1014 TokenSpaceGuid,
1015 '',
1016 '',
1017 DefaultValue,
1018 '',
1019 '',
1020 {},
1021 False,
1022 self.Guids[TokenSpaceGuid]
1023 )
1024 if Type == MODEL_PCD_PATCHABLE_IN_MODULE and ValueList[1]:
1025 # Patch PCD: TokenSpace.PcdCName|Value|Offset
1026 Pcd.Offset = ValueList[1]
1027
1028 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
1029 for Package in self.Packages:
1030 for key in Package.Pcds:
1031 if (Package.Pcds[key].TokenCName, Package.Pcds[key].TokenSpaceGuidCName) == (PcdRealName, TokenSpaceGuid):
1032 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
1033 Pcd_Type = item[0].split('_')[-1]
1034 if Pcd_Type == Package.Pcds[key].Type:
1035 Value = Package.Pcds[key]
1036 Value.TokenCName = Package.Pcds[key].TokenCName + '_' + Pcd_Type
1037 if len(key) == 2:
1038 newkey = (Value.TokenCName, key[1])
1039 elif len(key) == 3:
1040 newkey = (Value.TokenCName, key[1], key[2])
1041 del Package.Pcds[key]
1042 Package.Pcds[newkey] = Value
1043 break
1044 else:
1045 pass
1046 else:
1047 pass
1048
1049 # get necessary info from package declaring this PCD
1050 for Package in self.Packages:
1051 #
1052 # 'dynamic' in INF means its type is determined by platform;
1053 # if platform doesn't give its type, use 'lowest' one in the
1054 # following order, if any
1055 #
1056 # "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
1057 #
1058 PcdType = self._PCD_TYPE_STRING_[Type]
1059 if Type == MODEL_PCD_DYNAMIC:
1060 Pcd.Pending = True
1061 for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
1062 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
1063 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
1064 if str(item[0]).endswith(T) and (item[0], item[1], T) in Package.Pcds:
1065 PcdType = T
1066 PcdCName = item[0]
1067 break
1068 else:
1069 pass
1070 break
1071 else:
1072 if (PcdRealName, TokenSpaceGuid, T) in Package.Pcds:
1073 PcdType = T
1074 break
1075
1076 else:
1077 Pcd.Pending = False
1078 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
1079 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
1080 Pcd_Type = item[0].split('_')[-1]
1081 if Pcd_Type == PcdType:
1082 PcdCName = item[0]
1083 break
1084 else:
1085 pass
1086 else:
1087 pass
1088
1089 if (PcdCName, TokenSpaceGuid, PcdType) in Package.Pcds:
1090 PcdInPackage = Package.Pcds[PcdCName, TokenSpaceGuid, PcdType]
1091 Pcd.Type = PcdType
1092 Pcd.TokenValue = PcdInPackage.TokenValue
1093
1094 #
1095 # Check whether the token value exist or not.
1096 #
1097 if Pcd.TokenValue == None or Pcd.TokenValue == "":
1098 EdkLogger.error(
1099 'build',
1100 FORMAT_INVALID,
1101 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid, PcdRealName, str(Package)),
1102 File=self.MetaFile, Line=LineNo,
1103 ExtraData=None
1104 )
1105 #
1106 # Check hexadecimal token value length and format.
1107 #
1108 ReIsValidPcdTokenValue = re.compile(r"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re.DOTALL)
1109 if Pcd.TokenValue.startswith("0x") or Pcd.TokenValue.startswith("0X"):
1110 if ReIsValidPcdTokenValue.match(Pcd.TokenValue) == None:
1111 EdkLogger.error(
1112 'build',
1113 FORMAT_INVALID,
1114 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
1115 File=self.MetaFile, Line=LineNo,
1116 ExtraData=None
1117 )
1118
1119 #
1120 # Check decimal token value length and format.
1121 #
1122 else:
1123 try:
1124 TokenValueInt = int (Pcd.TokenValue, 10)
1125 if (TokenValueInt < 0 or TokenValueInt > 4294967295):
1126 EdkLogger.error(
1127 'build',
1128 FORMAT_INVALID,
1129 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
1130 File=self.MetaFile, Line=LineNo,
1131 ExtraData=None
1132 )
1133 except:
1134 EdkLogger.error(
1135 'build',
1136 FORMAT_INVALID,
1137 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
1138 File=self.MetaFile, Line=LineNo,
1139 ExtraData=None
1140 )
1141
1142 Pcd.DatumType = PcdInPackage.DatumType
1143 Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize
1144 Pcd.InfDefaultValue = Pcd.DefaultValue
1145 if Pcd.DefaultValue in [None, '']:
1146 Pcd.DefaultValue = PcdInPackage.DefaultValue
1147 break
1148 else:
1149 EdkLogger.error(
1150 'build',
1151 FORMAT_INVALID,
1152 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile),
1153 File=self.MetaFile, Line=LineNo,
1154 ExtraData="\t%s" % '\n\t'.join([str(P) for P in self.Packages])
1155 )
1156 Pcds[PcdCName, TokenSpaceGuid] = Pcd
1157
1158 return Pcds
1159
1160 ## check whether current module is binary module
1161 def _IsBinaryModule(self):
1162 if self.Binaries and not self.Sources:
1163 return True
1164 elif GlobalData.gIgnoreSource:
1165 return True
1166 else:
1167 return False
1168
1169 _Macros = property(_GetMacros)
1170 Arch = property(_GetArch, _SetArch)
1171 Platform = property(_GetPlatform, _SetPlatform)
1172
1173 HeaderComments = property(_GetHeaderComments)
1174 TailComments = property(_GetTailComments)
1175 AutoGenVersion = property(_GetInfVersion)
1176 BaseName = property(_GetBaseName)
1177 ModuleType = property(_GetModuleType)
1178 ComponentType = property(_GetComponentType)
1179 BuildType = property(_GetBuildType)
1180 Guid = property(_GetFileGuid)
1181 Version = property(_GetVersion)
1182 PcdIsDriver = property(_GetPcdIsDriver)
1183 Shadow = property(_GetShadow)
1184 CustomMakefile = property(_GetMakefile)
1185 Specification = property(_GetSpec)
1186 LibraryClass = property(_GetLibraryClass)
1187 ModuleEntryPointList = property(_GetEntryPoint)
1188 ModuleUnloadImageList = property(_GetUnloadImage)
1189 ConstructorList = property(_GetConstructor)
1190 DestructorList = property(_GetDestructor)
1191 Defines = property(_GetDefines)
1192 DxsFile = property(_GetDxsFile)
1193
1194 Binaries = property(_GetBinaryFiles)
1195 Sources = property(_GetSourceFiles)
1196 LibraryClasses = property(_GetLibraryClassUses)
1197 Libraries = property(_GetLibraryNames)
1198 Protocols = property(_GetProtocols)
1199 ProtocolComments = property(_GetProtocolComments)
1200 Ppis = property(_GetPpis)
1201 PpiComments = property(_GetPpiComments)
1202 Guids = property(_GetGuids)
1203 GuidComments = property(_GetGuidComments)
1204 Includes = property(_GetIncludes)
1205 Packages = property(_GetPackages)
1206 Pcds = property(_GetPcds)
1207 PcdComments = property(_GetPcdComments)
1208 BuildOptions = property(_GetBuildOptions)
1209 Depex = property(_GetDepex)
1210 DepexExpression = property(_GetDepexExpression)
1211 IsBinaryModule = property(_IsBinaryModule)
1212 IsSupportedArch = property(_IsSupportedArch)