2 # Generate AutoGen.h, AutoGen.c and *.depex files
4 # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 import Common
.LongFilePathOs
as os
18 import os
.path
as path
25 from StringIO
import StringIO
27 from StrGather
import *
28 from BuildEngine
import BuildRule
30 from Common
.LongFilePathSupport
import CopyLongFilePath
31 from Common
.BuildToolError
import *
32 from Common
.DataType
import *
33 from Common
.Misc
import *
34 from Common
.String
import *
35 import Common
.GlobalData
as GlobalData
36 from GenFds
.FdfParser
import *
37 from CommonDataClass
.CommonClass
import SkuInfoClass
38 from Workspace
.BuildClassObject
import *
39 from GenPatchPcdTable
.GenPatchPcdTable
import parsePcdInfoFromMapFile
40 import Common
.VpdInfoFile
as VpdInfoFile
41 from GenPcdDb
import CreatePcdDatabaseCode
42 from Workspace
.MetaFileCommentParser
import UsageList
43 from Common
.MultipleWorkspace
import MultipleWorkspace
as mws
44 import InfSectionParser
46 ## Regular expression for splitting Dependency Expression string into tokens
47 gDepexTokenPattern
= re
.compile("(\(|\)|\w+| \S+\.inf)")
50 # Match name = variable
52 gEfiVarStoreNamePattern
= re
.compile("\s*name\s*=\s*(\w+)")
54 # The format of guid in efivarstore statement likes following and must be correct:
55 # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
57 gEfiVarStoreGuidPattern
= re
.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
59 ## Mapping Makefile type
60 gMakeTypeMap
= {"MSFT":"nmake", "GCC":"gmake"}
63 ## Build rule configuration file
64 gDefaultBuildRuleFile
= 'Conf/build_rule.txt'
66 ## Build rule default version
67 AutoGenReqBuildRuleVerNum
= "0.1"
69 ## default file name for AutoGen
70 gAutoGenCodeFileName
= "AutoGen.c"
71 gAutoGenHeaderFileName
= "AutoGen.h"
72 gAutoGenStringFileName
= "%(module_name)sStrDefs.h"
73 gAutoGenStringFormFileName
= "%(module_name)sStrDefs.hpk"
74 gAutoGenDepexFileName
= "%(module_name)s.depex"
76 gInfSpecVersion
= "0x00010017"
79 # Template string to generic AsBuilt INF
81 gAsBuiltInfHeaderString
= TemplateString("""${header_comments}
87 INF_VERSION = ${module_inf_version}
88 BASE_NAME = ${module_name}
89 FILE_GUID = ${module_guid}
90 MODULE_TYPE = ${module_module_type}${BEGIN}
91 VERSION_STRING = ${module_version_string}${END}${BEGIN}
92 PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}
93 UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
94 PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}${BEGIN}
95 ENTRY_POINT = ${module_entry_point}${END}${BEGIN}
96 UNLOAD_IMAGE = ${module_unload_image}${END}${BEGIN}
97 CONSTRUCTOR = ${module_constructor}${END}${BEGIN}
98 DESTRUCTOR = ${module_destructor}${END}${BEGIN}
99 SHADOW = ${module_shadow}${END}${BEGIN}
100 PCI_VENDOR_ID = ${module_pci_vendor_id}${END}${BEGIN}
101 PCI_DEVICE_ID = ${module_pci_device_id}${END}${BEGIN}
102 PCI_CLASS_CODE = ${module_pci_class_code}${END}${BEGIN}
103 PCI_REVISION = ${module_pci_revision}${END}${BEGIN}
104 BUILD_NUMBER = ${module_build_number}${END}${BEGIN}
105 SPEC = ${module_spec}${END}${BEGIN}
106 UEFI_HII_RESOURCE_SECTION = ${module_uefi_hii_resource_section}${END}${BEGIN}
107 MODULE_UNI_FILE = ${module_uni_file}${END}
109 [Packages.${module_arch}]${BEGIN}
110 ${package_item}${END}
112 [Binaries.${module_arch}]${BEGIN}
115 [PatchPcd.${module_arch}]${BEGIN}
119 [Protocols.${module_arch}]${BEGIN}
123 [Ppis.${module_arch}]${BEGIN}
127 [Guids.${module_arch}]${BEGIN}
131 [PcdEx.${module_arch}]${BEGIN}
135 [LibraryClasses.${module_arch}]
136 ## @LIB_INSTANCES${BEGIN}
137 # ${libraryclasses_item}${END}
143 [BuildOptions.${module_arch}]
145 ## ${flags_item}${END}
148 ## Base class for AutoGen
150 # This class just implements the cache mechanism of AutoGen objects.
152 class AutoGen(object):
153 # database to maintain the objects of xxxAutoGen
154 _CACHE_
= {} # (BuildTarget, ToolChain) : {ARCH : {platform file: AutoGen object}}}
158 # @param Class class object of real AutoGen class
159 # (WorkspaceAutoGen, ModuleAutoGen or PlatformAutoGen)
160 # @param Workspace Workspace directory or WorkspaceAutoGen object
161 # @param MetaFile The path of meta file
162 # @param Target Build target
163 # @param Toolchain Tool chain name
164 # @param Arch Target arch
165 # @param *args The specific class related parameters
166 # @param **kwargs The specific class related dict parameters
168 def __new__(Class
, Workspace
, MetaFile
, Target
, Toolchain
, Arch
, *args
, **kwargs
):
169 # check if the object has been created
170 Key
= (Target
, Toolchain
)
171 if Key
not in Class
._CACHE
_ or Arch
not in Class
._CACHE
_[Key
] \
172 or MetaFile
not in Class
._CACHE
_[Key
][Arch
]:
173 AutoGenObject
= super(AutoGen
, Class
).__new
__(Class
)
174 # call real constructor
175 if not AutoGenObject
._Init
(Workspace
, MetaFile
, Target
, Toolchain
, Arch
, *args
, **kwargs
):
177 if Key
not in Class
._CACHE
_:
178 Class
._CACHE
_[Key
] = {}
179 if Arch
not in Class
._CACHE
_[Key
]:
180 Class
._CACHE
_[Key
][Arch
] = {}
181 Class
._CACHE
_[Key
][Arch
][MetaFile
] = AutoGenObject
183 AutoGenObject
= Class
._CACHE
_[Key
][Arch
][MetaFile
]
189 # The file path of platform file will be used to represent hash value of this object
191 # @retval int Hash value of the file path of platform file
194 return hash(self
.MetaFile
)
198 # The file path of platform file will be used to represent this object
200 # @retval string String of platform file path
203 return str(self
.MetaFile
)
206 def __eq__(self
, Other
):
207 return Other
and self
.MetaFile
== Other
209 ## Workspace AutoGen class
211 # This class is used mainly to control the whole platform build for different
212 # architecture. This class will generate top level makefile.
214 class WorkspaceAutoGen(AutoGen
):
215 ## Real constructor of WorkspaceAutoGen
217 # This method behaves the same as __init__ except that it needs explicit invoke
218 # (in super class's __new__ method)
220 # @param WorkspaceDir Root directory of workspace
221 # @param ActivePlatform Meta-file of active platform
222 # @param Target Build target
223 # @param Toolchain Tool chain name
224 # @param ArchList List of architecture of current build
225 # @param MetaFileDb Database containing meta-files
226 # @param BuildConfig Configuration of build
227 # @param ToolDefinition Tool chain definitions
228 # @param FlashDefinitionFile File of flash definition
229 # @param Fds FD list to be generated
230 # @param Fvs FV list to be generated
231 # @param Caps Capsule list to be generated
232 # @param SkuId SKU id from command line
234 def _Init(self
, WorkspaceDir
, ActivePlatform
, Target
, Toolchain
, ArchList
, MetaFileDb
,
235 BuildConfig
, ToolDefinition
, FlashDefinitionFile
='', Fds
=None, Fvs
=None, Caps
=None, SkuId
='', UniFlag
=None,
236 Progress
=None, BuildModule
=None):
243 self
.BuildDatabase
= MetaFileDb
244 self
.MetaFile
= ActivePlatform
245 self
.WorkspaceDir
= WorkspaceDir
246 self
.Platform
= self
.BuildDatabase
[self
.MetaFile
, 'COMMON', Target
, Toolchain
]
247 GlobalData
.gActivePlatform
= self
.Platform
248 self
.BuildTarget
= Target
249 self
.ToolChain
= Toolchain
250 self
.ArchList
= ArchList
252 self
.UniFlag
= UniFlag
254 self
.TargetTxt
= BuildConfig
255 self
.ToolDef
= ToolDefinition
256 self
.FdfFile
= FlashDefinitionFile
257 self
.FdTargetList
= Fds
258 self
.FvTargetList
= Fvs
259 self
.CapTargetList
= Caps
260 self
.AutoGenObjectList
= []
262 # there's many relative directory operations, so ...
263 os
.chdir(self
.WorkspaceDir
)
268 if not self
.ArchList
:
269 ArchList
= set(self
.Platform
.SupArchList
)
271 ArchList
= set(self
.ArchList
) & set(self
.Platform
.SupArchList
)
273 EdkLogger
.error("build", PARAMETER_INVALID
,
274 ExtraData
= "Invalid ARCH specified. [Valid ARCH: %s]" % (" ".join(self
.Platform
.SupArchList
)))
275 elif self
.ArchList
and len(ArchList
) != len(self
.ArchList
):
276 SkippedArchList
= set(self
.ArchList
).symmetric_difference(set(self
.Platform
.SupArchList
))
277 EdkLogger
.verbose("\nArch [%s] is ignored because the platform supports [%s] only!"
278 % (" ".join(SkippedArchList
), " ".join(self
.Platform
.SupArchList
)))
279 self
.ArchList
= tuple(ArchList
)
281 # Validate build target
282 if self
.BuildTarget
not in self
.Platform
.BuildTargets
:
283 EdkLogger
.error("build", PARAMETER_INVALID
,
284 ExtraData
="Build target [%s] is not supported by the platform. [Valid target: %s]"
285 % (self
.BuildTarget
, " ".join(self
.Platform
.BuildTargets
)))
288 # parse FDF file to get PCDs in it, if any
290 self
.FdfFile
= self
.Platform
.FlashDefinition
294 EdkLogger
.info('%-16s = %s' % ("Architecture(s)", ' '.join(self
.ArchList
)))
295 EdkLogger
.info('%-16s = %s' % ("Build target", self
.BuildTarget
))
296 EdkLogger
.info('%-16s = %s' % ("Toolchain", self
.ToolChain
))
298 EdkLogger
.info('\n%-24s = %s' % ("Active Platform", self
.Platform
))
300 EdkLogger
.info('%-24s = %s' % ("Active Module", BuildModule
))
303 EdkLogger
.info('%-24s = %s' % ("Flash Image Definition", self
.FdfFile
))
305 EdkLogger
.verbose("\nFLASH_DEFINITION = %s" % self
.FdfFile
)
308 Progress
.Start("\nProcessing meta-data")
312 # Mark now build in AutoGen Phase
314 GlobalData
.gAutoGenPhase
= True
315 Fdf
= FdfParser(self
.FdfFile
.Path
)
317 GlobalData
.gFdfParser
= Fdf
318 GlobalData
.gAutoGenPhase
= False
319 PcdSet
= Fdf
.Profile
.PcdDict
320 if Fdf
.CurrentFdName
and Fdf
.CurrentFdName
in Fdf
.Profile
.FdDict
:
321 FdDict
= Fdf
.Profile
.FdDict
[Fdf
.CurrentFdName
]
322 for FdRegion
in FdDict
.RegionList
:
323 if str(FdRegion
.RegionType
) is 'FILE' and self
.Platform
.VpdToolGuid
in str(FdRegion
.RegionDataList
):
324 if int(FdRegion
.Offset
) % 8 != 0:
325 EdkLogger
.error("build", FORMAT_INVALID
, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion
.Offset
))
326 ModuleList
= Fdf
.Profile
.InfList
327 self
.FdfProfile
= Fdf
.Profile
328 for fvname
in self
.FvTargetList
:
329 if fvname
.upper() not in self
.FdfProfile
.FvDict
:
330 EdkLogger
.error("build", OPTION_VALUE_INVALID
,
331 "No such an FV in FDF file: %s" % fvname
)
335 self
.FdfProfile
= None
336 if self
.FdTargetList
:
337 EdkLogger
.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self
.FdTargetList
))
338 self
.FdTargetList
= []
339 if self
.FvTargetList
:
340 EdkLogger
.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self
.FvTargetList
))
341 self
.FvTargetList
= []
342 if self
.CapTargetList
:
343 EdkLogger
.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self
.CapTargetList
))
344 self
.CapTargetList
= []
346 # apply SKU and inject PCDs from Flash Definition file
347 for Arch
in self
.ArchList
:
348 Platform
= self
.BuildDatabase
[self
.MetaFile
, Arch
, Target
, Toolchain
]
352 PGen
= PlatformAutoGen(self
, self
.MetaFile
, Target
, Toolchain
, Arch
)
353 #Collect package set information from INF of FDF
355 for Inf
in ModuleList
:
356 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
)
357 if ModuleFile
in Platform
.Modules
:
359 ModuleData
= self
.BuildDatabase
[ModuleFile
, Arch
, Target
, Toolchain
]
360 PkgSet
.update(ModuleData
.Packages
)
361 Pkgs
= list(PkgSet
) + list(PGen
.PackageList
)
364 DecPcds
[Pcd
[0], Pcd
[1]] = Pkg
.Pcds
[Pcd
]
365 DecPcdsKey
.add((Pcd
[0], Pcd
[1], Pcd
[2]))
367 Platform
.SkuName
= self
.SkuId
368 for Name
, Guid
in PcdSet
:
369 if (Name
, Guid
) not in DecPcds
:
373 "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid
, Name
),
374 File
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][0],
375 Line
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][1]
378 # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message.
379 if (Name
, Guid
, TAB_PCDS_FIXED_AT_BUILD
) in DecPcdsKey \
380 or (Name
, Guid
, TAB_PCDS_PATCHABLE_IN_MODULE
) in DecPcdsKey \
381 or (Name
, Guid
, TAB_PCDS_FEATURE_FLAG
) in DecPcdsKey
:
382 Platform
.AddPcd(Name
, Guid
, PcdSet
[Name
, Guid
])
384 elif (Name
, Guid
, TAB_PCDS_DYNAMIC
) in DecPcdsKey
or (Name
, Guid
, TAB_PCDS_DYNAMIC_EX
) in DecPcdsKey
:
388 "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid
, Name
),
389 File
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][0],
390 Line
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][1]
393 Pa
= PlatformAutoGen(self
, self
.MetaFile
, Target
, Toolchain
, Arch
)
395 # Explicitly collect platform's dynamic PCDs
397 Pa
.CollectPlatformDynamicPcds()
398 Pa
.CollectFixedAtBuildPcds()
399 self
.AutoGenObjectList
.append(Pa
)
402 # Check PCDs token value conflict in each DEC file.
404 self
._CheckAllPcdsTokenValueConflict
()
407 # Check PCD type and definition between DSC and DEC
409 self
._CheckPcdDefineAndType
()
412 # self._CheckDuplicateInFV(Fdf)
414 self
._BuildDir
= None
416 self
._MakeFileDir
= None
417 self
._BuildCommand
= None
421 ## _CheckDuplicateInFV() method
423 # Check whether there is duplicate modules/files exist in FV section.
424 # The check base on the file GUID;
426 def _CheckDuplicateInFV(self
, Fdf
):
427 for Fv
in Fdf
.Profile
.FvDict
:
429 for FfsFile
in Fdf
.Profile
.FvDict
[Fv
].FfsList
:
430 if FfsFile
.InfFileName
and FfsFile
.NameGuid
== None:
435 for Pa
in self
.AutoGenObjectList
:
438 for Module
in Pa
.ModuleAutoGenList
:
439 if path
.normpath(Module
.MetaFile
.File
) == path
.normpath(FfsFile
.InfFileName
):
441 if not Module
.Guid
.upper() in _GuidDict
.keys():
442 _GuidDict
[Module
.Guid
.upper()] = FfsFile
445 EdkLogger
.error("build",
447 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
448 FfsFile
.CurrentLineContent
,
449 _GuidDict
[Module
.Guid
.upper()].CurrentLineNum
,
450 _GuidDict
[Module
.Guid
.upper()].CurrentLineContent
,
451 Module
.Guid
.upper()),
452 ExtraData
=self
.FdfFile
)
454 # Some INF files not have entity in DSC file.
457 if FfsFile
.InfFileName
.find('$') == -1:
458 InfPath
= NormPath(FfsFile
.InfFileName
)
459 if not os
.path
.exists(InfPath
):
460 EdkLogger
.error('build', GENFDS_ERROR
, "Non-existant Module %s !" % (FfsFile
.InfFileName
))
462 PathClassObj
= PathClass(FfsFile
.InfFileName
, self
.WorkspaceDir
)
464 # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use
465 # BuildObject from one of AutoGenObjectList is enough.
467 InfObj
= self
.AutoGenObjectList
[0].BuildDatabase
.WorkspaceDb
.BuildObject
[PathClassObj
, 'COMMON', self
.BuildTarget
, self
.ToolChain
]
468 if not InfObj
.Guid
.upper() in _GuidDict
.keys():
469 _GuidDict
[InfObj
.Guid
.upper()] = FfsFile
471 EdkLogger
.error("build",
473 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
474 FfsFile
.CurrentLineContent
,
475 _GuidDict
[InfObj
.Guid
.upper()].CurrentLineNum
,
476 _GuidDict
[InfObj
.Guid
.upper()].CurrentLineContent
,
477 InfObj
.Guid
.upper()),
478 ExtraData
=self
.FdfFile
)
481 if FfsFile
.NameGuid
!= None:
482 _CheckPCDAsGuidPattern
= re
.compile("^PCD\(.+\..+\)$")
485 # If the NameGuid reference a PCD name.
486 # The style must match: PCD(xxxx.yyy)
488 if _CheckPCDAsGuidPattern
.match(FfsFile
.NameGuid
):
490 # Replace the PCD value.
492 _PcdName
= FfsFile
.NameGuid
.lstrip("PCD(").rstrip(")")
494 for Pa
in self
.AutoGenObjectList
:
496 for PcdItem
in Pa
.AllPcdList
:
497 if (PcdItem
.TokenSpaceGuidCName
+ "." + PcdItem
.TokenCName
) == _PcdName
:
499 # First convert from CFormatGuid to GUID string
501 _PcdGuidString
= GuidStructureStringToGuidString(PcdItem
.DefaultValue
)
503 if not _PcdGuidString
:
505 # Then try Byte array.
507 _PcdGuidString
= GuidStructureByteArrayToGuidString(PcdItem
.DefaultValue
)
509 if not _PcdGuidString
:
511 # Not Byte array or CFormat GUID, raise error.
513 EdkLogger
.error("build",
515 "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName
, PcdItem
.DefaultValue
),
516 ExtraData
=self
.FdfFile
)
518 if not _PcdGuidString
.upper() in _GuidDict
.keys():
519 _GuidDict
[_PcdGuidString
.upper()] = FfsFile
523 EdkLogger
.error("build",
525 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
526 FfsFile
.CurrentLineContent
,
527 _GuidDict
[_PcdGuidString
.upper()].CurrentLineNum
,
528 _GuidDict
[_PcdGuidString
.upper()].CurrentLineContent
,
529 FfsFile
.NameGuid
.upper()),
530 ExtraData
=self
.FdfFile
)
532 if not FfsFile
.NameGuid
.upper() in _GuidDict
.keys():
533 _GuidDict
[FfsFile
.NameGuid
.upper()] = FfsFile
536 # Two raw file GUID conflict.
538 EdkLogger
.error("build",
540 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
541 FfsFile
.CurrentLineContent
,
542 _GuidDict
[FfsFile
.NameGuid
.upper()].CurrentLineNum
,
543 _GuidDict
[FfsFile
.NameGuid
.upper()].CurrentLineContent
,
544 FfsFile
.NameGuid
.upper()),
545 ExtraData
=self
.FdfFile
)
548 def _CheckPcdDefineAndType(self
):
550 "FixedAtBuild", "PatchableInModule", "FeatureFlag",
551 "Dynamic", #"DynamicHii", "DynamicVpd",
552 "DynamicEx", # "DynamicExHii", "DynamicExVpd"
555 # This dict store PCDs which are not used by any modules with specified arches
557 for Pa
in self
.AutoGenObjectList
:
558 # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid
559 for Pcd
in Pa
.Platform
.Pcds
:
560 PcdType
= Pa
.Platform
.Pcds
[Pcd
].Type
562 # If no PCD type, this PCD comes from FDF
566 # Try to remove Hii and Vpd suffix
567 if PcdType
.startswith("DynamicEx"):
568 PcdType
= "DynamicEx"
569 elif PcdType
.startswith("Dynamic"):
572 for Package
in Pa
.PackageList
:
573 # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType
574 if (Pcd
[0], Pcd
[1], PcdType
) in Package
.Pcds
:
576 for Type
in PcdTypeList
:
577 if (Pcd
[0], Pcd
[1], Type
) in Package
.Pcds
:
581 "Type [%s] of PCD [%s.%s] in DSC file doesn't match the type [%s] defined in DEC file." \
582 % (Pa
.Platform
.Pcds
[Pcd
].Type
, Pcd
[1], Pcd
[0], Type
),
587 UnusedPcd
.setdefault(Pcd
, []).append(Pa
.Arch
)
589 for Pcd
in UnusedPcd
:
592 "The PCD was not specified by any INF module in the platform for the given architecture.\n"
593 "\tPCD: [%s.%s]\n\tPlatform: [%s]\n\tArch: %s"
594 % (Pcd
[1], Pcd
[0], os
.path
.basename(str(self
.MetaFile
)), str(UnusedPcd
[Pcd
])),
599 return "%s [%s]" % (self
.MetaFile
, ", ".join(self
.ArchList
))
601 ## Return the directory to store FV files
603 if self
._FvDir
== None:
604 self
._FvDir
= path
.join(self
.BuildDir
, 'FV')
607 ## Return the directory to store all intermediate and final files built
608 def _GetBuildDir(self
):
609 return self
.AutoGenObjectList
[0].BuildDir
611 ## Return the build output directory platform specifies
612 def _GetOutputDir(self
):
613 return self
.Platform
.OutputDirectory
615 ## Return platform name
617 return self
.Platform
.PlatformName
619 ## Return meta-file GUID
621 return self
.Platform
.Guid
623 ## Return platform version
624 def _GetVersion(self
):
625 return self
.Platform
.Version
627 ## Return paths of tools
628 def _GetToolDefinition(self
):
629 return self
.AutoGenObjectList
[0].ToolDefinition
631 ## Return directory of platform makefile
633 # @retval string Makefile directory
635 def _GetMakeFileDir(self
):
636 if self
._MakeFileDir
== None:
637 self
._MakeFileDir
= self
.BuildDir
638 return self
._MakeFileDir
640 ## Return build command string
642 # @retval string Build command string
644 def _GetBuildCommand(self
):
645 if self
._BuildCommand
== None:
646 # BuildCommand should be all the same. So just get one from platform AutoGen
647 self
._BuildCommand
= self
.AutoGenObjectList
[0].BuildCommand
648 return self
._BuildCommand
650 ## Check the PCDs token value conflict in each DEC file.
652 # Will cause build break and raise error message while two PCDs conflict.
656 def _CheckAllPcdsTokenValueConflict(self
):
657 for Pa
in self
.AutoGenObjectList
:
658 for Package
in Pa
.PackageList
:
659 PcdList
= Package
.Pcds
.values()
660 PcdList
.sort(lambda x
, y
: cmp(int(x
.TokenValue
, 0), int(y
.TokenValue
, 0)))
662 while (Count
< len(PcdList
) - 1) :
663 Item
= PcdList
[Count
]
664 ItemNext
= PcdList
[Count
+ 1]
666 # Make sure in the same token space the TokenValue should be unique
668 if (int(Item
.TokenValue
, 0) == int(ItemNext
.TokenValue
, 0)):
669 SameTokenValuePcdList
= []
670 SameTokenValuePcdList
.append(Item
)
671 SameTokenValuePcdList
.append(ItemNext
)
672 RemainPcdListLength
= len(PcdList
) - Count
- 2
673 for ValueSameCount
in range(RemainPcdListLength
):
674 if int(PcdList
[len(PcdList
) - RemainPcdListLength
+ ValueSameCount
].TokenValue
, 0) == int(Item
.TokenValue
, 0):
675 SameTokenValuePcdList
.append(PcdList
[len(PcdList
) - RemainPcdListLength
+ ValueSameCount
])
679 # Sort same token value PCD list with TokenGuid and TokenCName
681 SameTokenValuePcdList
.sort(lambda x
, y
: cmp("%s.%s" % (x
.TokenSpaceGuidCName
, x
.TokenCName
), "%s.%s" % (y
.TokenSpaceGuidCName
, y
.TokenCName
)))
682 SameTokenValuePcdListCount
= 0
683 while (SameTokenValuePcdListCount
< len(SameTokenValuePcdList
) - 1):
684 TemListItem
= SameTokenValuePcdList
[SameTokenValuePcdListCount
]
685 TemListItemNext
= SameTokenValuePcdList
[SameTokenValuePcdListCount
+ 1]
687 if (TemListItem
.TokenSpaceGuidCName
== TemListItemNext
.TokenSpaceGuidCName
) and (TemListItem
.TokenCName
!= TemListItemNext
.TokenCName
):
691 "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\
692 % (TemListItem
.TokenValue
, TemListItem
.TokenSpaceGuidCName
, TemListItem
.TokenCName
, TemListItemNext
.TokenSpaceGuidCName
, TemListItemNext
.TokenCName
, Package
),
695 SameTokenValuePcdListCount
+= 1
696 Count
+= SameTokenValuePcdListCount
699 PcdList
= Package
.Pcds
.values()
700 PcdList
.sort(lambda x
, y
: cmp("%s.%s" % (x
.TokenSpaceGuidCName
, x
.TokenCName
), "%s.%s" % (y
.TokenSpaceGuidCName
, y
.TokenCName
)))
702 while (Count
< len(PcdList
) - 1) :
703 Item
= PcdList
[Count
]
704 ItemNext
= PcdList
[Count
+ 1]
706 # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.
708 if (Item
.TokenSpaceGuidCName
== ItemNext
.TokenSpaceGuidCName
) and (Item
.TokenCName
== ItemNext
.TokenCName
) and (int(Item
.TokenValue
, 0) != int(ItemNext
.TokenValue
, 0)):
712 "The TokenValue [%s] of PCD [%s.%s] in %s defined in two places should be same as well."\
713 % (Item
.TokenValue
, Item
.TokenSpaceGuidCName
, Item
.TokenCName
, Package
),
717 ## Generate fds command
718 def _GenFdsCommand(self
):
719 return (GenMake
.TopLevelMakefile(self
)._TEMPLATE
_.Replace(GenMake
.TopLevelMakefile(self
)._TemplateDict
)).strip()
721 ## Create makefile for the platform and modules in it
723 # @param CreateDepsMakeFile Flag indicating if the makefile for
724 # modules will be created as well
726 def CreateMakeFile(self
, CreateDepsMakeFile
=False):
727 if CreateDepsMakeFile
:
728 for Pa
in self
.AutoGenObjectList
:
729 Pa
.CreateMakeFile(CreateDepsMakeFile
)
731 ## Create autogen code for platform and modules
733 # Since there's no autogen code for platform, this method will do nothing
734 # if CreateModuleCodeFile is set to False.
736 # @param CreateDepsCodeFile Flag indicating if creating module's
737 # autogen code file or not
739 def CreateCodeFile(self
, CreateDepsCodeFile
=False):
740 if not CreateDepsCodeFile
:
742 for Pa
in self
.AutoGenObjectList
:
743 Pa
.CreateCodeFile(CreateDepsCodeFile
)
745 ## Create AsBuilt INF file the platform
747 def CreateAsBuiltInf(self
):
750 Name
= property(_GetName
)
751 Guid
= property(_GetGuid
)
752 Version
= property(_GetVersion
)
753 OutputDir
= property(_GetOutputDir
)
755 ToolDefinition
= property(_GetToolDefinition
) # toolcode : tool path
757 BuildDir
= property(_GetBuildDir
)
758 FvDir
= property(_GetFvDir
)
759 MakeFileDir
= property(_GetMakeFileDir
)
760 BuildCommand
= property(_GetBuildCommand
)
761 GenFdsCommand
= property(_GenFdsCommand
)
763 ## AutoGen class for platform
765 # PlatformAutoGen class will process the original information in platform
766 # file in order to generate makefile for platform.
768 class PlatformAutoGen(AutoGen
):
770 # Used to store all PCDs for both PEI and DXE phase, in order to generate
771 # correct PCD database
774 _NonDynaPcdList_
= []
777 # The priority list while override build option
779 PrioList
= {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)
780 "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
781 "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE
782 "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE
783 "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
784 "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
785 "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE
786 "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE
787 "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE
788 "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE
789 "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE
790 "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE
791 "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE
792 "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE
793 "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE
794 "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)
796 ## The real constructor of PlatformAutoGen
798 # This method is not supposed to be called by users of PlatformAutoGen. It's
799 # only used by factory method __new__() to do real initialization work for an
800 # object of PlatformAutoGen
802 # @param Workspace WorkspaceAutoGen object
803 # @param PlatformFile Platform file (DSC file)
804 # @param Target Build target (DEBUG, RELEASE)
805 # @param Toolchain Name of tool chain
806 # @param Arch arch of the platform supports
808 def _Init(self
, Workspace
, PlatformFile
, Target
, Toolchain
, Arch
):
809 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "AutoGen platform [%s] [%s]" % (PlatformFile
, Arch
))
810 GlobalData
.gProcessingFile
= "%s [%s, %s, %s]" % (PlatformFile
, Arch
, Toolchain
, Target
)
812 self
.MetaFile
= PlatformFile
813 self
.Workspace
= Workspace
814 self
.WorkspaceDir
= Workspace
.WorkspaceDir
815 self
.ToolChain
= Toolchain
816 self
.BuildTarget
= Target
818 self
.SourceDir
= PlatformFile
.SubDir
819 self
.SourceOverrideDir
= None
820 self
.FdTargetList
= self
.Workspace
.FdTargetList
821 self
.FvTargetList
= self
.Workspace
.FvTargetList
823 # get the original module/package/platform objects
824 self
.BuildDatabase
= Workspace
.BuildDatabase
826 # flag indicating if the makefile/C-code file has been created or not
827 self
.IsMakeFileCreated
= False
828 self
.IsCodeFileCreated
= False
830 self
._Platform
= None
835 self
._BuildRule
= None
836 self
._SourceDir
= None
837 self
._BuildDir
= None
838 self
._OutputDir
= None
840 self
._MakeFileDir
= None
843 self
._PcdTokenNumber
= None # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber
844 self
._DynamicPcdList
= None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
845 self
._NonDynamicPcdList
= None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
846 self
._NonDynamicPcdDict
= {}
848 self
._ToolDefinitions
= None
849 self
._ToolDefFile
= None # toolcode : tool path
850 self
._ToolChainFamily
= None
851 self
._BuildRuleFamily
= None
852 self
._BuildOption
= None # toolcode : option
853 self
._EdkBuildOption
= None # edktoolcode : option
854 self
._EdkIIBuildOption
= None # edkiitoolcode : option
855 self
._PackageList
= None
856 self
._ModuleAutoGenList
= None
857 self
._LibraryAutoGenList
= None
858 self
._BuildCommand
= None
859 self
._AsBuildInfList
= []
860 self
._AsBuildModuleList
= []
861 if GlobalData
.gFdfParser
!= None:
862 self
._AsBuildInfList
= GlobalData
.gFdfParser
.Profile
.InfList
863 for Inf
in self
._AsBuildInfList
:
864 InfClass
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, self
.Arch
)
865 M
= self
.BuildDatabase
[InfClass
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
866 if not M
.IsSupportedArch
:
868 self
._AsBuildModuleList
.append(InfClass
)
869 # get library/modules for build
870 self
.LibraryBuildDirectoryList
= []
871 self
.ModuleBuildDirectoryList
= []
875 return "%s [%s]" % (self
.MetaFile
, self
.Arch
)
877 ## Create autogen code for platform and modules
879 # Since there's no autogen code for platform, this method will do nothing
880 # if CreateModuleCodeFile is set to False.
882 # @param CreateModuleCodeFile Flag indicating if creating module's
883 # autogen code file or not
885 def CreateCodeFile(self
, CreateModuleCodeFile
=False):
886 # only module has code to be greated, so do nothing if CreateModuleCodeFile is False
887 if self
.IsCodeFileCreated
or not CreateModuleCodeFile
:
890 for Ma
in self
.ModuleAutoGenList
:
891 Ma
.CreateCodeFile(True)
893 # don't do this twice
894 self
.IsCodeFileCreated
= True
896 ## Generate Fds Command
897 def _GenFdsCommand(self
):
898 return self
.Workspace
.GenFdsCommand
900 ## Create makefile for the platform and mdoules in it
902 # @param CreateModuleMakeFile Flag indicating if the makefile for
903 # modules will be created as well
905 def CreateMakeFile(self
, CreateModuleMakeFile
=False):
906 if CreateModuleMakeFile
:
907 for ModuleFile
in self
.Platform
.Modules
:
908 Ma
= ModuleAutoGen(self
.Workspace
, ModuleFile
, self
.BuildTarget
,
909 self
.ToolChain
, self
.Arch
, self
.MetaFile
)
910 Ma
.CreateMakeFile(True)
911 #Ma.CreateAsBuiltInf()
913 # no need to create makefile for the platform more than once
914 if self
.IsMakeFileCreated
:
917 # create library/module build dirs for platform
918 Makefile
= GenMake
.PlatformMakefile(self
)
919 self
.LibraryBuildDirectoryList
= Makefile
.GetLibraryBuildDirectoryList()
920 self
.ModuleBuildDirectoryList
= Makefile
.GetModuleBuildDirectoryList()
922 self
.IsMakeFileCreated
= True
924 ## Deal with Shared FixedAtBuild Pcds
926 def CollectFixedAtBuildPcds(self
):
927 for LibAuto
in self
.LibraryAutoGenList
:
928 FixedAtBuildPcds
= {}
929 ShareFixedAtBuildPcdsSameValue
= {}
930 for Module
in LibAuto
._ReferenceModules
:
931 for Pcd
in Module
.FixedAtBuildPcds
+ LibAuto
.FixedAtBuildPcds
:
932 key
= ".".join((Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
))
933 if key
not in FixedAtBuildPcds
:
934 ShareFixedAtBuildPcdsSameValue
[key
] = True
935 FixedAtBuildPcds
[key
] = Pcd
.DefaultValue
937 if FixedAtBuildPcds
[key
] != Pcd
.DefaultValue
:
938 ShareFixedAtBuildPcdsSameValue
[key
] = False
939 for Pcd
in LibAuto
.FixedAtBuildPcds
:
940 key
= ".".join((Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
))
941 if (Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
) not in self
.NonDynamicPcdDict
:
944 DscPcd
= self
.NonDynamicPcdDict
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)]
945 if DscPcd
.Type
!= "FixedAtBuild":
947 if key
in ShareFixedAtBuildPcdsSameValue
and ShareFixedAtBuildPcdsSameValue
[key
]:
948 LibAuto
.ConstPcd
[key
] = Pcd
.DefaultValue
950 ## Collect dynamic PCDs
952 # Gather dynamic PCDs list from each module and their settings from platform
953 # This interface should be invoked explicitly when platform action is created.
955 def CollectPlatformDynamicPcds(self
):
956 # for gathering error information
957 NoDatumTypePcdList
= set()
961 for InfName
in self
._AsBuildInfList
:
962 InfName
= mws
.join(self
.WorkspaceDir
, InfName
)
963 FdfModuleList
.append(os
.path
.normpath(InfName
))
964 for F
in self
.Platform
.Modules
.keys():
965 M
= ModuleAutoGen(self
.Workspace
, F
, self
.BuildTarget
, self
.ToolChain
, self
.Arch
, self
.MetaFile
)
966 #GuidValue.update(M.Guids)
968 self
.Platform
.Modules
[F
].M
= M
970 for PcdFromModule
in M
.ModulePcdList
+ M
.LibraryPcdList
:
971 # make sure that the "VOID*" kind of datum has MaxDatumSize set
972 if PcdFromModule
.DatumType
== "VOID*" and PcdFromModule
.MaxDatumSize
in [None, '']:
973 NoDatumTypePcdList
.add("%s.%s [%s]" % (PcdFromModule
.TokenSpaceGuidCName
, PcdFromModule
.TokenCName
, F
))
975 # Check the PCD from Binary INF or Source INF
976 if M
.IsBinaryModule
== True:
977 PcdFromModule
.IsFromBinaryInf
= True
979 # Check the PCD from DSC or not
980 if (PcdFromModule
.TokenCName
, PcdFromModule
.TokenSpaceGuidCName
) in self
.Platform
.Pcds
.keys():
981 PcdFromModule
.IsFromDsc
= True
983 PcdFromModule
.IsFromDsc
= False
984 if PcdFromModule
.Type
in GenC
.gDynamicPcd
or PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
985 if F
.Path
not in FdfModuleList
:
986 # If one of the Source built modules listed in the DSC is not listed
987 # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic
988 # access method (it is only listed in the DEC file that declares the
989 # PCD as PcdsDynamic), then build tool will report warning message
990 # notify the PI that they are attempting to build a module that must
991 # be included in a flash image in order to be functional. These Dynamic
992 # PCD will not be added into the Database unless it is used by other
993 # modules that are included in the FDF file.
994 if PcdFromModule
.Type
in GenC
.gDynamicPcd
and \
995 PcdFromModule
.IsFromBinaryInf
== False:
996 # Print warning message to let the developer make a determine.
997 if PcdFromModule
not in PcdNotInDb
:
998 PcdNotInDb
.append(PcdFromModule
)
1000 # If one of the Source built modules listed in the DSC is not listed in
1001 # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx
1002 # access method (it is only listed in the DEC file that declares the
1003 # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the
1004 # PCD to the Platform's PCD Database.
1005 if PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1006 if PcdFromModule
not in PcdNotInDb
:
1007 PcdNotInDb
.append(PcdFromModule
)
1010 # If a dynamic PCD used by a PEM module/PEI module & DXE module,
1011 # it should be stored in Pcd PEI database, If a dynamic only
1012 # used by DXE module, it should be stored in DXE PCD database.
1013 # The default Phase is DXE
1015 if M
.ModuleType
in ["PEIM", "PEI_CORE"]:
1016 PcdFromModule
.Phase
= "PEI"
1017 if PcdFromModule
not in self
._DynaPcdList
_:
1018 self
._DynaPcdList
_.append(PcdFromModule
)
1019 elif PcdFromModule
.Phase
== 'PEI':
1020 # overwrite any the same PCD existing, if Phase is PEI
1021 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1022 self
._DynaPcdList
_[Index
] = PcdFromModule
1023 elif PcdFromModule
not in self
._NonDynaPcdList
_:
1024 self
._NonDynaPcdList
_.append(PcdFromModule
)
1025 elif PcdFromModule
in self
._NonDynaPcdList
_ and PcdFromModule
.IsFromBinaryInf
== True:
1026 Index
= self
._NonDynaPcdList
_.index(PcdFromModule
)
1027 if self
._NonDynaPcdList
_[Index
].IsFromBinaryInf
== False:
1028 #The PCD from Binary INF will override the same one from source INF
1029 self
._NonDynaPcdList
_.remove (self
._NonDynaPcdList
_[Index
])
1030 PcdFromModule
.Pending
= False
1031 self
._NonDynaPcdList
_.append (PcdFromModule
)
1032 # Parse the DynamicEx PCD from the AsBuild INF module list of FDF.
1034 for ModuleInf
in self
.Platform
.Modules
.keys():
1035 DscModuleList
.append (os
.path
.normpath(ModuleInf
.Path
))
1036 # add the PCD from modules that listed in FDF but not in DSC to Database
1037 for InfName
in FdfModuleList
:
1038 if InfName
not in DscModuleList
:
1039 InfClass
= PathClass(InfName
)
1040 M
= self
.BuildDatabase
[InfClass
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1041 # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source)
1042 # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here.
1043 # For binary module, if in current arch, we need to list the PCDs into database.
1044 if not M
.IsSupportedArch
:
1046 # Override the module PCD setting by platform setting
1047 ModulePcdList
= self
.ApplyPcdSetting(M
, M
.Pcds
)
1048 for PcdFromModule
in ModulePcdList
:
1049 PcdFromModule
.IsFromBinaryInf
= True
1050 PcdFromModule
.IsFromDsc
= False
1051 # Only allow the DynamicEx and Patchable PCD in AsBuild INF
1052 if PcdFromModule
.Type
not in GenC
.gDynamicExPcd
and PcdFromModule
.Type
not in TAB_PCDS_PATCHABLE_IN_MODULE
:
1053 EdkLogger
.error("build", AUTOGEN_ERROR
, "PCD setting error",
1055 ExtraData
="\n\tExisted %s PCD %s in:\n\t\t%s\n"
1056 % (PcdFromModule
.Type
, PcdFromModule
.TokenCName
, InfName
))
1057 # make sure that the "VOID*" kind of datum has MaxDatumSize set
1058 if PcdFromModule
.DatumType
== "VOID*" and PcdFromModule
.MaxDatumSize
in [None, '']:
1059 NoDatumTypePcdList
.add("%s.%s [%s]" % (PcdFromModule
.TokenSpaceGuidCName
, PcdFromModule
.TokenCName
, InfName
))
1060 if M
.ModuleType
in ["PEIM", "PEI_CORE"]:
1061 PcdFromModule
.Phase
= "PEI"
1062 if PcdFromModule
not in self
._DynaPcdList
_ and PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1063 self
._DynaPcdList
_.append(PcdFromModule
)
1064 elif PcdFromModule
not in self
._NonDynaPcdList
_ and PcdFromModule
.Type
in TAB_PCDS_PATCHABLE_IN_MODULE
:
1065 self
._NonDynaPcdList
_.append(PcdFromModule
)
1066 if PcdFromModule
in self
._DynaPcdList
_ and PcdFromModule
.Phase
== 'PEI' and PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1067 # Overwrite the phase of any the same PCD existing, if Phase is PEI.
1068 # It is to solve the case that a dynamic PCD used by a PEM module/PEI
1069 # module & DXE module at a same time.
1070 # Overwrite the type of the PCDs in source INF by the type of AsBuild
1071 # INF file as DynamicEx.
1072 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1073 self
._DynaPcdList
_[Index
].Phase
= PcdFromModule
.Phase
1074 self
._DynaPcdList
_[Index
].Type
= PcdFromModule
.Type
1075 for PcdFromModule
in self
._NonDynaPcdList
_:
1076 # If a PCD is not listed in the DSC file, but binary INF files used by
1077 # this platform all (that use this PCD) list the PCD in a [PatchPcds]
1078 # section, AND all source INF files used by this platform the build
1079 # that use the PCD list the PCD in either a [Pcds] or [PatchPcds]
1080 # section, then the tools must NOT add the PCD to the Platform's PCD
1081 # Database; the build must assign the access method for this PCD as
1082 # PcdsPatchableInModule.
1083 if PcdFromModule
not in self
._DynaPcdList
_:
1085 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1086 if PcdFromModule
.IsFromDsc
== False and \
1087 PcdFromModule
.Type
in TAB_PCDS_PATCHABLE_IN_MODULE
and \
1088 PcdFromModule
.IsFromBinaryInf
== True and \
1089 self
._DynaPcdList
_[Index
].IsFromBinaryInf
== False:
1090 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1091 self
._DynaPcdList
_.remove (self
._DynaPcdList
_[Index
])
1093 # print out error information and break the build, if error found
1094 if len(NoDatumTypePcdList
) > 0:
1095 NoDatumTypePcdListString
= "\n\t\t".join(NoDatumTypePcdList
)
1096 EdkLogger
.error("build", AUTOGEN_ERROR
, "PCD setting error",
1098 ExtraData
="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"
1099 % NoDatumTypePcdListString
)
1100 self
._NonDynamicPcdList
= self
._NonDynaPcdList
_
1101 self
._DynamicPcdList
= self
._DynaPcdList
_
1103 # Sort dynamic PCD list to:
1104 # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should
1105 # try to be put header of dynamicd List
1106 # 2) If PCD is HII type, the PCD item should be put after unicode type PCD
1108 # The reason of sorting is make sure the unicode string is in double-byte alignment in string table.
1110 UnicodePcdArray
= []
1114 VpdFile
= VpdInfoFile
.VpdInfoFile()
1115 NeedProcessVpdMapFile
= False
1117 if (self
.Workspace
.ArchList
[-1] == self
.Arch
):
1118 for Pcd
in self
._DynamicPcdList
:
1119 # just pick the a value to determine whether is unicode string type
1120 Sku
= Pcd
.SkuInfoList
[Pcd
.SkuInfoList
.keys()[0]]
1121 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1123 PcdValue
= Sku
.DefaultValue
1124 if Pcd
.DatumType
== 'VOID*' and PcdValue
.startswith("L"):
1125 # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex
1126 UnicodePcdArray
.append(Pcd
)
1127 elif len(Sku
.VariableName
) > 0:
1128 # if found HII type PCD then insert to right of UnicodeIndex
1129 HiiPcdArray
.append(Pcd
)
1131 OtherPcdArray
.append(Pcd
)
1132 if Pcd
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
]:
1133 VpdPcdDict
[(Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
)] = Pcd
1135 PlatformPcds
= self
.Platform
.Pcds
.keys()
1138 # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.
1140 for PcdKey
in PlatformPcds
:
1141 Pcd
= self
.Platform
.Pcds
[PcdKey
]
1142 if Pcd
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
] and \
1143 PcdKey
in VpdPcdDict
:
1144 Pcd
= VpdPcdDict
[PcdKey
]
1145 for (SkuName
,Sku
) in Pcd
.SkuInfoList
.items():
1146 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1147 PcdValue
= Sku
.DefaultValue
1149 PcdValue
= Pcd
.DefaultValue
1150 if Sku
.VpdOffset
!= '*':
1151 if PcdValue
.startswith("{"):
1153 elif PcdValue
.startswith("L"):
1158 VpdOffset
= int(Sku
.VpdOffset
)
1161 VpdOffset
= int(Sku
.VpdOffset
, 16)
1163 EdkLogger
.error("build", FORMAT_INVALID
, "Invalid offset value %s for PCD %s.%s." % (Sku
.VpdOffset
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
1164 if VpdOffset
% Alignment
!= 0:
1165 if PcdValue
.startswith("{"):
1166 EdkLogger
.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
), File
=self
.MetaFile
)
1168 EdkLogger
.error("build", FORMAT_INVALID
, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Alignment
))
1169 VpdFile
.Add(Pcd
, Sku
.VpdOffset
)
1170 # if the offset of a VPD is *, then it need to be fixed up by third party tool.
1171 if not NeedProcessVpdMapFile
and Sku
.VpdOffset
== "*":
1172 NeedProcessVpdMapFile
= True
1173 if self
.Platform
.VpdToolGuid
== None or self
.Platform
.VpdToolGuid
== '':
1174 EdkLogger
.error("Build", FILE_NOT_FOUND
, \
1175 "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
1179 # Fix the PCDs define in VPD PCD section that never referenced by module.
1180 # An example is PCD for signature usage.
1182 for DscPcd
in PlatformPcds
:
1183 DscPcdEntry
= self
.Platform
.Pcds
[DscPcd
]
1184 if DscPcdEntry
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
]:
1185 if not (self
.Platform
.VpdToolGuid
== None or self
.Platform
.VpdToolGuid
== ''):
1187 for VpdPcd
in VpdFile
._VpdArray
.keys():
1188 # This PCD has been referenced by module
1189 if (VpdPcd
.TokenSpaceGuidCName
== DscPcdEntry
.TokenSpaceGuidCName
) and \
1190 (VpdPcd
.TokenCName
== DscPcdEntry
.TokenCName
):
1193 # Not found, it should be signature
1195 # just pick the a value to determine whether is unicode string type
1196 for (SkuName
,Sku
) in DscPcdEntry
.SkuInfoList
.items():
1197 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1199 # Need to iterate DEC pcd information to get the value & datumtype
1200 for eachDec
in self
.PackageList
:
1201 for DecPcd
in eachDec
.Pcds
:
1202 DecPcdEntry
= eachDec
.Pcds
[DecPcd
]
1203 if (DecPcdEntry
.TokenSpaceGuidCName
== DscPcdEntry
.TokenSpaceGuidCName
) and \
1204 (DecPcdEntry
.TokenCName
== DscPcdEntry
.TokenCName
):
1205 # Print warning message to let the developer make a determine.
1206 EdkLogger
.warn("build", "Unreferenced vpd pcd used!",
1207 File
=self
.MetaFile
, \
1208 ExtraData
= "PCD: %s.%s used in the DSC file %s is unreferenced." \
1209 %(DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
, self
.Platform
.MetaFile
.Path
))
1211 DscPcdEntry
.DatumType
= DecPcdEntry
.DatumType
1212 DscPcdEntry
.DefaultValue
= DecPcdEntry
.DefaultValue
1213 DscPcdEntry
.TokenValue
= DecPcdEntry
.TokenValue
1214 DscPcdEntry
.TokenSpaceGuidValue
= eachDec
.Guids
[DecPcdEntry
.TokenSpaceGuidCName
]
1215 # Only fix the value while no value provided in DSC file.
1216 if (Sku
.DefaultValue
== "" or Sku
.DefaultValue
==None):
1217 DscPcdEntry
.SkuInfoList
[DscPcdEntry
.SkuInfoList
.keys()[0]].DefaultValue
= DecPcdEntry
.DefaultValue
1219 if DscPcdEntry
not in self
._DynamicPcdList
:
1220 self
._DynamicPcdList
.append(DscPcdEntry
)
1221 # Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
1222 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1223 PcdValue
= Sku
.DefaultValue
1225 PcdValue
= DscPcdEntry
.DefaultValue
1226 if Sku
.VpdOffset
!= '*':
1227 if PcdValue
.startswith("{"):
1229 elif PcdValue
.startswith("L"):
1234 VpdOffset
= int(Sku
.VpdOffset
)
1237 VpdOffset
= int(Sku
.VpdOffset
, 16)
1239 EdkLogger
.error("build", FORMAT_INVALID
, "Invalid offset value %s for PCD %s.%s." % (Sku
.VpdOffset
, DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
))
1240 if VpdOffset
% Alignment
!= 0:
1241 if PcdValue
.startswith("{"):
1242 EdkLogger
.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
), File
=self
.MetaFile
)
1244 EdkLogger
.error("build", FORMAT_INVALID
, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
, Alignment
))
1245 VpdFile
.Add(DscPcdEntry
, Sku
.VpdOffset
)
1246 if not NeedProcessVpdMapFile
and Sku
.VpdOffset
== "*":
1247 NeedProcessVpdMapFile
= True
1248 if DscPcdEntry
.DatumType
== 'VOID*' and PcdValue
.startswith("L"):
1249 UnicodePcdArray
.append(DscPcdEntry
)
1250 elif len(Sku
.VariableName
) > 0:
1251 HiiPcdArray
.append(DscPcdEntry
)
1253 OtherPcdArray
.append(DscPcdEntry
)
1255 # if the offset of a VPD is *, then it need to be fixed up by third party tool.
1259 if (self
.Platform
.FlashDefinition
== None or self
.Platform
.FlashDefinition
== '') and \
1260 VpdFile
.GetCount() != 0:
1261 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
1262 "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self
.Platform
.MetaFile
))
1264 if VpdFile
.GetCount() != 0:
1265 FvPath
= os
.path
.join(self
.BuildDir
, "FV")
1266 if not os
.path
.exists(FvPath
):
1270 EdkLogger
.error("build", FILE_WRITE_FAILURE
, "Fail to create FV folder under %s" % self
.BuildDir
)
1272 VpdFilePath
= os
.path
.join(FvPath
, "%s.txt" % self
.Platform
.VpdToolGuid
)
1274 if VpdFile
.Write(VpdFilePath
):
1275 # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
1277 for ToolDef
in self
.ToolDefinition
.values():
1278 if ToolDef
.has_key("GUID") and ToolDef
["GUID"] == self
.Platform
.VpdToolGuid
:
1279 if not ToolDef
.has_key("PATH"):
1280 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self
.Platform
.VpdToolGuid
)
1281 BPDGToolName
= ToolDef
["PATH"]
1283 # Call third party GUID BPDG tool.
1284 if BPDGToolName
!= None:
1285 VpdInfoFile
.CallExtenalBPDGTool(BPDGToolName
, VpdFilePath
)
1287 EdkLogger
.error("Build", FILE_NOT_FOUND
, "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
1289 # Process VPD map file generated by third party BPDG tool
1290 if NeedProcessVpdMapFile
:
1291 VpdMapFilePath
= os
.path
.join(self
.BuildDir
, "FV", "%s.map" % self
.Platform
.VpdToolGuid
)
1292 if os
.path
.exists(VpdMapFilePath
):
1293 VpdFile
.Read(VpdMapFilePath
)
1296 for Pcd
in self
._DynamicPcdList
:
1297 # just pick the a value to determine whether is unicode string type
1299 for (SkuName
,Sku
) in Pcd
.SkuInfoList
.items():
1300 if Sku
.VpdOffset
== "*":
1301 Sku
.VpdOffset
= VpdFile
.GetOffset(Pcd
)[i
].strip()
1304 EdkLogger
.error("build", FILE_READ_FAILURE
, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath
)
1306 # Delete the DynamicPcdList At the last time enter into this function
1307 del self
._DynamicPcdList
[:]
1308 self
._DynamicPcdList
.extend(UnicodePcdArray
)
1309 self
._DynamicPcdList
.extend(HiiPcdArray
)
1310 self
._DynamicPcdList
.extend(OtherPcdArray
)
1311 self
.AllPcdList
= self
._NonDynamicPcdList
+ self
._DynamicPcdList
1313 ## Return the platform build data object
1314 def _GetPlatform(self
):
1315 if self
._Platform
== None:
1316 self
._Platform
= self
.BuildDatabase
[self
.MetaFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1317 return self
._Platform
1319 ## Return platform name
1321 return self
.Platform
.PlatformName
1323 ## Return the meta file GUID
1325 return self
.Platform
.Guid
1327 ## Return the platform version
1328 def _GetVersion(self
):
1329 return self
.Platform
.Version
1331 ## Return the FDF file name
1332 def _GetFdfFile(self
):
1333 if self
._FdfFile
== None:
1334 if self
.Workspace
.FdfFile
!= "":
1335 self
._FdfFile
= mws
.join(self
.WorkspaceDir
, self
.Workspace
.FdfFile
)
1338 return self
._FdfFile
1340 ## Return the build output directory platform specifies
1341 def _GetOutputDir(self
):
1342 return self
.Platform
.OutputDirectory
1344 ## Return the directory to store all intermediate and final files built
1345 def _GetBuildDir(self
):
1346 if self
._BuildDir
== None:
1347 if os
.path
.isabs(self
.OutputDir
):
1348 self
._BuildDir
= path
.join(
1349 path
.abspath(self
.OutputDir
),
1350 self
.BuildTarget
+ "_" + self
.ToolChain
,
1353 self
._BuildDir
= path
.join(
1356 self
.BuildTarget
+ "_" + self
.ToolChain
,
1358 return self
._BuildDir
1360 ## Return directory of platform makefile
1362 # @retval string Makefile directory
1364 def _GetMakeFileDir(self
):
1365 if self
._MakeFileDir
== None:
1366 self
._MakeFileDir
= path
.join(self
.BuildDir
, self
.Arch
)
1367 return self
._MakeFileDir
1369 ## Return build command string
1371 # @retval string Build command string
1373 def _GetBuildCommand(self
):
1374 if self
._BuildCommand
== None:
1375 self
._BuildCommand
= []
1376 if "MAKE" in self
.ToolDefinition
and "PATH" in self
.ToolDefinition
["MAKE"]:
1377 self
._BuildCommand
+= SplitOption(self
.ToolDefinition
["MAKE"]["PATH"])
1378 if "FLAGS" in self
.ToolDefinition
["MAKE"]:
1379 NewOption
= self
.ToolDefinition
["MAKE"]["FLAGS"].strip()
1381 self
._BuildCommand
+= SplitOption(NewOption
)
1382 return self
._BuildCommand
1384 ## Get tool chain definition
1386 # Get each tool defition for given tool chain from tools_def.txt and platform
1388 def _GetToolDefinition(self
):
1389 if self
._ToolDefinitions
== None:
1390 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDictionary
1391 if TAB_TOD_DEFINES_COMMAND_TYPE
not in self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
:
1392 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No tools found in configuration",
1393 ExtraData
="[%s]" % self
.MetaFile
)
1394 self
._ToolDefinitions
= {}
1396 for Def
in ToolDefinition
:
1397 Target
, Tag
, Arch
, Tool
, Attr
= Def
.split("_")
1398 if Target
!= self
.BuildTarget
or Tag
!= self
.ToolChain
or Arch
!= self
.Arch
:
1401 Value
= ToolDefinition
[Def
]
1402 # don't record the DLL
1404 DllPathList
.add(Value
)
1407 if Tool
not in self
._ToolDefinitions
:
1408 self
._ToolDefinitions
[Tool
] = {}
1409 self
._ToolDefinitions
[Tool
][Attr
] = Value
1413 if GlobalData
.gOptions
.SilentMode
and "MAKE" in self
._ToolDefinitions
:
1414 if "FLAGS" not in self
._ToolDefinitions
["MAKE"]:
1415 self
._ToolDefinitions
["MAKE"]["FLAGS"] = ""
1416 self
._ToolDefinitions
["MAKE"]["FLAGS"] += " -s"
1418 for Tool
in self
._ToolDefinitions
:
1419 for Attr
in self
._ToolDefinitions
[Tool
]:
1420 Value
= self
._ToolDefinitions
[Tool
][Attr
]
1421 if Tool
in self
.BuildOption
and Attr
in self
.BuildOption
[Tool
]:
1422 # check if override is indicated
1423 if self
.BuildOption
[Tool
][Attr
].startswith('='):
1424 Value
= self
.BuildOption
[Tool
][Attr
][1:]
1426 Value
+= " " + self
.BuildOption
[Tool
][Attr
]
1429 # Don't put MAKE definition in the file
1433 ToolsDef
+= "%s = %s\n" % (Tool
, Value
)
1435 # Don't put MAKE definition in the file
1440 ToolsDef
+= "%s_%s = %s\n" % (Tool
, Attr
, Value
)
1443 SaveFileOnChange(self
.ToolDefinitionFile
, ToolsDef
)
1444 for DllPath
in DllPathList
:
1445 os
.environ
["PATH"] = DllPath
+ os
.pathsep
+ os
.environ
["PATH"]
1446 os
.environ
["MAKE_FLAGS"] = MakeFlags
1448 return self
._ToolDefinitions
1450 ## Return the paths of tools
1451 def _GetToolDefFile(self
):
1452 if self
._ToolDefFile
== None:
1453 self
._ToolDefFile
= os
.path
.join(self
.MakeFileDir
, "TOOLS_DEF." + self
.Arch
)
1454 return self
._ToolDefFile
1456 ## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'.
1457 def _GetToolChainFamily(self
):
1458 if self
._ToolChainFamily
== None:
1459 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
1460 if TAB_TOD_DEFINES_FAMILY
not in ToolDefinition \
1461 or self
.ToolChain
not in ToolDefinition
[TAB_TOD_DEFINES_FAMILY
] \
1462 or not ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
.ToolChain
]:
1463 EdkLogger
.verbose("No tool chain family found in configuration for %s. Default to MSFT." \
1465 self
._ToolChainFamily
= "MSFT"
1467 self
._ToolChainFamily
= ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
.ToolChain
]
1468 return self
._ToolChainFamily
1470 def _GetBuildRuleFamily(self
):
1471 if self
._BuildRuleFamily
== None:
1472 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
1473 if TAB_TOD_DEFINES_BUILDRULEFAMILY
not in ToolDefinition \
1474 or self
.ToolChain
not in ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
] \
1475 or not ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
][self
.ToolChain
]:
1476 EdkLogger
.verbose("No tool chain family found in configuration for %s. Default to MSFT." \
1478 self
._BuildRuleFamily
= "MSFT"
1480 self
._BuildRuleFamily
= ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
][self
.ToolChain
]
1481 return self
._BuildRuleFamily
1483 ## Return the build options specific for all modules in this platform
1484 def _GetBuildOptions(self
):
1485 if self
._BuildOption
== None:
1486 self
._BuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
)
1487 return self
._BuildOption
1489 ## Return the build options specific for EDK modules in this platform
1490 def _GetEdkBuildOptions(self
):
1491 if self
._EdkBuildOption
== None:
1492 self
._EdkBuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
, EDK_NAME
)
1493 return self
._EdkBuildOption
1495 ## Return the build options specific for EDKII modules in this platform
1496 def _GetEdkIIBuildOptions(self
):
1497 if self
._EdkIIBuildOption
== None:
1498 self
._EdkIIBuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
, EDKII_NAME
)
1499 return self
._EdkIIBuildOption
1501 ## Parse build_rule.txt in Conf Directory.
1503 # @retval BuildRule object
1505 def _GetBuildRule(self
):
1506 if self
._BuildRule
== None:
1507 BuildRuleFile
= None
1508 if TAB_TAT_DEFINES_BUILD_RULE_CONF
in self
.Workspace
.TargetTxt
.TargetTxtDictionary
:
1509 BuildRuleFile
= self
.Workspace
.TargetTxt
.TargetTxtDictionary
[TAB_TAT_DEFINES_BUILD_RULE_CONF
]
1510 if BuildRuleFile
in [None, '']:
1511 BuildRuleFile
= gDefaultBuildRuleFile
1512 self
._BuildRule
= BuildRule(BuildRuleFile
)
1513 if self
._BuildRule
._FileVersion
== "":
1514 self
._BuildRule
._FileVersion
= AutoGenReqBuildRuleVerNum
1516 if self
._BuildRule
._FileVersion
< AutoGenReqBuildRuleVerNum
:
1517 # If Build Rule's version is less than the version number required by the tools, halting the build.
1518 EdkLogger
.error("build", AUTOGEN_ERROR
,
1519 ExtraData
="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\
1520 % (self
._BuildRule
._FileVersion
, AutoGenReqBuildRuleVerNum
))
1522 return self
._BuildRule
1524 ## Summarize the packages used by modules in this platform
1525 def _GetPackageList(self
):
1526 if self
._PackageList
== None:
1527 self
._PackageList
= set()
1528 for La
in self
.LibraryAutoGenList
:
1529 self
._PackageList
.update(La
.DependentPackageList
)
1530 for Ma
in self
.ModuleAutoGenList
:
1531 self
._PackageList
.update(Ma
.DependentPackageList
)
1532 #Collect package set information from INF of FDF
1534 for ModuleFile
in self
._AsBuildModuleList
:
1535 if ModuleFile
in self
.Platform
.Modules
:
1537 ModuleData
= self
.BuildDatabase
[ModuleFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1538 PkgSet
.update(ModuleData
.Packages
)
1539 self
._PackageList
= list(self
._PackageList
) + list (PkgSet
)
1540 return self
._PackageList
1542 def _GetNonDynamicPcdDict(self
):
1543 if self
._NonDynamicPcdDict
:
1544 return self
._NonDynamicPcdDict
1545 for Pcd
in self
.NonDynamicPcdList
:
1546 self
._NonDynamicPcdDict
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)] = Pcd
1547 return self
._NonDynamicPcdDict
1549 ## Get list of non-dynamic PCDs
1550 def _GetNonDynamicPcdList(self
):
1551 if self
._NonDynamicPcdList
== None:
1552 self
.CollectPlatformDynamicPcds()
1553 return self
._NonDynamicPcdList
1555 ## Get list of dynamic PCDs
1556 def _GetDynamicPcdList(self
):
1557 if self
._DynamicPcdList
== None:
1558 self
.CollectPlatformDynamicPcds()
1559 return self
._DynamicPcdList
1561 ## Generate Token Number for all PCD
1562 def _GetPcdTokenNumbers(self
):
1563 if self
._PcdTokenNumber
== None:
1564 self
._PcdTokenNumber
= sdict()
1567 # Make the Dynamic and DynamicEx PCD use within different TokenNumber area.
1571 # TokenNumber 0 ~ 10
1573 # TokeNumber 11 ~ 20
1575 for Pcd
in self
.DynamicPcdList
:
1576 if Pcd
.Phase
== "PEI":
1577 if Pcd
.Type
in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
1578 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1579 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1582 for Pcd
in self
.DynamicPcdList
:
1583 if Pcd
.Phase
== "PEI":
1584 if Pcd
.Type
in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
1585 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1586 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1589 for Pcd
in self
.DynamicPcdList
:
1590 if Pcd
.Phase
== "DXE":
1591 if Pcd
.Type
in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
1592 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1593 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1596 for Pcd
in self
.DynamicPcdList
:
1597 if Pcd
.Phase
== "DXE":
1598 if Pcd
.Type
in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
1599 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1600 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1603 for Pcd
in self
.NonDynamicPcdList
:
1604 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1606 return self
._PcdTokenNumber
1608 ## Summarize ModuleAutoGen objects of all modules/libraries to be built for this platform
1609 def _GetAutoGenObjectList(self
):
1610 self
._ModuleAutoGenList
= []
1611 self
._LibraryAutoGenList
= []
1612 for ModuleFile
in self
.Platform
.Modules
:
1621 if Ma
not in self
._ModuleAutoGenList
:
1622 self
._ModuleAutoGenList
.append(Ma
)
1623 for La
in Ma
.LibraryAutoGenList
:
1624 if La
not in self
._LibraryAutoGenList
:
1625 self
._LibraryAutoGenList
.append(La
)
1626 if Ma
not in La
._ReferenceModules
:
1627 La
._ReferenceModules
.append(Ma
)
1629 ## Summarize ModuleAutoGen objects of all modules to be built for this platform
1630 def _GetModuleAutoGenList(self
):
1631 if self
._ModuleAutoGenList
== None:
1632 self
._GetAutoGenObjectList
()
1633 return self
._ModuleAutoGenList
1635 ## Summarize ModuleAutoGen objects of all libraries to be built for this platform
1636 def _GetLibraryAutoGenList(self
):
1637 if self
._LibraryAutoGenList
== None:
1638 self
._GetAutoGenObjectList
()
1639 return self
._LibraryAutoGenList
1641 ## Test if a module is supported by the platform
1643 # An error will be raised directly if the module or its arch is not supported
1644 # by the platform or current configuration
1646 def ValidModule(self
, Module
):
1647 return Module
in self
.Platform
.Modules
or Module
in self
.Platform
.LibraryInstances \
1648 or Module
in self
._AsBuildModuleList
1650 ## Resolve the library classes in a module to library instances
1652 # This method will not only resolve library classes but also sort the library
1653 # instances according to the dependency-ship.
1655 # @param Module The module from which the library classes will be resolved
1657 # @retval library_list List of library instances sorted
1659 def ApplyLibraryInstance(self
, Module
):
1660 ModuleType
= Module
.ModuleType
1662 # for overridding library instances with module specific setting
1663 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
1665 # add forced library instances (specified under LibraryClasses sections)
1667 # If a module has a MODULE_TYPE of USER_DEFINED,
1668 # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
1670 if Module
.ModuleType
!= SUP_MODULE_USER_DEFINED
:
1671 for LibraryClass
in self
.Platform
.LibraryClasses
.GetKeys():
1672 if LibraryClass
.startswith("NULL") and self
.Platform
.LibraryClasses
[LibraryClass
, Module
.ModuleType
]:
1673 Module
.LibraryClasses
[LibraryClass
] = self
.Platform
.LibraryClasses
[LibraryClass
, Module
.ModuleType
]
1675 # add forced library instances (specified in module overrides)
1676 for LibraryClass
in PlatformModule
.LibraryClasses
:
1677 if LibraryClass
.startswith("NULL"):
1678 Module
.LibraryClasses
[LibraryClass
] = PlatformModule
.LibraryClasses
[LibraryClass
]
1681 LibraryConsumerList
= [Module
]
1683 ConsumedByList
= sdict()
1684 LibraryInstance
= sdict()
1686 EdkLogger
.verbose("")
1687 EdkLogger
.verbose("Library instances of module [%s] [%s]:" % (str(Module
), self
.Arch
))
1688 while len(LibraryConsumerList
) > 0:
1689 M
= LibraryConsumerList
.pop()
1690 for LibraryClassName
in M
.LibraryClasses
:
1691 if LibraryClassName
not in LibraryInstance
:
1692 # override library instance for this module
1693 if LibraryClassName
in PlatformModule
.LibraryClasses
:
1694 LibraryPath
= PlatformModule
.LibraryClasses
[LibraryClassName
]
1696 LibraryPath
= self
.Platform
.LibraryClasses
[LibraryClassName
, ModuleType
]
1697 if LibraryPath
== None or LibraryPath
== "":
1698 LibraryPath
= M
.LibraryClasses
[LibraryClassName
]
1699 if LibraryPath
== None or LibraryPath
== "":
1700 EdkLogger
.error("build", RESOURCE_NOT_AVAILABLE
,
1701 "Instance of library class [%s] is not found" % LibraryClassName
,
1703 ExtraData
="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M
), self
.Arch
, str(Module
)))
1705 LibraryModule
= self
.BuildDatabase
[LibraryPath
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1706 # for those forced library instance (NULL library), add a fake library class
1707 if LibraryClassName
.startswith("NULL"):
1708 LibraryModule
.LibraryClass
.append(LibraryClassObject(LibraryClassName
, [ModuleType
]))
1709 elif LibraryModule
.LibraryClass
== None \
1710 or len(LibraryModule
.LibraryClass
) == 0 \
1711 or (ModuleType
!= 'USER_DEFINED'
1712 and ModuleType
not in LibraryModule
.LibraryClass
[0].SupModList
):
1713 # only USER_DEFINED can link against any library instance despite of its SupModList
1714 EdkLogger
.error("build", OPTION_MISSING
,
1715 "Module type [%s] is not supported by library instance [%s]" \
1716 % (ModuleType
, LibraryPath
), File
=self
.MetaFile
,
1717 ExtraData
="consumed by [%s]" % str(Module
))
1719 LibraryInstance
[LibraryClassName
] = LibraryModule
1720 LibraryConsumerList
.append(LibraryModule
)
1721 EdkLogger
.verbose("\t" + str(LibraryClassName
) + " : " + str(LibraryModule
))
1723 LibraryModule
= LibraryInstance
[LibraryClassName
]
1725 if LibraryModule
== None:
1728 if LibraryModule
.ConstructorList
!= [] and LibraryModule
not in Constructor
:
1729 Constructor
.append(LibraryModule
)
1731 if LibraryModule
not in ConsumedByList
:
1732 ConsumedByList
[LibraryModule
] = []
1733 # don't add current module itself to consumer list
1735 if M
in ConsumedByList
[LibraryModule
]:
1737 ConsumedByList
[LibraryModule
].append(M
)
1739 # Initialize the sorted output list to the empty set
1741 SortedLibraryList
= []
1743 # Q <- Set of all nodes with no incoming edges
1745 LibraryList
= [] #LibraryInstance.values()
1747 for LibraryClassName
in LibraryInstance
:
1748 M
= LibraryInstance
[LibraryClassName
]
1749 LibraryList
.append(M
)
1750 if ConsumedByList
[M
] == []:
1754 # start the DAG algorithm
1758 while Q
== [] and EdgeRemoved
:
1760 # for each node Item with a Constructor
1761 for Item
in LibraryList
:
1762 if Item
not in Constructor
:
1764 # for each Node without a constructor with an edge e from Item to Node
1765 for Node
in ConsumedByList
[Item
]:
1766 if Node
in Constructor
:
1768 # remove edge e from the graph if Node has no constructor
1769 ConsumedByList
[Item
].remove(Node
)
1771 if ConsumedByList
[Item
] == []:
1772 # insert Item into Q
1777 # DAG is done if there's no more incoming edge for all nodes
1781 # remove node from Q
1784 SortedLibraryList
.append(Node
)
1786 # for each node Item with an edge e from Node to Item do
1787 for Item
in LibraryList
:
1788 if Node
not in ConsumedByList
[Item
]:
1790 # remove edge e from the graph
1791 ConsumedByList
[Item
].remove(Node
)
1793 if ConsumedByList
[Item
] != []:
1795 # insert Item into Q, if Item has no other incoming edges
1799 # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
1801 for Item
in LibraryList
:
1802 if ConsumedByList
[Item
] != [] and Item
in Constructor
and len(Constructor
) > 1:
1803 ErrorMessage
= "\tconsumed by " + "\n\tconsumed by ".join([str(L
) for L
in ConsumedByList
[Item
]])
1804 EdkLogger
.error("build", BUILD_ERROR
, 'Library [%s] with constructors has a cycle' % str(Item
),
1805 ExtraData
=ErrorMessage
, File
=self
.MetaFile
)
1806 if Item
not in SortedLibraryList
:
1807 SortedLibraryList
.append(Item
)
1810 # Build the list of constructor and destructir names
1811 # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
1813 SortedLibraryList
.reverse()
1814 return SortedLibraryList
1817 ## Override PCD setting (type, value, ...)
1819 # @param ToPcd The PCD to be overrided
1820 # @param FromPcd The PCD overrideing from
1822 def _OverridePcd(self
, ToPcd
, FromPcd
, Module
=""):
1824 # in case there's PCDs coming from FDF file, which have no type given.
1825 # at this point, ToPcd.Type has the type found from dependent
1829 if ToPcd
.Pending
and FromPcd
.Type
not in [None, '']:
1830 ToPcd
.Type
= FromPcd
.Type
1831 elif (ToPcd
.Type
not in [None, '']) and (FromPcd
.Type
not in [None, ''])\
1832 and (ToPcd
.Type
!= FromPcd
.Type
) and (ToPcd
.Type
in FromPcd
.Type
):
1833 if ToPcd
.Type
.strip() == "DynamicEx":
1834 ToPcd
.Type
= FromPcd
.Type
1835 elif ToPcd
.Type
not in [None, ''] and FromPcd
.Type
not in [None, ''] \
1836 and ToPcd
.Type
!= FromPcd
.Type
:
1837 EdkLogger
.error("build", OPTION_CONFLICT
, "Mismatched PCD type",
1838 ExtraData
="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\
1839 % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
,
1840 ToPcd
.Type
, Module
, FromPcd
.Type
),
1843 if FromPcd
.MaxDatumSize
not in [None, '']:
1844 ToPcd
.MaxDatumSize
= FromPcd
.MaxDatumSize
1845 if FromPcd
.DefaultValue
not in [None, '']:
1846 ToPcd
.DefaultValue
= FromPcd
.DefaultValue
1847 if FromPcd
.TokenValue
not in [None, '']:
1848 ToPcd
.TokenValue
= FromPcd
.TokenValue
1849 if FromPcd
.MaxDatumSize
not in [None, '']:
1850 ToPcd
.MaxDatumSize
= FromPcd
.MaxDatumSize
1851 if FromPcd
.DatumType
not in [None, '']:
1852 ToPcd
.DatumType
= FromPcd
.DatumType
1853 if FromPcd
.SkuInfoList
not in [None, '', []]:
1854 ToPcd
.SkuInfoList
= FromPcd
.SkuInfoList
1856 # check the validation of datum
1857 IsValid
, Cause
= CheckPcdDatum(ToPcd
.DatumType
, ToPcd
.DefaultValue
)
1859 EdkLogger
.error('build', FORMAT_INVALID
, Cause
, File
=self
.MetaFile
,
1860 ExtraData
="%s.%s" % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
))
1861 ToPcd
.validateranges
= FromPcd
.validateranges
1862 ToPcd
.validlists
= FromPcd
.validlists
1863 ToPcd
.expressions
= FromPcd
.expressions
1865 if ToPcd
.DatumType
== "VOID*" and ToPcd
.MaxDatumSize
in ['', None]:
1866 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "No MaxDatumSize specified for PCD %s.%s" \
1867 % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
))
1868 Value
= ToPcd
.DefaultValue
1869 if Value
in [None, '']:
1870 ToPcd
.MaxDatumSize
= '1'
1871 elif Value
[0] == 'L':
1872 ToPcd
.MaxDatumSize
= str((len(Value
) - 2) * 2)
1873 elif Value
[0] == '{':
1874 ToPcd
.MaxDatumSize
= str(len(Value
.split(',')))
1876 ToPcd
.MaxDatumSize
= str(len(Value
) - 1)
1878 # apply default SKU for dynamic PCDS if specified one is not available
1879 if (ToPcd
.Type
in PCD_DYNAMIC_TYPE_LIST
or ToPcd
.Type
in PCD_DYNAMIC_EX_TYPE_LIST
) \
1880 and ToPcd
.SkuInfoList
in [None, {}, '']:
1881 if self
.Platform
.SkuName
in self
.Platform
.SkuIds
:
1882 SkuName
= self
.Platform
.SkuName
1885 ToPcd
.SkuInfoList
= {
1886 SkuName
: SkuInfoClass(SkuName
, self
.Platform
.SkuIds
[SkuName
], '', '', '', '', '', ToPcd
.DefaultValue
)
1889 ## Apply PCD setting defined platform to a module
1891 # @param Module The module from which the PCD setting will be overrided
1893 # @retval PCD_list The list PCDs with settings from platform
1895 def ApplyPcdSetting(self
, Module
, Pcds
):
1896 # for each PCD in module
1897 for Name
, Guid
in Pcds
:
1898 PcdInModule
= Pcds
[Name
, Guid
]
1899 # find out the PCD setting in platform
1900 if (Name
, Guid
) in self
.Platform
.Pcds
:
1901 PcdInPlatform
= self
.Platform
.Pcds
[Name
, Guid
]
1903 PcdInPlatform
= None
1904 # then override the settings if any
1905 self
._OverridePcd
(PcdInModule
, PcdInPlatform
, Module
)
1906 # resolve the VariableGuid value
1907 for SkuId
in PcdInModule
.SkuInfoList
:
1908 Sku
= PcdInModule
.SkuInfoList
[SkuId
]
1909 if Sku
.VariableGuid
== '': continue
1910 Sku
.VariableGuidValue
= GuidValue(Sku
.VariableGuid
, self
.PackageList
)
1911 if Sku
.VariableGuidValue
== None:
1912 PackageList
= "\n\t".join([str(P
) for P
in self
.PackageList
])
1915 RESOURCE_NOT_AVAILABLE
,
1916 "Value of GUID [%s] is not found in" % Sku
.VariableGuid
,
1917 ExtraData
=PackageList
+ "\n\t(used with %s.%s from module %s)" \
1918 % (Guid
, Name
, str(Module
)),
1922 # override PCD settings with module specific setting
1923 if Module
in self
.Platform
.Modules
:
1924 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
1925 for Key
in PlatformModule
.Pcds
:
1927 self
._OverridePcd
(Pcds
[Key
], PlatformModule
.Pcds
[Key
], Module
)
1928 return Pcds
.values()
1930 ## Resolve library names to library modules
1932 # (for Edk.x modules)
1934 # @param Module The module from which the library names will be resolved
1936 # @retval library_list The list of library modules
1938 def ResolveLibraryReference(self
, Module
):
1939 EdkLogger
.verbose("")
1940 EdkLogger
.verbose("Library instances of module [%s] [%s]:" % (str(Module
), self
.Arch
))
1941 LibraryConsumerList
= [Module
]
1943 # "CompilerStub" is a must for Edk modules
1944 if Module
.Libraries
:
1945 Module
.Libraries
.append("CompilerStub")
1947 while len(LibraryConsumerList
) > 0:
1948 M
= LibraryConsumerList
.pop()
1949 for LibraryName
in M
.Libraries
:
1950 Library
= self
.Platform
.LibraryClasses
[LibraryName
, ':dummy:']
1952 for Key
in self
.Platform
.LibraryClasses
.data
.keys():
1953 if LibraryName
.upper() == Key
.upper():
1954 Library
= self
.Platform
.LibraryClasses
[Key
, ':dummy:']
1957 EdkLogger
.warn("build", "Library [%s] is not found" % LibraryName
, File
=str(M
),
1958 ExtraData
="\t%s [%s]" % (str(Module
), self
.Arch
))
1961 if Library
not in LibraryList
:
1962 LibraryList
.append(Library
)
1963 LibraryConsumerList
.append(Library
)
1964 EdkLogger
.verbose("\t" + LibraryName
+ " : " + str(Library
) + ' ' + str(type(Library
)))
1967 ## Calculate the priority value of the build option
1969 # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
1971 # @retval Value Priority value based on the priority list.
1973 def CalculatePriorityValue(self
, Key
):
1974 Target
, ToolChain
, Arch
, CommandType
, Attr
= Key
.split('_')
1975 PriorityValue
= 0x11111
1977 PriorityValue
&= 0x01111
1978 if ToolChain
== "*":
1979 PriorityValue
&= 0x10111
1981 PriorityValue
&= 0x11011
1982 if CommandType
== "*":
1983 PriorityValue
&= 0x11101
1985 PriorityValue
&= 0x11110
1987 return self
.PrioList
["0x%0.5x" % PriorityValue
]
1990 ## Expand * in build option key
1992 # @param Options Options to be expanded
1994 # @retval options Options expanded
1996 def _ExpandBuildOption(self
, Options
, ModuleStyle
=None):
2003 # Construct a list contain the build options which need override.
2007 # Key[0] -- tool family
2008 # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
2010 if (Key
[0] == self
.BuildRuleFamily
and
2011 (ModuleStyle
== None or len(Key
) < 3 or (len(Key
) > 2 and Key
[2] == ModuleStyle
))):
2012 Target
, ToolChain
, Arch
, CommandType
, Attr
= Key
[1].split('_')
2013 if Target
== self
.BuildTarget
or Target
== "*":
2014 if ToolChain
== self
.ToolChain
or ToolChain
== "*":
2015 if Arch
== self
.Arch
or Arch
== "*":
2016 if Options
[Key
].startswith("="):
2017 if OverrideList
.get(Key
[1]) != None:
2018 OverrideList
.pop(Key
[1])
2019 OverrideList
[Key
[1]] = Options
[Key
]
2022 # Use the highest priority value.
2024 if (len(OverrideList
) >= 2):
2025 KeyList
= OverrideList
.keys()
2026 for Index
in range(len(KeyList
)):
2027 NowKey
= KeyList
[Index
]
2028 Target1
, ToolChain1
, Arch1
, CommandType1
, Attr1
= NowKey
.split("_")
2029 for Index1
in range(len(KeyList
) - Index
- 1):
2030 NextKey
= KeyList
[Index1
+ Index
+ 1]
2032 # Compare two Key, if one is included by another, choose the higher priority one
2034 Target2
, ToolChain2
, Arch2
, CommandType2
, Attr2
= NextKey
.split("_")
2035 if Target1
== Target2
or Target1
== "*" or Target2
== "*":
2036 if ToolChain1
== ToolChain2
or ToolChain1
== "*" or ToolChain2
== "*":
2037 if Arch1
== Arch2
or Arch1
== "*" or Arch2
== "*":
2038 if CommandType1
== CommandType2
or CommandType1
== "*" or CommandType2
== "*":
2039 if Attr1
== Attr2
or Attr1
== "*" or Attr2
== "*":
2040 if self
.CalculatePriorityValue(NowKey
) > self
.CalculatePriorityValue(NextKey
):
2041 if Options
.get((self
.BuildRuleFamily
, NextKey
)) != None:
2042 Options
.pop((self
.BuildRuleFamily
, NextKey
))
2044 if Options
.get((self
.BuildRuleFamily
, NowKey
)) != None:
2045 Options
.pop((self
.BuildRuleFamily
, NowKey
))
2048 if ModuleStyle
!= None and len (Key
) > 2:
2049 # Check Module style is EDK or EDKII.
2050 # Only append build option for the matched style module.
2051 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
2053 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
2056 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
2057 # if tool chain family doesn't match, skip it
2058 if Tool
in self
.ToolDefinition
and Family
!= "":
2059 FamilyIsNull
= False
2060 if self
.ToolDefinition
[Tool
].get(TAB_TOD_DEFINES_BUILDRULEFAMILY
, "") != "":
2061 if Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_BUILDRULEFAMILY
]:
2063 elif Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_FAMILY
]:
2066 # expand any wildcard
2067 if Target
== "*" or Target
== self
.BuildTarget
:
2068 if Tag
== "*" or Tag
== self
.ToolChain
:
2069 if Arch
== "*" or Arch
== self
.Arch
:
2070 if Tool
not in BuildOptions
:
2071 BuildOptions
[Tool
] = {}
2072 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
2073 BuildOptions
[Tool
][Attr
] = Options
[Key
]
2075 # append options for the same tool
2076 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
2077 # Build Option Family has been checked, which need't to be checked again for family.
2078 if FamilyMatch
or FamilyIsNull
:
2082 if ModuleStyle
!= None and len (Key
) > 2:
2083 # Check Module style is EDK or EDKII.
2084 # Only append build option for the matched style module.
2085 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
2087 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
2090 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
2091 # if tool chain family doesn't match, skip it
2092 if Tool
not in self
.ToolDefinition
or Family
== "":
2094 # option has been added before
2095 if Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_FAMILY
]:
2098 # expand any wildcard
2099 if Target
== "*" or Target
== self
.BuildTarget
:
2100 if Tag
== "*" or Tag
== self
.ToolChain
:
2101 if Arch
== "*" or Arch
== self
.Arch
:
2102 if Tool
not in BuildOptions
:
2103 BuildOptions
[Tool
] = {}
2104 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
2105 BuildOptions
[Tool
][Attr
] = Options
[Key
]
2107 # append options for the same tool
2108 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
2111 ## Append build options in platform to a module
2113 # @param Module The module to which the build options will be appened
2115 # @retval options The options appended with build options in platform
2117 def ApplyBuildOption(self
, Module
):
2118 # Get the different options for the different style module
2119 if Module
.AutoGenVersion
< 0x00010005:
2120 PlatformOptions
= self
.EdkBuildOption
2121 ModuleTypeOptions
= self
.Platform
.GetBuildOptionsByModuleType(EDK_NAME
, Module
.ModuleType
)
2123 PlatformOptions
= self
.EdkIIBuildOption
2124 ModuleTypeOptions
= self
.Platform
.GetBuildOptionsByModuleType(EDKII_NAME
, Module
.ModuleType
)
2125 ModuleTypeOptions
= self
._ExpandBuildOption
(ModuleTypeOptions
)
2126 ModuleOptions
= self
._ExpandBuildOption
(Module
.BuildOptions
)
2127 if Module
in self
.Platform
.Modules
:
2128 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
2129 PlatformModuleOptions
= self
._ExpandBuildOption
(PlatformModule
.BuildOptions
)
2131 PlatformModuleOptions
= {}
2133 BuildRuleOrder
= None
2134 for Options
in [self
.ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
2135 for Tool
in Options
:
2136 for Attr
in Options
[Tool
]:
2137 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
2138 BuildRuleOrder
= Options
[Tool
][Attr
]
2140 AllTools
= set(ModuleOptions
.keys() + PlatformOptions
.keys() +
2141 PlatformModuleOptions
.keys() + ModuleTypeOptions
.keys() +
2142 self
.ToolDefinition
.keys())
2144 for Tool
in AllTools
:
2145 if Tool
not in BuildOptions
:
2146 BuildOptions
[Tool
] = {}
2148 for Options
in [self
.ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
2149 if Tool
not in Options
:
2151 for Attr
in Options
[Tool
]:
2152 Value
= Options
[Tool
][Attr
]
2154 # Do not generate it in Makefile
2156 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
2158 if Attr
not in BuildOptions
[Tool
]:
2159 BuildOptions
[Tool
][Attr
] = ""
2160 # check if override is indicated
2161 if Value
.startswith('='):
2162 ToolPath
= Value
[1:]
2163 ToolPath
= mws
.handleWsMacro(ToolPath
)
2164 BuildOptions
[Tool
][Attr
] = ToolPath
2166 Value
= mws
.handleWsMacro(Value
)
2167 BuildOptions
[Tool
][Attr
] += " " + Value
2168 if Module
.AutoGenVersion
< 0x00010005 and self
.Workspace
.UniFlag
!= None:
2170 # Override UNI flag only for EDK module.
2172 if 'BUILD' not in BuildOptions
:
2173 BuildOptions
['BUILD'] = {}
2174 BuildOptions
['BUILD']['FLAGS'] = self
.Workspace
.UniFlag
2175 return BuildOptions
, BuildRuleOrder
2177 Platform
= property(_GetPlatform
)
2178 Name
= property(_GetName
)
2179 Guid
= property(_GetGuid
)
2180 Version
= property(_GetVersion
)
2182 OutputDir
= property(_GetOutputDir
)
2183 BuildDir
= property(_GetBuildDir
)
2184 MakeFileDir
= property(_GetMakeFileDir
)
2185 FdfFile
= property(_GetFdfFile
)
2187 PcdTokenNumber
= property(_GetPcdTokenNumbers
) # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber
2188 DynamicPcdList
= property(_GetDynamicPcdList
) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
2189 NonDynamicPcdList
= property(_GetNonDynamicPcdList
) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
2190 NonDynamicPcdDict
= property(_GetNonDynamicPcdDict
)
2191 PackageList
= property(_GetPackageList
)
2193 ToolDefinition
= property(_GetToolDefinition
) # toolcode : tool path
2194 ToolDefinitionFile
= property(_GetToolDefFile
) # toolcode : lib path
2195 ToolChainFamily
= property(_GetToolChainFamily
)
2196 BuildRuleFamily
= property(_GetBuildRuleFamily
)
2197 BuildOption
= property(_GetBuildOptions
) # toolcode : option
2198 EdkBuildOption
= property(_GetEdkBuildOptions
) # edktoolcode : option
2199 EdkIIBuildOption
= property(_GetEdkIIBuildOptions
) # edkiitoolcode : option
2201 BuildCommand
= property(_GetBuildCommand
)
2202 BuildRule
= property(_GetBuildRule
)
2203 ModuleAutoGenList
= property(_GetModuleAutoGenList
)
2204 LibraryAutoGenList
= property(_GetLibraryAutoGenList
)
2205 GenFdsCommand
= property(_GenFdsCommand
)
2207 ## ModuleAutoGen class
2209 # This class encapsules the AutoGen behaviors for the build tools. In addition to
2210 # the generation of AutoGen.h and AutoGen.c, it will generate *.depex file according
2211 # to the [depex] section in module's inf file.
2213 class ModuleAutoGen(AutoGen
):
2214 ## The real constructor of ModuleAutoGen
2216 # This method is not supposed to be called by users of ModuleAutoGen. It's
2217 # only used by factory method __new__() to do real initialization work for an
2218 # object of ModuleAutoGen
2220 # @param Workspace EdkIIWorkspaceBuild object
2221 # @param ModuleFile The path of module file
2222 # @param Target Build target (DEBUG, RELEASE)
2223 # @param Toolchain Name of tool chain
2224 # @param Arch The arch the module supports
2225 # @param PlatformFile Platform meta-file
2227 def _Init(self
, Workspace
, ModuleFile
, Target
, Toolchain
, Arch
, PlatformFile
):
2228 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "AutoGen module [%s] [%s]" % (ModuleFile
, Arch
))
2229 GlobalData
.gProcessingFile
= "%s [%s, %s, %s]" % (ModuleFile
, Arch
, Toolchain
, Target
)
2231 self
.Workspace
= Workspace
2232 self
.WorkspaceDir
= Workspace
.WorkspaceDir
2234 self
.MetaFile
= ModuleFile
2235 self
.PlatformInfo
= PlatformAutoGen(Workspace
, PlatformFile
, Target
, Toolchain
, Arch
)
2236 # check if this module is employed by active platform
2237 if not self
.PlatformInfo
.ValidModule(self
.MetaFile
):
2238 EdkLogger
.verbose("Module [%s] for [%s] is not employed by active platform\n" \
2239 % (self
.MetaFile
, Arch
))
2242 self
.SourceDir
= self
.MetaFile
.SubDir
2243 self
.SourceDir
= mws
.relpath(self
.SourceDir
, self
.WorkspaceDir
)
2245 self
.SourceOverrideDir
= None
2246 # use overrided path defined in DSC file
2247 if self
.MetaFile
.Key
in GlobalData
.gOverrideDir
:
2248 self
.SourceOverrideDir
= GlobalData
.gOverrideDir
[self
.MetaFile
.Key
]
2250 self
.ToolChain
= Toolchain
2251 self
.BuildTarget
= Target
2253 self
.ToolChainFamily
= self
.PlatformInfo
.ToolChainFamily
2254 self
.BuildRuleFamily
= self
.PlatformInfo
.BuildRuleFamily
2256 self
.IsMakeFileCreated
= False
2257 self
.IsCodeFileCreated
= False
2258 self
.IsAsBuiltInfCreated
= False
2259 self
.DepexGenerated
= False
2261 self
.BuildDatabase
= self
.Workspace
.BuildDatabase
2262 self
.BuildRuleOrder
= None
2267 self
._Version
= None
2268 self
._ModuleType
= None
2269 self
._ComponentType
= None
2270 self
._PcdIsDriver
= None
2271 self
._AutoGenVersion
= None
2272 self
._LibraryFlag
= None
2273 self
._CustomMakefile
= None
2276 self
._BuildDir
= None
2277 self
._OutputDir
= None
2278 self
._DebugDir
= None
2279 self
._MakeFileDir
= None
2281 self
._IncludePathList
= None
2282 self
._AutoGenFileList
= None
2283 self
._UnicodeFileList
= None
2284 self
._SourceFileList
= None
2285 self
._ObjectFileList
= None
2286 self
._BinaryFileList
= None
2288 self
._DependentPackageList
= None
2289 self
._DependentLibraryList
= None
2290 self
._LibraryAutoGenList
= None
2291 self
._DerivedPackageList
= None
2292 self
._ModulePcdList
= None
2293 self
._LibraryPcdList
= None
2294 self
._PcdComments
= sdict()
2295 self
._GuidList
= None
2296 self
._GuidsUsedByPcd
= None
2297 self
._GuidComments
= sdict()
2298 self
._ProtocolList
= None
2299 self
._ProtocolComments
= sdict()
2300 self
._PpiList
= None
2301 self
._PpiComments
= sdict()
2302 self
._DepexList
= None
2303 self
._DepexExpressionList
= None
2304 self
._BuildOption
= None
2305 self
._BuildOptionIncPathList
= None
2306 self
._BuildTargets
= None
2307 self
._IntroBuildTargetList
= None
2308 self
._FinalBuildTargetList
= None
2309 self
._FileTypes
= None
2310 self
._BuildRules
= None
2312 ## The Modules referenced to this Library
2313 # Only Library has this attribute
2314 self
._ReferenceModules
= []
2316 ## Store the FixedAtBuild Pcds
2318 self
._FixedAtBuildPcds
= []
2323 return "%s [%s]" % (self
.MetaFile
, self
.Arch
)
2325 # Get FixedAtBuild Pcds of this Module
2326 def _GetFixedAtBuildPcds(self
):
2327 if self
._FixedAtBuildPcds
:
2328 return self
._FixedAtBuildPcds
2329 for Pcd
in self
.ModulePcdList
:
2331 if not (Pcd
.Pending
== False and Pcd
.Type
== "FixedAtBuild"):
2333 elif Pcd
.Type
!= "FixedAtBuild":
2335 if Pcd
not in self
._FixedAtBuildPcds
:
2336 self
._FixedAtBuildPcds
.append(Pcd
)
2338 return self
._FixedAtBuildPcds
2340 def _GetUniqueBaseName(self
):
2341 BaseName
= self
.Name
2342 for Module
in self
.PlatformInfo
.ModuleAutoGenList
:
2343 if Module
.MetaFile
== self
.MetaFile
:
2345 if Module
.Name
== self
.Name
:
2346 if uuid
.UUID(Module
.Guid
) == uuid
.UUID(self
.Guid
):
2347 EdkLogger
.error("build", FILE_DUPLICATED
, 'Modules have same BaseName and FILE_GUID:\n'
2348 ' %s\n %s' % (Module
.MetaFile
, self
.MetaFile
))
2349 BaseName
= '%s_%s' % (self
.Name
, self
.Guid
)
2352 # Macros could be used in build_rule.txt (also Makefile)
2353 def _GetMacros(self
):
2354 if self
._Macro
== None:
2355 self
._Macro
= sdict()
2356 self
._Macro
["WORKSPACE" ] = self
.WorkspaceDir
2357 self
._Macro
["MODULE_NAME" ] = self
.Name
2358 self
._Macro
["MODULE_NAME_GUID" ] = self
._GetUniqueBaseName
()
2359 self
._Macro
["MODULE_GUID" ] = self
.Guid
2360 self
._Macro
["MODULE_VERSION" ] = self
.Version
2361 self
._Macro
["MODULE_TYPE" ] = self
.ModuleType
2362 self
._Macro
["MODULE_FILE" ] = str(self
.MetaFile
)
2363 self
._Macro
["MODULE_FILE_BASE_NAME" ] = self
.MetaFile
.BaseName
2364 self
._Macro
["MODULE_RELATIVE_DIR" ] = self
.SourceDir
2365 self
._Macro
["MODULE_DIR" ] = self
.SourceDir
2367 self
._Macro
["BASE_NAME" ] = self
.Name
2369 self
._Macro
["ARCH" ] = self
.Arch
2370 self
._Macro
["TOOLCHAIN" ] = self
.ToolChain
2371 self
._Macro
["TOOLCHAIN_TAG" ] = self
.ToolChain
2372 self
._Macro
["TOOL_CHAIN_TAG" ] = self
.ToolChain
2373 self
._Macro
["TARGET" ] = self
.BuildTarget
2375 self
._Macro
["BUILD_DIR" ] = self
.PlatformInfo
.BuildDir
2376 self
._Macro
["BIN_DIR" ] = os
.path
.join(self
.PlatformInfo
.BuildDir
, self
.Arch
)
2377 self
._Macro
["LIB_DIR" ] = os
.path
.join(self
.PlatformInfo
.BuildDir
, self
.Arch
)
2378 self
._Macro
["MODULE_BUILD_DIR" ] = self
.BuildDir
2379 self
._Macro
["OUTPUT_DIR" ] = self
.OutputDir
2380 self
._Macro
["DEBUG_DIR" ] = self
.DebugDir
2383 ## Return the module build data object
2384 def _GetModule(self
):
2385 if self
._Module
== None:
2386 self
._Module
= self
.Workspace
.BuildDatabase
[self
.MetaFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
2389 ## Return the module name
2390 def _GetBaseName(self
):
2391 return self
.Module
.BaseName
2393 ## Return the module DxsFile if exist
2394 def _GetDxsFile(self
):
2395 return self
.Module
.DxsFile
2397 ## Return the module SourceOverridePath
2398 def _GetSourceOverridePath(self
):
2399 return self
.Module
.SourceOverridePath
2401 ## Return the module meta-file GUID
2404 # To build same module more than once, the module path with FILE_GUID overridden has
2405 # the file name FILE_GUIDmodule.inf, but the relative path (self.MetaFile.File) is the realy path
2406 # in DSC. The overridden GUID can be retrieved from file name
2408 if os
.path
.basename(self
.MetaFile
.File
) != os
.path
.basename(self
.MetaFile
.Path
):
2410 # Length of GUID is 36
2412 return os
.path
.basename(self
.MetaFile
.Path
)[:36]
2413 return self
.Module
.Guid
2415 ## Return the module version
2416 def _GetVersion(self
):
2417 return self
.Module
.Version
2419 ## Return the module type
2420 def _GetModuleType(self
):
2421 return self
.Module
.ModuleType
2423 ## Return the component type (for Edk.x style of module)
2424 def _GetComponentType(self
):
2425 return self
.Module
.ComponentType
2427 ## Return the build type
2428 def _GetBuildType(self
):
2429 return self
.Module
.BuildType
2431 ## Return the PCD_IS_DRIVER setting
2432 def _GetPcdIsDriver(self
):
2433 return self
.Module
.PcdIsDriver
2435 ## Return the autogen version, i.e. module meta-file version
2436 def _GetAutoGenVersion(self
):
2437 return self
.Module
.AutoGenVersion
2439 ## Check if the module is library or not
2440 def _IsLibrary(self
):
2441 if self
._LibraryFlag
== None:
2442 if self
.Module
.LibraryClass
!= None and self
.Module
.LibraryClass
!= []:
2443 self
._LibraryFlag
= True
2445 self
._LibraryFlag
= False
2446 return self
._LibraryFlag
2448 ## Check if the module is binary module or not
2449 def _IsBinaryModule(self
):
2450 return self
.Module
.IsBinaryModule
2452 ## Return the directory to store intermediate files of the module
2453 def _GetBuildDir(self
):
2454 if self
._BuildDir
== None:
2455 self
._BuildDir
= path
.join(
2456 self
.PlatformInfo
.BuildDir
,
2459 self
.MetaFile
.BaseName
2461 CreateDirectory(self
._BuildDir
)
2462 return self
._BuildDir
2464 ## Return the directory to store the intermediate object files of the mdoule
2465 def _GetOutputDir(self
):
2466 if self
._OutputDir
== None:
2467 self
._OutputDir
= path
.join(self
.BuildDir
, "OUTPUT")
2468 CreateDirectory(self
._OutputDir
)
2469 return self
._OutputDir
2471 ## Return the directory to store auto-gened source files of the mdoule
2472 def _GetDebugDir(self
):
2473 if self
._DebugDir
== None:
2474 self
._DebugDir
= path
.join(self
.BuildDir
, "DEBUG")
2475 CreateDirectory(self
._DebugDir
)
2476 return self
._DebugDir
2478 ## Return the path of custom file
2479 def _GetCustomMakefile(self
):
2480 if self
._CustomMakefile
== None:
2481 self
._CustomMakefile
= {}
2482 for Type
in self
.Module
.CustomMakefile
:
2483 if Type
in gMakeTypeMap
:
2484 MakeType
= gMakeTypeMap
[Type
]
2487 if self
.SourceOverrideDir
!= None:
2488 File
= os
.path
.join(self
.SourceOverrideDir
, self
.Module
.CustomMakefile
[Type
])
2489 if not os
.path
.exists(File
):
2490 File
= os
.path
.join(self
.SourceDir
, self
.Module
.CustomMakefile
[Type
])
2492 File
= os
.path
.join(self
.SourceDir
, self
.Module
.CustomMakefile
[Type
])
2493 self
._CustomMakefile
[MakeType
] = File
2494 return self
._CustomMakefile
2496 ## Return the directory of the makefile
2498 # @retval string The directory string of module's makefile
2500 def _GetMakeFileDir(self
):
2501 return self
.BuildDir
2503 ## Return build command string
2505 # @retval string Build command string
2507 def _GetBuildCommand(self
):
2508 return self
.PlatformInfo
.BuildCommand
2510 ## Get object list of all packages the module and its dependent libraries belong to
2512 # @retval list The list of package object
2514 def _GetDerivedPackageList(self
):
2516 for M
in [self
.Module
] + self
.DependentLibraryList
:
2517 for Package
in M
.Packages
:
2518 if Package
in PackageList
:
2520 PackageList
.append(Package
)
2523 ## Get the depex string
2525 # @return : a string contain all depex expresion.
2526 def _GetDepexExpresionString(self
):
2529 ## DPX_SOURCE IN Define section.
2530 if self
.Module
.DxsFile
:
2532 for M
in [self
.Module
] + self
.DependentLibraryList
:
2533 Filename
= M
.MetaFile
.Path
2534 InfObj
= InfSectionParser
.InfSectionParser(Filename
)
2535 DepexExpresionList
= InfObj
.GetDepexExpresionList()
2536 for DepexExpresion
in DepexExpresionList
:
2537 for key
in DepexExpresion
.keys():
2538 Arch
, ModuleType
= key
2539 # the type of build module is USER_DEFINED.
2540 # All different DEPEX section tags would be copied into the As Built INF file
2541 # and there would be separate DEPEX section tags
2542 if self
.ModuleType
.upper() == SUP_MODULE_USER_DEFINED
:
2543 if (Arch
.upper() == self
.Arch
.upper()) and (ModuleType
.upper() != TAB_ARCH_COMMON
):
2544 DepexList
.append({(Arch
, ModuleType
): DepexExpresion
[key
][:]})
2546 if Arch
.upper() == TAB_ARCH_COMMON
or \
2547 (Arch
.upper() == self
.Arch
.upper() and \
2548 ModuleType
.upper() in [TAB_ARCH_COMMON
, self
.ModuleType
.upper()]):
2549 DepexList
.append({(Arch
, ModuleType
): DepexExpresion
[key
][:]})
2551 #the type of build module is USER_DEFINED.
2552 if self
.ModuleType
.upper() == SUP_MODULE_USER_DEFINED
:
2553 for Depex
in DepexList
:
2554 for key
in Depex
.keys():
2555 DepexStr
+= '[Depex.%s.%s]\n' % key
2556 DepexStr
+= '\n'.join(['# '+ val
for val
in Depex
[key
]])
2559 return '[Depex.%s]\n' % self
.Arch
2562 #the type of build module not is USER_DEFINED.
2564 for Depex
in DepexList
:
2569 for D
in Depex
.values():
2570 DepexStr
+= ' '.join([val
for val
in D
])
2571 Index
= DepexStr
.find('END')
2572 if Index
> -1 and Index
== len(DepexStr
) - 3:
2573 DepexStr
= DepexStr
[:-3]
2574 DepexStr
= DepexStr
.strip()
2577 DepexStr
= DepexStr
.lstrip('(').rstrip(')').strip()
2579 return '[Depex.%s]\n' % self
.Arch
2580 return '[Depex.%s]\n# ' % self
.Arch
+ DepexStr
2582 ## Merge dependency expression
2584 # @retval list The token list of the dependency expression after parsed
2586 def _GetDepexTokenList(self
):
2587 if self
._DepexList
== None:
2588 self
._DepexList
= {}
2589 if self
.DxsFile
or self
.IsLibrary
or TAB_DEPENDENCY_EXPRESSION_FILE
in self
.FileTypes
:
2590 return self
._DepexList
2592 self
._DepexList
[self
.ModuleType
] = []
2594 for ModuleType
in self
._DepexList
:
2595 DepexList
= self
._DepexList
[ModuleType
]
2597 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
2599 for M
in [self
.Module
] + self
.DependentLibraryList
:
2601 for D
in M
.Depex
[self
.Arch
, ModuleType
]:
2603 DepexList
.append('AND')
2604 DepexList
.append('(')
2606 if DepexList
[-1] == 'END': # no need of a END at this time
2608 DepexList
.append(')')
2611 EdkLogger
.verbose("DEPEX[%s] (+%s) = %s" % (self
.Name
, M
.BaseName
, DepexList
))
2612 if 'BEFORE' in DepexList
or 'AFTER' in DepexList
:
2614 if len(DepexList
) > 0:
2615 EdkLogger
.verbose('')
2616 return self
._DepexList
2618 ## Merge dependency expression
2620 # @retval list The token list of the dependency expression after parsed
2622 def _GetDepexExpressionTokenList(self
):
2623 if self
._DepexExpressionList
== None:
2624 self
._DepexExpressionList
= {}
2625 if self
.DxsFile
or self
.IsLibrary
or TAB_DEPENDENCY_EXPRESSION_FILE
in self
.FileTypes
:
2626 return self
._DepexExpressionList
2628 self
._DepexExpressionList
[self
.ModuleType
] = ''
2630 for ModuleType
in self
._DepexExpressionList
:
2631 DepexExpressionList
= self
._DepexExpressionList
[ModuleType
]
2633 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
2635 for M
in [self
.Module
] + self
.DependentLibraryList
:
2637 for D
in M
.DepexExpression
[self
.Arch
, ModuleType
]:
2638 if DepexExpressionList
!= '':
2639 DepexExpressionList
+= ' AND '
2640 DepexExpressionList
+= '('
2641 DepexExpressionList
+= D
2642 DepexExpressionList
= DepexExpressionList
.rstrip('END').strip()
2643 DepexExpressionList
+= ')'
2646 EdkLogger
.verbose("DEPEX[%s] (+%s) = %s" % (self
.Name
, M
.BaseName
, DepexExpressionList
))
2647 if 'BEFORE' in DepexExpressionList
or 'AFTER' in DepexExpressionList
:
2649 if len(DepexExpressionList
) > 0:
2650 EdkLogger
.verbose('')
2651 self
._DepexExpressionList
[ModuleType
] = DepexExpressionList
2652 return self
._DepexExpressionList
2654 ## Return the list of specification version required for the module
2656 # @retval list The list of specification defined in module file
2658 def _GetSpecification(self
):
2659 return self
.Module
.Specification
2661 ## Tool option for the module build
2663 # @param PlatformInfo The object of PlatformBuildInfo
2664 # @retval dict The dict containing valid options
2666 def _GetModuleBuildOption(self
):
2667 if self
._BuildOption
== None:
2668 self
._BuildOption
, self
.BuildRuleOrder
= self
.PlatformInfo
.ApplyBuildOption(self
.Module
)
2669 if self
.BuildRuleOrder
:
2670 self
.BuildRuleOrder
= ['.%s' % Ext
for Ext
in self
.BuildRuleOrder
.split()]
2671 return self
._BuildOption
2673 ## Get include path list from tool option for the module build
2675 # @retval list The include path list
2677 def _GetBuildOptionIncPathList(self
):
2678 if self
._BuildOptionIncPathList
== None:
2680 # Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT
2681 # is the former use /I , the Latter used -I to specify include directories
2683 if self
.PlatformInfo
.ToolChainFamily
in ('MSFT'):
2684 gBuildOptIncludePattern
= re
.compile(r
"(?:.*?)/I[ \t]*([^ ]*)", re
.MULTILINE | re
.DOTALL
)
2685 elif self
.PlatformInfo
.ToolChainFamily
in ('INTEL', 'GCC', 'RVCT'):
2686 gBuildOptIncludePattern
= re
.compile(r
"(?:.*?)-I[ \t]*([^ ]*)", re
.MULTILINE | re
.DOTALL
)
2689 # New ToolChainFamily, don't known whether there is option to specify include directories
2691 self
._BuildOptionIncPathList
= []
2692 return self
._BuildOptionIncPathList
2694 BuildOptionIncPathList
= []
2695 for Tool
in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'):
2698 FlagOption
= self
.BuildOption
[Tool
][Attr
]
2702 if self
.PlatformInfo
.ToolChainFamily
!= 'RVCT':
2703 IncPathList
= [NormPath(Path
, self
.Macros
) for Path
in gBuildOptIncludePattern
.findall(FlagOption
)]
2706 # RVCT may specify a list of directory seperated by commas
2709 for Path
in gBuildOptIncludePattern
.findall(FlagOption
):
2710 PathList
= GetSplitList(Path
, TAB_COMMA_SPLIT
)
2711 IncPathList
+= [NormPath(PathEntry
, self
.Macros
) for PathEntry
in PathList
]
2714 # EDK II modules must not reference header files outside of the packages they depend on or
2715 # within the module's directory tree. Report error if violation.
2717 if self
.AutoGenVersion
>= 0x00010005 and len(IncPathList
) > 0:
2718 for Path
in IncPathList
:
2719 if (Path
not in self
.IncludePathList
) and (CommonPath([Path
, self
.MetaFile
.Dir
]) != self
.MetaFile
.Dir
):
2720 ErrMsg
= "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path
, Tool
, FlagOption
)
2721 EdkLogger
.error("build",
2724 File
=str(self
.MetaFile
))
2727 BuildOptionIncPathList
+= IncPathList
2729 self
._BuildOptionIncPathList
= BuildOptionIncPathList
2731 return self
._BuildOptionIncPathList
2733 ## Return a list of files which can be built from source
2735 # What kind of files can be built is determined by build rules in
2736 # $(CONF_DIRECTORY)/build_rule.txt and toolchain family.
2738 def _GetSourceFileList(self
):
2739 if self
._SourceFileList
== None:
2740 self
._SourceFileList
= []
2741 for F
in self
.Module
.Sources
:
2743 if F
.TagName
not in ("", "*", self
.ToolChain
):
2744 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "The toolchain [%s] for processing file [%s] is found, "
2745 "but [%s] is needed" % (F
.TagName
, str(F
), self
.ToolChain
))
2747 # match tool chain family
2748 if F
.ToolChainFamily
not in ("", "*", self
.ToolChainFamily
):
2751 "The file [%s] must be built by tools of [%s], " \
2752 "but current toolchain family is [%s]" \
2753 % (str(F
), F
.ToolChainFamily
, self
.ToolChainFamily
))
2756 # add the file path into search path list for file including
2757 if F
.Dir
not in self
.IncludePathList
and self
.AutoGenVersion
>= 0x00010005:
2758 self
.IncludePathList
.insert(0, F
.Dir
)
2759 self
._SourceFileList
.append(F
)
2761 self
._MatchBuildRuleOrder
(self
._SourceFileList
)
2763 for F
in self
._SourceFileList
:
2764 self
._ApplyBuildRule
(F
, TAB_UNKNOWN_FILE
)
2765 return self
._SourceFileList
2767 def _MatchBuildRuleOrder(self
, FileList
):
2769 self
._GetModuleBuildOption
()
2770 for SingleFile
in FileList
:
2771 if self
.BuildRuleOrder
and SingleFile
.Ext
in self
.BuildRuleOrder
and SingleFile
.Ext
in self
.BuildRules
:
2772 key
= SingleFile
.Path
.split(SingleFile
.Ext
)[0]
2773 if key
in Order_Dict
:
2774 Order_Dict
[key
].append(SingleFile
.Ext
)
2776 Order_Dict
[key
] = [SingleFile
.Ext
]
2779 for F
in Order_Dict
:
2780 if len(Order_Dict
[F
]) > 1:
2781 Order_Dict
[F
].sort(key
=lambda i
: self
.BuildRuleOrder
.index(i
))
2782 for Ext
in Order_Dict
[F
][1:]:
2783 RemoveList
.append(F
+ Ext
)
2785 for item
in RemoveList
:
2786 FileList
.remove(item
)
2790 ## Return the list of unicode files
2791 def _GetUnicodeFileList(self
):
2792 if self
._UnicodeFileList
== None:
2793 if TAB_UNICODE_FILE
in self
.FileTypes
:
2794 self
._UnicodeFileList
= self
.FileTypes
[TAB_UNICODE_FILE
]
2796 self
._UnicodeFileList
= []
2797 return self
._UnicodeFileList
2799 ## Return a list of files which can be built from binary
2801 # "Build" binary files are just to copy them to build directory.
2803 # @retval list The list of files which can be built later
2805 def _GetBinaryFiles(self
):
2806 if self
._BinaryFileList
== None:
2807 self
._BinaryFileList
= []
2808 for F
in self
.Module
.Binaries
:
2809 if F
.Target
not in ['COMMON', '*'] and F
.Target
!= self
.BuildTarget
:
2811 self
._BinaryFileList
.append(F
)
2812 self
._ApplyBuildRule
(F
, F
.Type
)
2813 return self
._BinaryFileList
2815 def _GetBuildRules(self
):
2816 if self
._BuildRules
== None:
2818 BuildRuleDatabase
= self
.PlatformInfo
.BuildRule
2819 for Type
in BuildRuleDatabase
.FileTypeList
:
2820 #first try getting build rule by BuildRuleFamily
2821 RuleObject
= BuildRuleDatabase
[Type
, self
.BuildType
, self
.Arch
, self
.BuildRuleFamily
]
2823 # build type is always module type, but ...
2824 if self
.ModuleType
!= self
.BuildType
:
2825 RuleObject
= BuildRuleDatabase
[Type
, self
.ModuleType
, self
.Arch
, self
.BuildRuleFamily
]
2826 #second try getting build rule by ToolChainFamily
2828 RuleObject
= BuildRuleDatabase
[Type
, self
.BuildType
, self
.Arch
, self
.ToolChainFamily
]
2830 # build type is always module type, but ...
2831 if self
.ModuleType
!= self
.BuildType
:
2832 RuleObject
= BuildRuleDatabase
[Type
, self
.ModuleType
, self
.Arch
, self
.ToolChainFamily
]
2835 RuleObject
= RuleObject
.Instantiate(self
.Macros
)
2836 BuildRules
[Type
] = RuleObject
2837 for Ext
in RuleObject
.SourceFileExtList
:
2838 BuildRules
[Ext
] = RuleObject
2839 self
._BuildRules
= BuildRules
2840 return self
._BuildRules
2842 def _ApplyBuildRule(self
, File
, FileType
):
2843 if self
._BuildTargets
== None:
2844 self
._IntroBuildTargetList
= set()
2845 self
._FinalBuildTargetList
= set()
2846 self
._BuildTargets
= {}
2847 self
._FileTypes
= {}
2849 SubDirectory
= os
.path
.join(self
.OutputDir
, File
.SubDir
)
2850 if not os
.path
.exists(SubDirectory
):
2851 CreateDirectory(SubDirectory
)
2857 # Make sure to get build rule order value
2859 self
._GetModuleBuildOption
()
2861 while Index
< len(SourceList
):
2862 Source
= SourceList
[Index
]
2866 CreateDirectory(Source
.Dir
)
2868 if File
.IsBinary
and File
== Source
and self
._BinaryFileList
!= None and File
in self
._BinaryFileList
:
2869 # Skip all files that are not binary libraries
2870 if not self
.IsLibrary
:
2872 RuleObject
= self
.BuildRules
[TAB_DEFAULT_BINARY_FILE
]
2873 elif FileType
in self
.BuildRules
:
2874 RuleObject
= self
.BuildRules
[FileType
]
2875 elif Source
.Ext
in self
.BuildRules
:
2876 RuleObject
= self
.BuildRules
[Source
.Ext
]
2878 # stop at no more rules
2880 self
._FinalBuildTargetList
.add(LastTarget
)
2883 FileType
= RuleObject
.SourceFileType
2884 if FileType
not in self
._FileTypes
:
2885 self
._FileTypes
[FileType
] = set()
2886 self
._FileTypes
[FileType
].add(Source
)
2888 # stop at STATIC_LIBRARY for library
2889 if self
.IsLibrary
and FileType
== TAB_STATIC_LIBRARY
:
2891 self
._FinalBuildTargetList
.add(LastTarget
)
2894 Target
= RuleObject
.Apply(Source
, self
.BuildRuleOrder
)
2897 self
._FinalBuildTargetList
.add(LastTarget
)
2899 elif not Target
.Outputs
:
2900 # Only do build for target with outputs
2901 self
._FinalBuildTargetList
.add(Target
)
2903 if FileType
not in self
._BuildTargets
:
2904 self
._BuildTargets
[FileType
] = set()
2905 self
._BuildTargets
[FileType
].add(Target
)
2907 if not Source
.IsBinary
and Source
== File
:
2908 self
._IntroBuildTargetList
.add(Target
)
2910 # to avoid cyclic rule
2911 if FileType
in RuleChain
:
2914 RuleChain
.append(FileType
)
2915 SourceList
.extend(Target
.Outputs
)
2917 FileType
= TAB_UNKNOWN_FILE
2919 def _GetTargets(self
):
2920 if self
._BuildTargets
== None:
2921 self
._IntroBuildTargetList
= set()
2922 self
._FinalBuildTargetList
= set()
2923 self
._BuildTargets
= {}
2924 self
._FileTypes
= {}
2926 #TRICK: call _GetSourceFileList to apply build rule for source files
2927 if self
.SourceFileList
:
2930 #TRICK: call _GetBinaryFileList to apply build rule for binary files
2931 if self
.BinaryFileList
:
2934 return self
._BuildTargets
2936 def _GetIntroTargetList(self
):
2938 return self
._IntroBuildTargetList
2940 def _GetFinalTargetList(self
):
2942 return self
._FinalBuildTargetList
2944 def _GetFileTypes(self
):
2946 return self
._FileTypes
2948 ## Get the list of package object the module depends on
2950 # @retval list The package object list
2952 def _GetDependentPackageList(self
):
2953 return self
.Module
.Packages
2955 ## Return the list of auto-generated code file
2957 # @retval list The list of auto-generated file
2959 def _GetAutoGenFileList(self
):
2960 UniStringAutoGenC
= True
2961 UniStringBinBuffer
= StringIO()
2962 if self
.BuildType
== 'UEFI_HII':
2963 UniStringAutoGenC
= False
2964 if self
._AutoGenFileList
== None:
2965 self
._AutoGenFileList
= {}
2966 AutoGenC
= TemplateString()
2967 AutoGenH
= TemplateString()
2968 StringH
= TemplateString()
2969 GenC
.CreateCode(self
, AutoGenC
, AutoGenH
, StringH
, UniStringAutoGenC
, UniStringBinBuffer
)
2971 # AutoGen.c is generated if there are library classes in inf, or there are object files
2973 if str(AutoGenC
) != "" and (len(self
.Module
.LibraryClasses
) > 0
2974 or TAB_OBJECT_FILE
in self
.FileTypes
):
2975 AutoFile
= PathClass(gAutoGenCodeFileName
, self
.DebugDir
)
2976 self
._AutoGenFileList
[AutoFile
] = str(AutoGenC
)
2977 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2978 if str(AutoGenH
) != "":
2979 AutoFile
= PathClass(gAutoGenHeaderFileName
, self
.DebugDir
)
2980 self
._AutoGenFileList
[AutoFile
] = str(AutoGenH
)
2981 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2982 if str(StringH
) != "":
2983 AutoFile
= PathClass(gAutoGenStringFileName
% {"module_name":self
.Name
}, self
.DebugDir
)
2984 self
._AutoGenFileList
[AutoFile
] = str(StringH
)
2985 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2986 if UniStringBinBuffer
!= None and UniStringBinBuffer
.getvalue() != "":
2987 AutoFile
= PathClass(gAutoGenStringFormFileName
% {"module_name":self
.Name
}, self
.OutputDir
)
2988 self
._AutoGenFileList
[AutoFile
] = UniStringBinBuffer
.getvalue()
2989 AutoFile
.IsBinary
= True
2990 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2991 if UniStringBinBuffer
!= None:
2992 UniStringBinBuffer
.close()
2993 return self
._AutoGenFileList
2995 ## Return the list of library modules explicitly or implicityly used by this module
2996 def _GetLibraryList(self
):
2997 if self
._DependentLibraryList
== None:
2998 # only merge library classes and PCD for non-library module
3000 self
._DependentLibraryList
= []
3002 if self
.AutoGenVersion
< 0x00010005:
3003 self
._DependentLibraryList
= self
.PlatformInfo
.ResolveLibraryReference(self
.Module
)
3005 self
._DependentLibraryList
= self
.PlatformInfo
.ApplyLibraryInstance(self
.Module
)
3006 return self
._DependentLibraryList
3009 def UpdateComments(Recver
, Src
):
3011 if Key
not in Recver
:
3013 Recver
[Key
].extend(Src
[Key
])
3014 ## Get the list of PCDs from current module
3016 # @retval list The list of PCD
3018 def _GetModulePcdList(self
):
3019 if self
._ModulePcdList
== None:
3020 # apply PCD settings from platform
3021 self
._ModulePcdList
= self
.PlatformInfo
.ApplyPcdSetting(self
.Module
, self
.Module
.Pcds
)
3022 self
.UpdateComments(self
._PcdComments
, self
.Module
.PcdComments
)
3023 return self
._ModulePcdList
3025 ## Get the list of PCDs from dependent libraries
3027 # @retval list The list of PCD
3029 def _GetLibraryPcdList(self
):
3030 if self
._LibraryPcdList
== None:
3032 if not self
.IsLibrary
:
3033 # get PCDs from dependent libraries
3034 for Library
in self
.DependentLibraryList
:
3035 self
.UpdateComments(self
._PcdComments
, Library
.PcdComments
)
3036 for Key
in Library
.Pcds
:
3037 # skip duplicated PCDs
3038 if Key
in self
.Module
.Pcds
or Key
in Pcds
:
3040 Pcds
[Key
] = copy
.copy(Library
.Pcds
[Key
])
3041 # apply PCD settings from platform
3042 self
._LibraryPcdList
= self
.PlatformInfo
.ApplyPcdSetting(self
.Module
, Pcds
)
3044 self
._LibraryPcdList
= []
3045 return self
._LibraryPcdList
3047 ## Get the GUID value mapping
3049 # @retval dict The mapping between GUID cname and its value
3051 def _GetGuidList(self
):
3052 if self
._GuidList
== None:
3053 self
._GuidList
= sdict()
3054 self
._GuidList
.update(self
.Module
.Guids
)
3055 for Library
in self
.DependentLibraryList
:
3056 self
._GuidList
.update(Library
.Guids
)
3057 self
.UpdateComments(self
._GuidComments
, Library
.GuidComments
)
3058 self
.UpdateComments(self
._GuidComments
, self
.Module
.GuidComments
)
3059 return self
._GuidList
3061 def GetGuidsUsedByPcd(self
):
3062 if self
._GuidsUsedByPcd
== None:
3063 self
._GuidsUsedByPcd
= sdict()
3064 self
._GuidsUsedByPcd
.update(self
.Module
.GetGuidsUsedByPcd())
3065 for Library
in self
.DependentLibraryList
:
3066 self
._GuidsUsedByPcd
.update(Library
.GetGuidsUsedByPcd())
3067 return self
._GuidsUsedByPcd
3068 ## Get the protocol value mapping
3070 # @retval dict The mapping between protocol cname and its value
3072 def _GetProtocolList(self
):
3073 if self
._ProtocolList
== None:
3074 self
._ProtocolList
= sdict()
3075 self
._ProtocolList
.update(self
.Module
.Protocols
)
3076 for Library
in self
.DependentLibraryList
:
3077 self
._ProtocolList
.update(Library
.Protocols
)
3078 self
.UpdateComments(self
._ProtocolComments
, Library
.ProtocolComments
)
3079 self
.UpdateComments(self
._ProtocolComments
, self
.Module
.ProtocolComments
)
3080 return self
._ProtocolList
3082 ## Get the PPI value mapping
3084 # @retval dict The mapping between PPI cname and its value
3086 def _GetPpiList(self
):
3087 if self
._PpiList
== None:
3088 self
._PpiList
= sdict()
3089 self
._PpiList
.update(self
.Module
.Ppis
)
3090 for Library
in self
.DependentLibraryList
:
3091 self
._PpiList
.update(Library
.Ppis
)
3092 self
.UpdateComments(self
._PpiComments
, Library
.PpiComments
)
3093 self
.UpdateComments(self
._PpiComments
, self
.Module
.PpiComments
)
3094 return self
._PpiList
3096 ## Get the list of include search path
3098 # @retval list The list path
3100 def _GetIncludePathList(self
):
3101 if self
._IncludePathList
== None:
3102 self
._IncludePathList
= []
3103 if self
.AutoGenVersion
< 0x00010005:
3104 for Inc
in self
.Module
.Includes
:
3105 if Inc
not in self
._IncludePathList
:
3106 self
._IncludePathList
.append(Inc
)
3108 Inc
= path
.join(Inc
, self
.Arch
.capitalize())
3109 if os
.path
.exists(Inc
) and Inc
not in self
._IncludePathList
:
3110 self
._IncludePathList
.append(Inc
)
3111 # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time
3112 self
._IncludePathList
.append(self
.DebugDir
)
3114 self
._IncludePathList
.append(self
.MetaFile
.Dir
)
3115 self
._IncludePathList
.append(self
.DebugDir
)
3117 for Package
in self
.Module
.Packages
:
3118 PackageDir
= mws
.join(self
.WorkspaceDir
, Package
.MetaFile
.Dir
)
3119 if PackageDir
not in self
._IncludePathList
:
3120 self
._IncludePathList
.append(PackageDir
)
3121 for Inc
in Package
.Includes
:
3122 if Inc
not in self
._IncludePathList
:
3123 self
._IncludePathList
.append(str(Inc
))
3124 return self
._IncludePathList
3126 ## Get HII EX PCDs which maybe used by VFR
3128 # efivarstore used by VFR may relate with HII EX PCDs
3129 # Get the variable name and GUID from efivarstore and HII EX PCD
3130 # List the HII EX PCDs in As Built INF if both name and GUID match.
3132 # @retval list HII EX PCDs
3134 def _GetPcdsMaybeUsedByVfr(self
):
3135 if not self
.SourceFileList
:
3139 for SrcFile
in self
.SourceFileList
:
3140 if SrcFile
.Ext
.lower() != '.vfr':
3142 Vfri
= os
.path
.join(self
.OutputDir
, SrcFile
.BaseName
+ '.i')
3143 if not os
.path
.exists(Vfri
):
3145 VfriFile
= open(Vfri
, 'r')
3146 Content
= VfriFile
.read()
3148 Pos
= Content
.find('efivarstore')
3151 # Make sure 'efivarstore' is the start of efivarstore statement
3152 # In case of the value of 'name' (name = efivarstore) is equal to 'efivarstore'
3155 while Index
>= 0 and Content
[Index
] in ' \t\r\n':
3157 if Index
>= 0 and Content
[Index
] != ';':
3158 Pos
= Content
.find('efivarstore', Pos
+ len('efivarstore'))
3161 # 'efivarstore' must be followed by name and guid
3163 Name
= gEfiVarStoreNamePattern
.search(Content
, Pos
)
3166 Guid
= gEfiVarStoreGuidPattern
.search(Content
, Pos
)
3169 NameArray
= ConvertStringToByteArray('L"' + Name
.group(1) + '"')
3170 NameGuids
.append((NameArray
, GuidStructureStringToGuidString(Guid
.group(1))))
3171 Pos
= Content
.find('efivarstore', Name
.end())
3175 for Pcd
in self
.PlatformInfo
.Platform
.Pcds
.values():
3176 if Pcd
.Type
!= TAB_PCDS_DYNAMIC_EX_HII
:
3178 for SkuName
in Pcd
.SkuInfoList
:
3179 SkuInfo
= Pcd
.SkuInfoList
[SkuName
]
3180 Name
= ConvertStringToByteArray(SkuInfo
.VariableName
)
3181 Value
= GuidValue(SkuInfo
.VariableGuid
, self
.PlatformInfo
.PackageList
)
3184 Guid
= GuidStructureStringToGuidString(Value
)
3185 if (Name
, Guid
) in NameGuids
and Pcd
not in HiiExPcds
:
3186 HiiExPcds
.append(Pcd
)
3191 def _GenOffsetBin(self
):
3193 for SourceFile
in self
.Module
.Sources
:
3194 if SourceFile
.Type
.upper() == ".VFR" :
3196 # search the .map file to find the offset of vfr binary in the PE32+/TE file.
3198 VfrUniBaseName
[SourceFile
.BaseName
] = (SourceFile
.BaseName
+ "Bin")
3199 if SourceFile
.Type
.upper() == ".UNI" :
3201 # search the .map file to find the offset of Uni strings binary in the PE32+/TE file.
3203 VfrUniBaseName
["UniOffsetName"] = (self
.Name
+ "Strings")
3205 if len(VfrUniBaseName
) == 0:
3207 MapFileName
= os
.path
.join(self
.OutputDir
, self
.Name
+ ".map")
3208 EfiFileName
= os
.path
.join(self
.OutputDir
, self
.Name
+ ".efi")
3209 VfrUniOffsetList
= GetVariableOffset(MapFileName
, EfiFileName
, VfrUniBaseName
.values())
3210 if not VfrUniOffsetList
:
3213 OutputName
= '%sOffset.bin' % self
.Name
3214 UniVfrOffsetFileName
= os
.path
.join( self
.OutputDir
, OutputName
)
3217 fInputfile
= open(UniVfrOffsetFileName
, "wb+", 0)
3219 EdkLogger
.error("build", FILE_OPEN_FAILURE
, "File open failed for %s" % UniVfrOffsetFileName
,None)
3221 # Use a instance of StringIO to cache data
3222 fStringIO
= StringIO('')
3224 for Item
in VfrUniOffsetList
:
3225 if (Item
[0].find("Strings") != -1):
3227 # UNI offset in image.
3229 # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }
3231 UniGuid
= [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]
3232 UniGuid
= [chr(ItemGuid
) for ItemGuid
in UniGuid
]
3233 fStringIO
.write(''.join(UniGuid
))
3234 UniValue
= pack ('Q', int (Item
[1], 16))
3235 fStringIO
.write (UniValue
)
3238 # VFR binary offset in image.
3240 # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };
3242 VfrGuid
= [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]
3243 VfrGuid
= [chr(ItemGuid
) for ItemGuid
in VfrGuid
]
3244 fStringIO
.write(''.join(VfrGuid
))
3246 VfrValue
= pack ('Q', int (Item
[1], 16))
3247 fStringIO
.write (VfrValue
)
3249 # write data into file.
3252 fInputfile
.write (fStringIO
.getvalue())
3254 EdkLogger
.error("build", FILE_WRITE_FAILURE
, "Write data to file %s failed, please check whether the "
3255 "file been locked or using by other applications." %UniVfrOffsetFileName
,None)
3261 ## Create AsBuilt INF file the module
3263 def CreateAsBuiltInf(self
):
3264 if self
.IsAsBuiltInfCreated
:
3267 # Skip the following code for EDK I inf
3268 if self
.AutoGenVersion
< 0x00010005:
3271 # Skip the following code for libraries
3275 # Skip the following code for modules with no source files
3276 if self
.SourceFileList
== None or self
.SourceFileList
== []:
3279 # Skip the following code for modules without any binary files
3280 if self
.BinaryFileList
<> None and self
.BinaryFileList
<> []:
3283 ### TODO: How to handles mixed source and binary modules
3285 # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries
3286 # Also find all packages that the DynamicEx PCDs depend on
3291 PcdTokenSpaceList
= []
3292 for Pcd
in self
.ModulePcdList
+ self
.LibraryPcdList
:
3293 if Pcd
.Type
== TAB_PCDS_PATCHABLE_IN_MODULE
:
3294 PatchablePcds
[Pcd
.TokenCName
] = Pcd
3295 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'PatchableInModule'))
3296 elif Pcd
.Type
in GenC
.gDynamicExPcd
:
3299 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'DynamicEx'))
3300 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'Dynamic'))
3301 PcdTokenSpaceList
.append(Pcd
.TokenSpaceGuidCName
)
3303 GuidList
.update(self
.GuidList
)
3304 for TokenSpace
in self
.GetGuidsUsedByPcd():
3305 # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list
3306 # The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs
3307 if TokenSpace
not in PcdTokenSpaceList
and TokenSpace
in GuidList
:
3308 GuidList
.pop(TokenSpace
)
3309 CheckList
= (GuidList
, self
.PpiList
, self
.ProtocolList
, PcdCheckList
)
3310 for Package
in self
.DerivedPackageList
:
3311 if Package
in Packages
:
3313 BeChecked
= (Package
.Guids
, Package
.Ppis
, Package
.Protocols
, Package
.Pcds
)
3315 for Index
in range(len(BeChecked
)):
3316 for Item
in CheckList
[Index
]:
3317 if Item
in BeChecked
[Index
]:
3318 Packages
+= [Package
]
3323 VfrPcds
= self
._GetPcdsMaybeUsedByVfr
()
3324 for Pkg
in self
.PlatformInfo
.PackageList
:
3327 for VfrPcd
in VfrPcds
:
3328 if ((VfrPcd
.TokenCName
, VfrPcd
.TokenSpaceGuidCName
, 'DynamicEx') in Pkg
.Pcds
or
3329 (VfrPcd
.TokenCName
, VfrPcd
.TokenSpaceGuidCName
, 'Dynamic') in Pkg
.Pcds
):
3333 ModuleType
= self
.ModuleType
3334 if ModuleType
== 'UEFI_DRIVER' and self
.DepexGenerated
:
3335 ModuleType
= 'DXE_DRIVER'
3338 if self
.PcdIsDriver
!= '':
3339 DriverType
= self
.PcdIsDriver
3342 MDefs
= self
.Module
.Defines
3345 'module_name' : self
.Name
,
3346 'module_guid' : Guid
,
3347 'module_module_type' : ModuleType
,
3348 'module_version_string' : [MDefs
['VERSION_STRING']] if 'VERSION_STRING' in MDefs
else [],
3349 'pcd_is_driver_string' : [],
3350 'module_uefi_specification_version' : [],
3351 'module_pi_specification_version' : [],
3352 'module_entry_point' : self
.Module
.ModuleEntryPointList
,
3353 'module_unload_image' : self
.Module
.ModuleUnloadImageList
,
3354 'module_constructor' : self
.Module
.ConstructorList
,
3355 'module_destructor' : self
.Module
.DestructorList
,
3356 'module_shadow' : [MDefs
['SHADOW']] if 'SHADOW' in MDefs
else [],
3357 'module_pci_vendor_id' : [MDefs
['PCI_VENDOR_ID']] if 'PCI_VENDOR_ID' in MDefs
else [],
3358 'module_pci_device_id' : [MDefs
['PCI_DEVICE_ID']] if 'PCI_DEVICE_ID' in MDefs
else [],
3359 'module_pci_class_code' : [MDefs
['PCI_CLASS_CODE']] if 'PCI_CLASS_CODE' in MDefs
else [],
3360 'module_pci_revision' : [MDefs
['PCI_REVISION']] if 'PCI_REVISION' in MDefs
else [],
3361 'module_build_number' : [MDefs
['BUILD_NUMBER']] if 'BUILD_NUMBER' in MDefs
else [],
3362 'module_spec' : [MDefs
['SPEC']] if 'SPEC' in MDefs
else [],
3363 'module_uefi_hii_resource_section' : [MDefs
['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs
else [],
3364 'module_uni_file' : [MDefs
['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs
else [],
3365 'module_arch' : self
.Arch
,
3366 'package_item' : ['%s' % (Package
.MetaFile
.File
.replace('\\', '/')) for Package
in Packages
],
3368 'patchablepcd_item' : [],
3370 'protocol_item' : [],
3374 'libraryclasses_item' : []
3377 if self
.AutoGenVersion
> int(gInfSpecVersion
, 0):
3378 AsBuiltInfDict
['module_inf_version'] = '0x%08x' % self
.AutoGenVersion
3380 AsBuiltInfDict
['module_inf_version'] = gInfSpecVersion
3383 AsBuiltInfDict
['pcd_is_driver_string'] += [DriverType
]
3385 if 'UEFI_SPECIFICATION_VERSION' in self
.Specification
:
3386 AsBuiltInfDict
['module_uefi_specification_version'] += [self
.Specification
['UEFI_SPECIFICATION_VERSION']]
3387 if 'PI_SPECIFICATION_VERSION' in self
.Specification
:
3388 AsBuiltInfDict
['module_pi_specification_version'] += [self
.Specification
['PI_SPECIFICATION_VERSION']]
3390 OutputDir
= self
.OutputDir
.replace('\\', '/').strip('/')
3391 if self
.ModuleType
in ['BASE', 'USER_DEFINED']:
3392 for Item
in self
.CodaTargetList
:
3393 File
= Item
.Target
.Path
.replace('\\', '/').strip('/').replace(OutputDir
, '').strip('/')
3394 if Item
.Target
.Ext
.lower() == '.aml':
3395 AsBuiltInfDict
['binary_item'] += ['ASL|' + File
]
3396 elif Item
.Target
.Ext
.lower() == '.acpi':
3397 AsBuiltInfDict
['binary_item'] += ['ACPI|' + File
]
3399 AsBuiltInfDict
['binary_item'] += ['BIN|' + File
]
3401 for Item
in self
.CodaTargetList
:
3402 File
= Item
.Target
.Path
.replace('\\', '/').strip('/').replace(OutputDir
, '').strip('/')
3403 if Item
.Target
.Ext
.lower() == '.efi':
3404 AsBuiltInfDict
['binary_item'] += ['PE32|' + self
.Name
+ '.efi']
3406 AsBuiltInfDict
['binary_item'] += ['BIN|' + File
]
3407 if self
.DepexGenerated
:
3408 if self
.ModuleType
in ['PEIM']:
3409 AsBuiltInfDict
['binary_item'] += ['PEI_DEPEX|' + self
.Name
+ '.depex']
3410 if self
.ModuleType
in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:
3411 AsBuiltInfDict
['binary_item'] += ['DXE_DEPEX|' + self
.Name
+ '.depex']
3412 if self
.ModuleType
in ['DXE_SMM_DRIVER']:
3413 AsBuiltInfDict
['binary_item'] += ['SMM_DEPEX|' + self
.Name
+ '.depex']
3415 Bin
= self
._GenOffsetBin
()
3417 AsBuiltInfDict
['binary_item'] += ['BIN|%s' % Bin
]
3419 for Root
, Dirs
, Files
in os
.walk(OutputDir
):
3421 if File
.lower().endswith('.pdb'):
3422 AsBuiltInfDict
['binary_item'] += ['DISPOSABLE|' + File
]
3423 HeaderComments
= self
.Module
.HeaderComments
3425 for Index
in range(len(HeaderComments
)):
3426 if HeaderComments
[Index
].find('@BinaryHeader') != -1:
3427 HeaderComments
[Index
] = HeaderComments
[Index
].replace('@BinaryHeader', '@file')
3430 AsBuiltInfDict
['header_comments'] = '\n'.join(HeaderComments
[StartPos
:]).replace(':#', '://')
3431 AsBuiltInfDict
['tail_comments'] = '\n'.join(self
.Module
.TailComments
)
3434 (self
.ProtocolList
, self
._ProtocolComments
, 'protocol_item'),
3435 (self
.PpiList
, self
._PpiComments
, 'ppi_item'),
3436 (GuidList
, self
._GuidComments
, 'guid_item')
3438 for Item
in GenList
:
3439 for CName
in Item
[0]:
3441 if CName
in Item
[1]:
3442 Comments
= '\n '.join(Item
[1][CName
])
3445 Entry
= Comments
+ '\n ' + CName
3446 AsBuiltInfDict
[Item
[2]].append(Entry
)
3447 PatchList
= parsePcdInfoFromMapFile(
3448 os
.path
.join(self
.OutputDir
, self
.Name
+ '.map'),
3449 os
.path
.join(self
.OutputDir
, self
.Name
+ '.efi')
3452 for PatchPcd
in PatchList
:
3453 if PatchPcd
[0] not in PatchablePcds
:
3455 Pcd
= PatchablePcds
[PatchPcd
[0]]
3457 if Pcd
.DatumType
!= 'VOID*':
3458 HexFormat
= '0x%02x'
3459 if Pcd
.DatumType
== 'UINT16':
3460 HexFormat
= '0x%04x'
3461 elif Pcd
.DatumType
== 'UINT32':
3462 HexFormat
= '0x%08x'
3463 elif Pcd
.DatumType
== 'UINT64':
3464 HexFormat
= '0x%016x'
3465 PcdValue
= HexFormat
% int(Pcd
.DefaultValue
, 0)
3467 if Pcd
.MaxDatumSize
== None or Pcd
.MaxDatumSize
== '':
3468 EdkLogger
.error("build", AUTOGEN_ERROR
,
3469 "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3471 ArraySize
= int(Pcd
.MaxDatumSize
, 0)
3472 PcdValue
= Pcd
.DefaultValue
3473 if PcdValue
[0] != '{':
3475 if PcdValue
[0] == 'L':
3477 PcdValue
= PcdValue
.lstrip('L')
3478 PcdValue
= eval(PcdValue
)
3480 for Index
in range(0, len(PcdValue
)):
3482 CharVal
= ord(PcdValue
[Index
])
3483 NewValue
= NewValue
+ '0x%02x' % (CharVal
& 0x00FF) + ', ' \
3484 + '0x%02x' % (CharVal
>> 8) + ', '
3486 NewValue
= NewValue
+ '0x%02x' % (ord(PcdValue
[Index
]) % 0x100) + ', '
3489 Padding
= Padding
* 2
3490 ArraySize
= ArraySize
/ 2
3491 if ArraySize
< (len(PcdValue
) + 1):
3492 EdkLogger
.error("build", AUTOGEN_ERROR
,
3493 "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3495 if ArraySize
> len(PcdValue
) + 1:
3496 NewValue
= NewValue
+ Padding
* (ArraySize
- len(PcdValue
) - 1)
3497 PcdValue
= NewValue
+ Padding
.strip().rstrip(',') + '}'
3498 elif len(PcdValue
.split(',')) <= ArraySize
:
3499 PcdValue
= PcdValue
.rstrip('}') + ', 0x00' * (ArraySize
- len(PcdValue
.split(',')))
3502 EdkLogger
.error("build", AUTOGEN_ERROR
,
3503 "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3505 PcdItem
= '%s.%s|%s|0x%X' % \
3506 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, PcdValue
, PatchPcd
[1])
3508 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in self
._PcdComments
:
3509 PcdComments
= '\n '.join(self
._PcdComments
[Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
])
3511 PcdItem
= PcdComments
+ '\n ' + PcdItem
3512 AsBuiltInfDict
['patchablepcd_item'].append(PcdItem
)
3515 for Pcd
in Pcds
+ VfrPcds
:
3520 if Pcd
.Type
== TAB_PCDS_DYNAMIC_EX_HII
:
3521 for SkuName
in Pcd
.SkuInfoList
:
3522 SkuInfo
= Pcd
.SkuInfoList
[SkuName
]
3523 SkuId
= SkuInfo
.SkuId
3524 HiiInfo
= '## %s|%s|%s' % (SkuInfo
.VariableName
, SkuInfo
.VariableGuid
, SkuInfo
.VariableOffset
)
3528 # Don't generate duplicated HII PCD
3530 if (SkuId
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in HiiPcds
:
3533 HiiPcds
.append((SkuId
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
3534 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in self
._PcdComments
:
3535 PcdCommentList
= self
._PcdComments
[Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
][:]
3539 for Index
, Comment
in enumerate(PcdCommentList
):
3540 for Usage
in UsageList
:
3541 if Comment
.find(Usage
) != -1:
3545 if UsageIndex
!= -1:
3546 PcdCommentList
[UsageIndex
] = '## %s %s %s' % (UsageStr
, HiiInfo
, PcdCommentList
[UsageIndex
].replace(UsageStr
, ''))
3548 PcdCommentList
.append('## UNDEFINED ' + HiiInfo
)
3549 PcdComments
= '\n '.join(PcdCommentList
)
3550 PcdEntry
= Pcd
.TokenSpaceGuidCName
+ '.' + Pcd
.TokenCName
3552 PcdEntry
= PcdComments
+ '\n ' + PcdEntry
3553 AsBuiltInfDict
['pcd_item'] += [PcdEntry
]
3554 for Item
in self
.BuildOption
:
3555 if 'FLAGS' in self
.BuildOption
[Item
]:
3556 AsBuiltInfDict
['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self
.ToolChainFamily
, self
.BuildTarget
, self
.ToolChain
, self
.Arch
, Item
, self
.BuildOption
[Item
]['FLAGS'].strip())]
3558 # Generated LibraryClasses section in comments.
3559 for Library
in self
.LibraryAutoGenList
:
3560 AsBuiltInfDict
['libraryclasses_item'] += [Library
.MetaFile
.File
.replace('\\', '/')]
3562 # Generated depex expression section in comments.
3563 AsBuiltInfDict
['depexsection_item'] = ''
3564 DepexExpresion
= self
._GetDepexExpresionString
()
3566 AsBuiltInfDict
['depexsection_item'] = DepexExpresion
3568 AsBuiltInf
= TemplateString()
3569 AsBuiltInf
.Append(gAsBuiltInfHeaderString
.Replace(AsBuiltInfDict
))
3571 SaveFileOnChange(os
.path
.join(self
.OutputDir
, self
.Name
+ '.inf'), str(AsBuiltInf
), False)
3573 self
.IsAsBuiltInfCreated
= True
3575 ## Create makefile for the module and its dependent libraries
3577 # @param CreateLibraryMakeFile Flag indicating if or not the makefiles of
3578 # dependent libraries will be created
3580 def CreateMakeFile(self
, CreateLibraryMakeFile
=True):
3581 # Ignore generating makefile when it is a binary module
3582 if self
.IsBinaryModule
:
3585 if self
.IsMakeFileCreated
:
3588 if not self
.IsLibrary
and CreateLibraryMakeFile
:
3589 for LibraryAutoGen
in self
.LibraryAutoGenList
:
3590 LibraryAutoGen
.CreateMakeFile()
3592 if len(self
.CustomMakefile
) == 0:
3593 Makefile
= GenMake
.ModuleMakefile(self
)
3595 Makefile
= GenMake
.CustomMakefile(self
)
3596 if Makefile
.Generate():
3597 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated makefile for module %s [%s]" %
3598 (self
.Name
, self
.Arch
))
3600 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Skipped the generation of makefile for module %s [%s]" %
3601 (self
.Name
, self
.Arch
))
3603 self
.IsMakeFileCreated
= True
3605 def CopyBinaryFiles(self
):
3606 for File
in self
.Module
.Binaries
:
3608 DstPath
= os
.path
.join(self
.OutputDir
, os
.path
.basename(SrcPath
))
3609 CopyLongFilePath(SrcPath
, DstPath
)
3610 ## Create autogen code for the module and its dependent libraries
3612 # @param CreateLibraryCodeFile Flag indicating if or not the code of
3613 # dependent libraries will be created
3615 def CreateCodeFile(self
, CreateLibraryCodeFile
=True):
3616 if self
.IsCodeFileCreated
:
3619 # Need to generate PcdDatabase even PcdDriver is binarymodule
3620 if self
.IsBinaryModule
and self
.PcdIsDriver
!= '':
3621 CreatePcdDatabaseCode(self
, TemplateString(), TemplateString())
3623 if self
.IsBinaryModule
:
3625 self
.CopyBinaryFiles()
3628 if not self
.IsLibrary
and CreateLibraryCodeFile
:
3629 for LibraryAutoGen
in self
.LibraryAutoGenList
:
3630 LibraryAutoGen
.CreateCodeFile()
3633 IgoredAutoGenList
= []
3635 for File
in self
.AutoGenFileList
:
3636 if GenC
.Generate(File
.Path
, self
.AutoGenFileList
[File
], File
.IsBinary
):
3637 #Ignore Edk AutoGen.c
3638 if self
.AutoGenVersion
< 0x00010005 and File
.Name
== 'AutoGen.c':
3641 AutoGenList
.append(str(File
))
3643 IgoredAutoGenList
.append(str(File
))
3645 # Skip the following code for EDK I inf
3646 if self
.AutoGenVersion
< 0x00010005:
3649 for ModuleType
in self
.DepexList
:
3650 # Ignore empty [depex] section or [depex] section for "USER_DEFINED" module
3651 if len(self
.DepexList
[ModuleType
]) == 0 or ModuleType
== "USER_DEFINED":
3654 Dpx
= GenDepex
.DependencyExpression(self
.DepexList
[ModuleType
], ModuleType
, True)
3655 DpxFile
= gAutoGenDepexFileName
% {"module_name" : self
.Name
}
3657 if len(Dpx
.PostfixNotation
) <> 0:
3658 self
.DepexGenerated
= True
3660 if Dpx
.Generate(path
.join(self
.OutputDir
, DpxFile
)):
3661 AutoGenList
.append(str(DpxFile
))
3663 IgoredAutoGenList
.append(str(DpxFile
))
3665 if IgoredAutoGenList
== []:
3666 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated [%s] files for module %s [%s]" %
3667 (" ".join(AutoGenList
), self
.Name
, self
.Arch
))
3668 elif AutoGenList
== []:
3669 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Skipped the generation of [%s] files for module %s [%s]" %
3670 (" ".join(IgoredAutoGenList
), self
.Name
, self
.Arch
))
3672 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated [%s] (skipped %s) files for module %s [%s]" %
3673 (" ".join(AutoGenList
), " ".join(IgoredAutoGenList
), self
.Name
, self
.Arch
))
3675 self
.IsCodeFileCreated
= True
3678 ## Summarize the ModuleAutoGen objects of all libraries used by this module
3679 def _GetLibraryAutoGenList(self
):
3680 if self
._LibraryAutoGenList
== None:
3681 self
._LibraryAutoGenList
= []
3682 for Library
in self
.DependentLibraryList
:
3689 self
.PlatformInfo
.MetaFile
3691 if La
not in self
._LibraryAutoGenList
:
3692 self
._LibraryAutoGenList
.append(La
)
3693 for Lib
in La
.CodaTargetList
:
3694 self
._ApplyBuildRule
(Lib
.Target
, TAB_UNKNOWN_FILE
)
3695 return self
._LibraryAutoGenList
3697 Module
= property(_GetModule
)
3698 Name
= property(_GetBaseName
)
3699 Guid
= property(_GetGuid
)
3700 Version
= property(_GetVersion
)
3701 ModuleType
= property(_GetModuleType
)
3702 ComponentType
= property(_GetComponentType
)
3703 BuildType
= property(_GetBuildType
)
3704 PcdIsDriver
= property(_GetPcdIsDriver
)
3705 AutoGenVersion
= property(_GetAutoGenVersion
)
3706 Macros
= property(_GetMacros
)
3707 Specification
= property(_GetSpecification
)
3709 IsLibrary
= property(_IsLibrary
)
3710 IsBinaryModule
= property(_IsBinaryModule
)
3711 BuildDir
= property(_GetBuildDir
)
3712 OutputDir
= property(_GetOutputDir
)
3713 DebugDir
= property(_GetDebugDir
)
3714 MakeFileDir
= property(_GetMakeFileDir
)
3715 CustomMakefile
= property(_GetCustomMakefile
)
3717 IncludePathList
= property(_GetIncludePathList
)
3718 AutoGenFileList
= property(_GetAutoGenFileList
)
3719 UnicodeFileList
= property(_GetUnicodeFileList
)
3720 SourceFileList
= property(_GetSourceFileList
)
3721 BinaryFileList
= property(_GetBinaryFiles
) # FileType : [File List]
3722 Targets
= property(_GetTargets
)
3723 IntroTargetList
= property(_GetIntroTargetList
)
3724 CodaTargetList
= property(_GetFinalTargetList
)
3725 FileTypes
= property(_GetFileTypes
)
3726 BuildRules
= property(_GetBuildRules
)
3728 DependentPackageList
= property(_GetDependentPackageList
)
3729 DependentLibraryList
= property(_GetLibraryList
)
3730 LibraryAutoGenList
= property(_GetLibraryAutoGenList
)
3731 DerivedPackageList
= property(_GetDerivedPackageList
)
3733 ModulePcdList
= property(_GetModulePcdList
)
3734 LibraryPcdList
= property(_GetLibraryPcdList
)
3735 GuidList
= property(_GetGuidList
)
3736 ProtocolList
= property(_GetProtocolList
)
3737 PpiList
= property(_GetPpiList
)
3738 DepexList
= property(_GetDepexTokenList
)
3739 DxsFile
= property(_GetDxsFile
)
3740 DepexExpressionList
= property(_GetDepexExpressionTokenList
)
3741 BuildOption
= property(_GetModuleBuildOption
)
3742 BuildOptionIncPathList
= property(_GetBuildOptionIncPathList
)
3743 BuildCommand
= property(_GetBuildCommand
)
3745 FixedAtBuildPcds
= property(_GetFixedAtBuildPcds
)
3747 # This acts like the main() function for the script, unless it is 'import'ed into another script.
3748 if __name__
== '__main__':