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 if 'PROCESSOR' in GlobalData
.gEdkGlobal
.keys():
792 Macros
['PROCESSOR'] = GlobalData
.gEdkGlobal
['PROCESSOR']
794 Macros
['PROCESSOR'] = self
._Arch
795 RecordList
= self
._RawData
[MODEL_EFI_INCLUDE
, self
._Arch
, self
._Platform
]
796 for Record
in RecordList
:
797 if Record
[0].find('EDK_SOURCE') > -1:
798 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
799 File
= NormPath(Record
[0], self
._Macros
)
801 File
= os
.path
.join(self
._ModuleDir
, File
)
803 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
804 File
= RealPath(os
.path
.normpath(File
))
806 self
._Includes
.append(File
)
808 # TRICK: let compiler to choose correct header file
809 Macros
['EDK_SOURCE'] = GlobalData
.gEdkSource
810 File
= NormPath(Record
[0], self
._Macros
)
812 File
= os
.path
.join(self
._ModuleDir
, File
)
814 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
815 File
= RealPath(os
.path
.normpath(File
))
817 self
._Includes
.append(File
)
819 File
= NormPath(Record
[0], Macros
)
821 File
= os
.path
.join(self
._ModuleDir
, File
)
823 File
= mws
.join(GlobalData
.gWorkspace
, File
)
824 File
= RealPath(os
.path
.normpath(File
))
826 self
._Includes
.append(File
)
827 if not File
and Record
[0].find('EFI_SOURCE') > -1:
828 # tricky to regard WorkSpace as EFI_SOURCE
829 Macros
['EFI_SOURCE'] = GlobalData
.gWorkspace
830 File
= NormPath(Record
[0], Macros
)
832 File
= os
.path
.join(self
._ModuleDir
, File
)
834 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
835 File
= RealPath(os
.path
.normpath(File
))
837 self
._Includes
.append(File
)
838 return self
._Includes
840 ## Retrieve packages this module depends on
841 def _GetPackages(self
):
842 if self
._Packages
is None:
844 RecordList
= self
._RawData
[MODEL_META_DATA_PACKAGE
, self
._Arch
, self
._Platform
]
845 Macros
= self
._Macros
846 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
847 for Record
in RecordList
:
848 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
850 # check the file validation
851 ErrorCode
, ErrorInfo
= File
.Validate('.dec')
853 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
854 # parse this package now. we need it to get protocol/ppi/guid value
855 Package
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
856 self
._Packages
.append(Package
)
857 return self
._Packages
859 ## Retrieve PCD comments
860 def _GetPcdComments(self
):
862 return self
._PcdComments
863 ## Retrieve PCDs used in this module
865 if self
._Pcds
is None:
866 self
._Pcds
= OrderedDict()
867 self
._PcdComments
= OrderedDict()
868 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
869 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
870 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
871 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC
))
872 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC_EX
))
875 ## Retrieve build options specific to this module
876 def _GetBuildOptions(self
):
877 if self
._BuildOptions
is None:
878 self
._BuildOptions
= OrderedDict()
879 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, self
._Platform
]
880 for Record
in RecordList
:
881 ToolChainFamily
= Record
[0]
882 ToolChain
= Record
[1]
884 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
or Option
.startswith('='):
885 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Option
887 # concatenate the option string if they're for the same tool
888 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
889 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
890 return self
._BuildOptions
892 ## Retrieve dependency expression
894 if self
._Depex
is None:
895 self
._Depex
= tdict(False, 2)
896 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
898 # If the module has only Binaries and no Sources, then ignore [Depex]
899 if self
.Sources
is None or self
.Sources
== []:
900 if self
.Binaries
is not None and self
.Binaries
!= []:
903 # PEIM and DXE drivers must have a valid [Depex] section
904 if len(self
.LibraryClass
) == 0 and len(RecordList
) == 0:
905 if self
.ModuleType
== 'DXE_DRIVER' or self
.ModuleType
== 'PEIM' or self
.ModuleType
== 'DXE_SMM_DRIVER' or \
906 self
.ModuleType
== 'DXE_SAL_DRIVER' or self
.ModuleType
== 'DXE_RUNTIME_DRIVER':
907 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
908 % self
.ModuleType
, File
=self
.MetaFile
)
910 if len(RecordList
) != 0 and self
.ModuleType
== 'USER_DEFINED':
911 for Record
in RecordList
:
912 if Record
[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']:
913 EdkLogger
.error('build', FORMAT_INVALID
,
914 "'%s' module must specify the type of [Depex] section" % self
.ModuleType
,
917 Depex
= OrderedDict()
918 for Record
in RecordList
:
919 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
921 ModuleType
= Record
[4]
922 TokenList
= DepexStr
.split()
923 if (Arch
, ModuleType
) not in Depex
:
924 Depex
[Arch
, ModuleType
] = []
925 DepexList
= Depex
[Arch
, ModuleType
]
926 for Token
in TokenList
:
927 if Token
in DEPEX_SUPPORTED_OPCODE
:
928 DepexList
.append(Token
)
929 elif Token
.endswith(".inf"): # module file name
930 ModuleFile
= os
.path
.normpath(Token
)
931 Module
= self
.BuildDatabase
[ModuleFile
]
933 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "Module is not found in active platform",
934 ExtraData
=Token
, File
=self
.MetaFile
, Line
=Record
[-1])
935 DepexList
.append(Module
.Guid
)
937 # get the GUID value now
938 Value
= ProtocolValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
940 Value
= PpiValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
942 Value
= GuidValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
944 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
945 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
946 "Value of [%s] is not found in" % Token
,
947 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
948 DepexList
.append(Value
)
949 for Arch
, ModuleType
in Depex
:
950 self
._Depex
[Arch
, ModuleType
] = Depex
[Arch
, ModuleType
]
953 ## Retrieve depedency expression
954 def _GetDepexExpression(self
):
955 if self
._DepexExpression
is None:
956 self
._DepexExpression
= tdict(False, 2)
957 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
958 DepexExpression
= OrderedDict()
959 for Record
in RecordList
:
960 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
962 ModuleType
= Record
[4]
963 TokenList
= DepexStr
.split()
964 if (Arch
, ModuleType
) not in DepexExpression
:
965 DepexExpression
[Arch
, ModuleType
] = ''
966 for Token
in TokenList
:
967 DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
] + Token
.strip() + ' '
968 for Arch
, ModuleType
in DepexExpression
:
969 self
._DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
]
970 return self
._DepexExpression
972 def GetGuidsUsedByPcd(self
):
973 return self
._GuidsUsedByPcd
974 ## Retrieve PCD for given type
975 def _GetPcd(self
, Type
):
977 PcdDict
= tdict(True, 4)
979 RecordList
= self
._RawData
[Type
, self
._Arch
, self
._Platform
]
980 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, Platform
, Id
, LineNo
in RecordList
:
981 PcdDict
[Arch
, Platform
, PcdCName
, TokenSpaceGuid
] = (Setting
, LineNo
)
982 PcdList
.append((PcdCName
, TokenSpaceGuid
))
984 if TokenSpaceGuid
not in self
.Guids
:
985 Value
= GuidValue(TokenSpaceGuid
, self
.Packages
, self
.MetaFile
.Path
)
987 PackageList
= "\n\t".join([str(P
) for P
in self
.Packages
])
988 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
989 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid
,
990 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=LineNo
)
991 self
.Guids
[TokenSpaceGuid
] = Value
992 self
._GuidsUsedByPcd
[TokenSpaceGuid
] = Value
993 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Id
]
995 for CmtRec
in CommentRecords
:
996 Comments
.append(CmtRec
[0])
997 self
._PcdComments
[TokenSpaceGuid
, PcdCName
] = Comments
999 # resolve PCD type, value, datum info, etc. by getting its definition from package
1000 _GuidDict
= self
.Guids
.copy()
1001 for PcdCName
, TokenSpaceGuid
in PcdList
:
1002 PcdRealName
= PcdCName
1003 Setting
, LineNo
= PcdDict
[self
._Arch
, self
.Platform
, PcdCName
, TokenSpaceGuid
]
1006 ValueList
= AnalyzePcdData(Setting
)
1007 DefaultValue
= ValueList
[0]
1008 Pcd
= PcdClassObject(
1018 self
.Guids
[TokenSpaceGuid
]
1020 if Type
== MODEL_PCD_PATCHABLE_IN_MODULE
and ValueList
[1]:
1021 # Patch PCD: TokenSpace.PcdCName|Value|Offset
1022 Pcd
.Offset
= ValueList
[1]
1024 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1025 for Package
in self
.Packages
:
1026 for key
in Package
.Pcds
:
1027 if (Package
.Pcds
[key
].TokenCName
, Package
.Pcds
[key
].TokenSpaceGuidCName
) == (PcdRealName
, TokenSpaceGuid
):
1028 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1029 Pcd_Type
= item
[0].split('_')[-1]
1030 if Pcd_Type
== Package
.Pcds
[key
].Type
:
1031 Value
= Package
.Pcds
[key
]
1032 Value
.TokenCName
= Package
.Pcds
[key
].TokenCName
+ '_' + Pcd_Type
1034 newkey
= (Value
.TokenCName
, key
[1])
1036 newkey
= (Value
.TokenCName
, key
[1], key
[2])
1037 del Package
.Pcds
[key
]
1038 Package
.Pcds
[newkey
] = Value
1045 # get necessary info from package declaring this PCD
1046 for Package
in self
.Packages
:
1048 # 'dynamic' in INF means its type is determined by platform;
1049 # if platform doesn't give its type, use 'lowest' one in the
1050 # following order, if any
1052 # "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
1054 _GuidDict
.update(Package
.Guids
)
1055 PcdType
= self
._PCD
_TYPE
_STRING
_[Type
]
1056 if Type
== MODEL_PCD_DYNAMIC
:
1058 for T
in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
1059 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1060 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1061 if str(item
[0]).endswith(T
) and (item
[0], item
[1], T
) in Package
.Pcds
:
1069 if (PcdRealName
, TokenSpaceGuid
, T
) in Package
.Pcds
:
1075 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1076 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1077 Pcd_Type
= item
[0].split('_')[-1]
1078 if Pcd_Type
== PcdType
:
1086 if (PcdCName
, TokenSpaceGuid
, PcdType
) in Package
.Pcds
:
1087 PcdInPackage
= Package
.Pcds
[PcdCName
, TokenSpaceGuid
, PcdType
]
1089 Pcd
.TokenValue
= PcdInPackage
.TokenValue
1092 # Check whether the token value exist or not.
1094 if Pcd
.TokenValue
is None or Pcd
.TokenValue
== "":
1098 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid
, PcdRealName
, str(Package
)),
1099 File
=self
.MetaFile
, Line
=LineNo
,
1103 # Check hexadecimal token value length and format.
1105 ReIsValidPcdTokenValue
= re
.compile(r
"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re
.DOTALL
)
1106 if Pcd
.TokenValue
.startswith("0x") or Pcd
.TokenValue
.startswith("0X"):
1107 if ReIsValidPcdTokenValue
.match(Pcd
.TokenValue
) is None:
1111 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd
.TokenValue
, TokenSpaceGuid
, PcdRealName
, str(Package
)),
1112 File
=self
.MetaFile
, Line
=LineNo
,
1117 # Check decimal token value length and format.
1121 TokenValueInt
= int (Pcd
.TokenValue
, 10)
1122 if (TokenValueInt
< 0 or TokenValueInt
> 4294967295):
1126 "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
)),
1127 File
=self
.MetaFile
, Line
=LineNo
,
1134 "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
)),
1135 File
=self
.MetaFile
, Line
=LineNo
,
1139 Pcd
.DatumType
= PcdInPackage
.DatumType
1140 Pcd
.MaxDatumSize
= PcdInPackage
.MaxDatumSize
1141 Pcd
.InfDefaultValue
= Pcd
.DefaultValue
1142 if Pcd
.DefaultValue
in [None, '']:
1143 Pcd
.DefaultValue
= PcdInPackage
.DefaultValue
1146 Pcd
.DefaultValue
= ValueExpressionEx(Pcd
.DefaultValue
, Pcd
.DatumType
, _GuidDict
)(True)
1147 except BadExpression
, Value
:
1148 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid
, PcdRealName
, Pcd
.DefaultValue
, Value
),
1149 File
=self
.MetaFile
, Line
=LineNo
)
1155 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid
, PcdRealName
, self
.MetaFile
),
1156 File
=self
.MetaFile
, Line
=LineNo
,
1157 ExtraData
="\t%s" % '\n\t'.join([str(P
) for P
in self
.Packages
])
1159 Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
1163 ## check whether current module is binary module
1164 def _IsBinaryModule(self
):
1165 if self
.Binaries
and not self
.Sources
:
1167 elif GlobalData
.gIgnoreSource
:
1172 _Macros
= property(_GetMacros
)
1173 Arch
= property(_GetArch
, _SetArch
)
1174 Platform
= property(_GetPlatform
, _SetPlatform
)
1176 HeaderComments
= property(_GetHeaderComments
)
1177 TailComments
= property(_GetTailComments
)
1178 AutoGenVersion
= property(_GetInfVersion
)
1179 BaseName
= property(_GetBaseName
)
1180 ModuleType
= property(_GetModuleType
)
1181 ComponentType
= property(_GetComponentType
)
1182 BuildType
= property(_GetBuildType
)
1183 Guid
= property(_GetFileGuid
)
1184 Version
= property(_GetVersion
)
1185 PcdIsDriver
= property(_GetPcdIsDriver
)
1186 Shadow
= property(_GetShadow
)
1187 CustomMakefile
= property(_GetMakefile
)
1188 Specification
= property(_GetSpec
)
1189 LibraryClass
= property(_GetLibraryClass
)
1190 ModuleEntryPointList
= property(_GetEntryPoint
)
1191 ModuleUnloadImageList
= property(_GetUnloadImage
)
1192 ConstructorList
= property(_GetConstructor
)
1193 DestructorList
= property(_GetDestructor
)
1194 Defines
= property(_GetDefines
)
1195 DxsFile
= property(_GetDxsFile
)
1197 Binaries
= property(_GetBinaryFiles
)
1198 Sources
= property(_GetSourceFiles
)
1199 LibraryClasses
= property(_GetLibraryClassUses
)
1200 Libraries
= property(_GetLibraryNames
)
1201 Protocols
= property(_GetProtocols
)
1202 ProtocolComments
= property(_GetProtocolComments
)
1203 Ppis
= property(_GetPpis
)
1204 PpiComments
= property(_GetPpiComments
)
1205 Guids
= property(_GetGuids
)
1206 GuidComments
= property(_GetGuidComments
)
1207 Includes
= property(_GetIncludes
)
1208 Packages
= property(_GetPackages
)
1209 Pcds
= property(_GetPcds
)
1210 PcdComments
= property(_GetPcdComments
)
1211 BuildOptions
= property(_GetBuildOptions
)
1212 Depex
= property(_GetDepex
)
1213 DepexExpression
= property(_GetDepexExpression
)
1214 IsBinaryModule
= property(_IsBinaryModule
)
1215 IsSupportedArch
= property(_IsSupportedArch
)