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
)
176 ## Return the name of platform employing this module
177 def _GetPlatform(self
):
178 return self
._Platform
180 def _GetHeaderComments(self
):
181 if not self
._HeaderComments
:
182 self
._HeaderComments
= []
183 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER_COMMENT
]
184 for Record
in RecordList
:
185 self
._HeaderComments
.append(Record
[0])
186 return self
._HeaderComments
187 def _GetTailComments(self
):
188 if not self
._TailComments
:
189 self
._TailComments
= []
190 RecordList
= self
._RawData
[MODEL_META_DATA_TAIL_COMMENT
]
191 for Record
in RecordList
:
192 self
._TailComments
.append(Record
[0])
193 return self
._TailComments
194 ## Retrieve all information in [Defines] section
196 # (Retriving all [Defines] information in one-shot is just to save time.)
198 def _GetHeaderInfo(self
):
199 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
200 for Record
in RecordList
:
201 Name
, Value
= Record
[1], ReplaceMacro(Record
[2], self
._Macros
, False)
202 # items defined _PROPERTY_ don't need additional processing
205 self
._Defs
[Name
] = Value
206 self
._Macros
[Name
] = Value
207 # some special items in [Defines] section need special treatment
208 elif Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
209 if Name
in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
210 Name
= 'UEFI_SPECIFICATION_VERSION'
211 if self
._Specification
is None:
212 self
._Specification
= OrderedDict()
213 self
._Specification
[Name
] = GetHexVerValue(Value
)
214 if self
._Specification
[Name
] is None:
215 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
216 "'%s' format is not supported for %s" % (Value
, Name
),
217 File
=self
.MetaFile
, Line
=Record
[-1])
218 elif Name
== 'LIBRARY_CLASS':
219 if self
._LibraryClass
is None:
220 self
._LibraryClass
= []
221 ValueList
= GetSplitValueList(Value
)
222 LibraryClass
= ValueList
[0]
223 if len(ValueList
) > 1:
224 SupModuleList
= GetSplitValueList(ValueList
[1], ' ')
226 SupModuleList
= SUP_MODULE_LIST
227 self
._LibraryClass
.append(LibraryClassObject(LibraryClass
, SupModuleList
))
228 elif Name
== 'ENTRY_POINT':
229 if self
._ModuleEntryPointList
is None:
230 self
._ModuleEntryPointList
= []
231 self
._ModuleEntryPointList
.append(Value
)
232 elif Name
== 'UNLOAD_IMAGE':
233 if self
._ModuleUnloadImageList
is None:
234 self
._ModuleUnloadImageList
= []
237 self
._ModuleUnloadImageList
.append(Value
)
238 elif Name
== 'CONSTRUCTOR':
239 if self
._ConstructorList
is None:
240 self
._ConstructorList
= []
243 self
._ConstructorList
.append(Value
)
244 elif Name
== 'DESTRUCTOR':
245 if self
._DestructorList
is None:
246 self
._DestructorList
= []
249 self
._DestructorList
.append(Value
)
250 elif Name
== TAB_INF_DEFINES_CUSTOM_MAKEFILE
:
251 TokenList
= GetSplitValueList(Value
)
252 if self
._CustomMakefile
is None:
253 self
._CustomMakefile
= {}
254 if len(TokenList
) < 2:
255 self
._CustomMakefile
[TAB_COMPILER_MSFT
] = TokenList
[0]
256 self
._CustomMakefile
['GCC'] = TokenList
[0]
258 if TokenList
[0] not in [TAB_COMPILER_MSFT
, 'GCC']:
259 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
260 "No supported family [%s]" % TokenList
[0],
261 File
=self
.MetaFile
, Line
=Record
[-1])
262 self
._CustomMakefile
[TokenList
[0]] = TokenList
[1]
264 self
._Defs
[Name
] = Value
265 self
._Macros
[Name
] = Value
268 # Retrieve information in sections specific to Edk.x modules
270 if self
.AutoGenVersion
>= 0x00010005:
271 if not self
._ModuleType
:
272 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
273 "MODULE_TYPE is not given", File
=self
.MetaFile
)
274 if self
._ModuleType
not in SUP_MODULE_LIST
:
275 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
276 for Record
in RecordList
:
278 if Name
== "MODULE_TYPE":
281 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
,
282 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self
._ModuleType
, ' '.join(l
for l
in SUP_MODULE_LIST
)),
283 File
=self
.MetaFile
, Line
=LineNo
)
284 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
285 if self
._ModuleType
== SUP_MODULE_SMM_CORE
:
286 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
)
287 if (self
._Specification
is None) or (not 'PI_SPECIFICATION_VERSION' in self
._Specification
) or (int(self
._Specification
['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
288 if self
._ModuleType
== SUP_MODULE_MM_CORE_STANDALONE
:
289 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
)
290 if self
._ModuleType
== SUP_MODULE_MM_STANDALONE
:
291 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
)
292 if 'PCI_DEVICE_ID' in self
._Defs
and 'PCI_VENDOR_ID' in self
._Defs \
293 and 'PCI_CLASS_CODE' in self
._Defs
and 'PCI_REVISION' in self
._Defs
:
294 self
._BuildType
= 'UEFI_OPTIONROM'
295 if 'PCI_COMPRESS' in self
._Defs
:
296 if self
._Defs
['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
297 EdkLogger
.error("build", FORMAT_INVALID
, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self
.MetaFile
)
299 elif 'UEFI_HII_RESOURCE_SECTION' in self
._Defs \
300 and self
._Defs
['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
301 self
._BuildType
= 'UEFI_HII'
303 self
._BuildType
= self
._ModuleType
.upper()
306 File
= PathClass(NormPath(self
._DxsFile
), self
._ModuleDir
, Arch
=self
._Arch
)
307 # check the file validation
308 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
310 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
311 File
=self
.MetaFile
, Line
=LineNo
)
312 if self
.Sources
is None:
314 self
._Sources
.append(File
)
316 if not self
._ComponentType
:
317 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
318 "COMPONENT_TYPE is not given", File
=self
.MetaFile
)
319 self
._BuildType
= self
._ComponentType
.upper()
320 if self
._ComponentType
in COMPONENT_TO_MODULE_MAP_DICT
:
321 self
._ModuleType
= COMPONENT_TO_MODULE_MAP_DICT
[self
._ComponentType
]
322 if self
._ComponentType
== EDK_COMPONENT_TYPE_LIBRARY
:
323 self
._LibraryClass
= [LibraryClassObject(self
._BaseName
, SUP_MODULE_LIST
)]
324 # make use some [nmake] section macros
325 Macros
= self
._Macros
326 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
327 Macros
['PROCESSOR'] = self
._Arch
328 RecordList
= self
._RawData
[MODEL_META_DATA_NMAKE
, self
._Arch
, self
._Platform
]
329 for Name
, Value
, Dummy
, Arch
, Platform
, ID
, LineNo
in RecordList
:
330 Value
= ReplaceMacro(Value
, Macros
, True)
331 if Name
== "IMAGE_ENTRY_POINT":
332 if self
._ModuleEntryPointList
is None:
333 self
._ModuleEntryPointList
= []
334 self
._ModuleEntryPointList
.append(Value
)
335 elif Name
== "DPX_SOURCE":
336 File
= PathClass(NormPath(Value
), self
._ModuleDir
, Arch
=self
._Arch
)
337 # check the file validation
338 ErrorCode
, ErrorInfo
= File
.Validate(".dxs", CaseSensitive
=False)
340 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
,
341 File
=self
.MetaFile
, Line
=LineNo
)
342 if self
.Sources
is None:
344 self
._Sources
.append(File
)
346 ToolList
= self
._NMAKE
_FLAG
_PATTERN
_.findall(Name
)
347 if len(ToolList
) == 1:
348 if self
._BuildOptions
is None:
349 self
._BuildOptions
= OrderedDict()
351 if ToolList
[0] in self
._TOOL
_CODE
_:
352 Tool
= self
._TOOL
_CODE
_[ToolList
[0]]
355 ToolChain
= "*_*_*_%s_FLAGS" % Tool
356 # Edk.x only support MSFT tool chain
357 # ignore not replaced macros in value
358 ValueList
= GetSplitList(' ' + Value
, '/D')
360 for Index
in range(1, len(ValueList
)):
361 if ValueList
[Index
][-1] == '=' or ValueList
[Index
] == '':
363 Dummy
= Dummy
+ ' /D ' + ValueList
[Index
]
364 Value
= Dummy
.strip()
365 if (TAB_COMPILER_MSFT
, ToolChain
) not in self
._BuildOptions
:
366 self
._BuildOptions
[TAB_COMPILER_MSFT
, ToolChain
] = Value
368 OptionString
= self
._BuildOptions
[TAB_COMPILER_MSFT
, ToolChain
]
369 self
._BuildOptions
[TAB_COMPILER_MSFT
, ToolChain
] = OptionString
+ " " + Value
370 # set _Header to non-None in order to avoid database re-querying
371 self
._Header
_ = 'DUMMY'
373 ## Retrieve file version
374 def _GetInfVersion(self
):
375 if self
._AutoGenVersion
is None:
376 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, self
._Platform
]
377 for Record
in RecordList
:
378 if Record
[1] == TAB_INF_DEFINES_INF_VERSION
:
380 ValueList
= Record
[2].split('.')
381 Major
= '%04o' % int(ValueList
[0], 0)
382 Minor
= '%04o' % int(ValueList
[1], 0)
383 self
._AutoGenVersion
= int('0x' + Major
+ Minor
, 0)
385 self
._AutoGenVersion
= int(Record
[2], 0)
387 if self
._AutoGenVersion
is None:
388 self
._AutoGenVersion
= 0x00010000
389 return self
._AutoGenVersion
391 ## Retrieve BASE_NAME
392 def _GetBaseName(self
):
393 if self
._BaseName
is None:
394 if self
._Header
_ is None:
395 self
._GetHeaderInfo
()
396 if self
._BaseName
is None:
397 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BASE_NAME name", File
=self
.MetaFile
)
398 return self
._BaseName
401 def _GetDxsFile(self
):
402 if self
._DxsFile
is None:
403 if self
._Header
_ is None:
404 self
._GetHeaderInfo
()
405 if self
._DxsFile
is None:
409 ## Retrieve MODULE_TYPE
410 def _GetModuleType(self
):
411 if self
._ModuleType
is None:
412 if self
._Header
_ is None:
413 self
._GetHeaderInfo
()
414 if self
._ModuleType
is None:
415 self
._ModuleType
= SUP_MODULE_BASE
416 if self
._ModuleType
not in SUP_MODULE_LIST
:
417 self
._ModuleType
= SUP_MODULE_USER_DEFINED
418 return self
._ModuleType
420 ## Retrieve COMPONENT_TYPE
421 def _GetComponentType(self
):
422 if self
._ComponentType
is None:
423 if self
._Header
_ is None:
424 self
._GetHeaderInfo
()
425 if self
._ComponentType
is None:
426 self
._ComponentType
= SUP_MODULE_USER_DEFINED
427 return self
._ComponentType
429 ## Retrieve "BUILD_TYPE"
430 def _GetBuildType(self
):
431 if self
._BuildType
is None:
432 if self
._Header
_ is None:
433 self
._GetHeaderInfo
()
434 if not self
._BuildType
:
435 self
._BuildType
= SUP_MODULE_BASE
436 return self
._BuildType
438 ## Retrieve file guid
439 def _GetFileGuid(self
):
440 if self
._Guid
is None:
441 if self
._Header
_ is None:
442 self
._GetHeaderInfo
()
443 if self
._Guid
is None:
444 self
._Guid
= '00000000-0000-0000-0000-000000000000'
447 ## Retrieve module version
448 def _GetVersion(self
):
449 if self
._Version
is None:
450 if self
._Header
_ is None:
451 self
._GetHeaderInfo
()
452 if self
._Version
is None:
453 self
._Version
= '0.0'
456 ## Retrieve PCD_IS_DRIVER
457 def _GetPcdIsDriver(self
):
458 if self
._PcdIsDriver
is None:
459 if self
._Header
_ is None:
460 self
._GetHeaderInfo
()
461 if self
._PcdIsDriver
is None:
462 self
._PcdIsDriver
= ''
463 return self
._PcdIsDriver
466 def _GetShadow(self
):
467 if self
._Shadow
is None:
468 if self
._Header
_ is None:
469 self
._GetHeaderInfo
()
470 if self
._Shadow
is not None and self
._Shadow
.upper() == 'TRUE':
476 ## Retrieve CUSTOM_MAKEFILE
477 def _GetMakefile(self
):
478 if self
._CustomMakefile
is None:
479 if self
._Header
_ is None:
480 self
._GetHeaderInfo
()
481 if self
._CustomMakefile
is None:
482 self
._CustomMakefile
= {}
483 return self
._CustomMakefile
485 ## Retrieve EFI_SPECIFICATION_VERSION
487 if self
._Specification
is None:
488 if self
._Header
_ is None:
489 self
._GetHeaderInfo
()
490 if self
._Specification
is None:
491 self
._Specification
= {}
492 return self
._Specification
494 ## Retrieve LIBRARY_CLASS
495 def _GetLibraryClass(self
):
496 if self
._LibraryClass
is None:
497 if self
._Header
_ is None:
498 self
._GetHeaderInfo
()
499 if self
._LibraryClass
is None:
500 self
._LibraryClass
= []
501 return self
._LibraryClass
503 ## Retrieve ENTRY_POINT
504 def _GetEntryPoint(self
):
505 if self
._ModuleEntryPointList
is None:
506 if self
._Header
_ is None:
507 self
._GetHeaderInfo
()
508 if self
._ModuleEntryPointList
is None:
509 self
._ModuleEntryPointList
= []
510 return self
._ModuleEntryPointList
512 ## Retrieve UNLOAD_IMAGE
513 def _GetUnloadImage(self
):
514 if self
._ModuleUnloadImageList
is None:
515 if self
._Header
_ is None:
516 self
._GetHeaderInfo
()
517 if self
._ModuleUnloadImageList
is None:
518 self
._ModuleUnloadImageList
= []
519 return self
._ModuleUnloadImageList
521 ## Retrieve CONSTRUCTOR
522 def _GetConstructor(self
):
523 if self
._ConstructorList
is None:
524 if self
._Header
_ is None:
525 self
._GetHeaderInfo
()
526 if self
._ConstructorList
is None:
527 self
._ConstructorList
= []
528 return self
._ConstructorList
530 ## Retrieve DESTRUCTOR
531 def _GetDestructor(self
):
532 if self
._DestructorList
is None:
533 if self
._Header
_ is None:
534 self
._GetHeaderInfo
()
535 if self
._DestructorList
is None:
536 self
._DestructorList
= []
537 return self
._DestructorList
539 ## Retrieve definies other than above ones
540 def _GetDefines(self
):
541 if len(self
._Defs
) == 0 and self
._Header
_ is None:
542 self
._GetHeaderInfo
()
545 ## Retrieve binary files
546 def _GetBinaries(self
):
547 if self
._Binaries
is None:
549 RecordList
= self
._RawData
[MODEL_EFI_BINARY_FILE
, self
._Arch
, self
._Platform
]
550 Macros
= self
._Macros
551 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
552 Macros
['PROCESSOR'] = self
._Arch
553 for Record
in RecordList
:
559 TokenList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
561 Target
= TokenList
[0]
562 if len(TokenList
) > 1:
563 FeatureFlag
= Record
[1:]
565 File
= PathClass(NormPath(Record
[1], Macros
), self
._ModuleDir
, '', FileType
, True, self
._Arch
, '', Target
)
566 # check the file validation
567 ErrorCode
, ErrorInfo
= File
.Validate()
569 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
570 self
._Binaries
.append(File
)
571 return self
._Binaries
573 ## Retrieve binary files with error check.
574 def _GetBinaryFiles(self
):
575 Binaries
= self
._GetBinaries
()
576 if GlobalData
.gIgnoreSource
and Binaries
== []:
577 ErrorInfo
= "The INF file does not contain any Binaries to use in creating the image\n"
578 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
)
582 ## Retrieve source files
583 def _GetSourceFiles(self
):
584 # Ignore all source files in a binary build mode
585 if GlobalData
.gIgnoreSource
:
589 if self
._Sources
is None:
591 RecordList
= self
._RawData
[MODEL_EFI_SOURCE_FILE
, self
._Arch
, self
._Platform
]
592 Macros
= self
._Macros
593 for Record
in RecordList
:
595 ToolChainFamily
= Record
[1]
598 FeatureFlag
= Record
[4]
599 if self
.AutoGenVersion
< 0x00010005:
600 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
601 Macros
['PROCESSOR'] = self
._Arch
602 SourceFile
= NormPath(Record
[0], Macros
)
603 if SourceFile
[0] == os
.path
.sep
:
604 SourceFile
= mws
.join(GlobalData
.gWorkspace
, SourceFile
[1:])
605 # old module source files (Edk)
606 File
= PathClass(SourceFile
, self
._ModuleDir
, self
._SourceOverridePath
,
607 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
608 # check the file validation
609 ErrorCode
, ErrorInfo
= File
.Validate(CaseSensitive
=False)
611 if File
.Ext
.lower() == '.h':
612 EdkLogger
.warn('build', 'Include file not found', ExtraData
=ErrorInfo
,
613 File
=self
.MetaFile
, Line
=LineNo
)
616 EdkLogger
.error('build', ErrorCode
, ExtraData
=File
, File
=self
.MetaFile
, Line
=LineNo
)
618 File
= PathClass(NormPath(Record
[0], Macros
), self
._ModuleDir
, '',
619 '', False, self
._Arch
, ToolChainFamily
, '', TagName
, ToolCode
)
620 # check the file validation
621 ErrorCode
, ErrorInfo
= File
.Validate()
623 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
625 self
._Sources
.append(File
)
628 ## Retrieve library classes employed by this module
629 def _GetLibraryClassUses(self
):
630 if self
._LibraryClasses
is None:
631 self
._LibraryClasses
= OrderedDict()
632 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, self
._Platform
]
633 for Record
in RecordList
:
637 Instance
= NormPath(Instance
, self
._Macros
)
638 self
._LibraryClasses
[Lib
] = Instance
639 return self
._LibraryClasses
641 ## Retrieve library names (for Edk.x style of modules)
642 def _GetLibraryNames(self
):
643 if self
._Libraries
is None:
645 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
, self
._Platform
]
646 for Record
in RecordList
:
647 LibraryName
= ReplaceMacro(Record
[0], self
._Macros
, False)
648 # in case of name with '.lib' extension, which is unusual in Edk.x inf
649 LibraryName
= os
.path
.splitext(LibraryName
)[0]
650 if LibraryName
not in self
._Libraries
:
651 self
._Libraries
.append(LibraryName
)
652 return self
._Libraries
654 def _GetProtocolComments(self
):
656 return self
._ProtocolComments
657 ## Retrieve protocols consumed/produced by this module
658 def _GetProtocols(self
):
659 if self
._Protocols
is None:
660 self
._Protocols
= OrderedDict()
661 self
._ProtocolComments
= OrderedDict()
662 RecordList
= self
._RawData
[MODEL_EFI_PROTOCOL
, self
._Arch
, self
._Platform
]
663 for Record
in RecordList
:
665 Value
= ProtocolValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
667 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
668 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
669 "Value of Protocol [%s] is not found under [Protocols] section in" % CName
,
670 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
671 self
._Protocols
[CName
] = Value
672 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
674 for CmtRec
in CommentRecords
:
675 Comments
.append(CmtRec
[0])
676 self
._ProtocolComments
[CName
] = Comments
677 return self
._Protocols
679 def _GetPpiComments(self
):
681 return self
._PpiComments
682 ## Retrieve PPIs consumed/produced by this module
684 if self
._Ppis
is None:
685 self
._Ppis
= OrderedDict()
686 self
._PpiComments
= OrderedDict()
687 RecordList
= self
._RawData
[MODEL_EFI_PPI
, self
._Arch
, self
._Platform
]
688 for Record
in RecordList
:
690 Value
= PpiValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
692 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
693 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
694 "Value of PPI [%s] is not found under [Ppis] section in " % CName
,
695 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
696 self
._Ppis
[CName
] = Value
697 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
699 for CmtRec
in CommentRecords
:
700 Comments
.append(CmtRec
[0])
701 self
._PpiComments
[CName
] = Comments
704 def _GetGuidComments(self
):
706 return self
._GuidComments
707 ## Retrieve GUIDs consumed/produced by this module
709 if self
._Guids
is None:
710 self
._Guids
= OrderedDict()
711 self
._GuidComments
= OrderedDict()
712 RecordList
= self
._RawData
[MODEL_EFI_GUID
, self
._Arch
, self
._Platform
]
713 for Record
in RecordList
:
715 Value
= GuidValue(CName
, self
.Packages
, self
.MetaFile
.Path
)
717 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
718 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
719 "Value of Guid [%s] is not found under [Guids] section in" % CName
,
720 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
721 self
._Guids
[CName
] = Value
722 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Record
[5]]
724 for CmtRec
in CommentRecords
:
725 Comments
.append(CmtRec
[0])
726 self
._GuidComments
[CName
] = Comments
729 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
730 def _GetIncludes(self
):
731 if self
._Includes
is None:
733 if self
._SourceOverridePath
:
734 self
._Includes
.append(self
._SourceOverridePath
)
736 Macros
= self
._Macros
737 Macros
['PROCESSOR'] = GlobalData
.gEdkGlobal
.get('PROCESSOR', self
._Arch
)
738 RecordList
= self
._RawData
[MODEL_EFI_INCLUDE
, self
._Arch
, self
._Platform
]
739 for Record
in RecordList
:
740 if Record
[0].find('EDK_SOURCE') > -1:
741 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
742 File
= NormPath(Record
[0], self
._Macros
)
744 File
= os
.path
.join(self
._ModuleDir
, File
)
746 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
747 File
= RealPath(os
.path
.normpath(File
))
749 self
._Includes
.append(File
)
751 # TRICK: let compiler to choose correct header file
752 Macros
['EDK_SOURCE'] = GlobalData
.gEdkSource
753 File
= NormPath(Record
[0], self
._Macros
)
755 File
= os
.path
.join(self
._ModuleDir
, File
)
757 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
758 File
= RealPath(os
.path
.normpath(File
))
760 self
._Includes
.append(File
)
762 File
= NormPath(Record
[0], Macros
)
764 File
= os
.path
.join(self
._ModuleDir
, File
)
766 File
= mws
.join(GlobalData
.gWorkspace
, File
)
767 File
= RealPath(os
.path
.normpath(File
))
769 self
._Includes
.append(File
)
770 if not File
and Record
[0].find('EFI_SOURCE') > -1:
771 # tricky to regard WorkSpace as EFI_SOURCE
772 Macros
['EFI_SOURCE'] = GlobalData
.gWorkspace
773 File
= NormPath(Record
[0], Macros
)
775 File
= os
.path
.join(self
._ModuleDir
, File
)
777 File
= os
.path
.join(GlobalData
.gWorkspace
, File
)
778 File
= RealPath(os
.path
.normpath(File
))
780 self
._Includes
.append(File
)
781 return self
._Includes
783 ## Retrieve packages this module depends on
784 def _GetPackages(self
):
785 if self
._Packages
is None:
787 RecordList
= self
._RawData
[MODEL_META_DATA_PACKAGE
, self
._Arch
, self
._Platform
]
788 Macros
= self
._Macros
789 Macros
['EDK_SOURCE'] = GlobalData
.gEcpSource
790 for Record
in RecordList
:
791 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
793 # check the file validation
794 ErrorCode
, ErrorInfo
= File
.Validate('.dec')
796 EdkLogger
.error('build', ErrorCode
, ExtraData
=ErrorInfo
, File
=self
.MetaFile
, Line
=LineNo
)
797 # parse this package now. we need it to get protocol/ppi/guid value
798 Package
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
799 self
._Packages
.append(Package
)
800 return self
._Packages
802 ## Retrieve PCD comments
803 def _GetPcdComments(self
):
805 return self
._PcdComments
806 ## Retrieve PCDs used in this module
808 if self
._Pcds
is None:
809 self
._Pcds
= OrderedDict()
810 self
._PcdComments
= OrderedDict()
811 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
812 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
813 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
814 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC
))
815 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_DYNAMIC_EX
))
818 ## Retrieve build options specific to this module
819 def _GetBuildOptions(self
):
820 if self
._BuildOptions
is None:
821 self
._BuildOptions
= OrderedDict()
822 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, self
._Platform
]
823 for Record
in RecordList
:
824 ToolChainFamily
= Record
[0]
825 ToolChain
= Record
[1]
827 if (ToolChainFamily
, ToolChain
) not in self
._BuildOptions
or Option
.startswith('='):
828 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = Option
830 # concatenate the option string if they're for the same tool
831 OptionString
= self
._BuildOptions
[ToolChainFamily
, ToolChain
]
832 self
._BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
833 return self
._BuildOptions
835 ## Retrieve dependency expression
837 if self
._Depex
is None:
838 self
._Depex
= tdict(False, 2)
839 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
841 # If the module has only Binaries and no Sources, then ignore [Depex]
842 if self
.Sources
is None or self
.Sources
== []:
843 if self
.Binaries
is not None and self
.Binaries
!= []:
846 # PEIM and DXE drivers must have a valid [Depex] section
847 if len(self
.LibraryClass
) == 0 and len(RecordList
) == 0:
848 if self
.ModuleType
== SUP_MODULE_DXE_DRIVER
or self
.ModuleType
== SUP_MODULE_PEIM
or self
.ModuleType
== SUP_MODULE_DXE_SMM_DRIVER
or \
849 self
.ModuleType
== SUP_MODULE_DXE_SAL_DRIVER
or self
.ModuleType
== SUP_MODULE_DXE_RUNTIME_DRIVER
:
850 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
851 % self
.ModuleType
, File
=self
.MetaFile
)
853 if len(RecordList
) != 0 and self
.ModuleType
== SUP_MODULE_USER_DEFINED
:
854 for Record
in RecordList
:
855 if Record
[4] not in [SUP_MODULE_PEIM
, SUP_MODULE_DXE_DRIVER
, SUP_MODULE_DXE_SMM_DRIVER
]:
856 EdkLogger
.error('build', FORMAT_INVALID
,
857 "'%s' module must specify the type of [Depex] section" % self
.ModuleType
,
860 Depex
= OrderedDict()
861 for Record
in RecordList
:
862 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
864 ModuleType
= Record
[4]
865 TokenList
= DepexStr
.split()
866 if (Arch
, ModuleType
) not in Depex
:
867 Depex
[Arch
, ModuleType
] = []
868 DepexList
= Depex
[Arch
, ModuleType
]
869 for Token
in TokenList
:
870 if Token
in DEPEX_SUPPORTED_OPCODE_SET
:
871 DepexList
.append(Token
)
872 elif Token
.endswith(".inf"): # module file name
873 ModuleFile
= os
.path
.normpath(Token
)
874 Module
= self
.BuildDatabase
[ModuleFile
]
876 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "Module is not found in active platform",
877 ExtraData
=Token
, File
=self
.MetaFile
, Line
=Record
[-1])
878 DepexList
.append(Module
.Guid
)
880 # it use the Fixed PCD format
882 if tuple(Token
.split('.')[::-1]) not in self
.Pcds
:
883 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "PCD [{}] used in [Depex] section should be listed in module PCD section".format(Token
), File
=self
.MetaFile
, Line
=Record
[-1])
885 if self
.Pcds
[tuple(Token
.split('.')[::-1])].DatumType
!= TAB_VOID
:
886 EdkLogger
.error('build', FORMAT_INVALID
, "PCD [{}] used in [Depex] section should be VOID* datum type".format(Token
), File
=self
.MetaFile
, Line
=Record
[-1])
889 # get the GUID value now
890 Value
= ProtocolValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
892 Value
= PpiValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
894 Value
= GuidValue(Token
, self
.Packages
, self
.MetaFile
.Path
)
897 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
898 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
899 "Value of [%s] is not found in" % Token
,
900 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=Record
[-1])
901 DepexList
.append(Value
)
902 for Arch
, ModuleType
in Depex
:
903 self
._Depex
[Arch
, ModuleType
] = Depex
[Arch
, ModuleType
]
906 ## Retrieve depedency expression
907 def _GetDepexExpression(self
):
908 if self
._DepexExpression
is None:
909 self
._DepexExpression
= tdict(False, 2)
910 RecordList
= self
._RawData
[MODEL_EFI_DEPEX
, self
._Arch
]
911 DepexExpression
= OrderedDict()
912 for Record
in RecordList
:
913 DepexStr
= ReplaceMacro(Record
[0], self
._Macros
, False)
915 ModuleType
= Record
[4]
916 TokenList
= DepexStr
.split()
917 if (Arch
, ModuleType
) not in DepexExpression
:
918 DepexExpression
[Arch
, ModuleType
] = ''
919 for Token
in TokenList
:
920 DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
] + Token
.strip() + ' '
921 for Arch
, ModuleType
in DepexExpression
:
922 self
._DepexExpression
[Arch
, ModuleType
] = DepexExpression
[Arch
, ModuleType
]
923 return self
._DepexExpression
925 def GetGuidsUsedByPcd(self
):
926 return self
._GuidsUsedByPcd
927 ## Retrieve PCD for given type
928 def _GetPcd(self
, Type
):
930 PcdDict
= tdict(True, 4)
932 RecordList
= self
._RawData
[Type
, self
._Arch
, self
._Platform
]
933 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, Platform
, Id
, LineNo
in RecordList
:
934 PcdDict
[Arch
, Platform
, PcdCName
, TokenSpaceGuid
] = (Setting
, LineNo
)
935 PcdList
.append((PcdCName
, TokenSpaceGuid
))
937 if TokenSpaceGuid
not in self
.Guids
:
938 Value
= GuidValue(TokenSpaceGuid
, self
.Packages
, self
.MetaFile
.Path
)
940 PackageList
= "\n\t".join(str(P
) for P
in self
.Packages
)
941 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
,
942 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid
,
943 ExtraData
=PackageList
, File
=self
.MetaFile
, Line
=LineNo
)
944 self
.Guids
[TokenSpaceGuid
] = Value
945 self
._GuidsUsedByPcd
[TokenSpaceGuid
] = Value
946 CommentRecords
= self
._RawData
[MODEL_META_DATA_COMMENT
, self
._Arch
, self
._Platform
, Id
]
948 for CmtRec
in CommentRecords
:
949 Comments
.append(CmtRec
[0])
950 self
._PcdComments
[TokenSpaceGuid
, PcdCName
] = Comments
952 # resolve PCD type, value, datum info, etc. by getting its definition from package
953 _GuidDict
= self
.Guids
.copy()
954 for PcdCName
, TokenSpaceGuid
in PcdList
:
955 PcdRealName
= PcdCName
956 Setting
, LineNo
= PcdDict
[self
._Arch
, self
.Platform
, PcdCName
, TokenSpaceGuid
]
959 ValueList
= AnalyzePcdData(Setting
)
960 DefaultValue
= ValueList
[0]
961 Pcd
= PcdClassObject(
971 self
.Guids
[TokenSpaceGuid
]
973 if Type
== MODEL_PCD_PATCHABLE_IN_MODULE
and ValueList
[1]:
974 # Patch PCD: TokenSpace.PcdCName|Value|Offset
975 Pcd
.Offset
= ValueList
[1]
977 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
978 for Package
in self
.Packages
:
979 for key
in Package
.Pcds
:
980 if (Package
.Pcds
[key
].TokenCName
, Package
.Pcds
[key
].TokenSpaceGuidCName
) == (PcdRealName
, TokenSpaceGuid
):
981 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
982 Pcd_Type
= item
[0].split('_')[-1]
983 if Pcd_Type
== Package
.Pcds
[key
].Type
:
984 Value
= Package
.Pcds
[key
]
985 Value
.TokenCName
= Package
.Pcds
[key
].TokenCName
+ '_' + Pcd_Type
987 newkey
= (Value
.TokenCName
, key
[1])
989 newkey
= (Value
.TokenCName
, key
[1], key
[2])
990 del Package
.Pcds
[key
]
991 Package
.Pcds
[newkey
] = Value
998 # get necessary info from package declaring this PCD
999 for Package
in self
.Packages
:
1001 # 'dynamic' in INF means its type is determined by platform;
1002 # if platform doesn't give its type, use 'lowest' one in the
1003 # following order, if any
1005 # TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
1007 _GuidDict
.update(Package
.Guids
)
1008 PcdType
= self
._PCD
_TYPE
_STRING
_[Type
]
1009 if Type
== MODEL_PCD_DYNAMIC
:
1011 for T
in PCD_TYPE_LIST
:
1012 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1013 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1014 if str(item
[0]).endswith(T
) and (item
[0], item
[1], T
) in Package
.Pcds
:
1022 if (PcdRealName
, TokenSpaceGuid
, T
) in Package
.Pcds
:
1028 if (PcdRealName
, TokenSpaceGuid
) in GlobalData
.MixedPcd
:
1029 for item
in GlobalData
.MixedPcd
[(PcdRealName
, TokenSpaceGuid
)]:
1030 Pcd_Type
= item
[0].split('_')[-1]
1031 if Pcd_Type
== PcdType
:
1039 if (PcdCName
, TokenSpaceGuid
, PcdType
) in Package
.Pcds
:
1040 PcdInPackage
= Package
.Pcds
[PcdCName
, TokenSpaceGuid
, PcdType
]
1042 Pcd
.TokenValue
= PcdInPackage
.TokenValue
1045 # Check whether the token value exist or not.
1047 if Pcd
.TokenValue
is None or Pcd
.TokenValue
== "":
1051 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid
, PcdRealName
, str(Package
)),
1052 File
=self
.MetaFile
, Line
=LineNo
,
1056 # Check hexadecimal token value length and format.
1058 ReIsValidPcdTokenValue
= re
.compile(r
"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re
.DOTALL
)
1059 if Pcd
.TokenValue
.startswith("0x") or Pcd
.TokenValue
.startswith("0X"):
1060 if ReIsValidPcdTokenValue
.match(Pcd
.TokenValue
) is None:
1064 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd
.TokenValue
, TokenSpaceGuid
, PcdRealName
, str(Package
)),
1065 File
=self
.MetaFile
, Line
=LineNo
,
1070 # Check decimal token value length and format.
1074 TokenValueInt
= int (Pcd
.TokenValue
, 10)
1075 if (TokenValueInt
< 0 or TokenValueInt
> 4294967295):
1079 "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
)),
1080 File
=self
.MetaFile
, Line
=LineNo
,
1087 "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
)),
1088 File
=self
.MetaFile
, Line
=LineNo
,
1092 Pcd
.DatumType
= PcdInPackage
.DatumType
1093 Pcd
.MaxDatumSize
= PcdInPackage
.MaxDatumSize
1094 Pcd
.InfDefaultValue
= Pcd
.DefaultValue
1095 if not Pcd
.DefaultValue
:
1096 Pcd
.DefaultValue
= PcdInPackage
.DefaultValue
1099 Pcd
.DefaultValue
= ValueExpressionEx(Pcd
.DefaultValue
, Pcd
.DatumType
, _GuidDict
)(True)
1100 except BadExpression
as Value
:
1101 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid
, PcdRealName
, Pcd
.DefaultValue
, Value
),
1102 File
=self
.MetaFile
, Line
=LineNo
)
1108 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid
, PcdRealName
, self
.MetaFile
),
1109 File
=self
.MetaFile
, Line
=LineNo
,
1110 ExtraData
="\t%s" % '\n\t'.join(str(P
) for P
in self
.Packages
)
1112 Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
1116 ## check whether current module is binary module
1117 def _IsBinaryModule(self
):
1118 if self
.Binaries
and not self
.Sources
:
1120 elif GlobalData
.gIgnoreSource
:
1125 _Macros
= property(_GetMacros
)
1126 Arch
= property(_GetArch
)
1127 Platform
= property(_GetPlatform
)
1129 HeaderComments
= property(_GetHeaderComments
)
1130 TailComments
= property(_GetTailComments
)
1131 AutoGenVersion
= property(_GetInfVersion
)
1132 BaseName
= property(_GetBaseName
)
1133 ModuleType
= property(_GetModuleType
)
1134 ComponentType
= property(_GetComponentType
)
1135 BuildType
= property(_GetBuildType
)
1136 Guid
= property(_GetFileGuid
)
1137 Version
= property(_GetVersion
)
1138 PcdIsDriver
= property(_GetPcdIsDriver
)
1139 Shadow
= property(_GetShadow
)
1140 CustomMakefile
= property(_GetMakefile
)
1141 Specification
= property(_GetSpec
)
1142 LibraryClass
= property(_GetLibraryClass
)
1143 ModuleEntryPointList
= property(_GetEntryPoint
)
1144 ModuleUnloadImageList
= property(_GetUnloadImage
)
1145 ConstructorList
= property(_GetConstructor
)
1146 DestructorList
= property(_GetDestructor
)
1147 Defines
= property(_GetDefines
)
1148 DxsFile
= property(_GetDxsFile
)
1150 Binaries
= property(_GetBinaryFiles
)
1151 Sources
= property(_GetSourceFiles
)
1152 LibraryClasses
= property(_GetLibraryClassUses
)
1153 Libraries
= property(_GetLibraryNames
)
1154 Protocols
= property(_GetProtocols
)
1155 ProtocolComments
= property(_GetProtocolComments
)
1156 Ppis
= property(_GetPpis
)
1157 PpiComments
= property(_GetPpiComments
)
1158 Guids
= property(_GetGuids
)
1159 GuidComments
= property(_GetGuidComments
)
1160 Includes
= property(_GetIncludes
)
1161 Packages
= property(_GetPackages
)
1162 Pcds
= property(_GetPcds
)
1163 PcdComments
= property(_GetPcdComments
)
1164 BuildOptions
= property(_GetBuildOptions
)
1165 Depex
= property(_GetDepex
)
1166 DepexExpression
= property(_GetDepexExpression
)
1167 IsBinaryModule
= property(_IsBinaryModule
)