2 # This file is used to create a database used by build tool
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
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.
15 from Common
.StringUtils
import *
16 from Common
.DataType
import *
17 from Common
.Misc
import *
19 from MetaFileParser
import *
20 from collections
import OrderedDict
22 from Workspace
.BuildClassObject
import ModuleBuildClassObject
, LibraryClassObject
, PcdClassObject
23 ## Module build information from INF file
25 # This class is used to retrieve information stored in database and convert them
26 # into ModuleBuildClassObject form for easier use for AutoGen.
28 class InfBuildData(ModuleBuildClassObject
):
29 # dict used to convert PCD type in database to string used by build tool
31 MODEL_PCD_FIXED_AT_BUILD
: TAB_PCDS_FIXED_AT_BUILD
,
32 MODEL_PCD_PATCHABLE_IN_MODULE
: TAB_PCDS_PATCHABLE_IN_MODULE
,
33 MODEL_PCD_FEATURE_FLAG
: TAB_PCDS_FEATURE_FLAG
,
34 MODEL_PCD_DYNAMIC
: TAB_PCDS_DYNAMIC
,
35 MODEL_PCD_DYNAMIC_DEFAULT
: TAB_PCDS_DYNAMIC
,
36 MODEL_PCD_DYNAMIC_HII
: TAB_PCDS_DYNAMIC_HII
,
37 MODEL_PCD_DYNAMIC_VPD
: TAB_PCDS_DYNAMIC_VPD
,
38 MODEL_PCD_DYNAMIC_EX
: TAB_PCDS_DYNAMIC_EX
,
39 MODEL_PCD_DYNAMIC_EX_DEFAULT
: TAB_PCDS_DYNAMIC_EX
,
40 MODEL_PCD_DYNAMIC_EX_HII
: TAB_PCDS_DYNAMIC_EX_HII
,
41 MODEL_PCD_DYNAMIC_EX_VPD
: TAB_PCDS_DYNAMIC_EX_VPD
,
44 # dict used to convert part of [Defines] to members of InfBuildData directly
49 TAB_INF_DEFINES_BASE_NAME
: "_BaseName",
50 TAB_INF_DEFINES_FILE_GUID
: "_Guid",
51 TAB_INF_DEFINES_MODULE_TYPE
: "_ModuleType",
55 # TAB_INF_DEFINES_INF_VERSION : "_AutoGenVersion",
56 TAB_INF_DEFINES_COMPONENT_TYPE
: "_ComponentType",
57 TAB_INF_DEFINES_MAKEFILE_NAME
: "_MakefileName",
58 # TAB_INF_DEFINES_CUSTOM_MAKEFILE : "_CustomMakefile",
59 TAB_INF_DEFINES_DPX_SOURCE
:"_DxsFile",
60 TAB_INF_DEFINES_VERSION_NUMBER
: "_Version",
61 TAB_INF_DEFINES_VERSION_STRING
: "_Version",
62 TAB_INF_DEFINES_VERSION
: "_Version",
63 TAB_INF_DEFINES_PCD_IS_DRIVER
: "_PcdIsDriver",
64 TAB_INF_DEFINES_SHADOW
: "_Shadow",
66 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH
: "_SourceOverridePath",
69 # regular expression for converting XXX_FLAGS in [nmake] section to new type
70 _NMAKE_FLAG_PATTERN_
= re
.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re
.UNICODE
)
71 # dict used to convert old tool name used in [nmake] section to new ones
74 BINARY_FILE_TYPE_LIB
: "SLINK",
79 ## Constructor of DscBuildData
81 # Initialize object of DscBuildData
83 # @param FilePath The path of platform description file
84 # @param RawData The raw data of DSC file
85 # @param BuildDataBase Database used to retrieve module/package information
86 # @param Arch The target architecture
87 # @param Platform The name of platform employing this module
88 # @param Macros Macros used for replacement in DSC file
90 def __init__(self
, FilePath
, RawData
, BuildDatabase
, Arch
=TAB_ARCH_COMMON
, Target
=None, Toolchain
=None):
91 self
.MetaFile
= FilePath
92 self
._ModuleDir
= FilePath
.Dir
93 self
._RawData
= RawData
94 self
._Bdb
= BuildDatabase
97 self
._Toolchain
= Toolchain
98 self
._Platform
= TAB_COMMON
99 self
._SourceOverridePath
= None
100 if FilePath
.Key
in GlobalData
.gOverrideDir
:
101 self
._SourceOverridePath
= GlobalData
.gOverrideDir
[FilePath
.Key
]
105 def __setitem__(self
, key
, value
):
106 self
.__dict
__[self
._PROPERTY
_[key
]] = value
109 def __getitem__(self
, key
):
110 return self
.__dict
__[self
._PROPERTY
_[key
]]
113 def __contains__(self
, key
):
114 return key
in self
._PROPERTY
_
116 ## Set all internal used members of InfBuildData to None
118 self
._HeaderComments
= None
119 self
._TailComments
= None
121 self
._AutoGenVersion
= None
122 self
._BaseName
= None
124 self
._ModuleType
= None
125 self
._ComponentType
= None
126 self
._BuildType
= None
129 self
._PcdIsDriver
= None
130 self
._BinaryModule
= None
132 self
._MakefileName
= None
133 self
._CustomMakefile
= None
134 self
._Specification
= None
135 self
._LibraryClass
= None
136 self
._ModuleEntryPointList
= None
137 self
._ModuleUnloadImageList
= None
138 self
._ConstructorList
= None
139 self
._DestructorList
= None
140 self
._Defs
= OrderedDict()
141 self
._Binaries
= None
143 self
._LibraryClasses
= None
144 self
._Libraries
= None
145 self
._Protocols
= None
146 self
._ProtocolComments
= None
148 self
._PpiComments
= None
150 self
._GuidsUsedByPcd
= OrderedDict()
151 self
._GuidComments
= None
152 self
._Includes
= None
153 self
._Packages
= None
155 self
._PcdComments
= None
156 self
._BuildOptions
= None
158 self
._DepexExpression
= None
161 ## Get current effective macros
162 def _GetMacros(self
):
163 if self
.__Macros
is None:
165 # EDK_GLOBAL defined macros can be applied to EDK module
166 if self
.AutoGenVersion
< 0x00010005:
167 self
.__Macros
.update(GlobalData
.gEdkGlobal
)
168 self
.__Macros
.update(GlobalData
.gGlobalDefines
)
177 # Changing the default ARCH to another may affect all other information
178 # because all information in a platform may be ARCH-related. That's
179 # why we need to clear all internal used members, in order to cause all
180 # information to be re-retrieved.
182 # @param Value The value of ARCH
184 def _SetArch(self
, Value
):
185 if self
._Arch
== Value
:
190 ## Return the name of platform employing this module
191 def _GetPlatform(self
):
192 return self
._Platform
194 ## Change the name of platform employing this module
196 # Changing the default name of platform to another may affect some information
197 # because they may be PLATFORM-related. That's why we need to clear all internal
198 # used members, in order to cause all information to be re-retrieved.
200 def _SetPlatform(self
, Value
):
201 if self
._Platform
== Value
:
203 self
._Platform
= Value
205 def _GetHeaderComments(self
):
206 if not self
._HeaderComments
:
207 self
._HeaderComments
= []
208 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER_COMMENT
]
209 for Record
in RecordList
:
210 self
._HeaderComments
.append(Record
[0])
211 return self
._HeaderComments
212 def _GetTailComments(self
):
213 if not self
._TailComments
:
214 self
._TailComments
= []
215 RecordList
= self
._RawData
[MODEL_META_DATA_TAIL_COMMENT
]
216 for Record
in RecordList
:
217 self
._TailComments
.append(Record
[0])
218 return self
._TailComments
219 ## Retrieve all information in [Defines] section
221 # (Retriving all [Defines] information in one-shot is just to save time.)
223 def _GetHeaderInfo(self
):
224 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
225 for Record
in RecordList
:
226 Name
, Value
= Record
[1], ReplaceMacro(Record
[2], self
._Macros
, False)
227 # items defined _PROPERTY_ don't need additional processing
230 self
._Defs
[Name
] = Value
231 self
._Macros
[Name
] = Value
232 # some special items in [Defines] section need special treatment
233 elif Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
234 if Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
235 Name
= 'UEFI_SPECIFICATION_VERSION'
236 if self
._Specification
is None:
237 self
._Specification
= OrderedDict()
238 self
._Specification
[Name
] = GetHexVerValue(Value
)
239 if self
._Specification
[Name
] is None:
240 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
241 "'%s' format is not supported for %s" % (Value
, Name
),
242 File
=self
.MetaFile
, Line
=Record
[-1])
243 elif Name
== 'LIBRARY_CLASS':
244 if self
._LibraryClass
is None:
245 self
._LibraryClass
= []
246 ValueList
= GetSplitValueList(Value
)
247 LibraryClass
= ValueList
[0]
248 if len(ValueList
) > 1:
249 SupModuleList
= GetSplitValueList(ValueList
[1], ' ')
251 SupModuleList
= SUP_MODULE_LIST
252 self
._LibraryClass
.append(LibraryClassObject(LibraryClass
, SupModuleList
))
253 elif Name
== 'ENTRY_POINT':
254 if self
._ModuleEntryPointList
is None:
255 self
._ModuleEntryPointList
= []
256 self
._ModuleEntryPointList
.append(Value
)
257 elif Name
== 'UNLOAD_IMAGE':
258 if self
._ModuleUnloadImageList
is None:
259 self
._ModuleUnloadImageList
= []
262 self
._ModuleUnloadImageList
.append(Value
)
263 elif Name
== 'CONSTRUCTOR':
264 if self
._ConstructorList
is None:
265 self
._ConstructorList
= []
268 self
._ConstructorList
.append(Value
)
269 elif Name
== 'DESTRUCTOR':
270 if self
._DestructorList
is None:
271 self
._DestructorList
= []
274 self
._DestructorList
.append(Value
)
275 elif Name
== TAB_INF_DEFINES_CUSTOM_MAKEFILE
:
276 TokenList
= GetSplitValueList(Value
)
277 if self
._CustomMakefile
is None:
278 self
._CustomMakefile
= {}
279 if len(TokenList
) < 2:
280 self
._CustomMakefile
['MSFT'] = TokenList
[0]
281 self
._CustomMakefile
['GCC'] = TokenList
[0]
283 if TokenList
[0] not in ['MSFT', 'GCC']:
284 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
285 "No supported family [%s]" % TokenList
[0],
286 File
=self
.MetaFile
, Line
=Record
[-1])
287 self
._CustomMakefile
[TokenList
[0]] = TokenList
[1]
289 self
._Defs
[Name
] = Value
290 self
._Macros
[Name
] = Value
293 # Retrieve information in sections specific to Edk.x modules
295 if self
.AutoGenVersion
>= 0x00010005:
296 if not self
._ModuleType
:
297 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
298 "MODULE_TYPE is not given", File
=self
.MetaFile
)
299 if self
._ModuleType
not in SUP_MODULE_LIST
:
300 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
301 for Record
in RecordList
:
303 if Name
== "MODULE_TYPE":
306 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
307 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self
._ModuleType
, ' '.join(l
for l
in SUP_MODULE_LIST
)),
308 File
=self
.MetaFile
, Line
=LineNo
)
309 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
310 if self
._ModuleType
== SUP_MODULE_SMM_CORE
:
311 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
)
312 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
313 if self
._ModuleType
== SUP_MODULE_MM_CORE_STANDALONE
:
314 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
)
315 if self
._ModuleType
== SUP_MODULE_MM_STANDALONE
:
316 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
)
317 if 'PCI_DEVICE_ID' in self
._Defs
and 'PCI_VENDOR_ID' in self
._Defs \
318 and 'PCI_CLASS_CODE' in self
._Defs
and 'PCI_REVISION' in self
._Defs
:
319 self
._BuildType
= 'UEFI_OPTIONROM'
320 if 'PCI_COMPRESS' in self
._Defs
:
321 if self
._Defs
['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
322 EdkLogger
.error("build", FORMAT_INVALID
, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self
.MetaFile
)
324 elif 'UEFI_HII_RESOURCE_SECTION' in self
._Defs \
325 and self
._Defs
['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
326 self
._BuildType
= 'UEFI_HII'
328 self
._BuildType
= self
._ModuleType
.upper()
331 File
= PathClass(NormPath(self
._DxsFile
), self
._ModuleDir
, Arch
=self
._Arch
)
332 # check the file validation
333 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
335 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
336 File
=self
.MetaFile
, Line
=LineNo
)
337 if self
.Sources
is None:
339 self
._Sources
.append(File
)
341 if not self
._ComponentType
:
342 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
343 "COMPONENT_TYPE is not given", File
=self
.MetaFile
)
344 self
._BuildType
= self
._ComponentType
.upper()
345 if self
._ComponentType
in COMPONENT_TO_MODULE_MAP_DICT
:
346 self
._ModuleType
= COMPONENT_TO_MODULE_MAP_DICT
[self
._ComponentType
]
347 if self
._ComponentType
== EDK_COMPONENT_TYPE_LIBRARY
:
348 self
._LibraryClass
= [LibraryClassObject(self
._BaseName
, SUP_MODULE_LIST
)]
349 # make use some [nmake] section macros
350 Macros
= self
._Macros
351 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
352 Macros
['PROCESSOR'] = self
._Arch
353 RecordList
= self
._RawData
[MODEL_META_DATA_NMAKE
, self
._Arch
, self
._Platform
]
354 for Name
, Value
, Dummy
, Arch
, Platform
, ID
, LineNo
in RecordList
:
355 Value
= ReplaceMacro(Value
, Macros
, True)
356 if Name
== "IMAGE_ENTRY_POINT":
357 if self
._ModuleEntryPointList
is None:
358 self
._ModuleEntryPointList
= []
359 self
._ModuleEntryPointList
.append(Value
)
360 elif Name
== "DPX_SOURCE":
361 File
= PathClass(NormPath(Value
), self
._ModuleDir
, Arch
=self
._Arch
)
362 # check the file validation
363 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
365 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
366 File
=self
.MetaFile
, Line
=LineNo
)
367 if self
.Sources
is None:
369 self
._Sources
.append(File
)
371 ToolList
= self
._NMAKE
_FLAG
_PATTERN
_.findall(Name
)
372 if len(ToolList
) == 0 or len(ToolList
) != 1:
374 # EdkLogger.warn("build", "Don't know how to do with macro [%s]" % Name,
375 # File=self.MetaFile, Line=LineNo)
377 if self
._BuildOptions
is None:
378 self
._BuildOptions
= OrderedDict()
380 if ToolList
[0] in self
._TOOL
_CODE
_:
381 Tool
= self
._TOOL
_CODE
_[ToolList
[0]]
384 ToolChain
= "*_*_*_%s_FLAGS" % Tool
385 ToolChainFamily
= 'MSFT' # Edk.x only support MSFT tool chain
386 # ignore not replaced macros in value
387 ValueList
= GetSplitList(' ' + Value
, '/D')
389 for Index
in range(1, len(ValueList
)):
390 if ValueList
[Index
][-1] == '=' or ValueList
[Index
] == '':
392 Dummy
= Dummy
+ ' /D ' + ValueList
[Index
]
393 Value
= Dummy
.strip()
394 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
:
395 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Value
397 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
398 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Value
399 # set _Header to non-None in order to avoid database re-querying
400 self
._Header
_ = 'DUMMY'
402 ## Retrieve file version
403 def _GetInfVersion(self
):
404 if self
._AutoGenVersion
is None:
405 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
406 for Record
in RecordList
:
407 if Record
[1] == TAB_INF_DEFINES_INF_VERSION
:
409 ValueList
= Record
[2].split('.')
410 Major
= '%04o' % int(ValueList
[0], 0)
411 Minor
= '%04o' % int(ValueList
[1], 0)
412 self
._AutoGenVersion
= int('0x' + Major
+ Minor
, 0)
414 self
._AutoGenVersion
= int(Record
[2], 0)
416 if self
._AutoGenVersion
is None:
417 self
._AutoGenVersion
= 0x00010000
418 return self
._AutoGenVersion
420 ## Retrieve BASE_NAME
421 def _GetBaseName(self
):
422 if self
._BaseName
is None:
423 if self
._Header
_ is None:
424 self
._GetHeaderInfo
()
425 if self
._BaseName
is None:
426 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BASE_NAME name", File
=self
.MetaFile
)
427 return self
._BaseName
430 def _GetDxsFile(self
):
431 if self
._DxsFile
is None:
432 if self
._Header
_ is None:
433 self
._GetHeaderInfo
()
434 if self
._DxsFile
is None:
438 ## Retrieve MODULE_TYPE
439 def _GetModuleType(self
):
440 if self
._ModuleType
is None:
441 if self
._Header
_ is None:
442 self
._GetHeaderInfo
()
443 if self
._ModuleType
is None:
444 self
._ModuleType
= SUP_MODULE_BASE
445 if self
._ModuleType
not in SUP_MODULE_LIST
:
446 self
._ModuleType
= SUP_MODULE_USER_DEFINED
447 return self
._ModuleType
449 ## Retrieve COMPONENT_TYPE
450 def _GetComponentType(self
):
451 if self
._ComponentType
is None:
452 if self
._Header
_ is None:
453 self
._GetHeaderInfo
()
454 if self
._ComponentType
is None:
455 self
._ComponentType
= SUP_MODULE_USER_DEFINED
456 return self
._ComponentType
458 ## Retrieve "BUILD_TYPE"
459 def _GetBuildType(self
):
460 if self
._BuildType
is None:
461 if self
._Header
_ is None:
462 self
._GetHeaderInfo
()
463 if not self
._BuildType
:
464 self
._BuildType
= SUP_MODULE_BASE
465 return self
._BuildType
467 ## Retrieve file guid
468 def _GetFileGuid(self
):
469 if self
._Guid
is None:
470 if self
._Header
_ is None:
471 self
._GetHeaderInfo
()
472 if self
._Guid
is None:
473 self
._Guid
= '00000000-0000-0000-0000-000000000000'
476 ## Retrieve module version
477 def _GetVersion(self
):
478 if self
._Version
is None:
479 if self
._Header
_ is None:
480 self
._GetHeaderInfo
()
481 if self
._Version
is None:
482 self
._Version
= '0.0'
485 ## Retrieve PCD_IS_DRIVER
486 def _GetPcdIsDriver(self
):
487 if self
._PcdIsDriver
is None:
488 if self
._Header
_ is None:
489 self
._GetHeaderInfo
()
490 if self
._PcdIsDriver
is None:
491 self
._PcdIsDriver
= ''
492 return self
._PcdIsDriver
495 def _GetShadow(self
):
496 if self
._Shadow
is None:
497 if self
._Header
_ is None:
498 self
._GetHeaderInfo
()
499 if self
._Shadow
is not None and self
._Shadow
.upper() == 'TRUE':
505 ## Retrieve CUSTOM_MAKEFILE
506 def _GetMakefile(self
):
507 if self
._CustomMakefile
is None:
508 if self
._Header
_ is None:
509 self
._GetHeaderInfo
()
510 if self
._CustomMakefile
is None:
511 self
._CustomMakefile
= {}
512 return self
._CustomMakefile
514 ## Retrieve EFI_SPECIFICATION_VERSION
516 if self
._Specification
is None:
517 if self
._Header
_ is None:
518 self
._GetHeaderInfo
()
519 if self
._Specification
is None:
520 self
._Specification
= {}
521 return self
._Specification
523 ## Retrieve LIBRARY_CLASS
524 def _GetLibraryClass(self
):
525 if self
._LibraryClass
is None:
526 if self
._Header
_ is None:
527 self
._GetHeaderInfo
()
528 if self
._LibraryClass
is None:
529 self
._LibraryClass
= []
530 return self
._LibraryClass
532 ## Retrieve ENTRY_POINT
533 def _GetEntryPoint(self
):
534 if self
._ModuleEntryPointList
is None:
535 if self
._Header
_ is None:
536 self
._GetHeaderInfo
()
537 if self
._ModuleEntryPointList
is None:
538 self
._ModuleEntryPointList
= []
539 return self
._ModuleEntryPointList
541 ## Retrieve UNLOAD_IMAGE
542 def _GetUnloadImage(self
):
543 if self
._ModuleUnloadImageList
is None:
544 if self
._Header
_ is None:
545 self
._GetHeaderInfo
()
546 if self
._ModuleUnloadImageList
is None:
547 self
._ModuleUnloadImageList
= []
548 return self
._ModuleUnloadImageList
550 ## Retrieve CONSTRUCTOR
551 def _GetConstructor(self
):
552 if self
._ConstructorList
is None:
553 if self
._Header
_ is None:
554 self
._GetHeaderInfo
()
555 if self
._ConstructorList
is None:
556 self
._ConstructorList
= []
557 return self
._ConstructorList
559 ## Retrieve DESTRUCTOR
560 def _GetDestructor(self
):
561 if self
._DestructorList
is None:
562 if self
._Header
_ is None:
563 self
._GetHeaderInfo
()
564 if self
._DestructorList
is None:
565 self
._DestructorList
= []
566 return self
._DestructorList
568 ## Retrieve definies other than above ones
569 def _GetDefines(self
):
570 if len(self
._Defs
) == 0 and self
._Header
_ is None:
571 self
._GetHeaderInfo
()
574 ## Retrieve binary files
575 def _GetBinaries(self
):
576 if self
._Binaries
is None:
578 RecordList
= self
._RawData
[MODEL_EFI_BINARY_FILE
, self
._Arch
, self
._Platform
]
579 Macros
= self
._Macros
580 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
581 Macros
['PROCESSOR'] = self
._Arch
582 for Record
in RecordList
:
588 TokenList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
590 Target
= TokenList
[0]
591 if len(TokenList
) > 1:
592 FeatureFlag
= Record
[1:]
594 File
= PathClass(NormPath(Record
[1], Macros
), self
._ModuleDir
, '', FileType
, True, self
._Arch
, '', Target
)
595 # check the file validation
596 ErrorCode
, ErrorInfo
= File
.Validate()
598 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
599 self
._Binaries
.append(File
)
600 return self
._Binaries
602 ## Retrieve binary files with error check.
603 def _GetBinaryFiles(self
):
604 Binaries
= self
._GetBinaries
()
605 if GlobalData
.gIgnoreSource
and Binaries
== []:
606 ErrorInfo
= "The INF file does not contain any Binaries to use in creating the image\n"
607 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
)
610 ## Check whether it exists the binaries with current ARCH in AsBuild INF
611 def _IsSupportedArch(self
):
612 if self
._GetBinaries
() and not self
._GetSourceFiles
():
616 ## Retrieve source files
617 def _GetSourceFiles(self
):
618 # Ignore all source files in a binary build mode
619 if GlobalData
.gIgnoreSource
:
623 if self
._Sources
is None:
625 RecordList
= self
._RawData
[MODEL_EFI_SOURCE_FILE
, self
._Arch
, self
._Platform
]
626 Macros
= self
._Macros
627 for Record
in RecordList
:
629 ToolChainFamily
= Record
[1]
632 FeatureFlag
= Record
[4]
633 if self
.AutoGenVersion
< 0x00010005:
634 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
635 Macros
['PROCESSOR'] = self
._Arch
636 SourceFile
= NormPath(Record
[0], Macros
)
637 if SourceFile
[0] == os
.path
.sep
:
638 SourceFile
= mws
.join(GlobalData
.gWorkspace
, SourceFile
[1:])
639 # old module source files (Edk)
640 File
= PathClass(SourceFile
, self
._ModuleDir
, self
._SourceOverridePath
,
641 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
642 # check the file validation
643 ErrorCode
, ErrorInfo
= File
.Validate(CaseSensitive
=False)
645 if File
.Ext
.lower() == '.h':
646 EdkLogger
.warn('build', 'Include file not found', ExtraData
=ErrorInfo
,
647 File
=self
.MetaFile
, Line
=LineNo
)
650 EdkLogger
.error('build', ErrorCode
, ExtraData
=File
, File
=self
.MetaFile
, Line
=LineNo
)
652 File
= PathClass(NormPath(Record
[0], Macros
), self
._ModuleDir
, '',
653 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
654 # check the file validation
655 ErrorCode
, ErrorInfo
= File
.Validate()
657 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
659 self
._Sources
.append(File
)
662 ## Retrieve library classes employed by this module
663 def _GetLibraryClassUses(self
):
664 if self
._LibraryClasses
is None:
665 self
._LibraryClasses
= OrderedDict()
666 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, self
._Platform
]
667 for Record
in RecordList
:
671 Instance
= NormPath(Instance
, self
._Macros
)
672 self
._LibraryClasses
[Lib
] = Instance
673 return self
._LibraryClasses
675 ## Retrieve library names (for Edk.x style of modules)
676 def _GetLibraryNames(self
):
677 if self
._Libraries
is None:
679 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
, self
._Platform
]
680 for Record
in RecordList
:
681 LibraryName
= ReplaceMacro(Record
[0], self
._Macros
, False)
682 # in case of name with '.lib' extension, which is unusual in Edk.x inf
683 LibraryName
= os
.path
.splitext(LibraryName
)[0]
684 if LibraryName
not in self
._Libraries
:
685 self
._Libraries
.append(LibraryName
)
686 return self
._Libraries
688 def _GetProtocolComments(self
):
690 return self
._ProtocolComments
691 ## Retrieve protocols consumed/produced by this module
692 def _GetProtocols(self
):
693 if self
._Protocols
is None:
694 self
._Protocols
= OrderedDict()
695 self
._ProtocolComments
= OrderedDict()
696 RecordList
= self
._RawData
[MODEL_EFI_PROTOCOL
, self
._Arch
, self
._Platform
]
697 for Record
in RecordList
:
699 Value
= ProtocolValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
701 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
702 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
703 "Value of Protocol [%s] is not found under [Protocols] section in" % CName
,
704 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
705 self
._Protocols
[CName
] = Value
706 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
708 for CmtRec
in CommentRecords
:
709 Comments
.append(CmtRec
[0])
710 self
._ProtocolComments
[CName
] = Comments
711 return self
._Protocols
713 def _GetPpiComments(self
):
715 return self
._PpiComments
716 ## Retrieve PPIs consumed/produced by this module
718 if self
._Ppis
is None:
719 self
._Ppis
= OrderedDict()
720 self
._PpiComments
= OrderedDict()
721 RecordList
= self
._RawData
[MODEL_EFI_PPI
, self
._Arch
, self
._Platform
]
722 for Record
in RecordList
:
724 Value
= PpiValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
726 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
727 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
728 "Value of PPI [%s] is not found under [Ppis] section in " % CName
,
729 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
730 self
._Ppis
[CName
] = Value
731 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
733 for CmtRec
in CommentRecords
:
734 Comments
.append(CmtRec
[0])
735 self
._PpiComments
[CName
] = Comments
738 def _GetGuidComments(self
):
740 return self
._GuidComments
741 ## Retrieve GUIDs consumed/produced by this module
743 if self
._Guids
is None:
744 self
._Guids
= OrderedDict()
745 self
._GuidComments
= OrderedDict()
746 RecordList
= self
._RawData
[MODEL_EFI_GUID
, self
._Arch
, self
._Platform
]
747 for Record
in RecordList
:
749 Value
= GuidValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
751 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
752 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
753 "Value of Guid [%s] is not found under [Guids] section in" % CName
,
754 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
755 self
._Guids
[CName
] = Value
756 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
758 for CmtRec
in CommentRecords
:
759 Comments
.append(CmtRec
[0])
760 self
._GuidComments
[CName
] = Comments
763 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
764 def _GetIncludes(self
):
765 if self
._Includes
is None:
767 if self
._SourceOverridePath
:
768 self
._Includes
.append(self
._SourceOverridePath
)
770 Macros
= self
._Macros
771 Macros
['PROCESSOR'] = GlobalData
.gEdkGlobal
.get('PROCESSOR', self
._Arch
)
772 RecordList
= self
._RawData
[MODEL_EFI_INCLUDE
, self
._Arch
, self
._Platform
]
773 for Record
in RecordList
:
774 if Record
[0].find('EDK_SOURCE') > -1:
775 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
776 File
= NormPath(Record
[0], self
._Macros
)
778 File
= os
.path
.join(self
._ModuleDir
, File
)
780 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
781 File
= RealPath(os
.path
.normpath(File
))
783 self
._Includes
.append(File
)
785 # TRICK: let compiler to choose correct header file
786 Macros
['EDK_SOURCE'] = GlobalData
.gEdkSource
787 File
= NormPath(Record
[0], self
._Macros
)
789 File
= os
.path
.join(self
._ModuleDir
, File
)
791 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
792 File
= RealPath(os
.path
.normpath(File
))
794 self
._Includes
.append(File
)
796 File
= NormPath(Record
[0], Macros
)
798 File
= os
.path
.join(self
._ModuleDir
, File
)
800 File
= mws
.join(GlobalData
.gWorkspace
, File
)
801 File
= RealPath(os
.path
.normpath(File
))
803 self
._Includes
.append(File
)
804 if not File
and Record
[0].find('EFI_SOURCE') > -1:
805 # tricky to regard WorkSpace as EFI_SOURCE
806 Macros
['EFI_SOURCE'] = GlobalData
.gWorkspace
807 File
= NormPath(Record
[0], Macros
)
809 File
= os
.path
.join(self
._ModuleDir
, File
)
811 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
812 File
= RealPath(os
.path
.normpath(File
))
814 self
._Includes
.append(File
)
815 return self
._Includes
817 ## Retrieve packages this module depends on
818 def _GetPackages(self
):
819 if self
._Packages
is None:
821 RecordList
= self
._RawData
[MODEL_META_DATA_PACKAGE
, self
._Arch
, self
._Platform
]
822 Macros
= self
._Macros
823 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
824 for Record
in RecordList
:
825 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
827 # check the file validation
828 ErrorCode
, ErrorInfo
= File
.Validate('.dec')
830 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
831 # parse this package now. we need it to get protocol/ppi/guid value
832 Package
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
833 self
._Packages
.append(Package
)
834 return self
._Packages
836 ## Retrieve PCD comments
837 def _GetPcdComments(self
):
839 return self
._PcdComments
840 ## Retrieve PCDs used in this module
842 if self
._Pcds
is None:
843 self
._Pcds
= OrderedDict()
844 self
._PcdComments
= OrderedDict()
845 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
846 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
847 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
848 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC
))
849 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC_EX
))
852 ## Retrieve build options specific to this module
853 def _GetBuildOptions(self
):
854 if self
._BuildOptions
is None:
855 self
._BuildOptions
= OrderedDict()
856 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, self
._Platform
]
857 for Record
in RecordList
:
858 ToolChainFamily
= Record
[0]
859 ToolChain
= Record
[1]
861 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
or Option
.startswith('='):
862 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Option
864 # concatenate the option string if they're for the same tool
865 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
866 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
867 return self
._BuildOptions
869 ## Retrieve dependency expression
871 if self
._Depex
is None:
872 self
._Depex
= tdict(False, 2)
873 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
875 # If the module has only Binaries and no Sources, then ignore [Depex]
876 if self
.Sources
is None or self
.Sources
== []:
877 if self
.Binaries
is not None and self
.Binaries
!= []:
880 # PEIM and DXE drivers must have a valid [Depex] section
881 if len(self
.LibraryClass
) == 0 and len(RecordList
) == 0:
882 if self
.ModuleType
== SUP_MODULE_DXE_DRIVER
or self
.ModuleType
== SUP_MODULE_PEIM
or self
.ModuleType
== SUP_MODULE_DXE_SMM_DRIVER
or \
883 self
.ModuleType
== SUP_MODULE_DXE_SAL_DRIVER
or self
.ModuleType
== SUP_MODULE_DXE_RUNTIME_DRIVER
:
884 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
885 % self
.ModuleType
, File
=self
.MetaFile
)
887 if len(RecordList
) != 0 and self
.ModuleType
== SUP_MODULE_USER_DEFINED
:
888 for Record
in RecordList
:
889 if Record
[4] not in [SUP_MODULE_PEIM
, SUP_MODULE_DXE_DRIVER
, SUP_MODULE_DXE_SMM_DRIVER
]:
890 EdkLogger
.error('build', FORMAT_INVALID
,
891 "'%s' module must specify the type of [Depex] section" % self
.ModuleType
,
894 Depex
= OrderedDict()
895 for Record
in RecordList
:
896 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
898 ModuleType
= Record
[4]
899 TokenList
= DepexStr
.split()
900 if (Arch
, ModuleType
) not in Depex
:
901 Depex
[Arch
, ModuleType
] = []
902 DepexList
= Depex
[Arch
, ModuleType
]
903 for Token
in TokenList
:
904 if Token
in DEPEX_SUPPORTED_OPCODE_SET
:
905 DepexList
.append(Token
)
906 elif Token
.endswith(".inf"): # module file name
907 ModuleFile
= os
.path
.normpath(Token
)
908 Module
= self
.BuildDatabase
[ModuleFile
]
910 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "Module is not found in active platform",
911 ExtraData
=Token
, File
=self
.MetaFile
, Line
=Record
[-1])
912 DepexList
.append(Module
.Guid
)
914 # get the GUID value now
915 Value
= ProtocolValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
917 Value
= PpiValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
919 Value
= GuidValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
921 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
922 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
923 "Value of [%s] is not found in" % Token
,
924 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
925 DepexList
.append(Value
)
926 for Arch
, ModuleType
in Depex
:
927 self
._Depex
[Arch
, ModuleType
] = Depex
[Arch
, ModuleType
]
930 ## Retrieve depedency expression
931 def _GetDepexExpression(self
):
932 if self
._DepexExpression
is None:
933 self
._DepexExpression
= tdict(False, 2)
934 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
935 DepexExpression
= OrderedDict()
936 for Record
in RecordList
:
937 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
939 ModuleType
= Record
[4]
940 TokenList
= DepexStr
.split()
941 if (Arch
, ModuleType
) not in DepexExpression
:
942 DepexExpression
[Arch
, ModuleType
] = ''
943 for Token
in TokenList
:
944 DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
] + Token
.strip() + ' '
945 for Arch
, ModuleType
in DepexExpression
:
946 self
._DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
]
947 return self
._DepexExpression
949 def GetGuidsUsedByPcd(self
):
950 return self
._GuidsUsedByPcd
951 ## Retrieve PCD for given type
952 def _GetPcd(self
, Type
):
954 PcdDict
= tdict(True, 4)
956 RecordList
= self
._RawData
[Type
, self
._Arch
, self
._Platform
]
957 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, Platform
, Id
, LineNo
in RecordList
:
958 PcdDict
[Arch
, Platform
, PcdCName
, TokenSpaceGuid
] = (Setting
, LineNo
)
959 PcdList
.append((PcdCName
, TokenSpaceGuid
))
961 if TokenSpaceGuid
not in self
.Guids
:
962 Value
= GuidValue(TokenSpaceGuid
, self
.Packages
, self
.MetaFile
.Path
)
964 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
965 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
966 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid
,
967 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=LineNo
)
968 self
.Guids
[TokenSpaceGuid
] = Value
969 self
._GuidsUsedByPcd
[TokenSpaceGuid
] = Value
970 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Id
]
972 for CmtRec
in CommentRecords
:
973 Comments
.append(CmtRec
[0])
974 self
._PcdComments
[TokenSpaceGuid
, PcdCName
] = Comments
976 # resolve PCD type, value, datum info, etc. by getting its definition from package
977 _GuidDict
= self
.Guids
.copy()
978 for PcdCName
, TokenSpaceGuid
in PcdList
:
979 PcdRealName
= PcdCName
980 Setting
, LineNo
= PcdDict
[self
._Arch
, self
.Platform
, PcdCName
, TokenSpaceGuid
]
983 ValueList
= AnalyzePcdData(Setting
)
984 DefaultValue
= ValueList
[0]
985 Pcd
= PcdClassObject(
995 self
.Guids
[TokenSpaceGuid
]
997 if Type
== MODEL_PCD_PATCHABLE_IN_MODULE
and ValueList
[1]:
998 # Patch PCD: TokenSpace.PcdCName|Value|Offset
999 Pcd
.Offset
= ValueList
[1]
1001 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1002 for Package
in self
.Packages
:
1003 for key
in Package
.Pcds
:
1004 if (Package
.Pcds
[key
].TokenCName
, Package
.Pcds
[key
].TokenSpaceGuidCName
) == (PcdRealName
, TokenSpaceGuid
):
1005 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1006 Pcd_Type
= item
[0].split('_')[-1]
1007 if Pcd_Type
== Package
.Pcds
[key
].Type
:
1008 Value
= Package
.Pcds
[key
]
1009 Value
.TokenCName
= Package
.Pcds
[key
].TokenCName
+ '_' + Pcd_Type
1011 newkey
= (Value
.TokenCName
, key
[1])
1013 newkey
= (Value
.TokenCName
, key
[1], key
[2])
1014 del Package
.Pcds
[key
]
1015 Package
.Pcds
[newkey
] = Value
1022 # get necessary info from package declaring this PCD
1023 for Package
in self
.Packages
:
1025 # 'dynamic' in INF means its type is determined by platform;
1026 # if platform doesn't give its type, use 'lowest' one in the
1027 # following order, if any
1029 # TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
1031 _GuidDict
.update(Package
.Guids
)
1032 PcdType
= self
._PCD
_TYPE
_STRING
_[Type
]
1033 if Type
== MODEL_PCD_DYNAMIC
:
1035 for T
in PCD_TYPE_LIST
:
1036 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1037 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1038 if str(item
[0]).endswith(T
) and (item
[0], item
[1], T
) in Package
.Pcds
:
1046 if (PcdRealName
, TokenSpaceGuid
, T
) in Package
.Pcds
:
1052 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1053 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1054 Pcd_Type
= item
[0].split('_')[-1]
1055 if Pcd_Type
== PcdType
:
1063 if (PcdCName
, TokenSpaceGuid
, PcdType
) in Package
.Pcds
:
1064 PcdInPackage
= Package
.Pcds
[PcdCName
, TokenSpaceGuid
, PcdType
]
1066 Pcd
.TokenValue
= PcdInPackage
.TokenValue
1069 # Check whether the token value exist or not.
1071 if Pcd
.TokenValue
is None or Pcd
.TokenValue
== "":
1075 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid
, PcdRealName
, str(Package
)),
1076 File
=self
.MetaFile
, Line
=LineNo
,
1080 # Check hexadecimal token value length and format.
1082 ReIsValidPcdTokenValue
= re
.compile(r
"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re
.DOTALL
)
1083 if Pcd
.TokenValue
.startswith("0x") or Pcd
.TokenValue
.startswith("0X"):
1084 if ReIsValidPcdTokenValue
.match(Pcd
.TokenValue
) is None:
1088 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd
.TokenValue
, TokenSpaceGuid
, PcdRealName
, str(Package
)),
1089 File
=self
.MetaFile
, Line
=LineNo
,
1094 # Check decimal token value length and format.
1098 TokenValueInt
= int (Pcd
.TokenValue
, 10)
1099 if (TokenValueInt
< 0 or TokenValueInt
> 4294967295):
1103 "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
)),
1104 File
=self
.MetaFile
, Line
=LineNo
,
1111 "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
)),
1112 File
=self
.MetaFile
, Line
=LineNo
,
1116 Pcd
.DatumType
= PcdInPackage
.DatumType
1117 Pcd
.MaxDatumSize
= PcdInPackage
.MaxDatumSize
1118 Pcd
.InfDefaultValue
= Pcd
.DefaultValue
1119 if not Pcd
.DefaultValue
:
1120 Pcd
.DefaultValue
= PcdInPackage
.DefaultValue
1123 Pcd
.DefaultValue
= ValueExpressionEx(Pcd
.DefaultValue
, Pcd
.DatumType
, _GuidDict
)(True)
1124 except BadExpression
as Value
:
1125 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid
, PcdRealName
, Pcd
.DefaultValue
, Value
),
1126 File
=self
.MetaFile
, Line
=LineNo
)
1132 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid
, PcdRealName
, self
.MetaFile
),
1133 File
=self
.MetaFile
, Line
=LineNo
,
1134 ExtraData
="\t%s" % '\n\t'.join(str(P
) for P
in self
.Packages
)
1136 Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
1140 ## check whether current module is binary module
1141 def _IsBinaryModule(self
):
1142 if self
.Binaries
and not self
.Sources
:
1144 elif GlobalData
.gIgnoreSource
:
1149 _Macros
= property(_GetMacros
)
1150 Arch
= property(_GetArch
, _SetArch
)
1151 Platform
= property(_GetPlatform
, _SetPlatform
)
1153 HeaderComments
= property(_GetHeaderComments
)
1154 TailComments
= property(_GetTailComments
)
1155 AutoGenVersion
= property(_GetInfVersion
)
1156 BaseName
= property(_GetBaseName
)
1157 ModuleType
= property(_GetModuleType
)
1158 ComponentType
= property(_GetComponentType
)
1159 BuildType
= property(_GetBuildType
)
1160 Guid
= property(_GetFileGuid
)
1161 Version
= property(_GetVersion
)
1162 PcdIsDriver
= property(_GetPcdIsDriver
)
1163 Shadow
= property(_GetShadow
)
1164 CustomMakefile
= property(_GetMakefile
)
1165 Specification
= property(_GetSpec
)
1166 LibraryClass
= property(_GetLibraryClass
)
1167 ModuleEntryPointList
= property(_GetEntryPoint
)
1168 ModuleUnloadImageList
= property(_GetUnloadImage
)
1169 ConstructorList
= property(_GetConstructor
)
1170 DestructorList
= property(_GetDestructor
)
1171 Defines
= property(_GetDefines
)
1172 DxsFile
= property(_GetDxsFile
)
1174 Binaries
= property(_GetBinaryFiles
)
1175 Sources
= property(_GetSourceFiles
)
1176 LibraryClasses
= property(_GetLibraryClassUses
)
1177 Libraries
= property(_GetLibraryNames
)
1178 Protocols
= property(_GetProtocols
)
1179 ProtocolComments
= property(_GetProtocolComments
)
1180 Ppis
= property(_GetPpis
)
1181 PpiComments
= property(_GetPpiComments
)
1182 Guids
= property(_GetGuids
)
1183 GuidComments
= property(_GetGuidComments
)
1184 Includes
= property(_GetIncludes
)
1185 Packages
= property(_GetPackages
)
1186 Pcds
= property(_GetPcds
)
1187 PcdComments
= property(_GetPcdComments
)
1188 BuildOptions
= property(_GetBuildOptions
)
1189 Depex
= property(_GetDepex
)
1190 DepexExpression
= property(_GetDepexExpression
)
1191 IsBinaryModule
= property(_IsBinaryModule
)
1192 IsSupportedArch
= property(_IsSupportedArch
)