From 97fa0ee9b1cffbb4b97ee35365afa7afcf50e174 Mon Sep 17 00:00:00 2001 From: Yingke Liu Date: Thu, 28 Aug 2014 13:53:34 +0000 Subject: License header updated to match correct format. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yingke Liu Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15971 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 334 +++++++++++++++++++++++++---- 1 file changed, 293 insertions(+), 41 deletions(-) (limited to 'BaseTools/Source/Python/AutoGen/AutoGen.py') diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 8c62ac8e72..8cd387072e 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -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} - -[Packages]${BEGIN} + 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.${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)) -- cgit v1.2.3