License header updated to match correct format.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yingke Liu <yingke.d.liu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15971 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -40,15 +40,27 @@ import Common.VpdInfoFile as VpdInfoFile
|
||||
from GenPcdDb import CreatePcdDatabaseCode
|
||||
from Workspace.MetaFileCommentParser import UsageList
|
||||
|
||||
import InfSectionParser
|
||||
|
||||
## Regular expression for splitting Dependency Expression string into tokens
|
||||
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
|
||||
|
||||
#
|
||||
# Match name = variable
|
||||
#
|
||||
gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
|
||||
#
|
||||
# The format of guid in efivarstore statement likes following and must be correct:
|
||||
# guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
|
||||
#
|
||||
gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
|
||||
|
||||
## Mapping Makefile type
|
||||
gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}
|
||||
|
||||
|
||||
## Build rule configuration file
|
||||
gBuildRuleFile = 'Conf/build_rule.txt'
|
||||
gDefaultBuildRuleFile = 'Conf/build_rule.txt'
|
||||
|
||||
## Build rule default version
|
||||
AutoGenReqBuildRuleVerNum = "0.1"
|
||||
@ -60,22 +72,40 @@ gAutoGenStringFileName = "%(module_name)sStrDefs.h"
|
||||
gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"
|
||||
gAutoGenDepexFileName = "%(module_name)s.depex"
|
||||
|
||||
gInfSpecVersion = "0x00010017"
|
||||
|
||||
#
|
||||
# Template string to generic AsBuilt INF
|
||||
#
|
||||
gAsBuiltInfHeaderString = TemplateString("""${header_comments}
|
||||
|
||||
# DO NOT EDIT
|
||||
# FILE auto-generated
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010016
|
||||
INF_VERSION = ${module_inf_version}
|
||||
BASE_NAME = ${module_name}
|
||||
FILE_GUID = ${module_guid}
|
||||
MODULE_TYPE = ${module_module_type}
|
||||
VERSION_STRING = ${module_version_string}${BEGIN}
|
||||
MODULE_TYPE = ${module_module_type}${BEGIN}
|
||||
VERSION_STRING = ${module_version_string}${END}${BEGIN}
|
||||
PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}
|
||||
UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
|
||||
PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}
|
||||
PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}${BEGIN}
|
||||
ENTRY_POINT = ${module_entry_point}${END}${BEGIN}
|
||||
UNLOAD_IMAGE = ${module_unload_image}${END}${BEGIN}
|
||||
CONSTRUCTOR = ${module_constructor}${END}${BEGIN}
|
||||
DESTRUCTOR = ${module_destructor}${END}${BEGIN}
|
||||
SHADOW = ${module_shadow}${END}${BEGIN}
|
||||
PCI_VENDOR_ID = ${module_pci_vendor_id}${END}${BEGIN}
|
||||
PCI_DEVICE_ID = ${module_pci_device_id}${END}${BEGIN}
|
||||
PCI_CLASS_CODE = ${module_pci_class_code}${END}${BEGIN}
|
||||
PCI_REVISION = ${module_pci_revision}${END}${BEGIN}
|
||||
BUILD_NUMBER = ${module_build_number}${END}${BEGIN}
|
||||
SPEC = ${module_spec}${END}${BEGIN}
|
||||
UEFI_HII_RESOURCE_SECTION = ${module_uefi_hii_resource_section}${END}${BEGIN}
|
||||
MODULE_UNI_FILE = ${module_uni_file}${END}
|
||||
|
||||
[Packages]${BEGIN}
|
||||
[Packages.${module_arch}]${BEGIN}
|
||||
${package_item}${END}
|
||||
|
||||
[Binaries.${module_arch}]${BEGIN}
|
||||
@ -84,19 +114,32 @@ gAsBuiltInfHeaderString = TemplateString("""${header_comments}
|
||||
[PatchPcd.${module_arch}]${BEGIN}
|
||||
${patchablepcd_item}
|
||||
${END}
|
||||
|
||||
[Protocols.${module_arch}]${BEGIN}
|
||||
${protocol_item}
|
||||
${END}
|
||||
|
||||
[Ppis.${module_arch}]${BEGIN}
|
||||
${ppi_item}
|
||||
${END}
|
||||
|
||||
[Guids.${module_arch}]${BEGIN}
|
||||
${guid_item}
|
||||
${END}
|
||||
|
||||
[PcdEx.${module_arch}]${BEGIN}
|
||||
${pcd_item}
|
||||
${END}
|
||||
|
||||
[LibraryClasses.${module_arch}]
|
||||
## @LIB_INSTANCES${BEGIN}
|
||||
# ${libraryclasses_item}${END}
|
||||
|
||||
${depexsection_item}
|
||||
|
||||
${tail_comments}
|
||||
|
||||
[BuildOptions.${module_arch}]
|
||||
## @AsBuilt${BEGIN}
|
||||
## ${flags_item}${END}
|
||||
""")
|
||||
@ -240,6 +283,15 @@ class WorkspaceAutoGen(AutoGen):
|
||||
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"
|
||||
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))
|
||||
|
||||
# Validate SKU ID
|
||||
if not self.SkuId:
|
||||
self.SkuId = 'DEFAULT'
|
||||
|
||||
if self.SkuId not in self.Platform.SkuIds:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"
|
||||
% (self.SkuId, " ".join(self.Platform.SkuIds.keys())))
|
||||
|
||||
# parse FDF file to get PCDs in it, if any
|
||||
if not self.FdfFile:
|
||||
self.FdfFile = self.Platform.FlashDefinition
|
||||
@ -299,6 +351,7 @@ class WorkspaceAutoGen(AutoGen):
|
||||
DecPcds = {}
|
||||
DecPcdsKey = set()
|
||||
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
|
||||
#Collect package set information from INF of FDF
|
||||
PkgSet = set()
|
||||
for Inf in ModuleList:
|
||||
ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)
|
||||
@ -355,10 +408,10 @@ class WorkspaceAutoGen(AutoGen):
|
||||
# Check PCD type and definition between DSC and DEC
|
||||
#
|
||||
self._CheckPcdDefineAndType()
|
||||
|
||||
if self.FdfFile:
|
||||
self._CheckDuplicateInFV(Fdf)
|
||||
|
||||
|
||||
# if self.FdfFile:
|
||||
# self._CheckDuplicateInFV(Fdf)
|
||||
|
||||
self._BuildDir = None
|
||||
self._FvDir = None
|
||||
self._MakeFileDir = None
|
||||
@ -662,7 +715,7 @@ class WorkspaceAutoGen(AutoGen):
|
||||
ExtraData=None
|
||||
)
|
||||
Count += 1
|
||||
|
||||
## Generate fds command
|
||||
def _GenFdsCommand(self):
|
||||
return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()
|
||||
|
||||
@ -817,9 +870,6 @@ class PlatformAutoGen(AutoGen):
|
||||
# get library/modules for build
|
||||
self.LibraryBuildDirectoryList = []
|
||||
self.ModuleBuildDirectoryList = []
|
||||
# get the original module/package/platform objects
|
||||
self.LibraryBuildDirectoryList = []
|
||||
self.ModuleBuildDirectoryList = []
|
||||
return True
|
||||
|
||||
def __repr__(self):
|
||||
@ -859,7 +909,7 @@ class PlatformAutoGen(AutoGen):
|
||||
Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,
|
||||
self.ToolChain, self.Arch, self.MetaFile)
|
||||
Ma.CreateMakeFile(True)
|
||||
Ma.CreateAsBuiltInf()
|
||||
#Ma.CreateAsBuiltInf()
|
||||
|
||||
# no need to create makefile for the platform more than once
|
||||
if self.IsMakeFileCreated:
|
||||
@ -923,8 +973,11 @@ class PlatformAutoGen(AutoGen):
|
||||
if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
|
||||
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
|
||||
|
||||
# Check the PCD from Binary INF or Source INF
|
||||
if M.IsBinaryModule == True:
|
||||
PcdFromModule.IsFromBinaryInf = True
|
||||
|
||||
# Check the PCD from DSC or not
|
||||
if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():
|
||||
PcdFromModule.IsFromDsc = True
|
||||
else:
|
||||
@ -943,11 +996,11 @@ class PlatformAutoGen(AutoGen):
|
||||
PcdFromModule.IsFromBinaryInf == False:
|
||||
# Print warning message to let the developer make a determine.
|
||||
if PcdFromModule not in PcdNotInDb:
|
||||
EdkLogger.warn("build",
|
||||
"A PCD listed in the DSC (%s.%s, %s) is used by a module not in the FDF. If the PCD is not used by any module listed in the FDF this PCD will be ignored. " \
|
||||
% (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, self.Platform.MetaFile.Path),
|
||||
File=self.MetaFile, \
|
||||
ExtraData=None)
|
||||
# EdkLogger.warn("build",
|
||||
# "A PCD listed in the DSC (%s.%s, %s) is used by a module not in the FDF. If the PCD is not used by any module listed in the FDF this PCD will be ignored. " \
|
||||
# % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, self.Platform.MetaFile.Path),
|
||||
# File=self.MetaFile, \
|
||||
# ExtraData=None)
|
||||
PcdNotInDb.append(PcdFromModule)
|
||||
continue
|
||||
# If one of the Source built modules listed in the DSC is not listed in
|
||||
@ -1017,6 +1070,11 @@ class PlatformAutoGen(AutoGen):
|
||||
elif PcdFromModule not in self._NonDynaPcdList_ and PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
self._NonDynaPcdList_.append(PcdFromModule)
|
||||
if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in GenC.gDynamicExPcd:
|
||||
# Overwrite the phase of any the same PCD existing, if Phase is PEI.
|
||||
# It is to solve the case that a dynamic PCD used by a PEM module/PEI
|
||||
# module & DXE module at a same time.
|
||||
# Overwrite the type of the PCDs in source INF by the type of AsBuild
|
||||
# INF file as DynamicEx.
|
||||
Index = self._DynaPcdList_.index(PcdFromModule)
|
||||
self._DynaPcdList_[Index].Phase = PcdFromModule.Phase
|
||||
self._DynaPcdList_[Index].Type = PcdFromModule.Type
|
||||
@ -1050,16 +1108,16 @@ class PlatformAutoGen(AutoGen):
|
||||
# If PCD is listed in a PcdsDynamicHii, PcdsDynamicExHii, PcdsDynamicHii or PcdsDynamicExHii
|
||||
# section, and the PCD is not used by any module that is listed in the DSC file, the build
|
||||
# provide a warning message.
|
||||
for PcdKey in self.Platform.Pcds.keys():
|
||||
Pcd = self.Platform.Pcds[PcdKey]
|
||||
if Pcd not in self._DynamicPcdList + PcdNotInDb and \
|
||||
Pcd.Type in [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_HII]:
|
||||
# Print warning message to let the developer make a determine.
|
||||
EdkLogger.warn("build",
|
||||
"A %s PCD listed in the DSC (%s.%s, %s) is not used by any module." \
|
||||
% (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path),
|
||||
File=self.MetaFile, \
|
||||
ExtraData=None)
|
||||
#for PcdKey in self.Platform.Pcds.keys():
|
||||
# Pcd = self.Platform.Pcds[PcdKey]
|
||||
# if Pcd not in self._DynamicPcdList + PcdNotInDb and \
|
||||
# Pcd.Type in [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_HII]:
|
||||
# # Print warning message to let the developer make a determine.
|
||||
#EdkLogger.warn("build",
|
||||
# "A %s PCD listed in the DSC (%s.%s, %s) is not used by any module." \
|
||||
# % (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path),
|
||||
# File=self.MetaFile, \
|
||||
# ExtraData=None)
|
||||
#
|
||||
# Sort dynamic PCD list to:
|
||||
# 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should
|
||||
@ -1421,7 +1479,7 @@ class PlatformAutoGen(AutoGen):
|
||||
self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)
|
||||
return self._EdkIIBuildOption
|
||||
|
||||
## Parse build_rule.txt in $(WORKSPACE)/Conf/build_rule.txt
|
||||
## Parse build_rule.txt in Conf Directory.
|
||||
#
|
||||
# @retval BuildRule object
|
||||
#
|
||||
@ -1431,7 +1489,7 @@ class PlatformAutoGen(AutoGen):
|
||||
if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:
|
||||
BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
|
||||
if BuildRuleFile in [None, '']:
|
||||
BuildRuleFile = gBuildRuleFile
|
||||
BuildRuleFile = gDefaultBuildRuleFile
|
||||
self._BuildRule = BuildRule(BuildRuleFile)
|
||||
if self._BuildRule._FileVersion == "":
|
||||
self._BuildRule._FileVersion = AutoGenReqBuildRuleVerNum
|
||||
@ -2140,6 +2198,9 @@ class ModuleAutoGen(AutoGen):
|
||||
return False
|
||||
|
||||
self.SourceDir = self.MetaFile.SubDir
|
||||
if self.SourceDir.upper().find(self.WorkspaceDir.upper()) == 0:
|
||||
self.SourceDir = self.SourceDir[len(self.WorkspaceDir) + 1:]
|
||||
|
||||
self.SourceOverrideDir = None
|
||||
# use overrided path defined in DSC file
|
||||
if self.MetaFile.Key in GlobalData.gOverrideDir:
|
||||
@ -2284,6 +2345,16 @@ class ModuleAutoGen(AutoGen):
|
||||
|
||||
## Return the module meta-file GUID
|
||||
def _GetGuid(self):
|
||||
#
|
||||
# To build same module more than once, the module path with FILE_GUID overridden has
|
||||
# the file name FILE_GUIDmodule.inf, but the relative path (self.MetaFile.File) is the realy path
|
||||
# in DSC. The overridden GUID can be retrieved from file name
|
||||
#
|
||||
if os.path.basename(self.MetaFile.File) != os.path.basename(self.MetaFile.Path):
|
||||
#
|
||||
# Length of GUID is 36
|
||||
#
|
||||
return os.path.basename(self.MetaFile.Path)[:36]
|
||||
return self.Module.Guid
|
||||
|
||||
## Return the module version
|
||||
@ -2393,7 +2464,66 @@ class ModuleAutoGen(AutoGen):
|
||||
continue
|
||||
PackageList.append(Package)
|
||||
return PackageList
|
||||
|
||||
|
||||
## Get the depex string
|
||||
#
|
||||
# @return : a string contain all depex expresion.
|
||||
def _GetDepexExpresionString(self):
|
||||
DepexStr = ''
|
||||
DepexList = []
|
||||
## DPX_SOURCE IN Define section.
|
||||
if self.Module.DxsFile:
|
||||
return DepexStr
|
||||
for M in [self.Module] + self.DependentLibraryList:
|
||||
Filename = M.MetaFile.Path
|
||||
InfObj = InfSectionParser.InfSectionParser(Filename)
|
||||
DepexExpresionList = InfObj.GetDepexExpresionList()
|
||||
for DepexExpresion in DepexExpresionList:
|
||||
for key in DepexExpresion.keys():
|
||||
Arch, ModuleType = key
|
||||
# the type of build module is USER_DEFINED.
|
||||
# All different DEPEX section tags would be copied into the As Built INF file
|
||||
# and there would be separate DEPEX section tags
|
||||
if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:
|
||||
if (Arch.upper() == self.Arch.upper()) and (ModuleType.upper() != TAB_ARCH_COMMON):
|
||||
DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})
|
||||
else:
|
||||
if Arch.upper() == TAB_ARCH_COMMON or \
|
||||
(Arch.upper() == self.Arch.upper() and \
|
||||
ModuleType.upper() in [TAB_ARCH_COMMON, self.ModuleType.upper()]):
|
||||
DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})
|
||||
|
||||
#the type of build module is USER_DEFINED.
|
||||
if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:
|
||||
for Depex in DepexList:
|
||||
for key in Depex.keys():
|
||||
DepexStr += '[Depex.%s.%s]\n' % key
|
||||
DepexStr += '\n'.join(['# '+ val for val in Depex[key]])
|
||||
DepexStr += '\n\n'
|
||||
if not DepexStr:
|
||||
return '[Depex.%s]\n' % self.Arch
|
||||
return DepexStr
|
||||
|
||||
#the type of build module not is USER_DEFINED.
|
||||
Count = 0
|
||||
for Depex in DepexList:
|
||||
Count += 1
|
||||
if DepexStr != '':
|
||||
DepexStr += ' AND '
|
||||
DepexStr += '('
|
||||
for D in Depex.values():
|
||||
DepexStr += ' '.join([val for val in D])
|
||||
Index = DepexStr.find('END')
|
||||
if Index > -1 and Index == len(DepexStr) - 3:
|
||||
DepexStr = DepexStr[:-3]
|
||||
DepexStr = DepexStr.strip()
|
||||
DepexStr += ')'
|
||||
if Count == 1:
|
||||
DepexStr = DepexStr.lstrip('(').rstrip(')').strip()
|
||||
if not DepexStr:
|
||||
return '[Depex.%s]\n' % self.Arch
|
||||
return '[Depex.%s]\n# ' % self.Arch + DepexStr
|
||||
|
||||
## Merge dependency expression
|
||||
#
|
||||
# @retval list The token list of the dependency expression after parsed
|
||||
@ -2546,7 +2676,7 @@ class ModuleAutoGen(AutoGen):
|
||||
## Return a list of files which can be built from source
|
||||
#
|
||||
# What kind of files can be built is determined by build rules in
|
||||
# $(WORKSPACE)/Conf/build_rule.txt and toolchain family.
|
||||
# $(CONF_DIRECTORY)/build_rule.txt and toolchain family.
|
||||
#
|
||||
def _GetSourceFileList(self):
|
||||
if self._SourceFileList == None:
|
||||
@ -2901,6 +3031,71 @@ class ModuleAutoGen(AutoGen):
|
||||
self._IncludePathList.append(str(Inc))
|
||||
return self._IncludePathList
|
||||
|
||||
## Get HII EX PCDs which maybe used by VFR
|
||||
#
|
||||
# efivarstore used by VFR may relate with HII EX PCDs
|
||||
# Get the variable name and GUID from efivarstore and HII EX PCD
|
||||
# List the HII EX PCDs in As Built INF if both name and GUID match.
|
||||
#
|
||||
# @retval list HII EX PCDs
|
||||
#
|
||||
def _GetPcdsMaybeUsedByVfr(self):
|
||||
if not self.SourceFileList:
|
||||
return []
|
||||
|
||||
NameGuids = []
|
||||
for SrcFile in self.SourceFileList:
|
||||
if SrcFile.Ext.lower() != '.vfr':
|
||||
continue
|
||||
Vfri = os.path.join(self.OutputDir, SrcFile.BaseName + '.i')
|
||||
if not os.path.exists(Vfri):
|
||||
continue
|
||||
VfriFile = open(Vfri, 'r')
|
||||
Content = VfriFile.read()
|
||||
VfriFile.close()
|
||||
Pos = Content.find('efivarstore')
|
||||
while Pos != -1:
|
||||
#
|
||||
# Make sure 'efivarstore' is the start of efivarstore statement
|
||||
# In case of the value of 'name' (name = efivarstore) is equal to 'efivarstore'
|
||||
#
|
||||
Index = Pos - 1
|
||||
while Index >= 0 and Content[Index] in ' \t\r\n':
|
||||
Index -= 1
|
||||
if Index >= 0 and Content[Index] != ';':
|
||||
Pos = Content.find('efivarstore', Pos + len('efivarstore'))
|
||||
continue
|
||||
#
|
||||
# 'efivarstore' must be followed by name and guid
|
||||
#
|
||||
Name = gEfiVarStoreNamePattern.search(Content, Pos)
|
||||
if not Name:
|
||||
break
|
||||
Guid = gEfiVarStoreGuidPattern.search(Content, Pos)
|
||||
if not Guid:
|
||||
break
|
||||
NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')
|
||||
NameGuids.append((NameArray, GuidStructureStringToGuidString(Guid.group(1))))
|
||||
Pos = Content.find('efivarstore', Name.end())
|
||||
if not NameGuids:
|
||||
return []
|
||||
HiiExPcds = []
|
||||
for Pcd in self.PlatformInfo.Platform.Pcds.values():
|
||||
if Pcd.Type != TAB_PCDS_DYNAMIC_EX_HII:
|
||||
continue
|
||||
for SkuName in Pcd.SkuInfoList:
|
||||
SkuInfo = Pcd.SkuInfoList[SkuName]
|
||||
Name = ConvertStringToByteArray(SkuInfo.VariableName)
|
||||
Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList)
|
||||
if not Value:
|
||||
continue
|
||||
Guid = GuidStructureStringToGuidString(Value)
|
||||
if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:
|
||||
HiiExPcds.append(Pcd)
|
||||
break
|
||||
|
||||
return HiiExPcds
|
||||
|
||||
## Create AsBuilt INF file the module
|
||||
#
|
||||
def CreateAsBuiltInf(self):
|
||||
@ -2963,6 +3158,16 @@ class ModuleAutoGen(AutoGen):
|
||||
break
|
||||
if Found: break
|
||||
|
||||
VfrPcds = self._GetPcdsMaybeUsedByVfr()
|
||||
for Pkg in self.PlatformInfo.PackageList:
|
||||
if Pkg in Packages:
|
||||
continue
|
||||
for VfrPcd in VfrPcds:
|
||||
if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'DynamicEx') in Pkg.Pcds or
|
||||
(VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'Dynamic') in Pkg.Pcds):
|
||||
Packages += [Pkg]
|
||||
break
|
||||
|
||||
ModuleType = self.ModuleType
|
||||
if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:
|
||||
ModuleType = 'DXE_DRIVER'
|
||||
@ -2971,14 +3176,30 @@ class ModuleAutoGen(AutoGen):
|
||||
if self.PcdIsDriver != '':
|
||||
DriverType = self.PcdIsDriver
|
||||
|
||||
Guid = self.Guid
|
||||
MDefs = self.Module.Defines
|
||||
|
||||
AsBuiltInfDict = {
|
||||
'module_name' : self.Name,
|
||||
'module_guid' : self.Guid,
|
||||
'module_guid' : Guid,
|
||||
'module_module_type' : ModuleType,
|
||||
'module_version_string' : self.Version,
|
||||
'module_version_string' : [MDefs['VERSION_STRING']] if 'VERSION_STRING' in MDefs else [],
|
||||
'pcd_is_driver_string' : [],
|
||||
'module_uefi_specification_version' : [],
|
||||
'module_pi_specification_version' : [],
|
||||
'module_entry_point' : self.Module.ModuleEntryPointList,
|
||||
'module_unload_image' : self.Module.ModuleUnloadImageList,
|
||||
'module_constructor' : self.Module.ConstructorList,
|
||||
'module_destructor' : self.Module.DestructorList,
|
||||
'module_shadow' : [MDefs['SHADOW']] if 'SHADOW' in MDefs else [],
|
||||
'module_pci_vendor_id' : [MDefs['PCI_VENDOR_ID']] if 'PCI_VENDOR_ID' in MDefs else [],
|
||||
'module_pci_device_id' : [MDefs['PCI_DEVICE_ID']] if 'PCI_DEVICE_ID' in MDefs else [],
|
||||
'module_pci_class_code' : [MDefs['PCI_CLASS_CODE']] if 'PCI_CLASS_CODE' in MDefs else [],
|
||||
'module_pci_revision' : [MDefs['PCI_REVISION']] if 'PCI_REVISION' in MDefs else [],
|
||||
'module_build_number' : [MDefs['BUILD_NUMBER']] if 'BUILD_NUMBER' in MDefs else [],
|
||||
'module_spec' : [MDefs['SPEC']] if 'SPEC' in MDefs else [],
|
||||
'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [],
|
||||
'module_uni_file' : [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs else [],
|
||||
'module_arch' : self.Arch,
|
||||
'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],
|
||||
'binary_item' : [],
|
||||
@ -2990,7 +3211,12 @@ class ModuleAutoGen(AutoGen):
|
||||
'flags_item' : [],
|
||||
'libraryclasses_item' : []
|
||||
}
|
||||
AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion
|
||||
|
||||
if self.AutoGenVersion > int(gInfSpecVersion, 0):
|
||||
AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion
|
||||
else:
|
||||
AsBuiltInfDict['module_inf_version'] = gInfSpecVersion
|
||||
|
||||
if DriverType:
|
||||
AsBuiltInfDict['pcd_is_driver_string'] += [DriverType]
|
||||
|
||||
@ -3036,6 +3262,8 @@ class ModuleAutoGen(AutoGen):
|
||||
StartPos = Index
|
||||
break
|
||||
AsBuiltInfDict['header_comments'] = '\n'.join(HeaderComments[StartPos:]).replace(':#', '://')
|
||||
AsBuiltInfDict['tail_comments'] = '\n'.join(self.Module.TailComments)
|
||||
|
||||
GenList = [
|
||||
(self.ProtocolList, self._ProtocolComments, 'protocol_item'),
|
||||
(self.PpiList, self._PpiComments, 'ppi_item'),
|
||||
@ -3116,28 +3344,42 @@ class ModuleAutoGen(AutoGen):
|
||||
if PcdComments:
|
||||
PcdItem = PcdComments + '\n ' + PcdItem
|
||||
AsBuiltInfDict['patchablepcd_item'].append(PcdItem)
|
||||
for Pcd in Pcds:
|
||||
|
||||
HiiPcds = []
|
||||
for Pcd in Pcds + VfrPcds:
|
||||
PcdComments = ''
|
||||
PcdCommentList = []
|
||||
HiiInfo = ''
|
||||
SkuId = ''
|
||||
if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:
|
||||
for SkuName in Pcd.SkuInfoList:
|
||||
SkuInfo = Pcd.SkuInfoList[SkuName]
|
||||
SkuId = SkuInfo.SkuId
|
||||
HiiInfo = '## %s|%s|%s' % (SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInfo.VariableOffset)
|
||||
break
|
||||
if SkuId:
|
||||
#
|
||||
# Don't generate duplicated HII PCD
|
||||
#
|
||||
if (SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in HiiPcds:
|
||||
continue
|
||||
else:
|
||||
HiiPcds.append((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
|
||||
if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:
|
||||
PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]
|
||||
if HiiInfo:
|
||||
UsageIndex = -1
|
||||
UsageStr = ''
|
||||
for Index, Comment in enumerate(PcdCommentList):
|
||||
for Usage in UsageList:
|
||||
if Comment.find(Usage) != -1:
|
||||
UsageStr = Usage
|
||||
UsageIndex = Index
|
||||
break
|
||||
if UsageIndex != -1:
|
||||
PcdCommentList[UsageIndex] = PcdCommentList[UsageIndex] + ' ' + HiiInfo
|
||||
PcdCommentList[UsageIndex] = '## %s %s %s' % (UsageStr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, ''))
|
||||
else:
|
||||
PcdCommentList.append('## ' + HiiInfo)
|
||||
PcdCommentList.append('## UNDEFINED ' + HiiInfo)
|
||||
PcdComments = '\n '.join(PcdCommentList)
|
||||
PcdEntry = Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName
|
||||
if PcdComments:
|
||||
@ -3146,6 +3388,16 @@ class ModuleAutoGen(AutoGen):
|
||||
for Item in self.BuildOption:
|
||||
if 'FLAGS' in self.BuildOption[Item]:
|
||||
AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]
|
||||
|
||||
# Generated LibraryClasses section in comments.
|
||||
for Library in self.LibraryAutoGenList:
|
||||
AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\', '/')]
|
||||
|
||||
# Generated depex expression section in comments.
|
||||
AsBuiltInfDict['depexsection_item'] = ''
|
||||
DepexExpresion = self._GetDepexExpresionString()
|
||||
if DepexExpresion:
|
||||
AsBuiltInfDict['depexsection_item'] = DepexExpresion
|
||||
|
||||
AsBuiltInf = TemplateString()
|
||||
AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))
|
||||
|
@ -247,6 +247,7 @@ MODULE_FILE = ${module_file}
|
||||
MODULE_FILE_BASE_NAME = ${module_file_base_name}
|
||||
BASE_NAME = $(MODULE_NAME)
|
||||
MODULE_RELATIVE_DIR = ${module_relative_directory}
|
||||
PACKAGE_RELATIVE_DIR = ${package_relative_directory}
|
||||
MODULE_DIR = $(WORKSPACE)${separator}${module_relative_directory}
|
||||
|
||||
MODULE_ENTRY_POINT = ${module_entry_point}
|
||||
@ -552,6 +553,10 @@ cleanlib:
|
||||
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join(D, MakefileName)}
|
||||
LibraryMakeCommandList.append(Command)
|
||||
|
||||
package_rel_dir = self._AutoGenObject.SourceDir
|
||||
if os.sep in package_rel_dir:
|
||||
package_rel_dir = package_rel_dir[package_rel_dir.index(os.sep) + 1:]
|
||||
|
||||
MakefileTemplateDict = {
|
||||
"makefile_header" : self._FILE_HEADER_[self._FileType],
|
||||
"makefile_path" : os.path.join("$(MODULE_BUILD_DIR)", MakefileName),
|
||||
@ -569,7 +574,8 @@ cleanlib:
|
||||
"module_file" : self._AutoGenObject.MetaFile.Name,
|
||||
"module_file_base_name" : self._AutoGenObject.MetaFile.BaseName,
|
||||
"module_relative_directory" : self._AutoGenObject.SourceDir,
|
||||
"module_extra_defines" : ["%s = %s" % (k, v) for k,v in self._AutoGenObject.Module.Defines.iteritems()],
|
||||
"package_relative_directory": package_rel_dir,
|
||||
"module_extra_defines" : ["%s = %s" % (k, v) for k, v in self._AutoGenObject.Module.Defines.iteritems()],
|
||||
|
||||
"architecture" : self._AutoGenObject.Arch,
|
||||
"toolchain_tag" : self._AutoGenObject.ToolChain,
|
||||
@ -1177,7 +1183,8 @@ cleanlib:
|
||||
def GetModuleBuildDirectoryList(self):
|
||||
DirList = []
|
||||
for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
|
||||
if not ModuleAutoGen.IsBinaryModule:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
|
||||
return DirList
|
||||
|
||||
## Get the root directory list for intermediate files of all libraries build
|
||||
@ -1187,7 +1194,8 @@ cleanlib:
|
||||
def GetLibraryBuildDirectoryList(self):
|
||||
DirList = []
|
||||
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
|
||||
if not LibraryAutoGen.IsBinaryModule:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
|
||||
return DirList
|
||||
|
||||
_TemplateDict = property(_CreateTemplateDict)
|
||||
@ -1200,7 +1208,7 @@ cleanlib:
|
||||
#
|
||||
class TopLevelMakefile(BuildFile):
|
||||
## template used to generate toplevel makefile
|
||||
_TEMPLATE_ = TemplateString('''${BEGIN}\tGenFds -f ${fdf_file} -o ${platform_build_directory} -t ${toolchain_tag} -b ${build_target} -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}''')
|
||||
_TEMPLATE_ = TemplateString('''${BEGIN}\tGenFds -f ${fdf_file} --conf=${conf_directory} -o ${platform_build_directory} -t ${toolchain_tag} -b ${build_target} -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}''')
|
||||
|
||||
## Constructor of TopLevelMakefile
|
||||
#
|
||||
@ -1258,6 +1266,9 @@ class TopLevelMakefile(BuildFile):
|
||||
if GlobalData.gCaseInsensitive:
|
||||
ExtraOption += " -c"
|
||||
|
||||
if GlobalData.gIgnoreSource:
|
||||
ExtraOption += " --ignore-sources"
|
||||
|
||||
MakefileName = self._FILE_NAME_[self._FileType]
|
||||
SubBuildCommandList = []
|
||||
for A in PlatformInfo.ArchList:
|
||||
@ -1272,6 +1283,7 @@ class TopLevelMakefile(BuildFile):
|
||||
"platform_guid" : PlatformInfo.Guid,
|
||||
"platform_version" : PlatformInfo.Version,
|
||||
"platform_build_directory" : PlatformInfo.BuildDir,
|
||||
"conf_directory" : GlobalData.gConfDirectory,
|
||||
|
||||
"toolchain_tag" : PlatformInfo.ToolChain,
|
||||
"build_target" : PlatformInfo.BuildTarget,
|
||||
@ -1301,7 +1313,8 @@ class TopLevelMakefile(BuildFile):
|
||||
def GetModuleBuildDirectoryList(self):
|
||||
DirList = []
|
||||
for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
|
||||
if not ModuleAutoGen.IsBinaryModule:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
|
||||
return DirList
|
||||
|
||||
## Get the root directory list for intermediate files of all libraries build
|
||||
@ -1311,7 +1324,8 @@ class TopLevelMakefile(BuildFile):
|
||||
def GetLibraryBuildDirectoryList(self):
|
||||
DirList = []
|
||||
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
|
||||
if not LibraryAutoGen.IsBinaryModule:
|
||||
DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
|
||||
return DirList
|
||||
|
||||
_TemplateDict = property(_CreateTemplateDict)
|
||||
|
107
BaseTools/Source/Python/AutoGen/InfSectionParser.py
Normal file
107
BaseTools/Source/Python/AutoGen/InfSectionParser.py
Normal file
@ -0,0 +1,107 @@
|
||||
## @file
|
||||
# Parser a Inf file and Get specify section data.
|
||||
#
|
||||
# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
## Import Modules
|
||||
#
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from Common.DataType import *
|
||||
|
||||
|
||||
class InfSectionParser():
|
||||
def __init__(self, FilePath):
|
||||
self._FilePath = FilePath
|
||||
self._FileSectionDataList = []
|
||||
self._ParserInf()
|
||||
|
||||
def _ParserInf(self):
|
||||
Filename = self._FilePath
|
||||
FileLinesList = []
|
||||
UserExtFind = False
|
||||
FindEnd = True
|
||||
FileLastLine = False
|
||||
SectionLine = ''
|
||||
SectionData = []
|
||||
|
||||
try:
|
||||
FileLinesList = open(Filename, "r", 0).readlines()
|
||||
except BaseException:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % Filename)
|
||||
|
||||
for Index in range(0, len(FileLinesList)):
|
||||
line = str(FileLinesList[Index]).strip()
|
||||
if Index + 1 == len(FileLinesList):
|
||||
FileLastLine = True
|
||||
NextLine = ''
|
||||
else:
|
||||
NextLine = str(FileLinesList[Index + 1]).strip()
|
||||
if UserExtFind and FindEnd == False:
|
||||
if line:
|
||||
SectionData.append(line)
|
||||
if line.lower().startswith(TAB_SECTION_START) and line.lower().endswith(TAB_SECTION_END):
|
||||
SectionLine = line
|
||||
UserExtFind = True
|
||||
FindEnd = False
|
||||
|
||||
if (NextLine != '' and NextLine[0] == TAB_SECTION_START and \
|
||||
NextLine[-1] == TAB_SECTION_END) or FileLastLine:
|
||||
UserExtFind = False
|
||||
FindEnd = True
|
||||
self._FileSectionDataList.append({SectionLine: SectionData[:]})
|
||||
SectionData = []
|
||||
SectionLine = ''
|
||||
|
||||
|
||||
# Get depex expresion
|
||||
#
|
||||
# @return: a list include some dictionary that key is section and value is a list contain all data.
|
||||
def GetDepexExpresionList(self):
|
||||
DepexExpresionList = []
|
||||
if not self._FileSectionDataList:
|
||||
return DepexExpresionList
|
||||
for SectionDataDict in self._FileSectionDataList:
|
||||
for key in SectionDataDict.keys():
|
||||
if key.lower() == "[depex]" or key.lower().startswith("[depex."):
|
||||
SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
|
||||
SubSectionList = [SectionLine]
|
||||
if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
|
||||
SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)
|
||||
for SubSection in SubSectionList:
|
||||
SectionList = SubSection.split(TAB_SPLIT)
|
||||
SubKey = ()
|
||||
if len(SectionList) == 1:
|
||||
SubKey = (TAB_ARCH_COMMON, TAB_ARCH_COMMON)
|
||||
elif len(SectionList) == 2:
|
||||
SubKey = (SectionList[1], TAB_ARCH_COMMON)
|
||||
elif len(SectionList) == 3:
|
||||
SubKey = (SectionList[1], SectionList[2])
|
||||
else:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR, 'Section %s is invalid.' % key)
|
||||
DepexExpresionList.append({SubKey: SectionDataDict[key]})
|
||||
return DepexExpresionList
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
## @file
|
||||
# This file is used to parse a strings file and create or add to a string database
|
||||
# file.
|
||||
#
|
||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
@ -7,10 +11,6 @@
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#
|
||||
#This file is used to parse a strings file and create or add to a string database file.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
|
@ -1,3 +1,6 @@
|
||||
## @file
|
||||
# This file is used to collect all defined strings in multiple uni files
|
||||
#
|
||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
@ -7,10 +10,6 @@
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#
|
||||
#This file is used to collect all defined strings in multiple uni files
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
|
Reference in New Issue
Block a user