## @file\r
# Generate AutoGen.h, AutoGen.c and *.depex files\r
#\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
\r
## Import Modules\r
#\r
-import os\r
+import Common.LongFilePathOs as os\r
import re\r
import os.path as path\r
import copy\r
from StrGather import *\r
from BuildEngine import BuildRule\r
\r
+from Common.LongFilePathSupport import CopyLongFilePath\r
from Common.BuildToolError import *\r
from Common.DataType import *\r
from Common.Misc import *\r
from GenFds.FdfParser import *\r
from CommonDataClass.CommonClass import SkuInfoClass\r
from Workspace.BuildClassObject import *\r
+from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile\r
import Common.VpdInfoFile as VpdInfoFile\r
+from GenPcdDb import CreatePcdDatabaseCode\r
+from Workspace.MetaFileCommentParser import UsageList\r
\r
-## Regular expression for splitting Dependency Expression stirng into tokens\r
+import InfSectionParser\r
+\r
+## Regular expression for splitting Dependency Expression string into tokens\r
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r
\r
+#\r
+# Match name = variable\r
+#\r
+gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")\r
+#\r
+# The format of guid in efivarstore statement likes following and must be correct:\r
+# guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}\r
+#\r
+gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")\r
+\r
## Mapping Makefile type\r
gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}\r
\r
\r
## Build rule configuration file\r
-gBuildRuleFile = 'Conf/build_rule.txt'\r
+gDefaultBuildRuleFile = 'Conf/build_rule.txt'\r
\r
## Build rule default version\r
AutoGenReqBuildRuleVerNum = "0.1"\r
gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"\r
gAutoGenDepexFileName = "%(module_name)s.depex"\r
\r
+gInfSpecVersion = "0x00010017"\r
+\r
#\r
# Template string to generic AsBuilt INF\r
#\r
-gAsBuiltInfHeaderString = TemplateString("""## @file\r
-# ${module_name}\r
-#\r
+gAsBuiltInfHeaderString = TemplateString("""${header_comments}\r
+\r
# DO NOT EDIT\r
-# FILE auto-generated Binary INF\r
-#\r
-##\r
+# FILE auto-generated\r
\r
[Defines]\r
- INF_VERSION = 0x00010016\r
+ INF_VERSION = ${module_inf_version}\r
BASE_NAME = ${module_name}\r
FILE_GUID = ${module_guid}\r
- MODULE_TYPE = ${module_module_type}\r
- VERSION_STRING = ${module_version_string}${BEGIN}\r
+ MODULE_TYPE = ${module_module_type}${BEGIN}\r
+ VERSION_STRING = ${module_version_string}${END}${BEGIN}\r
+ PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}\r
UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}\r
- PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}\r
-\r
-[Packages]${BEGIN}\r
+ PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}${BEGIN}\r
+ ENTRY_POINT = ${module_entry_point}${END}${BEGIN}\r
+ UNLOAD_IMAGE = ${module_unload_image}${END}${BEGIN}\r
+ CONSTRUCTOR = ${module_constructor}${END}${BEGIN}\r
+ DESTRUCTOR = ${module_destructor}${END}${BEGIN}\r
+ SHADOW = ${module_shadow}${END}${BEGIN}\r
+ PCI_VENDOR_ID = ${module_pci_vendor_id}${END}${BEGIN}\r
+ PCI_DEVICE_ID = ${module_pci_device_id}${END}${BEGIN}\r
+ PCI_CLASS_CODE = ${module_pci_class_code}${END}${BEGIN}\r
+ PCI_REVISION = ${module_pci_revision}${END}${BEGIN}\r
+ BUILD_NUMBER = ${module_build_number}${END}${BEGIN}\r
+ SPEC = ${module_spec}${END}${BEGIN}\r
+ UEFI_HII_RESOURCE_SECTION = ${module_uefi_hii_resource_section}${END}${BEGIN}\r
+ MODULE_UNI_FILE = ${module_uni_file}${END}\r
+\r
+[Packages.${module_arch}]${BEGIN}\r
${package_item}${END}\r
\r
[Binaries.${module_arch}]${BEGIN}\r
${binary_item}${END}\r
\r
-[PcdEx]${BEGIN}\r
- ${pcd_item}${END}\r
+[PatchPcd.${module_arch}]${BEGIN}\r
+ ${patchablepcd_item}\r
+${END}\r
+\r
+[Protocols.${module_arch}]${BEGIN}\r
+ ${protocol_item}\r
+${END}\r
+\r
+[Ppis.${module_arch}]${BEGIN}\r
+ ${ppi_item}\r
+${END}\r
+\r
+[Guids.${module_arch}]${BEGIN}\r
+ ${guid_item}\r
+${END}\r
+\r
+[PcdEx.${module_arch}]${BEGIN}\r
+ ${pcd_item}\r
+${END}\r
\r
+[LibraryClasses.${module_arch}]\r
+## @LIB_INSTANCES${BEGIN}\r
+# ${libraryclasses_item}${END}\r
+\r
+${depexsection_item}\r
+\r
+${tail_comments}\r
+\r
+[BuildOptions.${module_arch}]\r
## @AsBuilt${BEGIN}\r
## ${flags_item}${END}\r
""")\r
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"\r
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))\r
\r
- # Validate SKU ID\r
- if not self.SkuId:\r
- self.SkuId = 'DEFAULT'\r
-\r
- if self.SkuId not in self.Platform.SkuIds:\r
- EdkLogger.error("build", PARAMETER_INVALID, \r
- ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"\r
- % (self.SkuId, " ".join(self.Platform.SkuIds.keys())))\r
-\r
+ \r
# parse FDF file to get PCDs in it, if any\r
if not self.FdfFile:\r
self.FdfFile = self.Platform.FlashDefinition\r
GlobalData.gAutoGenPhase = True \r
Fdf = FdfParser(self.FdfFile.Path)\r
Fdf.ParseFile()\r
+ GlobalData.gFdfParser = Fdf\r
GlobalData.gAutoGenPhase = False\r
PcdSet = Fdf.Profile.PcdDict\r
ModuleList = Fdf.Profile.InfList\r
for Arch in self.ArchList:\r
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
\r
- DecPcds = set()\r
+ DecPcds = {}\r
+ DecPcdsKey = set()\r
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
- Pkgs = PGen.PackageList\r
+ #Collect package set information from INF of FDF\r
+ PkgSet = set()\r
+ for Inf in ModuleList:\r
+ ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
+ if ModuleFile in Platform.Modules:\r
+ continue\r
+ ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
+ PkgSet.update(ModuleData.Packages)\r
+ Pkgs = list(PkgSet) + list(PGen.PackageList)\r
for Pkg in Pkgs:\r
- for Pcd in Pkg.Pcds.keys():\r
- DecPcds.add((Pcd[0], Pcd[1]))\r
- Platform.IsPlatformPcdDeclared(DecPcds)\r
+ for Pcd in Pkg.Pcds:\r
+ DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]\r
+ DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2]))\r
\r
Platform.SkuName = self.SkuId\r
for Name, Guid in PcdSet:\r
File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r
Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r
)\r
- Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r
+ else:\r
+ # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message.\r
+ if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \\r
+ or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in DecPcdsKey \\r
+ or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecPcdsKey:\r
+ Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r
+ continue\r
+ elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:\r
+ EdkLogger.error(\r
+ 'build',\r
+ PARSER_ERROR,\r
+ "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid, Name),\r
+ File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r
+ Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r
+ )\r
\r
Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
#\r
# Explicitly collect platform's dynamic PCDs\r
#\r
Pa.CollectPlatformDynamicPcds()\r
+ Pa.CollectFixedAtBuildPcds()\r
self.AutoGenObjectList.append(Pa)\r
\r
#\r
# Check PCD type and definition between DSC and DEC\r
#\r
self._CheckPcdDefineAndType()\r
- \r
- if self.FdfFile:\r
- self._CheckDuplicateInFV(Fdf)\r
- \r
+\r
+# if self.FdfFile:\r
+# self._CheckDuplicateInFV(Fdf)\r
+\r
self._BuildDir = None\r
self._FvDir = None\r
self._MakeFileDir = None\r
ExtraData=None\r
)\r
Count += 1\r
- \r
+ ## Generate fds command\r
+ def _GenFdsCommand(self):\r
+ return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()\r
\r
## Create makefile for the platform and modules in it\r
#\r
# modules will be created as well\r
#\r
def CreateMakeFile(self, CreateDepsMakeFile=False):\r
- # create makefile for platform\r
- Makefile = GenMake.TopLevelMakefile(self)\r
- if Makefile.Generate():\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] %s\n" %\r
- (self.MetaFile, self.ArchList))\r
- else:\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] %s\n" %\r
- (self.MetaFile, self.ArchList))\r
-\r
if CreateDepsMakeFile:\r
for Pa in self.AutoGenObjectList:\r
Pa.CreateMakeFile(CreateDepsMakeFile)\r
FvDir = property(_GetFvDir)\r
MakeFileDir = property(_GetMakeFileDir)\r
BuildCommand = property(_GetBuildCommand)\r
+ GenFdsCommand = property(_GenFdsCommand)\r
\r
## AutoGen class for platform\r
#\r
self.FdTargetList = self.Workspace.FdTargetList\r
self.FvTargetList = self.Workspace.FvTargetList\r
self.AllPcdList = []\r
+ # get the original module/package/platform objects\r
+ self.BuildDatabase = Workspace.BuildDatabase\r
\r
# flag indicating if the makefile/C-code file has been created or not\r
self.IsMakeFileCreated = False\r
self._PcdTokenNumber = None # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r
self._DynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
self._NonDynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
+ self._NonDynamicPcdDict = {}\r
\r
self._ToolDefinitions = None\r
self._ToolDefFile = None # toolcode : tool path\r
self._ModuleAutoGenList = None\r
self._LibraryAutoGenList = None\r
self._BuildCommand = None\r
-\r
- # get the original module/package/platform objects\r
- self.BuildDatabase = Workspace.BuildDatabase\r
+ self._AsBuildInfList = []\r
+ self._AsBuildModuleList = []\r
+ if GlobalData.gFdfParser != None:\r
+ self._AsBuildInfList = GlobalData.gFdfParser.Profile.InfList\r
+ for Inf in self._AsBuildInfList:\r
+ InfClass = PathClass(NormPath(Inf), GlobalData.gWorkspace, self.Arch)\r
+ M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r
+ if not M.IsSupportedArch:\r
+ continue\r
+ self._AsBuildModuleList.append(InfClass)\r
+ # get library/modules for build\r
+ self.LibraryBuildDirectoryList = []\r
+ self.ModuleBuildDirectoryList = []\r
return True\r
\r
def __repr__(self):\r
# don't do this twice\r
self.IsCodeFileCreated = True\r
\r
+ ## Generate Fds Command\r
+ def _GenFdsCommand(self):\r
+ return self.Workspace.GenFdsCommand\r
+ \r
## Create makefile for the platform and mdoules in it\r
#\r
# @param CreateModuleMakeFile Flag indicating if the makefile for\r
Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
self.ToolChain, self.Arch, self.MetaFile)\r
Ma.CreateMakeFile(True)\r
- Ma.CreateAsBuiltInf()\r
+ #Ma.CreateAsBuiltInf()\r
\r
# no need to create makefile for the platform more than once\r
if self.IsMakeFileCreated:\r
return\r
\r
- # create makefile for platform\r
+ # create library/module build dirs for platform\r
Makefile = GenMake.PlatformMakefile(self)\r
- if Makefile.Generate():\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] [%s]\n" %\r
- (self.MetaFile, self.Arch))\r
- else:\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] [%s]\n" %\r
- (self.MetaFile, self.Arch))\r
+ self.LibraryBuildDirectoryList = Makefile.GetLibraryBuildDirectoryList()\r
+ self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()\r
+\r
self.IsMakeFileCreated = True\r
\r
+ ## Deal with Shared FixedAtBuild Pcds\r
+ #\r
+ def CollectFixedAtBuildPcds(self):\r
+ for LibAuto in self.LibraryAutoGenList:\r
+ FixedAtBuildPcds = {} \r
+ ShareFixedAtBuildPcdsSameValue = {} \r
+ for Module in LibAuto._ReferenceModules: \r
+ for Pcd in Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds:\r
+ key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) \r
+ if key not in FixedAtBuildPcds:\r
+ ShareFixedAtBuildPcdsSameValue[key] = True\r
+ FixedAtBuildPcds[key] = Pcd.DefaultValue\r
+ else:\r
+ if FixedAtBuildPcds[key] != Pcd.DefaultValue:\r
+ ShareFixedAtBuildPcdsSameValue[key] = False \r
+ for Pcd in LibAuto.FixedAtBuildPcds:\r
+ key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r
+ if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) not in self.NonDynamicPcdDict:\r
+ continue\r
+ else:\r
+ DscPcd = self.NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)]\r
+ if DscPcd.Type != "FixedAtBuild":\r
+ continue\r
+ if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]: \r
+ LibAuto.ConstPcd[key] = Pcd.DefaultValue\r
+\r
## Collect dynamic PCDs\r
#\r
# Gather dynamic PCDs list from each module and their settings from platform\r
def CollectPlatformDynamicPcds(self):\r
# for gathering error information\r
NoDatumTypePcdList = set()\r
-\r
+ PcdNotInDb = []\r
self._GuidValue = {}\r
+ FdfModuleList = []\r
+ for InfName in self._AsBuildInfList:\r
+ InfName = os.path.join(self.WorkspaceDir, InfName)\r
+ FdfModuleList.append(os.path.normpath(InfName))\r
for F in self.Platform.Modules.keys():\r
M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r
#GuidValue.update(M.Guids)\r
\r
for PcdFromModule in M.ModulePcdList+M.LibraryPcdList:\r
# make sure that the "VOID*" kind of datum has MaxDatumSize set\r
- if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize == None:\r
+ if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
\r
+ # Check the PCD from Binary INF or Source INF\r
+ if M.IsBinaryModule == True:\r
+ PcdFromModule.IsFromBinaryInf = True\r
+\r
+ # Check the PCD from DSC or not \r
+ if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():\r
+ PcdFromModule.IsFromDsc = True\r
+ else:\r
+ PcdFromModule.IsFromDsc = False\r
if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ if F.Path not in FdfModuleList:\r
+ # If one of the Source built modules listed in the DSC is not listed \r
+ # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic \r
+ # access method (it is only listed in the DEC file that declares the \r
+ # PCD as PcdsDynamic), then build tool will report warning message\r
+ # notify the PI that they are attempting to build a module that must \r
+ # be included in a flash image in order to be functional. These Dynamic \r
+ # PCD will not be added into the Database unless it is used by other \r
+ # modules that are included in the FDF file.\r
+ if PcdFromModule.Type in GenC.gDynamicPcd and \\r
+ PcdFromModule.IsFromBinaryInf == False:\r
+ # Print warning message to let the developer make a determine.\r
+ if PcdFromModule not in PcdNotInDb:\r
+ PcdNotInDb.append(PcdFromModule)\r
+ continue\r
+ # If one of the Source built modules listed in the DSC is not listed in \r
+ # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx \r
+ # access method (it is only listed in the DEC file that declares the \r
+ # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the \r
+ # PCD to the Platform's PCD Database.\r
+ if PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ if PcdFromModule not in PcdNotInDb:\r
+ PcdNotInDb.append(PcdFromModule)\r
+ continue\r
#\r
# If a dynamic PCD used by a PEM module/PEI module & DXE module,\r
# it should be stored in Pcd PEI database, If a dynamic only\r
self._DynaPcdList_[Index] = PcdFromModule\r
elif PcdFromModule not in self._NonDynaPcdList_:\r
self._NonDynaPcdList_.append(PcdFromModule)\r
+ elif PcdFromModule in self._NonDynaPcdList_ and PcdFromModule.IsFromBinaryInf == True:\r
+ Index = self._NonDynaPcdList_.index(PcdFromModule)\r
+ if self._NonDynaPcdList_[Index].IsFromBinaryInf == False:\r
+ #The PCD from Binary INF will override the same one from source INF\r
+ self._NonDynaPcdList_.remove (self._NonDynaPcdList_[Index])\r
+ PcdFromModule.Pending = False\r
+ self._NonDynaPcdList_.append (PcdFromModule)\r
+ # Parse the DynamicEx PCD from the AsBuild INF module list of FDF.\r
+ DscModuleList = []\r
+ for ModuleInf in self.Platform.Modules.keys():\r
+ DscModuleList.append (os.path.normpath(ModuleInf.Path))\r
+ # add the PCD from modules that listed in FDF but not in DSC to Database \r
+ for InfName in FdfModuleList:\r
+ if InfName not in DscModuleList:\r
+ InfClass = PathClass(InfName)\r
+ M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r
+ # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source) \r
+ # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here. \r
+ # For binary module, if in current arch, we need to list the PCDs into database. \r
+ if not M.IsSupportedArch:\r
+ continue\r
+ # Override the module PCD setting by platform setting\r
+ ModulePcdList = self.ApplyPcdSetting(M, M.Pcds)\r
+ for PcdFromModule in ModulePcdList:\r
+ PcdFromModule.IsFromBinaryInf = True\r
+ PcdFromModule.IsFromDsc = False\r
+ # Only allow the DynamicEx and Patchable PCD in AsBuild INF\r
+ if PcdFromModule.Type not in GenC.gDynamicExPcd and PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:\r
+ EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r
+ File=self.MetaFile,\r
+ ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"\r
+ % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))\r
+ # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
+ if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
+ NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))\r
+ if M.ModuleType in ["PEIM", "PEI_CORE"]:\r
+ PcdFromModule.Phase = "PEI"\r
+ if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ self._DynaPcdList_.append(PcdFromModule)\r
+ elif PcdFromModule not in self._NonDynaPcdList_ and PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:\r
+ self._NonDynaPcdList_.append(PcdFromModule)\r
+ if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ # Overwrite the phase of any the same PCD existing, if Phase is PEI.\r
+ # It is to solve the case that a dynamic PCD used by a PEM module/PEI \r
+ # module & DXE module at a same time.\r
+ # Overwrite the type of the PCDs in source INF by the type of AsBuild\r
+ # INF file as DynamicEx. \r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ self._DynaPcdList_[Index].Phase = PcdFromModule.Phase\r
+ self._DynaPcdList_[Index].Type = PcdFromModule.Type\r
+ for PcdFromModule in self._NonDynaPcdList_:\r
+ # If a PCD is not listed in the DSC file, but binary INF files used by \r
+ # this platform all (that use this PCD) list the PCD in a [PatchPcds] \r
+ # section, AND all source INF files used by this platform the build \r
+ # that use the PCD list the PCD in either a [Pcds] or [PatchPcds] \r
+ # section, then the tools must NOT add the PCD to the Platform's PCD\r
+ # Database; the build must assign the access method for this PCD as \r
+ # PcdsPatchableInModule.\r
+ if PcdFromModule not in self._DynaPcdList_:\r
+ continue\r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ if PcdFromModule.IsFromDsc == False and \\r
+ PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and \\r
+ PcdFromModule.IsFromBinaryInf == True and \\r
+ self._DynaPcdList_[Index].IsFromBinaryInf == False:\r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ self._DynaPcdList_.remove (self._DynaPcdList_[Index])\r
\r
# print out error information and break the build, if error found\r
if len(NoDatumTypePcdList) > 0:\r
% NoDatumTypePcdListString)\r
self._NonDynamicPcdList = self._NonDynaPcdList_\r
self._DynamicPcdList = self._DynaPcdList_\r
- self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
- \r
#\r
# Sort dynamic PCD list to:\r
# 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r
# Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.\r
#\r
for PcdKey in PlatformPcds:\r
- Pcd = self.Platform.Pcds[PcdKey] \r
- if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
- Pcd = VpdPcdDict[PcdKey]\r
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
- Sku.VpdOffset = Sku.VpdOffset.strip() \r
- #\r
- # Fix the optional data of VPD PCD.\r
- #\r
- if (Pcd.DatumType.strip() != "VOID*"):\r
- if Sku.DefaultValue == '':\r
- Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize\r
- Pcd.MaxDatumSize = None\r
- else:\r
- EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r
- File=self.MetaFile,\r
- ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"\r
- % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path)) \r
- \r
- VpdFile.Add(Pcd, Sku.VpdOffset)\r
- # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
- if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
- NeedProcessVpdMapFile = True\r
- if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':\r
- EdkLogger.error("Build", FILE_NOT_FOUND, \\r
- "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.")\r
+ Pcd = self.Platform.Pcds[PcdKey]\r
+ if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \\r
+ PcdKey in VpdPcdDict:\r
+ Pcd = VpdPcdDict[PcdKey]\r
+ for (SkuName,Sku) in Pcd.SkuInfoList.items():\r
+ Sku.VpdOffset = Sku.VpdOffset.strip()\r
+ VpdFile.Add(Pcd, Sku.VpdOffset)\r
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
+ NeedProcessVpdMapFile = True\r
+ if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':\r
+ EdkLogger.error("Build", FILE_NOT_FOUND, \\r
+ "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.")\r
\r
\r
#\r
# Not found, it should be signature\r
if not FoundFlag :\r
# just pick the a value to determine whether is unicode string type\r
- Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]\r
- Sku.VpdOffset = Sku.VpdOffset.strip() \r
- \r
- # Need to iterate DEC pcd information to get the value & datumtype\r
- for eachDec in self.PackageList:\r
- for DecPcd in eachDec.Pcds:\r
- DecPcdEntry = eachDec.Pcds[DecPcd]\r
- if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
- (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):\r
- # Print warning message to let the developer make a determine.\r
- EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r
- File=self.MetaFile, \\r
- ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r
- %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) \r
- \r
- DscPcdEntry.DatumType = DecPcdEntry.DatumType\r
- DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r
- # Only fix the value while no value provided in DSC file.\r
- if (Sku.DefaultValue == "" or Sku.DefaultValue==None):\r
- DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r
- \r
+ for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():\r
+ Sku.VpdOffset = Sku.VpdOffset.strip() \r
+ \r
+ # Need to iterate DEC pcd information to get the value & datumtype\r
+ for eachDec in self.PackageList:\r
+ for DecPcd in eachDec.Pcds:\r
+ DecPcdEntry = eachDec.Pcds[DecPcd]\r
+ if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
+ (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):\r
+ # Print warning message to let the developer make a determine.\r
+ EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r
+ File=self.MetaFile, \\r
+ ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r
+ %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) \r
+ \r
+ DscPcdEntry.DatumType = DecPcdEntry.DatumType\r
+ DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r
+ DscPcdEntry.TokenValue = DecPcdEntry.TokenValue\r
+ DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]\r
+ # Only fix the value while no value provided in DSC file.\r
+ if (Sku.DefaultValue == "" or Sku.DefaultValue==None):\r
+ DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r
+ \r
+ if DscPcdEntry not in self._DynamicPcdList:\r
+ self._DynamicPcdList.append(DscPcdEntry)\r
+# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]\r
+ Sku.VpdOffset = Sku.VpdOffset.strip()\r
+ PcdValue = Sku.DefaultValue\r
+ VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
+ NeedProcessVpdMapFile = True \r
+ if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
+ UnicodePcdArray.append(DscPcdEntry)\r
+ elif len(Sku.VariableName) > 0:\r
+ HiiPcdArray.append(DscPcdEntry)\r
+ else:\r
+ OtherPcdArray.append(DscPcdEntry)\r
+ \r
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
\r
- VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
- # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
- if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
- NeedProcessVpdMapFile = True \r
\r
\r
if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \\r
# Fixup "*" offset\r
for Pcd in self._DynamicPcdList:\r
# just pick the a value to determine whether is unicode string type\r
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] \r
- if Sku.VpdOffset == "*":\r
- Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0].strip()\r
+ i = 0\r
+ for (SkuName,Sku) in Pcd.SkuInfoList.items(): \r
+ if Sku.VpdOffset == "*":\r
+ Sku.VpdOffset = VpdFile.GetOffset(Pcd)[i].strip()\r
+ i += 1\r
else:\r
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
\r
self._DynamicPcdList.extend(UnicodePcdArray)\r
self._DynamicPcdList.extend(HiiPcdArray)\r
self._DynamicPcdList.extend(OtherPcdArray)\r
- \r
+ self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
\r
## Return the platform build data object\r
def _GetPlatform(self):\r
self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)\r
return self._EdkIIBuildOption\r
\r
- ## Parse build_rule.txt in $(WORKSPACE)/Conf/build_rule.txt\r
+ ## Parse build_rule.txt in Conf Directory.\r
#\r
# @retval BuildRule object\r
#\r
if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:\r
BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
if BuildRuleFile in [None, '']:\r
- BuildRuleFile = gBuildRuleFile\r
+ BuildRuleFile = gDefaultBuildRuleFile\r
self._BuildRule = BuildRule(BuildRuleFile)\r
if self._BuildRule._FileVersion == "":\r
self._BuildRule._FileVersion = AutoGenReqBuildRuleVerNum\r
self._PackageList.update(La.DependentPackageList)\r
for Ma in self.ModuleAutoGenList:\r
self._PackageList.update(Ma.DependentPackageList)\r
- self._PackageList = list(self._PackageList)\r
+ #Collect package set information from INF of FDF\r
+ PkgSet = set()\r
+ for ModuleFile in self._AsBuildModuleList:\r
+ if ModuleFile in self.Platform.Modules:\r
+ continue\r
+ ModuleData = self.BuildDatabase[ModuleFile, self.Arch, self.BuildTarget, self.ToolChain]\r
+ PkgSet.update(ModuleData.Packages)\r
+ self._PackageList = list(self._PackageList) + list (PkgSet)\r
return self._PackageList\r
\r
+ def _GetNonDynamicPcdDict(self):\r
+ if self._NonDynamicPcdDict:\r
+ return self._NonDynamicPcdDict\r
+ for Pcd in self.NonDynamicPcdList:\r
+ self._NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)] = Pcd\r
+ return self._NonDynamicPcdDict\r
+\r
## Get list of non-dynamic PCDs\r
def _GetNonDynamicPcdList(self):\r
if self._NonDynamicPcdList == None:\r
for La in Ma.LibraryAutoGenList:\r
if La not in self._LibraryAutoGenList:\r
self._LibraryAutoGenList.append(La)\r
+ if Ma not in La._ReferenceModules:\r
+ La._ReferenceModules.append(Ma)\r
\r
## Summarize ModuleAutoGen objects of all modules to be built for this platform\r
def _GetModuleAutoGenList(self):\r
# by the platform or current configuration\r
#\r
def ValidModule(self, Module):\r
- return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances\r
+ return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances \\r
+ or Module in self._AsBuildModuleList\r
\r
## Resolve the library classes in a module to library instances\r
#\r
% (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))\r
Value = ToPcd.DefaultValue\r
if Value in [None, '']:\r
- ToPcd.MaxDatumSize = 1\r
+ ToPcd.MaxDatumSize = '1'\r
elif Value[0] == 'L':\r
- ToPcd.MaxDatumSize = str(len(Value) * 2)\r
+ ToPcd.MaxDatumSize = str((len(Value) - 2) * 2)\r
elif Value[0] == '{':\r
ToPcd.MaxDatumSize = str(len(Value.split(',')))\r
else:\r
- ToPcd.MaxDatumSize = str(len(Value))\r
+ ToPcd.MaxDatumSize = str(len(Value) - 1)\r
\r
# apply default SKU for dynamic PCDS if specified one is not available\r
if (ToPcd.Type in PCD_DYNAMIC_TYPE_LIST or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_LIST) \\r
PcdTokenNumber = property(_GetPcdTokenNumbers) # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r
DynamicPcdList = property(_GetDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
NonDynamicPcdList = property(_GetNonDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
+ NonDynamicPcdDict = property(_GetNonDynamicPcdDict)\r
PackageList = property(_GetPackageList)\r
\r
ToolDefinition = property(_GetToolDefinition) # toolcode : tool path\r
BuildRule = property(_GetBuildRule)\r
ModuleAutoGenList = property(_GetModuleAutoGenList)\r
LibraryAutoGenList = property(_GetLibraryAutoGenList)\r
+ GenFdsCommand = property(_GenFdsCommand)\r
\r
## ModuleAutoGen class\r
#\r
return False\r
\r
self.SourceDir = self.MetaFile.SubDir\r
+ if self.SourceDir.upper().find(self.WorkspaceDir.upper()) == 0:\r
+ self.SourceDir = self.SourceDir[len(self.WorkspaceDir) + 1:]\r
+\r
self.SourceOverrideDir = None\r
# use overrided path defined in DSC file\r
if self.MetaFile.Key in GlobalData.gOverrideDir:\r
self._DerivedPackageList = None\r
self._ModulePcdList = None\r
self._LibraryPcdList = None\r
+ self._PcdComments = sdict()\r
self._GuidList = None\r
+ self._GuidsUsedByPcd = None\r
+ self._GuidComments = sdict()\r
self._ProtocolList = None\r
+ self._ProtocolComments = sdict()\r
self._PpiList = None\r
+ self._PpiComments = sdict()\r
self._DepexList = None\r
self._DepexExpressionList = None\r
self._BuildOption = None\r
self._FinalBuildTargetList = None\r
self._FileTypes = None\r
self._BuildRules = None\r
-\r
+ \r
+ ## The Modules referenced to this Library\r
+ # Only Library has this attribute\r
+ self._ReferenceModules = [] \r
+ \r
+ ## Store the FixedAtBuild Pcds\r
+ # \r
+ self._FixedAtBuildPcds = []\r
+ self.ConstPcd = {}\r
return True\r
\r
def __repr__(self):\r
return "%s [%s]" % (self.MetaFile, self.Arch)\r
\r
+ # Get FixedAtBuild Pcds of this Module\r
+ def _GetFixedAtBuildPcds(self):\r
+ if self._FixedAtBuildPcds:\r
+ return self._FixedAtBuildPcds\r
+ for Pcd in self.ModulePcdList:\r
+ if self.IsLibrary:\r
+ if not (Pcd.Pending == False and Pcd.Type == "FixedAtBuild"):\r
+ continue\r
+ elif Pcd.Type != "FixedAtBuild":\r
+ continue\r
+ if Pcd not in self._FixedAtBuildPcds:\r
+ self._FixedAtBuildPcds.append(Pcd)\r
+ \r
+ return self._FixedAtBuildPcds \r
+\r
# Macros could be used in build_rule.txt (also Makefile)\r
def _GetMacros(self):\r
if self._Macro == None:\r
\r
## Return the module meta-file GUID\r
def _GetGuid(self):\r
+ #\r
+ # To build same module more than once, the module path with FILE_GUID overridden has\r
+ # the file name FILE_GUIDmodule.inf, but the relative path (self.MetaFile.File) is the realy path\r
+ # in DSC. The overridden GUID can be retrieved from file name\r
+ #\r
+ if os.path.basename(self.MetaFile.File) != os.path.basename(self.MetaFile.Path):\r
+ #\r
+ # Length of GUID is 36\r
+ #\r
+ return os.path.basename(self.MetaFile.Path)[:36]\r
return self.Module.Guid\r
\r
## Return the module version\r
self._LibraryFlag = False\r
return self._LibraryFlag\r
\r
+ ## Check if the module is binary module or not\r
+ def _IsBinaryModule(self):\r
+ return self.Module.IsBinaryModule\r
+\r
## Return the directory to store intermediate files of the module\r
def _GetBuildDir(self):\r
if self._BuildDir == None:\r
continue\r
PackageList.append(Package)\r
return PackageList\r
-\r
+ \r
+ ## Get the depex string\r
+ #\r
+ # @return : a string contain all depex expresion.\r
+ def _GetDepexExpresionString(self):\r
+ DepexStr = ''\r
+ DepexList = []\r
+ ## DPX_SOURCE IN Define section.\r
+ if self.Module.DxsFile:\r
+ return DepexStr\r
+ for M in [self.Module] + self.DependentLibraryList:\r
+ Filename = M.MetaFile.Path\r
+ InfObj = InfSectionParser.InfSectionParser(Filename)\r
+ DepexExpresionList = InfObj.GetDepexExpresionList()\r
+ for DepexExpresion in DepexExpresionList:\r
+ for key in DepexExpresion.keys():\r
+ Arch, ModuleType = key\r
+ # the type of build module is USER_DEFINED.\r
+ # All different DEPEX section tags would be copied into the As Built INF file\r
+ # and there would be separate DEPEX section tags\r
+ if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
+ if (Arch.upper() == self.Arch.upper()) and (ModuleType.upper() != TAB_ARCH_COMMON):\r
+ DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})\r
+ else:\r
+ if Arch.upper() == TAB_ARCH_COMMON or \\r
+ (Arch.upper() == self.Arch.upper() and \\r
+ ModuleType.upper() in [TAB_ARCH_COMMON, self.ModuleType.upper()]):\r
+ DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})\r
+ \r
+ #the type of build module is USER_DEFINED.\r
+ if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
+ for Depex in DepexList:\r
+ for key in Depex.keys():\r
+ DepexStr += '[Depex.%s.%s]\n' % key\r
+ DepexStr += '\n'.join(['# '+ val for val in Depex[key]])\r
+ DepexStr += '\n\n'\r
+ if not DepexStr:\r
+ return '[Depex.%s]\n' % self.Arch\r
+ return DepexStr\r
+ \r
+ #the type of build module not is USER_DEFINED.\r
+ Count = 0\r
+ for Depex in DepexList:\r
+ Count += 1\r
+ if DepexStr != '':\r
+ DepexStr += ' AND '\r
+ DepexStr += '('\r
+ for D in Depex.values():\r
+ DepexStr += ' '.join([val for val in D])\r
+ Index = DepexStr.find('END')\r
+ if Index > -1 and Index == len(DepexStr) - 3:\r
+ DepexStr = DepexStr[:-3]\r
+ DepexStr = DepexStr.strip()\r
+ DepexStr += ')'\r
+ if Count == 1:\r
+ DepexStr = DepexStr.lstrip('(').rstrip(')').strip()\r
+ if not DepexStr:\r
+ return '[Depex.%s]\n' % self.Arch\r
+ return '[Depex.%s]\n# ' % self.Arch + DepexStr\r
+ \r
## Merge dependency expression\r
#\r
# @retval list The token list of the dependency expression after parsed\r
## Return a list of files which can be built from source\r
#\r
# What kind of files can be built is determined by build rules in\r
- # $(WORKSPACE)/Conf/build_rule.txt and toolchain family.\r
+ # $(CONF_DIRECTORY)/build_rule.txt and toolchain family.\r
#\r
def _GetSourceFileList(self):\r
if self._SourceFileList == None:\r
self._BuildTargets = {}\r
self._FileTypes = {}\r
\r
+ SubDirectory = os.path.join(self.OutputDir, File.SubDir)\r
+ if not os.path.exists(SubDirectory):\r
+ CreateDirectory(SubDirectory)\r
LastTarget = None\r
RuleChain = []\r
SourceList = [File]\r
AutoGenH = TemplateString()\r
StringH = TemplateString()\r
GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer)\r
- if str(AutoGenC) != "" and TAB_C_CODE_FILE in self.FileTypes:\r
+ #\r
+ # AutoGen.c is generated if there are library classes in inf, or there are object files\r
+ #\r
+ if str(AutoGenC) != "" and (len(self.Module.LibraryClasses) > 0\r
+ or TAB_OBJECT_FILE in self.FileTypes):\r
AutoFile = PathClass(gAutoGenCodeFileName, self.DebugDir)\r
self._AutoGenFileList[AutoFile] = str(AutoGenC)\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module)\r
return self._DependentLibraryList\r
\r
+ @staticmethod\r
+ def UpdateComments(Recver, Src):\r
+ for Key in Src:\r
+ if Key not in Recver:\r
+ Recver[Key] = []\r
+ Recver[Key].extend(Src[Key])\r
## Get the list of PCDs from current module\r
#\r
# @retval list The list of PCD\r
if self._ModulePcdList == None:\r
# apply PCD settings from platform\r
self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)\r
+ self.UpdateComments(self._PcdComments, self.Module.PcdComments)\r
return self._ModulePcdList\r
\r
## Get the list of PCDs from dependent libraries\r
if not self.IsLibrary:\r
# get PCDs from dependent libraries\r
for Library in self.DependentLibraryList:\r
+ self.UpdateComments(self._PcdComments, Library.PcdComments)\r
for Key in Library.Pcds:\r
# skip duplicated PCDs\r
if Key in self.Module.Pcds or Key in Pcds:\r
#\r
def _GetGuidList(self):\r
if self._GuidList == None:\r
- self._GuidList = self.Module.Guids\r
+ self._GuidList = sdict()\r
+ self._GuidList.update(self.Module.Guids)\r
for Library in self.DependentLibraryList:\r
self._GuidList.update(Library.Guids)\r
+ self.UpdateComments(self._GuidComments, Library.GuidComments)\r
+ self.UpdateComments(self._GuidComments, self.Module.GuidComments)\r
return self._GuidList\r
\r
+ def GetGuidsUsedByPcd(self):\r
+ if self._GuidsUsedByPcd == None:\r
+ self._GuidsUsedByPcd = sdict()\r
+ self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())\r
+ for Library in self.DependentLibraryList:\r
+ self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())\r
+ return self._GuidsUsedByPcd\r
## Get the protocol value mapping\r
#\r
# @retval dict The mapping between protocol cname and its value\r
#\r
def _GetProtocolList(self):\r
if self._ProtocolList == None:\r
- self._ProtocolList = self.Module.Protocols\r
+ self._ProtocolList = sdict()\r
+ self._ProtocolList.update(self.Module.Protocols)\r
for Library in self.DependentLibraryList:\r
self._ProtocolList.update(Library.Protocols)\r
+ self.UpdateComments(self._ProtocolComments, Library.ProtocolComments)\r
+ self.UpdateComments(self._ProtocolComments, self.Module.ProtocolComments)\r
return self._ProtocolList\r
\r
## Get the PPI value mapping\r
#\r
def _GetPpiList(self):\r
if self._PpiList == None:\r
- self._PpiList = self.Module.Ppis\r
+ self._PpiList = sdict()\r
+ self._PpiList.update(self.Module.Ppis)\r
for Library in self.DependentLibraryList:\r
self._PpiList.update(Library.Ppis)\r
+ self.UpdateComments(self._PpiComments, Library.PpiComments)\r
+ self.UpdateComments(self._PpiComments, self.Module.PpiComments)\r
return self._PpiList\r
\r
## Get the list of include search path\r
self._IncludePathList.append(str(Inc))\r
return self._IncludePathList\r
\r
+ ## Get HII EX PCDs which maybe used by VFR\r
+ #\r
+ # efivarstore used by VFR may relate with HII EX PCDs\r
+ # Get the variable name and GUID from efivarstore and HII EX PCD\r
+ # List the HII EX PCDs in As Built INF if both name and GUID match.\r
+ #\r
+ # @retval list HII EX PCDs\r
+ #\r
+ def _GetPcdsMaybeUsedByVfr(self):\r
+ if not self.SourceFileList:\r
+ return []\r
+\r
+ NameGuids = []\r
+ for SrcFile in self.SourceFileList:\r
+ if SrcFile.Ext.lower() != '.vfr':\r
+ continue\r
+ Vfri = os.path.join(self.OutputDir, SrcFile.BaseName + '.i')\r
+ if not os.path.exists(Vfri):\r
+ continue\r
+ VfriFile = open(Vfri, 'r')\r
+ Content = VfriFile.read()\r
+ VfriFile.close()\r
+ Pos = Content.find('efivarstore')\r
+ while Pos != -1:\r
+ #\r
+ # Make sure 'efivarstore' is the start of efivarstore statement\r
+ # In case of the value of 'name' (name = efivarstore) is equal to 'efivarstore'\r
+ #\r
+ Index = Pos - 1\r
+ while Index >= 0 and Content[Index] in ' \t\r\n':\r
+ Index -= 1\r
+ if Index >= 0 and Content[Index] != ';':\r
+ Pos = Content.find('efivarstore', Pos + len('efivarstore'))\r
+ continue\r
+ #\r
+ # 'efivarstore' must be followed by name and guid\r
+ #\r
+ Name = gEfiVarStoreNamePattern.search(Content, Pos)\r
+ if not Name:\r
+ break\r
+ Guid = gEfiVarStoreGuidPattern.search(Content, Pos)\r
+ if not Guid:\r
+ break\r
+ NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
+ NameGuids.append((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r
+ Pos = Content.find('efivarstore', Name.end())\r
+ if not NameGuids:\r
+ return []\r
+ HiiExPcds = []\r
+ for Pcd in self.PlatformInfo.Platform.Pcds.values():\r
+ if Pcd.Type != TAB_PCDS_DYNAMIC_EX_HII:\r
+ continue\r
+ for SkuName in Pcd.SkuInfoList:\r
+ SkuInfo = Pcd.SkuInfoList[SkuName]\r
+ Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
+ Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList)\r
+ if not Value:\r
+ continue\r
+ Guid = GuidStructureStringToGuidString(Value)\r
+ if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:\r
+ HiiExPcds.append(Pcd)\r
+ break\r
+\r
+ return HiiExPcds\r
+\r
## Create AsBuilt INF file the module\r
#\r
def CreateAsBuiltInf(self):\r
\r
### TODO: How to handles mixed source and binary modules\r
\r
- # Find all DynamicEx PCDs used by this module and dependent libraries\r
+ # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries\r
# Also find all packages that the DynamicEx PCDs depend on\r
Pcds = []\r
+ PatchablePcds = {}\r
Packages = [] \r
+ PcdCheckList = []\r
+ PcdTokenSpaceList = []\r
for Pcd in self.ModulePcdList + self.LibraryPcdList:\r
- if Pcd.Type in GenC.gDynamicExPcd:\r
- if Pcd not in Pcds:\r
- Pcds += [Pcd]\r
- for Package in self.DerivedPackageList:\r
- if Package not in Packages:\r
- if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:\r
- Packages += [Package]\r
- elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:\r
- Packages += [Package]\r
+ if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:\r
+ PatchablePcds[Pcd.TokenCName] = Pcd\r
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))\r
+ elif Pcd.Type in GenC.gDynamicExPcd:\r
+ if Pcd not in Pcds:\r
+ Pcds += [Pcd]\r
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))\r
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))\r
+ PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)\r
+ GuidList = sdict()\r
+ GuidList.update(self.GuidList)\r
+ for TokenSpace in self.GetGuidsUsedByPcd():\r
+ # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list\r
+ # The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs\r
+ if TokenSpace not in PcdTokenSpaceList and TokenSpace in GuidList:\r
+ GuidList.pop(TokenSpace)\r
+ CheckList = (GuidList, self.PpiList, self.ProtocolList, PcdCheckList)\r
+ for Package in self.DerivedPackageList:\r
+ if Package in Packages:\r
+ continue\r
+ BeChecked = (Package.Guids, Package.Ppis, Package.Protocols, Package.Pcds)\r
+ Found = False\r
+ for Index in range(len(BeChecked)):\r
+ for Item in CheckList[Index]:\r
+ if Item in BeChecked[Index]:\r
+ Packages += [Package]\r
+ Found = True\r
+ break\r
+ if Found: break\r
+\r
+ VfrPcds = self._GetPcdsMaybeUsedByVfr()\r
+ for Pkg in self.PlatformInfo.PackageList:\r
+ if Pkg in Packages:\r
+ continue\r
+ for VfrPcd in VfrPcds:\r
+ if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'DynamicEx') in Pkg.Pcds or\r
+ (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'Dynamic') in Pkg.Pcds):\r
+ Packages += [Pkg]\r
+ break\r
\r
ModuleType = self.ModuleType\r
if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:\r
- ModuleType = 'DXE_DRIVER'\r
+ ModuleType = 'DXE_DRIVER'\r
+\r
+ DriverType = ''\r
+ if self.PcdIsDriver != '':\r
+ DriverType = self.PcdIsDriver\r
+\r
+ Guid = self.Guid\r
+ MDefs = self.Module.Defines\r
\r
AsBuiltInfDict = {\r
'module_name' : self.Name,\r
- 'module_guid' : self.Guid,\r
+ 'module_guid' : Guid,\r
'module_module_type' : ModuleType,\r
- 'module_version_string' : self.Version,\r
+ 'module_version_string' : [MDefs['VERSION_STRING']] if 'VERSION_STRING' in MDefs else [],\r
+ 'pcd_is_driver_string' : [],\r
'module_uefi_specification_version' : [],\r
'module_pi_specification_version' : [],\r
+ 'module_entry_point' : self.Module.ModuleEntryPointList,\r
+ 'module_unload_image' : self.Module.ModuleUnloadImageList,\r
+ 'module_constructor' : self.Module.ConstructorList,\r
+ 'module_destructor' : self.Module.DestructorList,\r
+ 'module_shadow' : [MDefs['SHADOW']] if 'SHADOW' in MDefs else [],\r
+ 'module_pci_vendor_id' : [MDefs['PCI_VENDOR_ID']] if 'PCI_VENDOR_ID' in MDefs else [],\r
+ 'module_pci_device_id' : [MDefs['PCI_DEVICE_ID']] if 'PCI_DEVICE_ID' in MDefs else [],\r
+ 'module_pci_class_code' : [MDefs['PCI_CLASS_CODE']] if 'PCI_CLASS_CODE' in MDefs else [],\r
+ 'module_pci_revision' : [MDefs['PCI_REVISION']] if 'PCI_REVISION' in MDefs else [],\r
+ 'module_build_number' : [MDefs['BUILD_NUMBER']] if 'BUILD_NUMBER' in MDefs else [],\r
+ 'module_spec' : [MDefs['SPEC']] if 'SPEC' in MDefs else [],\r
+ 'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [],\r
+ 'module_uni_file' : [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs else [],\r
'module_arch' : self.Arch,\r
'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],\r
'binary_item' : [],\r
+ 'patchablepcd_item' : [],\r
'pcd_item' : [],\r
- 'flags_item' : []\r
+ 'protocol_item' : [],\r
+ 'ppi_item' : [],\r
+ 'guid_item' : [],\r
+ 'flags_item' : [],\r
+ 'libraryclasses_item' : []\r
}\r
\r
+ if self.AutoGenVersion > int(gInfSpecVersion, 0):\r
+ AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion\r
+ else:\r
+ AsBuiltInfDict['module_inf_version'] = gInfSpecVersion\r
+\r
+ if DriverType:\r
+ AsBuiltInfDict['pcd_is_driver_string'] += [DriverType]\r
+\r
if 'UEFI_SPECIFICATION_VERSION' in self.Specification:\r
AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]\r
if 'PI_SPECIFICATION_VERSION' in self.Specification:\r
if self.ModuleType in ['DXE_SMM_DRIVER']:\r
AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']\r
\r
- for Pcd in Pcds:\r
- AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]\r
- \r
+ for Root, Dirs, Files in os.walk(OutputDir):\r
+ for File in Files:\r
+ if File.lower().endswith('.pdb'):\r
+ AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File]\r
+ HeaderComments = self.Module.HeaderComments\r
+ StartPos = 0\r
+ for Index in range(len(HeaderComments)):\r
+ if HeaderComments[Index].find('@BinaryHeader') != -1:\r
+ HeaderComments[Index] = HeaderComments[Index].replace('@BinaryHeader', '@file')\r
+ StartPos = Index\r
+ break\r
+ AsBuiltInfDict['header_comments'] = '\n'.join(HeaderComments[StartPos:]).replace(':#', '://')\r
+ AsBuiltInfDict['tail_comments'] = '\n'.join(self.Module.TailComments)\r
+\r
+ GenList = [\r
+ (self.ProtocolList, self._ProtocolComments, 'protocol_item'),\r
+ (self.PpiList, self._PpiComments, 'ppi_item'),\r
+ (GuidList, self._GuidComments, 'guid_item')\r
+ ]\r
+ for Item in GenList:\r
+ for CName in Item[0]:\r
+ Comments = ''\r
+ if CName in Item[1]:\r
+ Comments = '\n '.join(Item[1][CName])\r
+ Entry = CName\r
+ if Comments:\r
+ Entry = Comments + '\n ' + CName\r
+ AsBuiltInfDict[Item[2]].append(Entry)\r
+ PatchList = parsePcdInfoFromMapFile(\r
+ os.path.join(self.OutputDir, self.Name + '.map'),\r
+ os.path.join(self.OutputDir, self.Name + '.efi')\r
+ )\r
+ if PatchList:\r
+ for PatchPcd in PatchList:\r
+ if PatchPcd[0] not in PatchablePcds:\r
+ continue\r
+ Pcd = PatchablePcds[PatchPcd[0]]\r
+ PcdValue = ''\r
+ if Pcd.DatumType != 'VOID*':\r
+ HexFormat = '0x%02x'\r
+ if Pcd.DatumType == 'UINT16':\r
+ HexFormat = '0x%04x'\r
+ elif Pcd.DatumType == 'UINT32':\r
+ HexFormat = '0x%08x'\r
+ elif Pcd.DatumType == 'UINT64':\r
+ HexFormat = '0x%016x'\r
+ PcdValue = HexFormat % int(Pcd.DefaultValue, 0)\r
+ else:\r
+ if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':\r
+ EdkLogger.error("build", AUTOGEN_ERROR,\r
+ "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ )\r
+ ArraySize = int(Pcd.MaxDatumSize, 0)\r
+ PcdValue = Pcd.DefaultValue\r
+ if PcdValue[0] != '{':\r
+ Unicode = False\r
+ if PcdValue[0] == 'L':\r
+ Unicode = True\r
+ PcdValue = PcdValue.lstrip('L')\r
+ PcdValue = eval(PcdValue)\r
+ NewValue = '{'\r
+ for Index in range(0, len(PcdValue)):\r
+ if Unicode:\r
+ CharVal = ord(PcdValue[Index])\r
+ NewValue = NewValue + '0x%02x' % (CharVal & 0x00FF) + ', ' \\r
+ + '0x%02x' % (CharVal >> 8) + ', '\r
+ else:\r
+ NewValue = NewValue + '0x%02x' % (ord(PcdValue[Index]) % 0x100) + ', '\r
+ Padding = '0x00, '\r
+ if Unicode:\r
+ Padding = Padding * 2\r
+ ArraySize = ArraySize / 2\r
+ if ArraySize < (len(PcdValue) + 1):\r
+ EdkLogger.error("build", AUTOGEN_ERROR,\r
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ )\r
+ if ArraySize > len(PcdValue) + 1:\r
+ NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1)\r
+ PcdValue = NewValue + Padding.strip().rstrip(',') + '}'\r
+ elif len(PcdValue.split(',')) <= ArraySize:\r
+ PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(',')))\r
+ PcdValue += '}'\r
+ else:\r
+ EdkLogger.error("build", AUTOGEN_ERROR,\r
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ )\r
+ PcdItem = '%s.%s|%s|0x%X' % \\r
+ (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, PcdValue, PatchPcd[1])\r
+ PcdComments = ''\r
+ if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r
+ PcdComments = '\n '.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])\r
+ if PcdComments:\r
+ PcdItem = PcdComments + '\n ' + PcdItem\r
+ AsBuiltInfDict['patchablepcd_item'].append(PcdItem)\r
+\r
+ HiiPcds = []\r
+ for Pcd in Pcds + VfrPcds:\r
+ PcdComments = ''\r
+ PcdCommentList = []\r
+ HiiInfo = ''\r
+ SkuId = ''\r
+ if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:\r
+ for SkuName in Pcd.SkuInfoList:\r
+ SkuInfo = Pcd.SkuInfoList[SkuName]\r
+ SkuId = SkuInfo.SkuId\r
+ HiiInfo = '## %s|%s|%s' % (SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInfo.VariableOffset)\r
+ break\r
+ if SkuId:\r
+ #\r
+ # Don't generate duplicated HII PCD\r
+ #\r
+ if (SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in HiiPcds:\r
+ continue\r
+ else:\r
+ HiiPcds.append((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
+ if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r
+ PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]\r
+ if HiiInfo:\r
+ UsageIndex = -1\r
+ UsageStr = ''\r
+ for Index, Comment in enumerate(PcdCommentList):\r
+ for Usage in UsageList:\r
+ if Comment.find(Usage) != -1:\r
+ UsageStr = Usage\r
+ UsageIndex = Index\r
+ break\r
+ if UsageIndex != -1:\r
+ PcdCommentList[UsageIndex] = '## %s %s %s' % (UsageStr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, '')) \r
+ else:\r
+ PcdCommentList.append('## UNDEFINED ' + HiiInfo)\r
+ PcdComments = '\n '.join(PcdCommentList)\r
+ PcdEntry = Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName\r
+ if PcdComments:\r
+ PcdEntry = PcdComments + '\n ' + PcdEntry\r
+ AsBuiltInfDict['pcd_item'] += [PcdEntry]\r
for Item in self.BuildOption:\r
if 'FLAGS' in self.BuildOption[Item]:\r
AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]\r
+\r
+ # Generated LibraryClasses section in comments.\r
+ for Library in self.LibraryAutoGenList:\r
+ AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\', '/')]\r
+ \r
+ # Generated depex expression section in comments.\r
+ AsBuiltInfDict['depexsection_item'] = ''\r
+ DepexExpresion = self._GetDepexExpresionString()\r
+ if DepexExpresion:\r
+ AsBuiltInfDict['depexsection_item'] = DepexExpresion\r
\r
AsBuiltInf = TemplateString()\r
AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))\r
# dependent libraries will be created\r
#\r
def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+ # Ignore generating makefile when it is a binary module\r
+ if self.IsBinaryModule:\r
+ return\r
+\r
if self.IsMakeFileCreated:\r
return\r
\r
\r
self.IsMakeFileCreated = True\r
\r
+ def CopyBinaryFiles(self):\r
+ for File in self.Module.Binaries:\r
+ SrcPath = File.Path\r
+ DstPath = os.path.join(self.OutputDir , os.path.basename(SrcPath))\r
+ CopyLongFilePath(SrcPath, DstPath)\r
## Create autogen code for the module and its dependent libraries\r
#\r
# @param CreateLibraryCodeFile Flag indicating if or not the code of\r
if self.IsCodeFileCreated:\r
return\r
\r
+ # Need to generate PcdDatabase even PcdDriver is binarymodule\r
+ if self.IsBinaryModule and self.PcdIsDriver != '':\r
+ CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
+ return\r
+ if self.IsBinaryModule:\r
+ if self.IsLibrary:\r
+ self.CopyBinaryFiles()\r
+ return\r
+\r
if not self.IsLibrary and CreateLibraryCodeFile:\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
LibraryAutoGen.CreateCodeFile()\r
Specification = property(_GetSpecification)\r
\r
IsLibrary = property(_IsLibrary)\r
-\r
+ IsBinaryModule = property(_IsBinaryModule)\r
BuildDir = property(_GetBuildDir)\r
OutputDir = property(_GetOutputDir)\r
DebugDir = property(_GetDebugDir)\r
BuildOption = property(_GetModuleBuildOption)\r
BuildOptionIncPathList = property(_GetBuildOptionIncPathList)\r
BuildCommand = property(_GetBuildCommand)\r
+ \r
+ FixedAtBuildPcds = property(_GetFixedAtBuildPcds)\r
\r
# This acts like the main() function for the script, unless it is 'import'ed into another script.\r
if __name__ == '__main__':\r