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
.String
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
: "FixedAtBuild",
32 MODEL_PCD_PATCHABLE_IN_MODULE
: "PatchableInModule",
33 MODEL_PCD_FEATURE_FLAG
: "FeatureFlag",
34 MODEL_PCD_DYNAMIC
: "Dynamic",
35 MODEL_PCD_DYNAMIC_DEFAULT
: "Dynamic",
36 MODEL_PCD_DYNAMIC_HII
: "DynamicHii",
37 MODEL_PCD_DYNAMIC_VPD
: "DynamicVpd",
38 MODEL_PCD_DYNAMIC_EX
: "DynamicEx",
39 MODEL_PCD_DYNAMIC_EX_DEFAULT
: "DynamicEx",
40 MODEL_PCD_DYNAMIC_EX_HII
: "DynamicExHii",
41 MODEL_PCD_DYNAMIC_EX_VPD
: "DynamicExVpd",
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 # dict used to convert Component type to Module type
72 "SECURITY_CORE" : "SEC",
73 "PEI_CORE" : "PEI_CORE",
74 "COMBINED_PEIM_DRIVER" : "PEIM",
76 "RELOCATABLE_PEIM" : "PEIM",
78 "BS_DRIVER" : "DXE_DRIVER",
79 "RT_DRIVER" : "DXE_RUNTIME_DRIVER",
80 "SAL_RT_DRIVER" : "DXE_SAL_DRIVER",
81 "DXE_SMM_DRIVER" : "DXE_SMM_DRIVER",
82 # "SMM_DRIVER" : "DXE_SMM_DRIVER",
83 # "BS_DRIVER" : "DXE_SMM_DRIVER",
84 # "BS_DRIVER" : "UEFI_DRIVER",
85 "APPLICATION" : "UEFI_APPLICATION",
89 # regular expression for converting XXX_FLAGS in [nmake] section to new type
90 _NMAKE_FLAG_PATTERN_
= re
.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re
.UNICODE
)
91 # dict used to convert old tool name used in [nmake] section to new ones
99 ## Constructor of DscBuildData
101 # Initialize object of DscBuildData
103 # @param FilePath The path of platform description file
104 # @param RawData The raw data of DSC file
105 # @param BuildDataBase Database used to retrieve module/package information
106 # @param Arch The target architecture
107 # @param Platform The name of platform employing this module
108 # @param Macros Macros used for replacement in DSC file
110 def __init__(self
, FilePath
, RawData
, BuildDatabase
, Arch
=TAB_ARCH_COMMON
, Target
=None, Toolchain
=None):
111 self
.MetaFile
= FilePath
112 self
._ModuleDir
= FilePath
.Dir
113 self
._RawData
= RawData
114 self
._Bdb
= BuildDatabase
116 self
._Target
= Target
117 self
._Toolchain
= Toolchain
118 self
._Platform
= TAB_COMMON
119 self
._SourceOverridePath
= None
120 if FilePath
.Key
in GlobalData
.gOverrideDir
:
121 self
._SourceOverridePath
= GlobalData
.gOverrideDir
[FilePath
.Key
]
125 def __setitem__(self
, key
, value
):
126 self
.__dict
__[self
._PROPERTY
_[key
]] = value
129 def __getitem__(self
, key
):
130 return self
.__dict
__[self
._PROPERTY
_[key
]]
133 def __contains__(self
, key
):
134 return key
in self
._PROPERTY
_
136 ## Set all internal used members of InfBuildData to None
138 self
._HeaderComments
= None
139 self
._TailComments
= None
141 self
._AutoGenVersion
= None
142 self
._BaseName
= None
144 self
._ModuleType
= None
145 self
._ComponentType
= None
146 self
._BuildType
= None
149 self
._PcdIsDriver
= None
150 self
._BinaryModule
= None
152 self
._MakefileName
= None
153 self
._CustomMakefile
= None
154 self
._Specification
= None
155 self
._LibraryClass
= None
156 self
._ModuleEntryPointList
= None
157 self
._ModuleUnloadImageList
= None
158 self
._ConstructorList
= None
159 self
._DestructorList
= None
160 self
._Defs
= OrderedDict()
161 self
._Binaries
= None
163 self
._LibraryClasses
= None
164 self
._Libraries
= None
165 self
._Protocols
= None
166 self
._ProtocolComments
= None
168 self
._PpiComments
= None
170 self
._GuidsUsedByPcd
= OrderedDict()
171 self
._GuidComments
= None
172 self
._Includes
= None
173 self
._Packages
= None
175 self
._PcdComments
= None
176 self
._BuildOptions
= None
178 self
._DepexExpression
= None
181 ## Get current effective macros
182 def _GetMacros(self
):
183 if self
.__Macros
is None:
185 # EDK_GLOBAL defined macros can be applied to EDK module
186 if self
.AutoGenVersion
< 0x00010005:
187 self
.__Macros
.update(GlobalData
.gEdkGlobal
)
188 self
.__Macros
.update(GlobalData
.gGlobalDefines
)
197 # Changing the default ARCH to another may affect all other information
198 # because all information in a platform may be ARCH-related. That's
199 # why we need to clear all internal used members, in order to cause all
200 # information to be re-retrieved.
202 # @param Value The value of ARCH
204 def _SetArch(self
, Value
):
205 if self
._Arch
== Value
:
210 ## Return the name of platform employing this module
211 def _GetPlatform(self
):
212 return self
._Platform
214 ## Change the name of platform employing this module
216 # Changing the default name of platform to another may affect some information
217 # because they may be PLATFORM-related. That's why we need to clear all internal
218 # used members, in order to cause all information to be re-retrieved.
220 def _SetPlatform(self
, Value
):
221 if self
._Platform
== Value
:
223 self
._Platform
= Value
225 def _GetHeaderComments(self
):
226 if not self
._HeaderComments
:
227 self
._HeaderComments
= []
228 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER_COMMENT
]
229 for Record
in RecordList
:
230 self
._HeaderComments
.append(Record
[0])
231 return self
._HeaderComments
232 def _GetTailComments(self
):
233 if not self
._TailComments
:
234 self
._TailComments
= []
235 RecordList
= self
._RawData
[MODEL_META_DATA_TAIL_COMMENT
]
236 for Record
in RecordList
:
237 self
._TailComments
.append(Record
[0])
238 return self
._TailComments
239 ## Retrieve all information in [Defines] section
241 # (Retriving all [Defines] information in one-shot is just to save time.)
243 def _GetHeaderInfo(self
):
244 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
245 for Record
in RecordList
:
246 Name
, Value
= Record
[1], ReplaceMacro(Record
[2], self
._Macros
, False)
247 # items defined _PROPERTY_ don't need additional processing
250 self
._Defs
[Name
] = Value
251 self
._Macros
[Name
] = Value
252 # some special items in [Defines] section need special treatment
253 elif Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
254 if Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
255 Name
= 'UEFI_SPECIFICATION_VERSION'
256 if self
._Specification
is None:
257 self
._Specification
= OrderedDict()
258 self
._Specification
[Name
] = GetHexVerValue(Value
)
259 if self
._Specification
[Name
] is None:
260 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
261 "'%s' format is not supported for %s" % (Value
, Name
),
262 File
=self
.MetaFile
, Line
=Record
[-1])
263 elif Name
== 'LIBRARY_CLASS':
264 if self
._LibraryClass
is None:
265 self
._LibraryClass
= []
266 ValueList
= GetSplitValueList(Value
)
267 LibraryClass
= ValueList
[0]
268 if len(ValueList
) > 1:
269 SupModuleList
= GetSplitValueList(ValueList
[1], ' ')
271 SupModuleList
= SUP_MODULE_LIST
272 self
._LibraryClass
.append(LibraryClassObject(LibraryClass
, SupModuleList
))
273 elif Name
== 'ENTRY_POINT':
274 if self
._ModuleEntryPointList
is None:
275 self
._ModuleEntryPointList
= []
276 self
._ModuleEntryPointList
.append(Value
)
277 elif Name
== 'UNLOAD_IMAGE':
278 if self
._ModuleUnloadImageList
is None:
279 self
._ModuleUnloadImageList
= []
282 self
._ModuleUnloadImageList
.append(Value
)
283 elif Name
== 'CONSTRUCTOR':
284 if self
._ConstructorList
is None:
285 self
._ConstructorList
= []
288 self
._ConstructorList
.append(Value
)
289 elif Name
== 'DESTRUCTOR':
290 if self
._DestructorList
is None:
291 self
._DestructorList
= []
294 self
._DestructorList
.append(Value
)
295 elif Name
== TAB_INF_DEFINES_CUSTOM_MAKEFILE
:
296 TokenList
= GetSplitValueList(Value
)
297 if self
._CustomMakefile
is None:
298 self
._CustomMakefile
= {}
299 if len(TokenList
) < 2:
300 self
._CustomMakefile
['MSFT'] = TokenList
[0]
301 self
._CustomMakefile
['GCC'] = TokenList
[0]
303 if TokenList
[0] not in ['MSFT', 'GCC']:
304 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
305 "No supported family [%s]" % TokenList
[0],
306 File
=self
.MetaFile
, Line
=Record
[-1])
307 self
._CustomMakefile
[TokenList
[0]] = TokenList
[1]
309 self
._Defs
[Name
] = Value
310 self
._Macros
[Name
] = Value
313 # Retrieve information in sections specific to Edk.x modules
315 if self
.AutoGenVersion
>= 0x00010005:
316 if not self
._ModuleType
:
317 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
318 "MODULE_TYPE is not given", File
=self
.MetaFile
)
319 if self
._ModuleType
not in SUP_MODULE_LIST
:
320 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
321 for Record
in RecordList
:
323 if Name
== "MODULE_TYPE":
326 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
327 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self
._ModuleType
, ' '.join(l
for l
in SUP_MODULE_LIST
)),
328 File
=self
.MetaFile
, Line
=LineNo
)
329 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
330 if self
._ModuleType
== SUP_MODULE_SMM_CORE
:
331 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
)
332 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
333 if self
._ModuleType
== SUP_MODULE_MM_CORE_STANDALONE
:
334 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
)
335 if self
._ModuleType
== SUP_MODULE_MM_STANDALONE
:
336 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
)
337 if 'PCI_DEVICE_ID' in self
._Defs
and 'PCI_VENDOR_ID' in self
._Defs \
338 and 'PCI_CLASS_CODE' in self
._Defs
and 'PCI_REVISION' in self
._Defs
:
339 self
._BuildType
= 'UEFI_OPTIONROM'
340 if 'PCI_COMPRESS' in self
._Defs
:
341 if self
._Defs
['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
342 EdkLogger
.error("build", FORMAT_INVALID
, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self
.MetaFile
)
344 elif 'UEFI_HII_RESOURCE_SECTION' in self
._Defs \
345 and self
._Defs
['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
346 self
._BuildType
= 'UEFI_HII'
348 self
._BuildType
= self
._ModuleType
.upper()
351 File
= PathClass(NormPath(self
._DxsFile
), self
._ModuleDir
, Arch
=self
._Arch
)
352 # check the file validation
353 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
355 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
356 File
=self
.MetaFile
, Line
=LineNo
)
357 if self
.Sources
is None:
359 self
._Sources
.append(File
)
361 if not self
._ComponentType
:
362 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
363 "COMPONENT_TYPE is not given", File
=self
.MetaFile
)
364 self
._BuildType
= self
._ComponentType
.upper()
365 if self
._ComponentType
in self
._MODULE
_TYPE
_:
366 self
._ModuleType
= self
._MODULE
_TYPE
_[self
._ComponentType
]
367 if self
._ComponentType
== 'LIBRARY':
368 self
._LibraryClass
= [LibraryClassObject(self
._BaseName
, SUP_MODULE_LIST
)]
369 # make use some [nmake] section macros
370 Macros
= self
._Macros
371 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
372 Macros
['PROCESSOR'] = self
._Arch
373 RecordList
= self
._RawData
[MODEL_META_DATA_NMAKE
, self
._Arch
, self
._Platform
]
374 for Name
, Value
, Dummy
, Arch
, Platform
, ID
, LineNo
in RecordList
:
375 Value
= ReplaceMacro(Value
, Macros
, True)
376 if Name
== "IMAGE_ENTRY_POINT":
377 if self
._ModuleEntryPointList
is None:
378 self
._ModuleEntryPointList
= []
379 self
._ModuleEntryPointList
.append(Value
)
380 elif Name
== "DPX_SOURCE":
381 File
= PathClass(NormPath(Value
), self
._ModuleDir
, Arch
=self
._Arch
)
382 # check the file validation
383 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
385 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
386 File
=self
.MetaFile
, Line
=LineNo
)
387 if self
.Sources
is None:
389 self
._Sources
.append(File
)
391 ToolList
= self
._NMAKE
_FLAG
_PATTERN
_.findall(Name
)
392 if len(ToolList
) == 0 or len(ToolList
) != 1:
394 # EdkLogger.warn("build", "Don't know how to do with macro [%s]" % Name,
395 # File=self.MetaFile, Line=LineNo)
397 if self
._BuildOptions
is None:
398 self
._BuildOptions
= OrderedDict()
400 if ToolList
[0] in self
._TOOL
_CODE
_:
401 Tool
= self
._TOOL
_CODE
_[ToolList
[0]]
404 ToolChain
= "*_*_*_%s_FLAGS" % Tool
405 ToolChainFamily
= 'MSFT' # Edk.x only support MSFT tool chain
406 # ignore not replaced macros in value
407 ValueList
= GetSplitList(' ' + Value
, '/D')
409 for Index
in range(1, len(ValueList
)):
410 if ValueList
[Index
][-1] == '=' or ValueList
[Index
] == '':
412 Dummy
= Dummy
+ ' /D ' + ValueList
[Index
]
413 Value
= Dummy
.strip()
414 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
:
415 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Value
417 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
418 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Value
419 # set _Header to non-None in order to avoid database re-querying
420 self
._Header
_ = 'DUMMY'
422 ## Retrieve file version
423 def _GetInfVersion(self
):
424 if self
._AutoGenVersion
is None:
425 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
426 for Record
in RecordList
:
427 if Record
[1] == TAB_INF_DEFINES_INF_VERSION
:
429 ValueList
= Record
[2].split('.')
430 Major
= '%04o' % int(ValueList
[0], 0)
431 Minor
= '%04o' % int(ValueList
[1], 0)
432 self
._AutoGenVersion
= int('0x' + Major
+ Minor
, 0)
434 self
._AutoGenVersion
= int(Record
[2], 0)
436 if self
._AutoGenVersion
is None:
437 self
._AutoGenVersion
= 0x00010000
438 return self
._AutoGenVersion
440 ## Retrieve BASE_NAME
441 def _GetBaseName(self
):
442 if self
._BaseName
is None:
443 if self
._Header
_ is None:
444 self
._GetHeaderInfo
()
445 if self
._BaseName
is None:
446 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BASE_NAME name", File
=self
.MetaFile
)
447 return self
._BaseName
450 def _GetDxsFile(self
):
451 if self
._DxsFile
is None:
452 if self
._Header
_ is None:
453 self
._GetHeaderInfo
()
454 if self
._DxsFile
is None:
458 ## Retrieve MODULE_TYPE
459 def _GetModuleType(self
):
460 if self
._ModuleType
is None:
461 if self
._Header
_ is None:
462 self
._GetHeaderInfo
()
463 if self
._ModuleType
is None:
464 self
._ModuleType
= 'BASE'
465 if self
._ModuleType
not in SUP_MODULE_LIST
:
466 self
._ModuleType
= "USER_DEFINED"
467 return self
._ModuleType
469 ## Retrieve COMPONENT_TYPE
470 def _GetComponentType(self
):
471 if self
._ComponentType
is None:
472 if self
._Header
_ is None:
473 self
._GetHeaderInfo
()
474 if self
._ComponentType
is None:
475 self
._ComponentType
= 'USER_DEFINED'
476 return self
._ComponentType
478 ## Retrieve "BUILD_TYPE"
479 def _GetBuildType(self
):
480 if self
._BuildType
is None:
481 if self
._Header
_ is None:
482 self
._GetHeaderInfo
()
483 if not self
._BuildType
:
484 self
._BuildType
= "BASE"
485 return self
._BuildType
487 ## Retrieve file guid
488 def _GetFileGuid(self
):
489 if self
._Guid
is None:
490 if self
._Header
_ is None:
491 self
._GetHeaderInfo
()
492 if self
._Guid
is None:
493 self
._Guid
= '00000000-0000-0000-0000-000000000000'
496 ## Retrieve module version
497 def _GetVersion(self
):
498 if self
._Version
is None:
499 if self
._Header
_ is None:
500 self
._GetHeaderInfo
()
501 if self
._Version
is None:
502 self
._Version
= '0.0'
505 ## Retrieve PCD_IS_DRIVER
506 def _GetPcdIsDriver(self
):
507 if self
._PcdIsDriver
is None:
508 if self
._Header
_ is None:
509 self
._GetHeaderInfo
()
510 if self
._PcdIsDriver
is None:
511 self
._PcdIsDriver
= ''
512 return self
._PcdIsDriver
515 def _GetShadow(self
):
516 if self
._Shadow
is None:
517 if self
._Header
_ is None:
518 self
._GetHeaderInfo
()
519 if self
._Shadow
is not None and self
._Shadow
.upper() == 'TRUE':
525 ## Retrieve CUSTOM_MAKEFILE
526 def _GetMakefile(self
):
527 if self
._CustomMakefile
is None:
528 if self
._Header
_ is None:
529 self
._GetHeaderInfo
()
530 if self
._CustomMakefile
is None:
531 self
._CustomMakefile
= {}
532 return self
._CustomMakefile
534 ## Retrieve EFI_SPECIFICATION_VERSION
536 if self
._Specification
is None:
537 if self
._Header
_ is None:
538 self
._GetHeaderInfo
()
539 if self
._Specification
is None:
540 self
._Specification
= {}
541 return self
._Specification
543 ## Retrieve LIBRARY_CLASS
544 def _GetLibraryClass(self
):
545 if self
._LibraryClass
is None:
546 if self
._Header
_ is None:
547 self
._GetHeaderInfo
()
548 if self
._LibraryClass
is None:
549 self
._LibraryClass
= []
550 return self
._LibraryClass
552 ## Retrieve ENTRY_POINT
553 def _GetEntryPoint(self
):
554 if self
._ModuleEntryPointList
is None:
555 if self
._Header
_ is None:
556 self
._GetHeaderInfo
()
557 if self
._ModuleEntryPointList
is None:
558 self
._ModuleEntryPointList
= []
559 return self
._ModuleEntryPointList
561 ## Retrieve UNLOAD_IMAGE
562 def _GetUnloadImage(self
):
563 if self
._ModuleUnloadImageList
is None:
564 if self
._Header
_ is None:
565 self
._GetHeaderInfo
()
566 if self
._ModuleUnloadImageList
is None:
567 self
._ModuleUnloadImageList
= []
568 return self
._ModuleUnloadImageList
570 ## Retrieve CONSTRUCTOR
571 def _GetConstructor(self
):
572 if self
._ConstructorList
is None:
573 if self
._Header
_ is None:
574 self
._GetHeaderInfo
()
575 if self
._ConstructorList
is None:
576 self
._ConstructorList
= []
577 return self
._ConstructorList
579 ## Retrieve DESTRUCTOR
580 def _GetDestructor(self
):
581 if self
._DestructorList
is None:
582 if self
._Header
_ is None:
583 self
._GetHeaderInfo
()
584 if self
._DestructorList
is None:
585 self
._DestructorList
= []
586 return self
._DestructorList
588 ## Retrieve definies other than above ones
589 def _GetDefines(self
):
590 if len(self
._Defs
) == 0 and self
._Header
_ is None:
591 self
._GetHeaderInfo
()
594 ## Retrieve binary files
595 def _GetBinaries(self
):
596 if self
._Binaries
is None:
598 RecordList
= self
._RawData
[MODEL_EFI_BINARY_FILE
, self
._Arch
, self
._Platform
]
599 Macros
= self
._Macros
600 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
601 Macros
['PROCESSOR'] = self
._Arch
602 for Record
in RecordList
:
608 TokenList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
610 Target
= TokenList
[0]
611 if len(TokenList
) > 1:
612 FeatureFlag
= Record
[1:]
614 File
= PathClass(NormPath(Record
[1], Macros
), self
._ModuleDir
, '', FileType
, True, self
._Arch
, '', Target
)
615 # check the file validation
616 ErrorCode
, ErrorInfo
= File
.Validate()
618 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
619 self
._Binaries
.append(File
)
620 return self
._Binaries
622 ## Retrieve binary files with error check.
623 def _GetBinaryFiles(self
):
624 Binaries
= self
._GetBinaries
()
625 if GlobalData
.gIgnoreSource
and Binaries
== []:
626 ErrorInfo
= "The INF file does not contain any Binaries to use in creating the image\n"
627 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
)
630 ## Check whether it exists the binaries with current ARCH in AsBuild INF
631 def _IsSupportedArch(self
):
632 if self
._GetBinaries
() and not self
._GetSourceFiles
():
636 ## Retrieve source files
637 def _GetSourceFiles(self
):
638 # Ignore all source files in a binary build mode
639 if GlobalData
.gIgnoreSource
:
643 if self
._Sources
is None:
645 RecordList
= self
._RawData
[MODEL_EFI_SOURCE_FILE
, self
._Arch
, self
._Platform
]
646 Macros
= self
._Macros
647 for Record
in RecordList
:
649 ToolChainFamily
= Record
[1]
652 FeatureFlag
= Record
[4]
653 if self
.AutoGenVersion
< 0x00010005:
654 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
655 Macros
['PROCESSOR'] = self
._Arch
656 SourceFile
= NormPath(Record
[0], Macros
)
657 if SourceFile
[0] == os
.path
.sep
:
658 SourceFile
= mws
.join(GlobalData
.gWorkspace
, SourceFile
[1:])
659 # old module source files (Edk)
660 File
= PathClass(SourceFile
, self
._ModuleDir
, self
._SourceOverridePath
,
661 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
662 # check the file validation
663 ErrorCode
, ErrorInfo
= File
.Validate(CaseSensitive
=False)
665 if File
.Ext
.lower() == '.h':
666 EdkLogger
.warn('build', 'Include file not found', ExtraData
=ErrorInfo
,
667 File
=self
.MetaFile
, Line
=LineNo
)
670 EdkLogger
.error('build', ErrorCode
, ExtraData
=File
, File
=self
.MetaFile
, Line
=LineNo
)
672 File
= PathClass(NormPath(Record
[0], Macros
), self
._ModuleDir
, '',
673 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
674 # check the file validation
675 ErrorCode
, ErrorInfo
= File
.Validate()
677 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
679 self
._Sources
.append(File
)
682 ## Retrieve library classes employed by this module
683 def _GetLibraryClassUses(self
):
684 if self
._LibraryClasses
is None:
685 self
._LibraryClasses
= OrderedDict()
686 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, self
._Platform
]
687 for Record
in RecordList
:
691 Instance
= NormPath(Instance
, self
._Macros
)
692 self
._LibraryClasses
[Lib
] = Instance
693 return self
._LibraryClasses
695 ## Retrieve library names (for Edk.x style of modules)
696 def _GetLibraryNames(self
):
697 if self
._Libraries
is None:
699 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
, self
._Platform
]
700 for Record
in RecordList
:
701 LibraryName
= ReplaceMacro(Record
[0], self
._Macros
, False)
702 # in case of name with '.lib' extension, which is unusual in Edk.x inf
703 LibraryName
= os
.path
.splitext(LibraryName
)[0]
704 if LibraryName
not in self
._Libraries
:
705 self
._Libraries
.append(LibraryName
)
706 return self
._Libraries
708 def _GetProtocolComments(self
):
710 return self
._ProtocolComments
711 ## Retrieve protocols consumed/produced by this module
712 def _GetProtocols(self
):
713 if self
._Protocols
is None:
714 self
._Protocols
= OrderedDict()
715 self
._ProtocolComments
= OrderedDict()
716 RecordList
= self
._RawData
[MODEL_EFI_PROTOCOL
, self
._Arch
, self
._Platform
]
717 for Record
in RecordList
:
719 Value
= ProtocolValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
721 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
722 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
723 "Value of Protocol [%s] is not found under [Protocols] section in" % CName
,
724 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
725 self
._Protocols
[CName
] = Value
726 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
728 for CmtRec
in CommentRecords
:
729 Comments
.append(CmtRec
[0])
730 self
._ProtocolComments
[CName
] = Comments
731 return self
._Protocols
733 def _GetPpiComments(self
):
735 return self
._PpiComments
736 ## Retrieve PPIs consumed/produced by this module
738 if self
._Ppis
is None:
739 self
._Ppis
= OrderedDict()
740 self
._PpiComments
= OrderedDict()
741 RecordList
= self
._RawData
[MODEL_EFI_PPI
, self
._Arch
, self
._Platform
]
742 for Record
in RecordList
:
744 Value
= PpiValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
746 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
747 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
748 "Value of PPI [%s] is not found under [Ppis] section in " % CName
,
749 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
750 self
._Ppis
[CName
] = Value
751 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
753 for CmtRec
in CommentRecords
:
754 Comments
.append(CmtRec
[0])
755 self
._PpiComments
[CName
] = Comments
758 def _GetGuidComments(self
):
760 return self
._GuidComments
761 ## Retrieve GUIDs consumed/produced by this module
763 if self
._Guids
is None:
764 self
._Guids
= OrderedDict()
765 self
._GuidComments
= OrderedDict()
766 RecordList
= self
._RawData
[MODEL_EFI_GUID
, self
._Arch
, self
._Platform
]
767 for Record
in RecordList
:
769 Value
= GuidValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
771 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
772 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
773 "Value of Guid [%s] is not found under [Guids] section in" % CName
,
774 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
775 self
._Guids
[CName
] = Value
776 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
778 for CmtRec
in CommentRecords
:
779 Comments
.append(CmtRec
[0])
780 self
._GuidComments
[CName
] = Comments
783 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
784 def _GetIncludes(self
):
785 if self
._Includes
is None:
787 if self
._SourceOverridePath
:
788 self
._Includes
.append(self
._SourceOverridePath
)
790 Macros
= self
._Macros
791 Macros
['PROCESSOR'] = GlobalData
.gEdkGlobal
.get('PROCESSOR', self
._Arch
)
792 RecordList
= self
._RawData
[MODEL_EFI_INCLUDE
, self
._Arch
, self
._Platform
]
793 for Record
in RecordList
:
794 if Record
[0].find('EDK_SOURCE') > -1:
795 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
796 File
= NormPath(Record
[0], self
._Macros
)
798 File
= os
.path
.join(self
._ModuleDir
, File
)
800 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
801 File
= RealPath(os
.path
.normpath(File
))
803 self
._Includes
.append(File
)
805 # TRICK: let compiler to choose correct header file
806 Macros
['EDK_SOURCE'] = GlobalData
.gEdkSource
807 File
= NormPath(Record
[0], self
._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
)
816 File
= NormPath(Record
[0], Macros
)
818 File
= os
.path
.join(self
._ModuleDir
, File
)
820 File
= mws
.join(GlobalData
.gWorkspace
, File
)
821 File
= RealPath(os
.path
.normpath(File
))
823 self
._Includes
.append(File
)
824 if not File
and Record
[0].find('EFI_SOURCE') > -1:
825 # tricky to regard WorkSpace as EFI_SOURCE
826 Macros
['EFI_SOURCE'] = GlobalData
.gWorkspace
827 File
= NormPath(Record
[0], Macros
)
829 File
= os
.path
.join(self
._ModuleDir
, File
)
831 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
832 File
= RealPath(os
.path
.normpath(File
))
834 self
._Includes
.append(File
)
835 return self
._Includes
837 ## Retrieve packages this module depends on
838 def _GetPackages(self
):
839 if self
._Packages
is None:
841 RecordList
= self
._RawData
[MODEL_META_DATA_PACKAGE
, self
._Arch
, self
._Platform
]
842 Macros
= self
._Macros
843 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
844 for Record
in RecordList
:
845 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
847 # check the file validation
848 ErrorCode
, ErrorInfo
= File
.Validate('.dec')
850 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
851 # parse this package now. we need it to get protocol/ppi/guid value
852 Package
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
853 self
._Packages
.append(Package
)
854 return self
._Packages
856 ## Retrieve PCD comments
857 def _GetPcdComments(self
):
859 return self
._PcdComments
860 ## Retrieve PCDs used in this module
862 if self
._Pcds
is None:
863 self
._Pcds
= OrderedDict()
864 self
._PcdComments
= OrderedDict()
865 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
866 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
867 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
868 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC
))
869 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC_EX
))
872 ## Retrieve build options specific to this module
873 def _GetBuildOptions(self
):
874 if self
._BuildOptions
is None:
875 self
._BuildOptions
= OrderedDict()
876 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, self
._Platform
]
877 for Record
in RecordList
:
878 ToolChainFamily
= Record
[0]
879 ToolChain
= Record
[1]
881 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
or Option
.startswith('='):
882 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Option
884 # concatenate the option string if they're for the same tool
885 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
886 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
887 return self
._BuildOptions
889 ## Retrieve dependency expression
891 if self
._Depex
is None:
892 self
._Depex
= tdict(False, 2)
893 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
895 # If the module has only Binaries and no Sources, then ignore [Depex]
896 if self
.Sources
is None or self
.Sources
== []:
897 if self
.Binaries
is not None and self
.Binaries
!= []:
900 # PEIM and DXE drivers must have a valid [Depex] section
901 if len(self
.LibraryClass
) == 0 and len(RecordList
) == 0:
902 if self
.ModuleType
== 'DXE_DRIVER' or self
.ModuleType
== 'PEIM' or self
.ModuleType
== 'DXE_SMM_DRIVER' or \
903 self
.ModuleType
== 'DXE_SAL_DRIVER' or self
.ModuleType
== 'DXE_RUNTIME_DRIVER':
904 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
905 % self
.ModuleType
, File
=self
.MetaFile
)
907 if len(RecordList
) != 0 and self
.ModuleType
== 'USER_DEFINED':
908 for Record
in RecordList
:
909 if Record
[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']:
910 EdkLogger
.error('build', FORMAT_INVALID
,
911 "'%s' module must specify the type of [Depex] section" % self
.ModuleType
,
914 Depex
= OrderedDict()
915 for Record
in RecordList
:
916 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
918 ModuleType
= Record
[4]
919 TokenList
= DepexStr
.split()
920 if (Arch
, ModuleType
) not in Depex
:
921 Depex
[Arch
, ModuleType
] = []
922 DepexList
= Depex
[Arch
, ModuleType
]
923 for Token
in TokenList
:
924 if Token
in DEPEX_SUPPORTED_OPCODE
:
925 DepexList
.append(Token
)
926 elif Token
.endswith(".inf"): # module file name
927 ModuleFile
= os
.path
.normpath(Token
)
928 Module
= self
.BuildDatabase
[ModuleFile
]
930 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "Module is not found in active platform",
931 ExtraData
=Token
, File
=self
.MetaFile
, Line
=Record
[-1])
932 DepexList
.append(Module
.Guid
)
934 # get the GUID value now
935 Value
= ProtocolValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
937 Value
= PpiValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
939 Value
= GuidValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
941 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
942 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
943 "Value of [%s] is not found in" % Token
,
944 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
945 DepexList
.append(Value
)
946 for Arch
, ModuleType
in Depex
:
947 self
._Depex
[Arch
, ModuleType
] = Depex
[Arch
, ModuleType
]
950 ## Retrieve depedency expression
951 def _GetDepexExpression(self
):
952 if self
._DepexExpression
is None:
953 self
._DepexExpression
= tdict(False, 2)
954 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
955 DepexExpression
= OrderedDict()
956 for Record
in RecordList
:
957 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
959 ModuleType
= Record
[4]
960 TokenList
= DepexStr
.split()
961 if (Arch
, ModuleType
) not in DepexExpression
:
962 DepexExpression
[Arch
, ModuleType
] = ''
963 for Token
in TokenList
:
964 DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
] + Token
.strip() + ' '
965 for Arch
, ModuleType
in DepexExpression
:
966 self
._DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
]
967 return self
._DepexExpression
969 def GetGuidsUsedByPcd(self
):
970 return self
._GuidsUsedByPcd
971 ## Retrieve PCD for given type
972 def _GetPcd(self
, Type
):
974 PcdDict
= tdict(True, 4)
976 RecordList
= self
._RawData
[Type
, self
._Arch
, self
._Platform
]
977 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, Platform
, Id
, LineNo
in RecordList
:
978 PcdDict
[Arch
, Platform
, PcdCName
, TokenSpaceGuid
] = (Setting
, LineNo
)
979 PcdList
.append((PcdCName
, TokenSpaceGuid
))
981 if TokenSpaceGuid
not in self
.Guids
:
982 Value
= GuidValue(TokenSpaceGuid
, self
.Packages
, self
.MetaFile
.Path
)
984 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
985 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
986 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid
,
987 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=LineNo
)
988 self
.Guids
[TokenSpaceGuid
] = Value
989 self
._GuidsUsedByPcd
[TokenSpaceGuid
] = Value
990 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Id
]
992 for CmtRec
in CommentRecords
:
993 Comments
.append(CmtRec
[0])
994 self
._PcdComments
[TokenSpaceGuid
, PcdCName
] = Comments
996 # resolve PCD type, value, datum info, etc. by getting its definition from package
997 _GuidDict
= self
.Guids
.copy()
998 for PcdCName
, TokenSpaceGuid
in PcdList
:
999 PcdRealName
= PcdCName
1000 Setting
, LineNo
= PcdDict
[self
._Arch
, self
.Platform
, PcdCName
, TokenSpaceGuid
]
1003 ValueList
= AnalyzePcdData(Setting
)
1004 DefaultValue
= ValueList
[0]
1005 Pcd
= PcdClassObject(
1015 self
.Guids
[TokenSpaceGuid
]
1017 if Type
== MODEL_PCD_PATCHABLE_IN_MODULE
and ValueList
[1]:
1018 # Patch PCD: TokenSpace.PcdCName|Value|Offset
1019 Pcd
.Offset
= ValueList
[1]
1021 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1022 for Package
in self
.Packages
:
1023 for key
in Package
.Pcds
:
1024 if (Package
.Pcds
[key
].TokenCName
, Package
.Pcds
[key
].TokenSpaceGuidCName
) == (PcdRealName
, TokenSpaceGuid
):
1025 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1026 Pcd_Type
= item
[0].split('_')[-1]
1027 if Pcd_Type
== Package
.Pcds
[key
].Type
:
1028 Value
= Package
.Pcds
[key
]
1029 Value
.TokenCName
= Package
.Pcds
[key
].TokenCName
+ '_' + Pcd_Type
1031 newkey
= (Value
.TokenCName
, key
[1])
1033 newkey
= (Value
.TokenCName
, key
[1], key
[2])
1034 del Package
.Pcds
[key
]
1035 Package
.Pcds
[newkey
] = Value
1042 # get necessary info from package declaring this PCD
1043 for Package
in self
.Packages
:
1045 # 'dynamic' in INF means its type is determined by platform;
1046 # if platform doesn't give its type, use 'lowest' one in the
1047 # following order, if any
1049 # "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
1051 _GuidDict
.update(Package
.Guids
)
1052 PcdType
= self
._PCD
_TYPE
_STRING
_[Type
]
1053 if Type
== MODEL_PCD_DYNAMIC
:
1055 for T
in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
1056 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1057 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1058 if str(item
[0]).endswith(T
) and (item
[0], item
[1], T
) in Package
.Pcds
:
1066 if (PcdRealName
, TokenSpaceGuid
, T
) in Package
.Pcds
:
1072 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1073 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1074 Pcd_Type
= item
[0].split('_')[-1]
1075 if Pcd_Type
== PcdType
:
1083 if (PcdCName
, TokenSpaceGuid
, PcdType
) in Package
.Pcds
:
1084 PcdInPackage
= Package
.Pcds
[PcdCName
, TokenSpaceGuid
, PcdType
]
1086 Pcd
.TokenValue
= PcdInPackage
.TokenValue
1089 # Check whether the token value exist or not.
1091 if Pcd
.TokenValue
is None or Pcd
.TokenValue
== "":
1095 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid
, PcdRealName
, str(Package
)),
1096 File
=self
.MetaFile
, Line
=LineNo
,
1100 # Check hexadecimal token value length and format.
1102 ReIsValidPcdTokenValue
= re
.compile(r
"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re
.DOTALL
)
1103 if Pcd
.TokenValue
.startswith("0x") or Pcd
.TokenValue
.startswith("0X"):
1104 if ReIsValidPcdTokenValue
.match(Pcd
.TokenValue
) is None:
1108 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd
.TokenValue
, TokenSpaceGuid
, PcdRealName
, str(Package
)),
1109 File
=self
.MetaFile
, Line
=LineNo
,
1114 # Check decimal token value length and format.
1118 TokenValueInt
= int (Pcd
.TokenValue
, 10)
1119 if (TokenValueInt
< 0 or TokenValueInt
> 4294967295):
1123 "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
)),
1124 File
=self
.MetaFile
, Line
=LineNo
,
1131 "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
)),
1132 File
=self
.MetaFile
, Line
=LineNo
,
1136 Pcd
.DatumType
= PcdInPackage
.DatumType
1137 Pcd
.MaxDatumSize
= PcdInPackage
.MaxDatumSize
1138 Pcd
.InfDefaultValue
= Pcd
.DefaultValue
1139 if Pcd
.DefaultValue
in [None, '']:
1140 Pcd
.DefaultValue
= PcdInPackage
.DefaultValue
1143 Pcd
.DefaultValue
= ValueExpressionEx(Pcd
.DefaultValue
, Pcd
.DatumType
, _GuidDict
)(True)
1144 except BadExpression
, Value
:
1145 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid
, PcdRealName
, Pcd
.DefaultValue
, Value
),
1146 File
=self
.MetaFile
, Line
=LineNo
)
1152 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid
, PcdRealName
, self
.MetaFile
),
1153 File
=self
.MetaFile
, Line
=LineNo
,
1154 ExtraData
="\t%s" % '\n\t'.join([str(P
) for P
in self
.Packages
])
1156 Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
1160 ## check whether current module is binary module
1161 def _IsBinaryModule(self
):
1162 if self
.Binaries
and not self
.Sources
:
1164 elif GlobalData
.gIgnoreSource
:
1169 _Macros
= property(_GetMacros
)
1170 Arch
= property(_GetArch
, _SetArch
)
1171 Platform
= property(_GetPlatform
, _SetPlatform
)
1173 HeaderComments
= property(_GetHeaderComments
)
1174 TailComments
= property(_GetTailComments
)
1175 AutoGenVersion
= property(_GetInfVersion
)
1176 BaseName
= property(_GetBaseName
)
1177 ModuleType
= property(_GetModuleType
)
1178 ComponentType
= property(_GetComponentType
)
1179 BuildType
= property(_GetBuildType
)
1180 Guid
= property(_GetFileGuid
)
1181 Version
= property(_GetVersion
)
1182 PcdIsDriver
= property(_GetPcdIsDriver
)
1183 Shadow
= property(_GetShadow
)
1184 CustomMakefile
= property(_GetMakefile
)
1185 Specification
= property(_GetSpec
)
1186 LibraryClass
= property(_GetLibraryClass
)
1187 ModuleEntryPointList
= property(_GetEntryPoint
)
1188 ModuleUnloadImageList
= property(_GetUnloadImage
)
1189 ConstructorList
= property(_GetConstructor
)
1190 DestructorList
= property(_GetDestructor
)
1191 Defines
= property(_GetDefines
)
1192 DxsFile
= property(_GetDxsFile
)
1194 Binaries
= property(_GetBinaryFiles
)
1195 Sources
= property(_GetSourceFiles
)
1196 LibraryClasses
= property(_GetLibraryClassUses
)
1197 Libraries
= property(_GetLibraryNames
)
1198 Protocols
= property(_GetProtocols
)
1199 ProtocolComments
= property(_GetProtocolComments
)
1200 Ppis
= property(_GetPpis
)
1201 PpiComments
= property(_GetPpiComments
)
1202 Guids
= property(_GetGuids
)
1203 GuidComments
= property(_GetGuidComments
)
1204 Includes
= property(_GetIncludes
)
1205 Packages
= property(_GetPackages
)
1206 Pcds
= property(_GetPcds
)
1207 PcdComments
= property(_GetPcdComments
)
1208 BuildOptions
= property(_GetBuildOptions
)
1209 Depex
= property(_GetDepex
)
1210 DepexExpression
= property(_GetDepexExpression
)
1211 IsBinaryModule
= property(_IsBinaryModule
)
1212 IsSupportedArch
= property(_IsSupportedArch
)