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