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 __future__
import absolute_import
16 from Common
.StringUtils
import *
17 from Common
.DataType
import *
18 from Common
.Misc
import *
20 from .MetaFileParser
import *
21 from collections
import OrderedDict
23 from Workspace
.BuildClassObject
import ModuleBuildClassObject
, LibraryClassObject
, PcdClassObject
24 ## Module build information from INF file
26 # This class is used to retrieve information stored in database and convert them
27 # into ModuleBuildClassObject form for easier use for AutoGen.
29 class InfBuildData(ModuleBuildClassObject
):
30 # dict used to convert PCD type in database to string used by build tool
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
,
45 # dict used to convert part of [Defines] to members of InfBuildData directly
50 TAB_INF_DEFINES_BASE_NAME
: "_BaseName",
51 TAB_INF_DEFINES_FILE_GUID
: "_Guid",
52 TAB_INF_DEFINES_MODULE_TYPE
: "_ModuleType",
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",
67 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH
: "_SourceOverridePath",
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
75 BINARY_FILE_TYPE_LIB
: "SLINK",
80 ## Constructor of DscBuildData
82 # Initialize object of DscBuildData
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
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
98 self
._Toolchain
= Toolchain
99 self
._Platform
= TAB_COMMON
100 self
._SourceOverridePath
= None
101 if FilePath
.Key
in GlobalData
.gOverrideDir
:
102 self
._SourceOverridePath
= GlobalData
.gOverrideDir
[FilePath
.Key
]
106 def __setitem__(self
, key
, value
):
107 self
.__dict
__[self
._PROPERTY
_[key
]] = value
110 def __getitem__(self
, key
):
111 return self
.__dict
__[self
._PROPERTY
_[key
]]
114 def __contains__(self
, key
):
115 return key
in self
._PROPERTY
_
117 ## Set all internal used members of InfBuildData to None
119 self
._HeaderComments
= None
120 self
._TailComments
= None
122 self
._AutoGenVersion
= None
123 self
._BaseName
= None
125 self
._ModuleType
= None
126 self
._ComponentType
= None
127 self
._BuildType
= None
130 self
._PcdIsDriver
= None
131 self
._BinaryModule
= None
133 self
._MakefileName
= None
134 self
._CustomMakefile
= None
135 self
._Specification
= None
136 self
._LibraryClass
= None
137 self
._ModuleEntryPointList
= None
138 self
._ModuleUnloadImageList
= None
139 self
._ConstructorList
= None
140 self
._DestructorList
= None
141 self
._Defs
= OrderedDict()
142 self
._Binaries
= None
144 self
._LibraryClasses
= None
145 self
._Libraries
= None
146 self
._Protocols
= None
147 self
._ProtocolComments
= None
149 self
._PpiComments
= None
151 self
._GuidsUsedByPcd
= OrderedDict()
152 self
._GuidComments
= None
153 self
._Includes
= None
154 self
._Packages
= None
156 self
._PcdComments
= None
157 self
._BuildOptions
= None
159 self
._DepexExpression
= None
162 ## Get current effective macros
163 def _GetMacros(self
):
164 if self
.__Macros
is None:
166 # EDK_GLOBAL defined macros can be applied to EDK module
167 if self
.AutoGenVersion
< 0x00010005:
168 self
.__Macros
.update(GlobalData
.gEdkGlobal
)
169 self
.__Macros
.update(GlobalData
.gGlobalDefines
)
178 # Changing the default ARCH to another may affect all other information
179 # because all information in a platform may be ARCH-related. That's
180 # why we need to clear all internal used members, in order to cause all
181 # information to be re-retrieved.
183 # @param Value The value of ARCH
185 def _SetArch(self
, Value
):
186 if self
._Arch
== Value
:
191 ## Return the name of platform employing this module
192 def _GetPlatform(self
):
193 return self
._Platform
195 ## Change the name of platform employing this module
197 # Changing the default name of platform to another may affect some information
198 # because they may be PLATFORM-related. That's why we need to clear all internal
199 # used members, in order to cause all information to be re-retrieved.
201 def _SetPlatform(self
, Value
):
202 if self
._Platform
== Value
:
204 self
._Platform
= Value
206 def _GetHeaderComments(self
):
207 if not self
._HeaderComments
:
208 self
._HeaderComments
= []
209 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER_COMMENT
]
210 for Record
in RecordList
:
211 self
._HeaderComments
.append(Record
[0])
212 return self
._HeaderComments
213 def _GetTailComments(self
):
214 if not self
._TailComments
:
215 self
._TailComments
= []
216 RecordList
= self
._RawData
[MODEL_META_DATA_TAIL_COMMENT
]
217 for Record
in RecordList
:
218 self
._TailComments
.append(Record
[0])
219 return self
._TailComments
220 ## Retrieve all information in [Defines] section
222 # (Retriving all [Defines] information in one-shot is just to save time.)
224 def _GetHeaderInfo(self
):
225 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
226 for Record
in RecordList
:
227 Name
, Value
= Record
[1], ReplaceMacro(Record
[2], self
._Macros
, False)
228 # items defined _PROPERTY_ don't need additional processing
231 self
._Defs
[Name
] = Value
232 self
._Macros
[Name
] = Value
233 # some special items in [Defines] section need special treatment
234 elif Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
235 if Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
236 Name
= 'UEFI_SPECIFICATION_VERSION'
237 if self
._Specification
is None:
238 self
._Specification
= OrderedDict()
239 self
._Specification
[Name
] = GetHexVerValue(Value
)
240 if self
._Specification
[Name
] is None:
241 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
242 "'%s' format is not supported for %s" % (Value
, Name
),
243 File
=self
.MetaFile
, Line
=Record
[-1])
244 elif Name
== 'LIBRARY_CLASS':
245 if self
._LibraryClass
is None:
246 self
._LibraryClass
= []
247 ValueList
= GetSplitValueList(Value
)
248 LibraryClass
= ValueList
[0]
249 if len(ValueList
) > 1:
250 SupModuleList
= GetSplitValueList(ValueList
[1], ' ')
252 SupModuleList
= SUP_MODULE_LIST
253 self
._LibraryClass
.append(LibraryClassObject(LibraryClass
, SupModuleList
))
254 elif Name
== 'ENTRY_POINT':
255 if self
._ModuleEntryPointList
is None:
256 self
._ModuleEntryPointList
= []
257 self
._ModuleEntryPointList
.append(Value
)
258 elif Name
== 'UNLOAD_IMAGE':
259 if self
._ModuleUnloadImageList
is None:
260 self
._ModuleUnloadImageList
= []
263 self
._ModuleUnloadImageList
.append(Value
)
264 elif Name
== 'CONSTRUCTOR':
265 if self
._ConstructorList
is None:
266 self
._ConstructorList
= []
269 self
._ConstructorList
.append(Value
)
270 elif Name
== 'DESTRUCTOR':
271 if self
._DestructorList
is None:
272 self
._DestructorList
= []
275 self
._DestructorList
.append(Value
)
276 elif Name
== TAB_INF_DEFINES_CUSTOM_MAKEFILE
:
277 TokenList
= GetSplitValueList(Value
)
278 if self
._CustomMakefile
is None:
279 self
._CustomMakefile
= {}
280 if len(TokenList
) < 2:
281 self
._CustomMakefile
['MSFT'] = TokenList
[0]
282 self
._CustomMakefile
['GCC'] = TokenList
[0]
284 if TokenList
[0] not in ['MSFT', 'GCC']:
285 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
286 "No supported family [%s]" % TokenList
[0],
287 File
=self
.MetaFile
, Line
=Record
[-1])
288 self
._CustomMakefile
[TokenList
[0]] = TokenList
[1]
290 self
._Defs
[Name
] = Value
291 self
._Macros
[Name
] = Value
294 # Retrieve information in sections specific to Edk.x modules
296 if self
.AutoGenVersion
>= 0x00010005:
297 if not self
._ModuleType
:
298 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
299 "MODULE_TYPE is not given", File
=self
.MetaFile
)
300 if self
._ModuleType
not in SUP_MODULE_LIST
:
301 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
302 for Record
in RecordList
:
304 if Name
== "MODULE_TYPE":
307 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
308 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self
._ModuleType
, ' '.join(l
for l
in SUP_MODULE_LIST
)),
309 File
=self
.MetaFile
, Line
=LineNo
)
310 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
311 if self
._ModuleType
== SUP_MODULE_SMM_CORE
:
312 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
)
313 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
314 if self
._ModuleType
== SUP_MODULE_MM_CORE_STANDALONE
:
315 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
)
316 if self
._ModuleType
== SUP_MODULE_MM_STANDALONE
:
317 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
)
318 if 'PCI_DEVICE_ID' in self
._Defs
and 'PCI_VENDOR_ID' in self
._Defs \
319 and 'PCI_CLASS_CODE' in self
._Defs
and 'PCI_REVISION' in self
._Defs
:
320 self
._BuildType
= 'UEFI_OPTIONROM'
321 if 'PCI_COMPRESS' in self
._Defs
:
322 if self
._Defs
['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
323 EdkLogger
.error("build", FORMAT_INVALID
, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self
.MetaFile
)
325 elif 'UEFI_HII_RESOURCE_SECTION' in self
._Defs \
326 and self
._Defs
['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
327 self
._BuildType
= 'UEFI_HII'
329 self
._BuildType
= self
._ModuleType
.upper()
332 File
= PathClass(NormPath(self
._DxsFile
), self
._ModuleDir
, Arch
=self
._Arch
)
333 # check the file validation
334 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
336 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
337 File
=self
.MetaFile
, Line
=LineNo
)
338 if self
.Sources
is None:
340 self
._Sources
.append(File
)
342 if not self
._ComponentType
:
343 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
344 "COMPONENT_TYPE is not given", File
=self
.MetaFile
)
345 self
._BuildType
= self
._ComponentType
.upper()
346 if self
._ComponentType
in COMPONENT_TO_MODULE_MAP_DICT
:
347 self
._ModuleType
= COMPONENT_TO_MODULE_MAP_DICT
[self
._ComponentType
]
348 if self
._ComponentType
== EDK_COMPONENT_TYPE_LIBRARY
:
349 self
._LibraryClass
= [LibraryClassObject(self
._BaseName
, SUP_MODULE_LIST
)]
350 # make use some [nmake] section macros
351 Macros
= self
._Macros
352 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
353 Macros
['PROCESSOR'] = self
._Arch
354 RecordList
= self
._RawData
[MODEL_META_DATA_NMAKE
, self
._Arch
, self
._Platform
]
355 for Name
, Value
, Dummy
, Arch
, Platform
, ID
, LineNo
in RecordList
:
356 Value
= ReplaceMacro(Value
, Macros
, True)
357 if Name
== "IMAGE_ENTRY_POINT":
358 if self
._ModuleEntryPointList
is None:
359 self
._ModuleEntryPointList
= []
360 self
._ModuleEntryPointList
.append(Value
)
361 elif Name
== "DPX_SOURCE":
362 File
= PathClass(NormPath(Value
), self
._ModuleDir
, Arch
=self
._Arch
)
363 # check the file validation
364 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
366 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
367 File
=self
.MetaFile
, Line
=LineNo
)
368 if self
.Sources
is None:
370 self
._Sources
.append(File
)
372 ToolList
= self
._NMAKE
_FLAG
_PATTERN
_.findall(Name
)
373 if len(ToolList
) == 0 or len(ToolList
) != 1:
375 # EdkLogger.warn("build", "Don't know how to do with macro [%s]" % Name,
376 # File=self.MetaFile, Line=LineNo)
378 if self
._BuildOptions
is None:
379 self
._BuildOptions
= OrderedDict()
381 if ToolList
[0] in self
._TOOL
_CODE
_:
382 Tool
= self
._TOOL
_CODE
_[ToolList
[0]]
385 ToolChain
= "*_*_*_%s_FLAGS" % Tool
386 ToolChainFamily
= 'MSFT' # Edk.x only support MSFT tool chain
387 # ignore not replaced macros in value
388 ValueList
= GetSplitList(' ' + Value
, '/D')
390 for Index
in range(1, len(ValueList
)):
391 if ValueList
[Index
][-1] == '=' or ValueList
[Index
] == '':
393 Dummy
= Dummy
+ ' /D ' + ValueList
[Index
]
394 Value
= Dummy
.strip()
395 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
:
396 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Value
398 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
399 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Value
400 # set _Header to non-None in order to avoid database re-querying
401 self
._Header
_ = 'DUMMY'
403 ## Retrieve file version
404 def _GetInfVersion(self
):
405 if self
._AutoGenVersion
is None:
406 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
407 for Record
in RecordList
:
408 if Record
[1] == TAB_INF_DEFINES_INF_VERSION
:
410 ValueList
= Record
[2].split('.')
411 Major
= '%04o' % int(ValueList
[0], 0)
412 Minor
= '%04o' % int(ValueList
[1], 0)
413 self
._AutoGenVersion
= int('0x' + Major
+ Minor
, 0)
415 self
._AutoGenVersion
= int(Record
[2], 0)
417 if self
._AutoGenVersion
is None:
418 self
._AutoGenVersion
= 0x00010000
419 return self
._AutoGenVersion
421 ## Retrieve BASE_NAME
422 def _GetBaseName(self
):
423 if self
._BaseName
is None:
424 if self
._Header
_ is None:
425 self
._GetHeaderInfo
()
426 if self
._BaseName
is None:
427 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BASE_NAME name", File
=self
.MetaFile
)
428 return self
._BaseName
431 def _GetDxsFile(self
):
432 if self
._DxsFile
is None:
433 if self
._Header
_ is None:
434 self
._GetHeaderInfo
()
435 if self
._DxsFile
is None:
439 ## Retrieve MODULE_TYPE
440 def _GetModuleType(self
):
441 if self
._ModuleType
is None:
442 if self
._Header
_ is None:
443 self
._GetHeaderInfo
()
444 if self
._ModuleType
is None:
445 self
._ModuleType
= SUP_MODULE_BASE
446 if self
._ModuleType
not in SUP_MODULE_LIST
:
447 self
._ModuleType
= SUP_MODULE_USER_DEFINED
448 return self
._ModuleType
450 ## Retrieve COMPONENT_TYPE
451 def _GetComponentType(self
):
452 if self
._ComponentType
is None:
453 if self
._Header
_ is None:
454 self
._GetHeaderInfo
()
455 if self
._ComponentType
is None:
456 self
._ComponentType
= SUP_MODULE_USER_DEFINED
457 return self
._ComponentType
459 ## Retrieve "BUILD_TYPE"
460 def _GetBuildType(self
):
461 if self
._BuildType
is None:
462 if self
._Header
_ is None:
463 self
._GetHeaderInfo
()
464 if not self
._BuildType
:
465 self
._BuildType
= SUP_MODULE_BASE
466 return self
._BuildType
468 ## Retrieve file guid
469 def _GetFileGuid(self
):
470 if self
._Guid
is None:
471 if self
._Header
_ is None:
472 self
._GetHeaderInfo
()
473 if self
._Guid
is None:
474 self
._Guid
= '00000000-0000-0000-0000-000000000000'
477 ## Retrieve module version
478 def _GetVersion(self
):
479 if self
._Version
is None:
480 if self
._Header
_ is None:
481 self
._GetHeaderInfo
()
482 if self
._Version
is None:
483 self
._Version
= '0.0'
486 ## Retrieve PCD_IS_DRIVER
487 def _GetPcdIsDriver(self
):
488 if self
._PcdIsDriver
is None:
489 if self
._Header
_ is None:
490 self
._GetHeaderInfo
()
491 if self
._PcdIsDriver
is None:
492 self
._PcdIsDriver
= ''
493 return self
._PcdIsDriver
496 def _GetShadow(self
):
497 if self
._Shadow
is None:
498 if self
._Header
_ is None:
499 self
._GetHeaderInfo
()
500 if self
._Shadow
is not None and self
._Shadow
.upper() == 'TRUE':
506 ## Retrieve CUSTOM_MAKEFILE
507 def _GetMakefile(self
):
508 if self
._CustomMakefile
is None:
509 if self
._Header
_ is None:
510 self
._GetHeaderInfo
()
511 if self
._CustomMakefile
is None:
512 self
._CustomMakefile
= {}
513 return self
._CustomMakefile
515 ## Retrieve EFI_SPECIFICATION_VERSION
517 if self
._Specification
is None:
518 if self
._Header
_ is None:
519 self
._GetHeaderInfo
()
520 if self
._Specification
is None:
521 self
._Specification
= {}
522 return self
._Specification
524 ## Retrieve LIBRARY_CLASS
525 def _GetLibraryClass(self
):
526 if self
._LibraryClass
is None:
527 if self
._Header
_ is None:
528 self
._GetHeaderInfo
()
529 if self
._LibraryClass
is None:
530 self
._LibraryClass
= []
531 return self
._LibraryClass
533 ## Retrieve ENTRY_POINT
534 def _GetEntryPoint(self
):
535 if self
._ModuleEntryPointList
is None:
536 if self
._Header
_ is None:
537 self
._GetHeaderInfo
()
538 if self
._ModuleEntryPointList
is None:
539 self
._ModuleEntryPointList
= []
540 return self
._ModuleEntryPointList
542 ## Retrieve UNLOAD_IMAGE
543 def _GetUnloadImage(self
):
544 if self
._ModuleUnloadImageList
is None:
545 if self
._Header
_ is None:
546 self
._GetHeaderInfo
()
547 if self
._ModuleUnloadImageList
is None:
548 self
._ModuleUnloadImageList
= []
549 return self
._ModuleUnloadImageList
551 ## Retrieve CONSTRUCTOR
552 def _GetConstructor(self
):
553 if self
._ConstructorList
is None:
554 if self
._Header
_ is None:
555 self
._GetHeaderInfo
()
556 if self
._ConstructorList
is None:
557 self
._ConstructorList
= []
558 return self
._ConstructorList
560 ## Retrieve DESTRUCTOR
561 def _GetDestructor(self
):
562 if self
._DestructorList
is None:
563 if self
._Header
_ is None:
564 self
._GetHeaderInfo
()
565 if self
._DestructorList
is None:
566 self
._DestructorList
= []
567 return self
._DestructorList
569 ## Retrieve definies other than above ones
570 def _GetDefines(self
):
571 if len(self
._Defs
) == 0 and self
._Header
_ is None:
572 self
._GetHeaderInfo
()
575 ## Retrieve binary files
576 def _GetBinaries(self
):
577 if self
._Binaries
is None:
579 RecordList
= self
._RawData
[MODEL_EFI_BINARY_FILE
, self
._Arch
, self
._Platform
]
580 Macros
= self
._Macros
581 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
582 Macros
['PROCESSOR'] = self
._Arch
583 for Record
in RecordList
:
589 TokenList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
591 Target
= TokenList
[0]
592 if len(TokenList
) > 1:
593 FeatureFlag
= Record
[1:]
595 File
= PathClass(NormPath(Record
[1], Macros
), self
._ModuleDir
, '', FileType
, True, self
._Arch
, '', Target
)
596 # check the file validation
597 ErrorCode
, ErrorInfo
= File
.Validate()
599 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
600 self
._Binaries
.append(File
)
601 return self
._Binaries
603 ## Retrieve binary files with error check.
604 def _GetBinaryFiles(self
):
605 Binaries
= self
._GetBinaries
()
606 if GlobalData
.gIgnoreSource
and Binaries
== []:
607 ErrorInfo
= "The INF file does not contain any Binaries to use in creating the image\n"
608 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
)
611 ## Check whether it exists the binaries with current ARCH in AsBuild INF
612 def _IsSupportedArch(self
):
613 if self
._GetBinaries
() and not self
._GetSourceFiles
():
617 ## Retrieve source files
618 def _GetSourceFiles(self
):
619 # Ignore all source files in a binary build mode
620 if GlobalData
.gIgnoreSource
:
624 if self
._Sources
is None:
626 RecordList
= self
._RawData
[MODEL_EFI_SOURCE_FILE
, self
._Arch
, self
._Platform
]
627 Macros
= self
._Macros
628 for Record
in RecordList
:
630 ToolChainFamily
= Record
[1]
633 FeatureFlag
= Record
[4]
634 if self
.AutoGenVersion
< 0x00010005:
635 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
636 Macros
['PROCESSOR'] = self
._Arch
637 SourceFile
= NormPath(Record
[0], Macros
)
638 if SourceFile
[0] == os
.path
.sep
:
639 SourceFile
= mws
.join(GlobalData
.gWorkspace
, SourceFile
[1:])
640 # old module source files (Edk)
641 File
= PathClass(SourceFile
, self
._ModuleDir
, self
._SourceOverridePath
,
642 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
643 # check the file validation
644 ErrorCode
, ErrorInfo
= File
.Validate(CaseSensitive
=False)
646 if File
.Ext
.lower() == '.h':
647 EdkLogger
.warn('build', 'Include file not found', ExtraData
=ErrorInfo
,
648 File
=self
.MetaFile
, Line
=LineNo
)
651 EdkLogger
.error('build', ErrorCode
, ExtraData
=File
, File
=self
.MetaFile
, Line
=LineNo
)
653 File
= PathClass(NormPath(Record
[0], Macros
), self
._ModuleDir
, '',
654 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
655 # check the file validation
656 ErrorCode
, ErrorInfo
= File
.Validate()
658 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
660 self
._Sources
.append(File
)
663 ## Retrieve library classes employed by this module
664 def _GetLibraryClassUses(self
):
665 if self
._LibraryClasses
is None:
666 self
._LibraryClasses
= OrderedDict()
667 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, self
._Platform
]
668 for Record
in RecordList
:
672 Instance
= NormPath(Instance
, self
._Macros
)
673 self
._LibraryClasses
[Lib
] = Instance
674 return self
._LibraryClasses
676 ## Retrieve library names (for Edk.x style of modules)
677 def _GetLibraryNames(self
):
678 if self
._Libraries
is None:
680 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
, self
._Platform
]
681 for Record
in RecordList
:
682 LibraryName
= ReplaceMacro(Record
[0], self
._Macros
, False)
683 # in case of name with '.lib' extension, which is unusual in Edk.x inf
684 LibraryName
= os
.path
.splitext(LibraryName
)[0]
685 if LibraryName
not in self
._Libraries
:
686 self
._Libraries
.append(LibraryName
)
687 return self
._Libraries
689 def _GetProtocolComments(self
):
691 return self
._ProtocolComments
692 ## Retrieve protocols consumed/produced by this module
693 def _GetProtocols(self
):
694 if self
._Protocols
is None:
695 self
._Protocols
= OrderedDict()
696 self
._ProtocolComments
= OrderedDict()
697 RecordList
= self
._RawData
[MODEL_EFI_PROTOCOL
, self
._Arch
, self
._Platform
]
698 for Record
in RecordList
:
700 Value
= ProtocolValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
702 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
703 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
704 "Value of Protocol [%s] is not found under [Protocols] section in" % CName
,
705 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
706 self
._Protocols
[CName
] = Value
707 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
709 for CmtRec
in CommentRecords
:
710 Comments
.append(CmtRec
[0])
711 self
._ProtocolComments
[CName
] = Comments
712 return self
._Protocols
714 def _GetPpiComments(self
):
716 return self
._PpiComments
717 ## Retrieve PPIs consumed/produced by this module
719 if self
._Ppis
is None:
720 self
._Ppis
= OrderedDict()
721 self
._PpiComments
= OrderedDict()
722 RecordList
= self
._RawData
[MODEL_EFI_PPI
, self
._Arch
, self
._Platform
]
723 for Record
in RecordList
:
725 Value
= PpiValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
727 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
728 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
729 "Value of PPI [%s] is not found under [Ppis] section in " % CName
,
730 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
731 self
._Ppis
[CName
] = Value
732 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
734 for CmtRec
in CommentRecords
:
735 Comments
.append(CmtRec
[0])
736 self
._PpiComments
[CName
] = Comments
739 def _GetGuidComments(self
):
741 return self
._GuidComments
742 ## Retrieve GUIDs consumed/produced by this module
744 if self
._Guids
is None:
745 self
._Guids
= OrderedDict()
746 self
._GuidComments
= OrderedDict()
747 RecordList
= self
._RawData
[MODEL_EFI_GUID
, self
._Arch
, self
._Platform
]
748 for Record
in RecordList
:
750 Value
= GuidValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
752 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
753 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
754 "Value of Guid [%s] is not found under [Guids] section in" % CName
,
755 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
756 self
._Guids
[CName
] = Value
757 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
759 for CmtRec
in CommentRecords
:
760 Comments
.append(CmtRec
[0])
761 self
._GuidComments
[CName
] = Comments
764 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
765 def _GetIncludes(self
):
766 if self
._Includes
is None:
768 if self
._SourceOverridePath
:
769 self
._Includes
.append(self
._SourceOverridePath
)
771 Macros
= self
._Macros
772 Macros
['PROCESSOR'] = GlobalData
.gEdkGlobal
.get('PROCESSOR', self
._Arch
)
773 RecordList
= self
._RawData
[MODEL_EFI_INCLUDE
, self
._Arch
, self
._Platform
]
774 for Record
in RecordList
:
775 if Record
[0].find('EDK_SOURCE') > -1:
776 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
777 File
= NormPath(Record
[0], self
._Macros
)
779 File
= os
.path
.join(self
._ModuleDir
, File
)
781 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
782 File
= RealPath(os
.path
.normpath(File
))
784 self
._Includes
.append(File
)
786 # TRICK: let compiler to choose correct header file
787 Macros
['EDK_SOURCE'] = GlobalData
.gEdkSource
788 File
= NormPath(Record
[0], self
._Macros
)
790 File
= os
.path
.join(self
._ModuleDir
, File
)
792 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
793 File
= RealPath(os
.path
.normpath(File
))
795 self
._Includes
.append(File
)
797 File
= NormPath(Record
[0], Macros
)
799 File
= os
.path
.join(self
._ModuleDir
, File
)
801 File
= mws
.join(GlobalData
.gWorkspace
, File
)
802 File
= RealPath(os
.path
.normpath(File
))
804 self
._Includes
.append(File
)
805 if not File
and Record
[0].find('EFI_SOURCE') > -1:
806 # tricky to regard WorkSpace as EFI_SOURCE
807 Macros
['EFI_SOURCE'] = GlobalData
.gWorkspace
808 File
= NormPath(Record
[0], Macros
)
810 File
= os
.path
.join(self
._ModuleDir
, File
)
812 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
813 File
= RealPath(os
.path
.normpath(File
))
815 self
._Includes
.append(File
)
816 return self
._Includes
818 ## Retrieve packages this module depends on
819 def _GetPackages(self
):
820 if self
._Packages
is None:
822 RecordList
= self
._RawData
[MODEL_META_DATA_PACKAGE
, self
._Arch
, self
._Platform
]
823 Macros
= self
._Macros
824 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
825 for Record
in RecordList
:
826 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
828 # check the file validation
829 ErrorCode
, ErrorInfo
= File
.Validate('.dec')
831 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
832 # parse this package now. we need it to get protocol/ppi/guid value
833 Package
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
834 self
._Packages
.append(Package
)
835 return self
._Packages
837 ## Retrieve PCD comments
838 def _GetPcdComments(self
):
840 return self
._PcdComments
841 ## Retrieve PCDs used in this module
843 if self
._Pcds
is None:
844 self
._Pcds
= OrderedDict()
845 self
._PcdComments
= OrderedDict()
846 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
847 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
848 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
849 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC
))
850 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC_EX
))
853 ## Retrieve build options specific to this module
854 def _GetBuildOptions(self
):
855 if self
._BuildOptions
is None:
856 self
._BuildOptions
= OrderedDict()
857 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, self
._Platform
]
858 for Record
in RecordList
:
859 ToolChainFamily
= Record
[0]
860 ToolChain
= Record
[1]
862 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
or Option
.startswith('='):
863 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Option
865 # concatenate the option string if they're for the same tool
866 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
867 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
868 return self
._BuildOptions
870 ## Retrieve dependency expression
872 if self
._Depex
is None:
873 self
._Depex
= tdict(False, 2)
874 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
876 # If the module has only Binaries and no Sources, then ignore [Depex]
877 if self
.Sources
is None or self
.Sources
== []:
878 if self
.Binaries
is not None and self
.Binaries
!= []:
881 # PEIM and DXE drivers must have a valid [Depex] section
882 if len(self
.LibraryClass
) == 0 and len(RecordList
) == 0:
883 if self
.ModuleType
== SUP_MODULE_DXE_DRIVER
or self
.ModuleType
== SUP_MODULE_PEIM
or self
.ModuleType
== SUP_MODULE_DXE_SMM_DRIVER
or \
884 self
.ModuleType
== SUP_MODULE_DXE_SAL_DRIVER
or self
.ModuleType
== SUP_MODULE_DXE_RUNTIME_DRIVER
:
885 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
886 % self
.ModuleType
, File
=self
.MetaFile
)
888 if len(RecordList
) != 0 and self
.ModuleType
== SUP_MODULE_USER_DEFINED
:
889 for Record
in RecordList
:
890 if Record
[4] not in [SUP_MODULE_PEIM
, SUP_MODULE_DXE_DRIVER
, SUP_MODULE_DXE_SMM_DRIVER
]:
891 EdkLogger
.error('build', FORMAT_INVALID
,
892 "'%s' module must specify the type of [Depex] section" % self
.ModuleType
,
895 Depex
= OrderedDict()
896 for Record
in RecordList
:
897 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
899 ModuleType
= Record
[4]
900 TokenList
= DepexStr
.split()
901 if (Arch
, ModuleType
) not in Depex
:
902 Depex
[Arch
, ModuleType
] = []
903 DepexList
= Depex
[Arch
, ModuleType
]
904 for Token
in TokenList
:
905 if Token
in DEPEX_SUPPORTED_OPCODE_SET
:
906 DepexList
.append(Token
)
907 elif Token
.endswith(".inf"): # module file name
908 ModuleFile
= os
.path
.normpath(Token
)
909 Module
= self
.BuildDatabase
[ModuleFile
]
911 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "Module is not found in active platform",
912 ExtraData
=Token
, File
=self
.MetaFile
, Line
=Record
[-1])
913 DepexList
.append(Module
.Guid
)
915 # get the GUID value now
916 Value
= ProtocolValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
918 Value
= PpiValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
920 Value
= GuidValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
922 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
923 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
924 "Value of [%s] is not found in" % Token
,
925 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
926 DepexList
.append(Value
)
927 for Arch
, ModuleType
in Depex
:
928 self
._Depex
[Arch
, ModuleType
] = Depex
[Arch
, ModuleType
]
931 ## Retrieve depedency expression
932 def _GetDepexExpression(self
):
933 if self
._DepexExpression
is None:
934 self
._DepexExpression
= tdict(False, 2)
935 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
936 DepexExpression
= OrderedDict()
937 for Record
in RecordList
:
938 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
940 ModuleType
= Record
[4]
941 TokenList
= DepexStr
.split()
942 if (Arch
, ModuleType
) not in DepexExpression
:
943 DepexExpression
[Arch
, ModuleType
] = ''
944 for Token
in TokenList
:
945 DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
] + Token
.strip() + ' '
946 for Arch
, ModuleType
in DepexExpression
:
947 self
._DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
]
948 return self
._DepexExpression
950 def GetGuidsUsedByPcd(self
):
951 return self
._GuidsUsedByPcd
952 ## Retrieve PCD for given type
953 def _GetPcd(self
, Type
):
955 PcdDict
= tdict(True, 4)
957 RecordList
= self
._RawData
[Type
, self
._Arch
, self
._Platform
]
958 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, Platform
, Id
, LineNo
in RecordList
:
959 PcdDict
[Arch
, Platform
, PcdCName
, TokenSpaceGuid
] = (Setting
, LineNo
)
960 PcdList
.append((PcdCName
, TokenSpaceGuid
))
962 if TokenSpaceGuid
not in self
.Guids
:
963 Value
= GuidValue(TokenSpaceGuid
, self
.Packages
, self
.MetaFile
.Path
)
965 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
966 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
967 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid
,
968 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=LineNo
)
969 self
.Guids
[TokenSpaceGuid
] = Value
970 self
._GuidsUsedByPcd
[TokenSpaceGuid
] = Value
971 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Id
]
973 for CmtRec
in CommentRecords
:
974 Comments
.append(CmtRec
[0])
975 self
._PcdComments
[TokenSpaceGuid
, PcdCName
] = Comments
977 # resolve PCD type, value, datum info, etc. by getting its definition from package
978 _GuidDict
= self
.Guids
.copy()
979 for PcdCName
, TokenSpaceGuid
in PcdList
:
980 PcdRealName
= PcdCName
981 Setting
, LineNo
= PcdDict
[self
._Arch
, self
.Platform
, PcdCName
, TokenSpaceGuid
]
984 ValueList
= AnalyzePcdData(Setting
)
985 DefaultValue
= ValueList
[0]
986 Pcd
= PcdClassObject(
996 self
.Guids
[TokenSpaceGuid
]
998 if Type
== MODEL_PCD_PATCHABLE_IN_MODULE
and ValueList
[1]:
999 # Patch PCD: TokenSpace.PcdCName|Value|Offset
1000 Pcd
.Offset
= ValueList
[1]
1002 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1003 for Package
in self
.Packages
:
1004 for key
in Package
.Pcds
:
1005 if (Package
.Pcds
[key
].TokenCName
, Package
.Pcds
[key
].TokenSpaceGuidCName
) == (PcdRealName
, TokenSpaceGuid
):
1006 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1007 Pcd_Type
= item
[0].split('_')[-1]
1008 if Pcd_Type
== Package
.Pcds
[key
].Type
:
1009 Value
= Package
.Pcds
[key
]
1010 Value
.TokenCName
= Package
.Pcds
[key
].TokenCName
+ '_' + Pcd_Type
1012 newkey
= (Value
.TokenCName
, key
[1])
1014 newkey
= (Value
.TokenCName
, key
[1], key
[2])
1015 del Package
.Pcds
[key
]
1016 Package
.Pcds
[newkey
] = Value
1023 # get necessary info from package declaring this PCD
1024 for Package
in self
.Packages
:
1026 # 'dynamic' in INF means its type is determined by platform;
1027 # if platform doesn't give its type, use 'lowest' one in the
1028 # following order, if any
1030 # TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
1032 _GuidDict
.update(Package
.Guids
)
1033 PcdType
= self
._PCD
_TYPE
_STRING
_[Type
]
1034 if Type
== MODEL_PCD_DYNAMIC
:
1036 for T
in PCD_TYPE_LIST
:
1037 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1038 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1039 if str(item
[0]).endswith(T
) and (item
[0], item
[1], T
) in Package
.Pcds
:
1047 if (PcdRealName
, TokenSpaceGuid
, T
) in Package
.Pcds
:
1053 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1054 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1055 Pcd_Type
= item
[0].split('_')[-1]
1056 if Pcd_Type
== PcdType
:
1064 if (PcdCName
, TokenSpaceGuid
, PcdType
) in Package
.Pcds
:
1065 PcdInPackage
= Package
.Pcds
[PcdCName
, TokenSpaceGuid
, PcdType
]
1067 Pcd
.TokenValue
= PcdInPackage
.TokenValue
1070 # Check whether the token value exist or not.
1072 if Pcd
.TokenValue
is None or Pcd
.TokenValue
== "":
1076 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid
, PcdRealName
, str(Package
)),
1077 File
=self
.MetaFile
, Line
=LineNo
,
1081 # Check hexadecimal token value length and format.
1083 ReIsValidPcdTokenValue
= re
.compile(r
"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re
.DOTALL
)
1084 if Pcd
.TokenValue
.startswith("0x") or Pcd
.TokenValue
.startswith("0X"):
1085 if ReIsValidPcdTokenValue
.match(Pcd
.TokenValue
) is None:
1089 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd
.TokenValue
, TokenSpaceGuid
, PcdRealName
, str(Package
)),
1090 File
=self
.MetaFile
, Line
=LineNo
,
1095 # Check decimal token value length and format.
1099 TokenValueInt
= int (Pcd
.TokenValue
, 10)
1100 if (TokenValueInt
< 0 or TokenValueInt
> 4294967295):
1104 "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
)),
1105 File
=self
.MetaFile
, Line
=LineNo
,
1112 "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
)),
1113 File
=self
.MetaFile
, Line
=LineNo
,
1117 Pcd
.DatumType
= PcdInPackage
.DatumType
1118 Pcd
.MaxDatumSize
= PcdInPackage
.MaxDatumSize
1119 Pcd
.InfDefaultValue
= Pcd
.DefaultValue
1120 if not Pcd
.DefaultValue
:
1121 Pcd
.DefaultValue
= PcdInPackage
.DefaultValue
1124 Pcd
.DefaultValue
= ValueExpressionEx(Pcd
.DefaultValue
, Pcd
.DatumType
, _GuidDict
)(True)
1125 except BadExpression
as Value
:
1126 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid
, PcdRealName
, Pcd
.DefaultValue
, Value
),
1127 File
=self
.MetaFile
, Line
=LineNo
)
1133 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid
, PcdRealName
, self
.MetaFile
),
1134 File
=self
.MetaFile
, Line
=LineNo
,
1135 ExtraData
="\t%s" % '\n\t'.join(str(P
) for P
in self
.Packages
)
1137 Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
1141 ## check whether current module is binary module
1142 def _IsBinaryModule(self
):
1143 if self
.Binaries
and not self
.Sources
:
1145 elif GlobalData
.gIgnoreSource
:
1150 _Macros
= property(_GetMacros
)
1151 Arch
= property(_GetArch
, _SetArch
)
1152 Platform
= property(_GetPlatform
, _SetPlatform
)
1154 HeaderComments
= property(_GetHeaderComments
)
1155 TailComments
= property(_GetTailComments
)
1156 AutoGenVersion
= property(_GetInfVersion
)
1157 BaseName
= property(_GetBaseName
)
1158 ModuleType
= property(_GetModuleType
)
1159 ComponentType
= property(_GetComponentType
)
1160 BuildType
= property(_GetBuildType
)
1161 Guid
= property(_GetFileGuid
)
1162 Version
= property(_GetVersion
)
1163 PcdIsDriver
= property(_GetPcdIsDriver
)
1164 Shadow
= property(_GetShadow
)
1165 CustomMakefile
= property(_GetMakefile
)
1166 Specification
= property(_GetSpec
)
1167 LibraryClass
= property(_GetLibraryClass
)
1168 ModuleEntryPointList
= property(_GetEntryPoint
)
1169 ModuleUnloadImageList
= property(_GetUnloadImage
)
1170 ConstructorList
= property(_GetConstructor
)
1171 DestructorList
= property(_GetDestructor
)
1172 Defines
= property(_GetDefines
)
1173 DxsFile
= property(_GetDxsFile
)
1175 Binaries
= property(_GetBinaryFiles
)
1176 Sources
= property(_GetSourceFiles
)
1177 LibraryClasses
= property(_GetLibraryClassUses
)
1178 Libraries
= property(_GetLibraryNames
)
1179 Protocols
= property(_GetProtocols
)
1180 ProtocolComments
= property(_GetProtocolComments
)
1181 Ppis
= property(_GetPpis
)
1182 PpiComments
= property(_GetPpiComments
)
1183 Guids
= property(_GetGuids
)
1184 GuidComments
= property(_GetGuidComments
)
1185 Includes
= property(_GetIncludes
)
1186 Packages
= property(_GetPackages
)
1187 Pcds
= property(_GetPcds
)
1188 PcdComments
= property(_GetPcdComments
)
1189 BuildOptions
= property(_GetBuildOptions
)
1190 Depex
= property(_GetDepex
)
1191 DepexExpression
= property(_GetDepexExpression
)
1192 IsBinaryModule
= property(_IsBinaryModule
)
1193 IsSupportedArch
= property(_IsSupportedArch
)