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