def _GenSources(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_SOURCES) # # Get all SourceFiles # SourceObj = self.Parser.InfSourcesSection.Sources DataList = SourceObj.keys() # # Go through each arch # SourceList = [] for Key in DataList: SourceData = SourceObj[Key] for Item in SourceData: SourceFile = Item.GetSourceFileName() Family = Item.GetFamily() FeatureFlag = Item.GetFeatureFlagExp() SupArchList = ConvertArchList(Item.GetSupArchList()) SupArchList.sort() Source = SourceFileObject() Source.SetSourceFile(SourceFile) Source.SetFamily(Family) Source.SetFeatureFlag(FeatureFlag) Source.SetSupArchList(SupArchList) SourceList.append(Source) self.SetSourceFileList(self.GetSourceFileList() + SourceList)
def _GenPackages(self, Skip): Logger.Debug(2, "Generate %s ..." % DT.TAB_PACKAGES) # # Get all Packages # PackageObj = self.Parser.InfPackageSection.Packages # # Go through each arch # for PackageItemObj in PackageObj: # # Need package information for dependency check usage # PackageDependency = PackageDependencyObject() PackageDependency.SetPackageFilePath(NormPath(PackageItemObj.GetPackageName())) PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList())) PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp()) PkgInfo = GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackageName()))) if PkgInfo[1] and PkgInfo[2]: PackageDependency.SetGuid(PkgInfo[1]) PackageDependency.SetVersion(PkgInfo[2]) elif Skip: continue else: Logger.Error("\nUPT", PARSER_ERROR, ST.ERR_INF_GET_PKG_DEPENDENCY_FAIL % PackageItemObj.GetPackageName(), File=self.FullPath) PackageDependencyList = self.GetPackageDependencyList() PackageDependencyList.append(PackageDependency) self.SetPackageDependencyList(PackageDependencyList)
def _GenPcds(self): if not GlobalData.gIS_BINARY_INF: Logger.Debug(2, "Generate %s ..." % DT.TAB_PCDS) # # Get all Pcds # PcdObj = self.Parser.InfPcdSection.Pcds KeysList = PcdObj.keys() # # Go through each arch # for (PcdType, PcdKey) in KeysList: PcdData = PcdObj[PcdType, PcdKey] for PcdItemObj in PcdData: CommentList = PcdItemObj.GetHelpStringList() if CommentList: for CommentItem in CommentList: Pcd = CommonObject.PcdObject() Pcd.SetCName(PcdItemObj.GetCName()) Pcd.SetTokenSpaceGuidCName(PcdItemObj.GetTokenSpaceGuidCName()) Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue()) Pcd.SetItemType(PcdType) Pcd.SetValidUsage(CommentItem.GetUsageItem()) Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp()) Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList())) HelpTextObj = CommonObject.TextObject() if self.UniFileClassObject: HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X) HelpTextObj.SetString(CommentItem.GetHelpStringItem()) Pcd.SetHelpTextList([HelpTextObj]) PcdList = self.GetPcdList() PcdList.append(Pcd) self.SetPcdList(PcdList)
def InsertSectionItems(Model, SectionItemList, ArchList, \ ThirdList, RecordSet): # # Insert each item data of a section # for Index in range(0, len(ArchList)): Arch = ArchList[Index] Third = ThirdList[Index] if Arch == '': Arch = DataType.TAB_ARCH_COMMON Records = RecordSet[Model] for SectionItem in SectionItemList: LineValue, StartLine, Comment = SectionItem[0], \ SectionItem[1], SectionItem[2] Logger.Debug(4, ST.MSG_PARSING % LineValue) # # And then parse DEFINE statement # if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1: continue # # At last parse other sections # IdNum = -1 Records.append([LineValue, Arch, StartLine, IdNum, Third, Comment]) if RecordSet != {}: RecordSet[Model] = Records
def _GenBuildOptions(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_BUILD_OPTIONS) # # Get all BuildOptions # BuildOptionsList = self.Parser.InfBuildOptionSection.GetBuildOptions() if not GlobalData.gIS_BINARY_INF: BuildOptionDict = {} for BuildOptionObj in BuildOptionsList: ArchList = BuildOptionObj.GetSupArchList() ArchList = ConvertArchList(ArchList) BuildOptionsContent = BuildOptionObj.GetContent() ArchString = ' '.join(ArchList) if not BuildOptionsContent: continue BuildOptionDict[ArchString] = BuildOptionsContent if not BuildOptionDict: return UserExtension = CommonObject.UserExtensionObject() UserExtension.SetBuildOptionDict(BuildOptionDict) UserExtension.SetIdentifier('BuildOptionModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) else: # # Not process this information, will be processed in GenBinaries() # pass
def _GenLibraryClasses(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_LIBRARY_CLASSES) if not GlobalData.gIS_BINARY_INF: # # Get all LibraryClasses # LibClassObj = self.Parser.InfLibraryClassSection.LibraryClasses Keys = LibClassObj.keys() for Key in Keys: LibraryClassData = LibClassObj[Key] for Item in LibraryClassData: LibraryClass = CommonObject.LibraryClassObject() LibraryClass.SetUsage(DT.USAGE_ITEM_CONSUMES) LibraryClass.SetLibraryClass(Item.GetLibName()) LibraryClass.SetRecommendedInstance(None) LibraryClass.SetFeatureFlag(Item.GetFeatureFlagExp()) LibraryClass.SetSupArchList( ConvertArchList(Item.GetSupArchList())) LibraryClass.SetSupModuleList(Item.GetSupModuleList()) HelpStringObj = Item.GetHelpString() if HelpStringObj != None: CommentString = GetHelpStringByRemoveHashKey( HelpStringObj.HeaderComments + HelpStringObj.TailComments) HelpTextHeaderObj = CommonObject.TextObject() HelpTextHeaderObj.SetString(CommentString) LibraryClass.SetHelpTextList([HelpTextHeaderObj]) self.SetLibraryClassList(self.GetLibraryClassList() + [LibraryClass])
def GenPcds(self, ContainerFile): Logger.Debug(2, "Generate %s ..." % TAB_PCDS) PcdObj = self.DecParser.GetPcdSectionObject() # # Get all Pcds # PcdDeclarations = [] IterList = [(TAB_PCDS_FIXED_AT_BUILD_NULL, 'FixedPcd'), (TAB_PCDS_PATCHABLE_IN_MODULE_NULL, 'PatchPcd'), (TAB_PCDS_FEATURE_FLAG_NULL, 'FeaturePcd'), (TAB_PCDS_DYNAMIC_EX_NULL, 'PcdEx'), (TAB_PCDS_DYNAMIC_NULL, 'Pcd')] # # For each PCD type # for PcdType, Type in IterList: # # Go through all archs # # for Arch in self.SupArchList + [TAB_ARCH_COMMON]: # for Item in PcdObj.GetPcdsByType(PcdType.upper()): PcdDeclaration = GenPcdDeclaration( ContainerFile, (Item.TokenSpaceGuidCName, Item.TokenCName, Item.DefaultValue, Item.DatumType, Item.TokenValue, Type, Item.GetHeadComment(), Item.GetTailComment(), '')) PcdDeclaration.SetSupArchList(Item.GetArchListOfType(PcdType)) PcdDeclarations.append(PcdDeclaration) self.SetPcdList(self.GetPcdList() + PcdDeclarations)
def GetCurrentFileList(DataBase, Guid, Version, WorkspaceDir): NewFileList = [] for Dir in DataBase.GetDpInstallDirList(Guid, Version): RootDir = os.path.normpath(os.path.join(WorkspaceDir, Dir)) for Root, Dirs, Files in os.walk(RootDir): Logger.Debug(0, Dirs) for File in Files: FilePath = os.path.join(Root, File) if FilePath not in NewFileList: NewFileList.append(FilePath) return NewFileList
def ParseDefine(LineValue, StartLine, Table, FileID, SectionName, \ SectionModel, Arch): Logger.Debug(Logger.DEBUG_2, ST.MSG_DEFINE_STATEMENT_FOUND % (LineValue, \ SectionName)) Define = \ GetSplitValueList(CleanString\ (LineValue[LineValue.upper().\ find(DataType.TAB_DEFINE.upper() + ' ') + \ len(DataType.TAB_DEFINE + ' ') : ]), \ DataType.TAB_EQUAL_SPLIT, 1) Table.Insert(DataType.MODEL_META_DATA_DEFINE, Define[0], Define[1], '', \ '', '', Arch, SectionModel, FileID, StartLine, -1, \ StartLine, -1, 0)
def GenPackageHeader(self, ContainerFile): Logger.Debug(2, "Generate PackageHeader ...") DefinesDict = {} # # Update all defines item in database # DefObj = self.DecParser.GetDefineSectionObject() for Item in DefObj.GetDefines(): # # put items into Dict except for PackageName, Guid, Version, DEC_SPECIFICATION # SkipItemList = [TAB_DEC_DEFINES_PACKAGE_NAME, \ TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_PACKAGE_VERSION, TAB_DEC_DEFINES_DEC_SPECIFICATION] if Item.Key in SkipItemList: continue DefinesDict['%s = %s' % (Item.Key, Item.Value)] = TAB_ARCH_COMMON self.SetBaseName(DefObj.GetPackageName()) self.SetVersion(DefObj.GetPackageVersion()) # self.SetName(DefObj.GetPackageName() + ' Version ' + \ # DefObj.GetPackageVersion()) self.SetName(os.path.splitext(self.GetFileName())[0]) self.SetGuid(DefObj.GetPackageGuid()) if DefinesDict: UserExtension = UserExtensionObject() UserExtension.SetDefinesDict(DefinesDict) UserExtension.SetIdentifier('DefineModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) # # Get All header comment section information # Abstract, Description, Copyright, License = \ ParseHeaderCommentSection(self.DecParser.GetHeadComment(), ContainerFile) self.SetAbstract(Abstract) self.SetDescription(Description) self.SetCopyright(Copyright) self.SetLicense(License)
def GenLibraryClasses(self, ContainerFile): if ContainerFile: pass Logger.Debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) LibraryClassDeclarations = [] LibObj = self.DecParser.GetLibraryClassSectionObject() for Item in LibObj.GetAllLibraryclasses(): LibraryClass = LibraryClassObject() LibraryClass.SetLibraryClass(Item.Libraryclass) LibraryClass.SetSupArchList(Item.GetArchList()) LibraryClass.SetIncludeHeader(Item.File) HelpTxt = ParseGenericComment(Item.GetHeadComment() + \ Item.GetTailComment(), None, '@libraryclass') if HelpTxt: LibraryClass.SetHelpTextList([HelpTxt]) LibraryClassDeclarations.append(LibraryClass) self.SetLibraryClassList(self.GetLibraryClassList() + \ LibraryClassDeclarations)
def GenPackageHeader(self, ContainerFile): Logger.Debug(2, "Generate PackageHeader ...") DefinesDict = {} # # Update all defines item in database # DefObj = self.DecParser.GetDefineSectionObject() for Item in DefObj.GetDefines(): # # put items into Dict except for PackageName, Guid, Version, DEC_SPECIFICATION # SkipItemList = [TAB_DEC_DEFINES_PACKAGE_NAME, \ TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_PACKAGE_VERSION, \ TAB_DEC_DEFINES_DEC_SPECIFICATION, TAB_DEC_DEFINES_PKG_UNI_FILE] if Item.Key in SkipItemList: continue DefinesDict['%s = %s' % (Item.Key, Item.Value)] = TAB_ARCH_COMMON self.SetBaseName(DefObj.GetPackageName()) self.SetVersion(DefObj.GetPackageVersion()) # self.SetName(DefObj.GetPackageName() + ' Version ' + \ # DefObj.GetPackageVersion()) self.SetName(os.path.splitext(self.GetFileName())[0]) self.SetGuid(DefObj.GetPackageGuid()) if DefObj.GetPackageUniFile(): ValidateUNIFilePath(DefObj.GetPackageUniFile()) self.UniFileClassObject = \ UniFileClassObject([PathClass(os.path.join(DefObj.GetPackagePath(), DefObj.GetPackageUniFile()))]) else: self.UniFileClassObject = None if DefinesDict: UserExtension = UserExtensionObject() UserExtension.SetDefinesDict(DefinesDict) UserExtension.SetIdentifier('DefineModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList( self.GetUserExtensionList() + [UserExtension] ) # # Get File header information # if self.UniFileClassObject: Lang = TAB_LANGUAGE_EN_X else: Lang = TAB_LANGUAGE_EN_US Abstract, Description, Copyright, License = \ ParseHeaderCommentSection(self.DecParser.GetHeadComment(), ContainerFile) if Abstract: self.SetAbstract((Lang, Abstract)) if Description: self.SetDescription((Lang, Description)) if Copyright: self.SetCopyright(('', Copyright)) if License: self.SetLicense(('', License)) # # Get Binary header information # if self.DecParser.BinaryHeadComment: Abstract, Description, Copyright, License = \ ParseHeaderCommentSection(self.DecParser.BinaryHeadComment, ContainerFile, True) if not Abstract or not Description or not Copyright or not License: Logger.Error('MkPkg', FORMAT_INVALID, ST.ERR_INVALID_BINARYHEADER_FORMAT, ContainerFile) else: self.SetBinaryHeaderAbstract((Lang, Abstract)) self.SetBinaryHeaderDescription((Lang, Description)) self.SetBinaryHeaderCopyright(('', Copyright)) self.SetBinaryHeaderLicense(('', License)) BinaryAbstractList = [] BinaryDescriptionList = [] #Get Binary header from UNI file # Initialize the UniStrDict dictionary, top keys are language codes UniStrDict = {} if self.UniFileClassObject: UniStrDict = self.UniFileClassObject.OrderedStringList for Lang in UniStrDict: for StringDefClassObject in UniStrDict[Lang]: Lang = GetLanguageCode1766(Lang) if StringDefClassObject.StringName == TAB_DEC_BINARY_ABSTRACT: if (Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)) \ not in self.GetBinaryHeaderAbstract(): BinaryAbstractList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue))) if StringDefClassObject.StringName == TAB_DEC_BINARY_DESCRIPTION: if (Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)) \ not in self.GetBinaryHeaderDescription(): BinaryDescriptionList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue))) #Combine Binary header from DEC file and UNI file BinaryAbstractList = self.GetBinaryHeaderAbstract() + BinaryAbstractList BinaryDescriptionList = self.GetBinaryHeaderDescription() + BinaryDescriptionList BinaryCopyrightList = self.GetBinaryHeaderCopyright() BinaryLicenseList = self.GetBinaryHeaderLicense() #Generate the UserExtensionObject for TianoCore."BinaryHeader" if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightList or BinaryLicenseList: BinaryUserExtension = UserExtensionObject() BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList) BinaryUserExtension.SetBinaryDescription(BinaryDescriptionList) BinaryUserExtension.SetBinaryCopyright(BinaryCopyrightList) BinaryUserExtension.SetBinaryLicense(BinaryLicenseList) BinaryUserExtension.SetIdentifier(TAB_BINARY_HEADER_IDENTIFIER) BinaryUserExtension.SetUserID(TAB_BINARY_HEADER_USERID) self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
def _GenInfDefineStateMent(HeaderComment, Name, Value, TailComment): Logger.Debug(5, HeaderComment + TailComment) Statement = '%s = %s' % (Name, Value) return Statement
def _GenGuidProtocolPpis(self, Type): Logger.Debug(2, "Generate %s ..." % Type) # # Get all Guid/Protocol/Ppis data # GuidObj = self.Parser.InfGuidSection.GetGuid() ProtocolObj = self.Parser.InfProtocolSection.GetProtocol() PpisObj = self.Parser.InfPpiSection.GetPpi() GuidProtocolPpiList = [] if Type == DT.TAB_GUIDS: GuidData = GuidObj.keys() for Item in GuidData: CommentList = Item.GetCommentList() # # Depend on CommentList content # generate muti-guid-obj # if CommentList: for GuidComentItem in CommentList: ListObject = CommonObject.GuidObject() ListObject.SetGuidTypeList( [GuidComentItem.GetGuidTypeItem()]) ListObject.SetVariableName( GuidComentItem.GetVariableNameItem()) ListObject.SetUsage(GuidComentItem.GetUsageItem()) ListObject.SetName(Item.GetName()) ListObject.SetCName(Item.GetName()) ListObject.SetSupArchList( ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) HelpString = GuidComentItem.GetHelpStringItem() HelpTxtTailObj = CommonObject.TextObject() HelpTxtTailObj.SetString(HelpString) ListObject.SetHelpTextList([HelpTxtTailObj]) GuidProtocolPpiList.append(ListObject) elif Type == DT.TAB_PROTOCOLS: ProtocolData = ProtocolObj.keys() for Item in ProtocolData: CommentList = Item.GetCommentList() for CommentItem in CommentList: ListObject = CommonObject.ProtocolObject() ListObject.SetCName(Item.GetName()) ListObject.SetSupArchList( ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) ListObject.SetNotify(CommentItem.GetNotify()) ListObject.SetUsage(CommentItem.GetUsageItem()) HelpTxtObj = CommonObject.TextObject() HelpString = CommentItem.GetHelpStringItem() HelpTxtObj.SetString(HelpString) ListObject.SetHelpTextList([HelpTxtObj]) GuidProtocolPpiList.append(ListObject) elif Type == DT.TAB_PPIS: PpiData = PpisObj.keys() for Item in PpiData: CommentList = Item.GetCommentList() for CommentItem in CommentList: ListObject = CommonObject.PpiObject() ListObject.SetCName(Item.GetName()) ListObject.SetSupArchList( ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) ListObject.SetNotify(CommentItem.GetNotify()) ListObject.SetUsage(CommentItem.GetUsage()) HelpTextObj = CommonObject.TextObject() HelpString = CommentItem.GetHelpStringItem() HelpTextObj.SetString(HelpString) ListObject.SetHelpTextList([HelpTextObj]) GuidProtocolPpiList.append(ListObject) if Type == DT.TAB_GUIDS: self.SetGuidList(self.GetGuidList() + GuidProtocolPpiList) elif Type == DT.TAB_PROTOCOLS: self.SetProtocolList(self.GetProtocolList() + GuidProtocolPpiList) elif Type == DT.TAB_PPIS: self.SetPpiList(self.GetPpiList() + GuidProtocolPpiList)
def GenPcds(self, ContainerFile): Logger.Debug(2, "Generate %s ..." % TAB_PCDS) PcdObj = self.DecParser.GetPcdSectionObject() # # Get all Pcds # PcdDeclarations = [] IterList = [ (TAB_PCDS_FIXED_AT_BUILD_NULL, 'FixedPcd'), (TAB_PCDS_PATCHABLE_IN_MODULE_NULL, 'PatchPcd'), (TAB_PCDS_FEATURE_FLAG_NULL, 'FeaturePcd'), (TAB_PCDS_DYNAMIC_EX_NULL, 'PcdEx'), (TAB_PCDS_DYNAMIC_NULL, 'Pcd')] PromptStrList = [] HelpStrList = [] PcdErrStrList = [] # Initialize UniStrDict dictionary, top keys are language codes UniStrDict = {} StrList = [] Language = '' if self.UniFileClassObject: Language = TAB_LANGUAGE_EN_X else: Language = TAB_LANGUAGE_EN_US if self.UniFileClassObject: UniStrDict = self.UniFileClassObject.OrderedStringList for Lang in UniStrDict: for StringDefClassObject in UniStrDict[Lang]: StrList = StringDefClassObject.StringName.split('_') # StringName format is STR_<TOKENSPACECNAME>_<PCDCNAME>_PROMPT if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[3] == TAB_STR_TOKENPROMPT: PromptStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \ StringDefClassObject.StringValue)) # StringName format is STR_<TOKENSPACECNAME>_<PCDCNAME>_HELP if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[3] == TAB_STR_TOKENHELP: HelpStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \ StringDefClassObject.StringValue)) # StringName format is STR_<TOKENSPACECNAME>_ERR_## if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[2] == TAB_STR_TOKENERR: PcdErrStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \ StringDefClassObject.StringValue)) # # For each PCD type # for PcdType, Type in IterList: # # Go through all archs # # for Arch in self.SupArchList + [TAB_ARCH_COMMON]: # for Item in PcdObj.GetPcdsByType(PcdType.upper()): PcdDeclaration = GenPcdDeclaration( ContainerFile, (Item.TokenSpaceGuidCName, Item.TokenCName, Item.DefaultValue, Item.DatumType, Item.TokenValue, Type, Item.GetHeadComment(), Item.GetTailComment(), ''), Language, self.DecParser.GetDefineSectionMacro() ) PcdDeclaration.SetSupArchList(Item.GetArchListOfType(PcdType)) # # Get PCD error message from PCD error comment section in DEC file # for PcdErr in PcdDeclaration.GetPcdErrorsList(): if (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.GetErrorNumber()) \ in self.DecParser.PcdErrorCommentDict: Key = (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.GetErrorNumber()) PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \ [(Language, self.DecParser.PcdErrorCommentDict[Key])]) for Index in range(0, len(PromptStrList)): StrNameList = PromptStrList[Index][1].split('_') if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \ StrNameList[2].lower() == Item.TokenCName.lower(): TxtObj = TextObject() TxtObj.SetLang(PromptStrList[Index][0]) TxtObj.SetString(PromptStrList[Index][2]) for Prompt in PcdDeclaration.GetPromptList(): if Prompt.GetLang() == TxtObj.GetLang() and \ Prompt.GetString() == TxtObj.GetString(): break else: PcdDeclaration.SetPromptList(PcdDeclaration.GetPromptList() + [TxtObj]) for Index in range(0, len(HelpStrList)): StrNameList = HelpStrList[Index][1].split('_') if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \ StrNameList[2].lower() == Item.TokenCName.lower(): TxtObj = TextObject() TxtObj.SetLang(HelpStrList[Index][0]) TxtObj.SetString(HelpStrList[Index][2]) for HelpStrObj in PcdDeclaration.GetHelpTextList(): if HelpStrObj.GetLang() == TxtObj.GetLang() and \ HelpStrObj.GetString() == TxtObj.GetString(): break else: PcdDeclaration.SetHelpTextList(PcdDeclaration.GetHelpTextList() + [TxtObj]) # # Get PCD error message from UNI file # for Index in range(0, len(PcdErrStrList)): StrNameList = PcdErrStrList[Index][1].split('_') if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \ StrNameList[2].lower() == TAB_STR_TOKENERR.lower(): for PcdErr in PcdDeclaration.GetPcdErrorsList(): if PcdErr.GetErrorNumber().lower() == (TAB_HEX_START + StrNameList[3]).lower() and \ (PcdErrStrList[Index][0], PcdErrStrList[Index][2]) not in PcdErr.GetErrorMessageList(): PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \ [(PcdErrStrList[Index][0], PcdErrStrList[Index][2])]) # # Check to prevent missing error message if a Pcd has the error code. # for PcdErr in PcdDeclaration.GetPcdErrorsList(): if PcdErr.GetErrorNumber().strip(): if not PcdErr.GetErrorMessageList(): Logger.Error('UPT', FORMAT_INVALID, ST.ERR_DECPARSE_PCD_UNMATCHED_ERRORCODE % PcdErr.GetErrorNumber(), ContainerFile, PcdErr.GetLineNum(), PcdErr.GetFileLine()) PcdDeclarations.append(PcdDeclaration) self.SetPcdList(self.GetPcdList() + PcdDeclarations) self.CheckPcdValue()
def GenIncludes(self, ContainerFile): if ContainerFile: pass Logger.Debug(2, "Generate %s ..." % TAB_INCLUDES) IncludesDict = Sdict() IncObj = self.DecParser.GetIncludeSectionObject() for Item in IncObj.GetAllIncludes(): IncludePath = os.path.normpath(Item.File) if platform.system() != 'Windows' and platform.system() != 'Microsoft': IncludePath = IncludePath.replace('\\', '/') if IncludePath in IncludesDict: if Item.GetArchList() == [TAB_ARCH_COMMON] or IncludesDict[IncludePath] == [TAB_ARCH_COMMON]: IncludesDict[IncludePath] = [TAB_ARCH_COMMON] else: IncludesDict[IncludePath] = IncludesDict[IncludePath] + Item.GetArchList() else: IncludesDict[IncludePath] = Item.GetArchList() # # get the standardIncludeFileList(industry), packageIncludeFileList # (others) for PackageObject # PackagePath = os.path.split(self.GetFullPath())[0] IncludePathList = \ sorted([os.path.normpath(Path) + sep for Path in IncludesDict.keys()]) # # get a non-overlap set of include path, IncludePathList should be # sorted, and path should be end with path separator '\' # NonOverLapList = [] for Path1 in IncludePathList: for Path2 in NonOverLapList: if Path1.startswith(Path2): break else: NonOverLapList.append(Path1) # # revert the list so the longest path shown first in list, also need # to remove the extra path separator '\' # as this list is used to search the supported Arch info # for IndexN in range (0, len(IncludePathList)): IncludePathList[IndexN] = os.path.normpath(IncludePathList[IndexN]) IncludePathList.sort() IncludePathList.reverse() # # save the include path list for later usage # self.SetIncludePathList(IncludePathList) StandardIncludeFileList = [] PackageIncludeFileList = [] IncludeFileList = [] for Path in NonOverLapList: FileList = GetFiles(os.path.join(PackagePath, Path), ['CVS', '.svn'], False) IncludeFileList += [os.path.normpath(os.path.join(Path, File)) for File in FileList] for Includefile in IncludeFileList: ExtName = os.path.splitext(Includefile)[1] if ExtName.upper() == '.DEC' and self.CheckMulDec: Logger.Error('MkPkg', UPT_MUL_DEC_ERROR, ST.ERR_MUL_DEC_ERROR%(os.path.dirname(ContainerFile), os.path.basename(ContainerFile), Includefile)) FileCombinePath = os.path.dirname(Includefile) Include = IncludeObject() for Path in IncludePathList: if FileCombinePath.startswith(Path): SupArchList = IncludesDict[Path] break Include.SetFilePath(Includefile) Include.SetSupArchList(SupArchList) if Includefile.find('IndustryStandard') != -1: StandardIncludeFileList.append(Include) else: PackageIncludeFileList.append(Include) self.SetStandardIncludeFileList(StandardIncludeFileList) # # put include path into the PackageIncludeFileList # PackagePathList = [] IncObj = self.DecParser.GetIncludeSectionObject() for Item in IncObj.GetAllIncludes(): IncludePath = Item.File Include = IncludeObject() Include.SetFilePath(IncludePath) Include.SetSupArchList(Item.GetArchList()) PackagePathList.append(Include) self.SetPackageIncludeFileList(PackagePathList + PackageIncludeFileList)
def _GenModuleHeader(self): Logger.Debug(2, "Generate ModuleHeader ...") # # Get all defines information form InfParser Object # RecordSet = self.Parser.InfDefSection.Defines # # Should only have one ArchString Item. # ArchString = RecordSet.keys()[0] ArchList = GetSplitValueList(ArchString, ' ') ArchList = ConvertArchList(ArchList) HasCalledFlag = False # # Get data from Sdict() # ValueList = RecordSet[ArchString] self.SetFileName(self.FileName) self.SetFullPath(self.FullPath) # # The INF's filename (without the directory path or the extension) # must be used for the value of the # ModuleSurfaceArea.Header.Name element # self.SetName(os.path.splitext(os.path.basename(self.FileName))[0]) self.WorkspaceDir = " " # # CombinePath and ModulePath # PathCount = self.FullPath.upper().find(self.WorkSpace.upper()) + len( self.WorkSpace) + 1 CombinePath = self.FullPath[PathCount:] self.SetCombinePath(CombinePath) ModulePath = os.path.split(CombinePath)[0] ModuleRelativePath = ModulePath if self.GetPackagePath() != '': ModuleRelativePath = ModulePath[ModulePath.find(self. GetPackagePath()) + len(self.GetPackagePath()) + 1:] self.SetModulePath(ModuleRelativePath) # # For Define Seciton Items. # DefineObj = ValueList # # Convert UEFI/PI version to decimal number # if DefineObj.GetUefiSpecificationVersion() != None: __UefiVersion = DefineObj.GetUefiSpecificationVersion().GetValue() __UefiVersion = ConvertVersionToDecimal(__UefiVersion) self.SetUefiSpecificationVersion(str(__UefiVersion)) if DefineObj.GetPiSpecificationVersion() != None: __PiVersion = DefineObj.GetPiSpecificationVersion().GetValue() __PiVersion = ConvertVersionToDecimal(__PiVersion) self.SetPiSpecificationVersion(str(__PiVersion)) SpecList = DefineObj.GetSpecification() NewSpecList = [] for SpecItem in SpecList: NewSpecList.append( (SpecItem[0], ConvertVersionToDecimal(SpecItem[1]))) self.SetSpecList(NewSpecList) # # must exist items in INF define section # MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING # if DefineObj.GetModuleType() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("MODULE_TYPE"), File=self.FullPath) else: self.SetModuleType(DefineObj.GetModuleType().GetValue()) ModuleType = DefineObj.GetModuleType().GetValue() if ModuleType: # # Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only # libraries are permitted to a have a MODULE_TYPE of "BASE". # if len(DefineObj.LibraryClass) == 0 and ModuleType == 'BASE': Logger.Error( "InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_MODULETYPE_INVALID, File=self.FullPath, Line=DefineObj.ModuleType.CurrentLine.LineNo, ExtraData=DefineObj.ModuleType.CurrentLine.LineString) self.LibModuleTypeList.append(ModuleType) if DefineObj.GetBaseName() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("BASE_NAME"), File=self.FullPath) else: self.SetBaseName(DefineObj.GetBaseName().GetValue()) if DefineObj.GetInfVersion() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("INF_VERSION"), File=self.FullPath) else: self.SetVersion(DefineObj.GetInfVersion().GetValue()) if DefineObj.GetFileGuid() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("FILE_GUID"), File=self.FullPath) else: self.SetGuid(DefineObj.GetFileGuid().GetValue()) if DefineObj.GetVersionString() == None: # # VERSION_STRING is missing from the [Defines] section, tools must assume that the module's version is 0. # self.SetVersion('0') else: # # Get version of INF # if DefineObj.GetVersionString().GetValue() != "": # # EDK2 inf # VersionString = DefineObj.GetVersionString().GetValue() if len(VersionString) > 0: VersionString = ConvertVersionToDecimal(VersionString) self.SetVersion(VersionString) else: # # EDK1 inf # Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath, RaiseError=Logger.IS_RAISE_ERROR) # # if there is Shadow, Should judge the MODULE_TYPE in # SEC, PEI_CORE and PEIM # if DefineObj.GetShadow(): ModuleTypeValue = DefineObj.GetModuleType().GetValue() if not (ModuleTypeValue == 'SEC' or ModuleTypeValue == 'PEI_CORE' or ModuleTypeValue == 'PEIM'): Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SHADOW_INVALID, File=self.FullPath) if DefineObj.GetPcdIsDriver() != None: self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue()) # # LIBRARY_CLASS # self._GenModuleHeaderLibClass(DefineObj, ArchList) # # CUSTOM_MAKEFILE # self.CustomMakefile = DefineObj.GetCustomMakefile() # # Externs in Defines section # Only one define section, so just call once. # if not HasCalledFlag: self._GenModuleHeaderExterns(DefineObj) HasCalledFlag = True # # each module has only one module header # self.SetSupArchList(ArchList) # # Get Hob/BootMode/EventList information # self._GenSpecialComments() # # put all define statement into user-extension sections # DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString) if DefinesDictNew: UserExtension = CommonObject.UserExtensionObject() UserExtension.SetDefinesDict(DefinesDictNew) UserExtension.SetIdentifier('DefineModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) # # Get all meta-file header information # the record is list of items formated: # [LineValue, Arch, StartLine, ID, Third] # InfHeaderObj = self.Parser.InfHeader # # Put header information into POM object # self.SetAbstract(InfHeaderObj.GetAbstract()) self.SetDescription(InfHeaderObj.GetDescription()) self.SetCopyright(InfHeaderObj.GetCopyright()) self.SetLicense(InfHeaderObj.GetLicense())
def _GenBinaries(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_BINARIES) BinariesDict = {} # # Get all Binary data # BinaryObj = self.Parser.InfBinariesSection.GetBinary() BinaryData = BinaryObj.keys() # # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section, # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute # if BinaryObj and not self.Parser.InfSourcesSection.GetSources(): self.BinaryModule = True else: self.BinaryModule = False BinaryFileObjectList = [] AsBuildLibraryClassList = [] AsBuildBuildOptionList = [] AsBuildIns = AsBuiltObject() # # Library AsBuild Info # for LibItem in self.Parser.InfLibraryClassSection.GetLibraryClasses(): AsBuildLibIns = AsBuildLibraryClassObject() AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid()) AsBuildLibIns.SetLibVersion(LibItem.GetVersion()) AsBuildLibIns.SetSupArchList(LibItem.GetSupArchList()) AsBuildLibraryClassList.append(AsBuildLibIns) AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList) # # BuildOption AsBuild Info # for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions( ): AsBuildBuildOptionList.append(BuildOptionItem) AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList) # # PatchPcd and PcdEx # AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(), AsBuildIns) # # Parse the DEC file that contains the GUID value of the GUID CName which is used by # SUBTYPE_GUID type binary file in the Binaries section in the INF file # DecObjList = [] if not self.PackagePath: WorkSpace = os.path.normpath(self.WorkSpace) TempPath = ModulePath = os.path.normpath(self.ModulePath) while ModulePath: TempPath = ModulePath ModulePath = os.path.dirname(ModulePath) PackageName = TempPath DecFilePath = os.path.normpath(os.path.join( WorkSpace, PackageName)) if DecFilePath: for File in os.listdir(DecFilePath): if File.upper().endswith('.DEC'): DecFileFullPath = os.path.normpath( os.path.join(DecFilePath, File)) DecObjList.append( DecPomAlignment(DecFileFullPath, self.WorkSpace)) BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData( BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, self.GetSupArchList(), self.BinaryModule, DecObjList) BinariesDict2 = {} for Key in BinariesDict: ValueList = BinariesDict[Key] if len(ValueList) > 1: BinariesDict2[Key] = ValueList else: # # if there is no TagName, ToolCode, HelpStr, # then do not need to put them into userextension # (Target, Family, TagName, HelpStr) = ValueList[0] if not (Target or Family or TagName or HelpStr): continue else: BinariesDict2[Key] = ValueList self.SetBinaryFileList(self.GetBinaryFileList() + BinaryFileObjectList) if BinariesDict2: UserExtension = CommonObject.UserExtensionObject() UserExtension.SetBinariesDict(BinariesDict2) UserExtension.SetIdentifier('BinaryFileModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
def GenGuidProtocolPpis(self, Type, ContainerFile): if ContainerFile: pass Logger.Debug(2, "Generate %s ..." % Type) Obj = None Factory = None if Type == TAB_GUIDS: Obj = self.DecParser.GetGuidSectionObject() def CreateGuidObject(): Object = GuidObject() Object.SetGuidTypeList([]) Object.SetUsage(None) Object.SetName(None) return Object Factory = CreateGuidObject elif Type == TAB_PROTOCOLS: Obj = self.DecParser.GetProtocolSectionObject() def CreateProtocolObject(): return ProtocolObject() Factory = CreateProtocolObject elif Type == TAB_PPIS: Obj = self.DecParser.GetPpiSectionObject() def CreatePpiObject(): return PpiObject() Factory = CreatePpiObject else: # # Should not be here # return DeclarationsList = [] # # Go through each arch # for Item in Obj.GetGuidStyleAllItems(): Name = Item.GuidCName Value = Item.GuidString HelpTxt = ParseGenericComment(Item.GetHeadComment() + \ Item.GetTailComment()) ListObject = Factory() ListObject.SetCName(Name) ListObject.SetGuid(Value) ListObject.SetSupArchList(Item.GetArchList()) if HelpTxt: if self.UniFileClassObject: HelpTxt.SetLang(TAB_LANGUAGE_EN_X) ListObject.SetHelpTextList([HelpTxt]) DeclarationsList.append(ListObject) # #GuidTypeList is abstracted from help # if Type == TAB_GUIDS: self.SetGuidList(self.GetGuidList() + DeclarationsList) elif Type == TAB_PROTOCOLS: self.SetProtocolList(self.GetProtocolList() + DeclarationsList) elif Type == TAB_PPIS: self.SetPpiList(self.GetPpiList() + DeclarationsList)
def _GenDepexes(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_DEPEX) PEI_LIST = [DT.SUP_MODULE_PEIM] SMM_LIST = [DT.SUP_MODULE_DXE_SMM_DRIVER] DXE_LIST = [ DT.SUP_MODULE_DXE_DRIVER, DT.SUP_MODULE_DXE_SAL_DRIVER, DT.SUP_MODULE_DXE_RUNTIME_DRIVER ] IsLibraryClass = self.GetIsLibrary() # # Get all Depexes # DepexData = self.Parser.InfDepexSection.GetDepex() SmmDepexList = [] DxeDepexList = [] PeiDepexList = [] for Depex in DepexData: ModuleType = Depex.GetModuleType() ModuleTypeList = [] if IsLibraryClass: if not self.GetIsLibraryModList(): Logger.Error( "\nMkPkg", PARSER_ERROR, ST. ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_LIBRARY_CLASS, self.GetFullPath(), RaiseError=True) if ModuleType and ModuleType not in self.GetIsLibraryModList(): Logger.Error( "\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED, self.GetFullPath(), RaiseError=True) if ModuleType: ModuleTypeList = [ModuleType] else: for ModuleTypeInList in self.GetIsLibraryModList(): if ModuleTypeInList in DT.VALID_DEPEX_MODULE_TYPE_LIST: ModuleTypeList.append(ModuleTypeInList) if not ModuleTypeList: Logger.Error( "\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED, self.GetFullPath(), RaiseError=True) else: if not ModuleType: ModuleType = self.ModuleType if ModuleType not in DT.VALID_DEPEX_MODULE_TYPE_LIST: Logger.Error( "\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType), self.GetFullPath(), RaiseError=True) if ModuleType != self.ModuleType: Logger.Error( "\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED, self.GetFullPath(), RaiseError=True) ModuleTypeList = [ModuleType] for ModuleType in ModuleTypeList: DepexIns = DepexObject() DepexIns.SetDepex(Depex.GetDepexContent()) if IsLibraryClass: DepexIns.SetModuleType(ModuleType) else: if Depex.GetModuleType(): DepexIns.SetModuleType(Depex.GetModuleType()) DepexIns.SetSupArchList(ConvertArchList([Depex.GetSupArch()])) DepexIns.SetFeatureFlag(Depex.GetFeatureFlagExp()) if Depex.HelpString: HelpIns = CommonObject.TextObject() HelpIns.SetString( GetHelpStringByRemoveHashKey(Depex.HelpString)) DepexIns.SetHelpText(HelpIns) if ModuleType in SMM_LIST: SmmDepexList.append(DepexIns) if ModuleType in DXE_LIST: DxeDepexList.append(DepexIns) if ModuleType in PEI_LIST: PeiDepexList.append(DepexIns) if ModuleType == DT.SUP_MODULE_UEFI_DRIVER: if IsLibraryClass: DxeDepexList.append(DepexIns) else: Logger.Error( "\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_DRIVER, self.GetFullPath(), RaiseError=True) #End of for ModuleType in ModuleTypeList self._GenDepexesList(SmmDepexList, DxeDepexList, PeiDepexList)
def ReplaceMacro(String, MacroDefinitions=None, SelfReplacement=False, Line=None, FileName=None, Flag=False): LastString = String if MacroDefinitions == None: MacroDefinitions = {} while MacroDefinitions: QuotedStringList = [] HaveQuotedMacroFlag = False if not Flag: MacroUsed = gMACRO_PATTERN.findall(String) else: ReQuotedString = re.compile('\"') QuotedStringList = ReQuotedString.split(String) if len(QuotedStringList) >= 3: HaveQuotedMacroFlag = True Count = 0 MacroString = "" for QuotedStringItem in QuotedStringList: Count += 1 if Count % 2 != 0: MacroString += QuotedStringItem if Count == len(QuotedStringList) and Count % 2 == 0: MacroString += QuotedStringItem MacroUsed = gMACRO_PATTERN.findall(MacroString) # # no macro found in String, stop replacing # if len(MacroUsed) == 0: break for Macro in MacroUsed: if Macro not in MacroDefinitions: if SelfReplacement: String = String.replace("$(%s)" % Macro, '') Logger.Debug( 5, "Delete undefined MACROs in file %s line %d: %s!" % (FileName, Line[1], Line[0])) continue if not HaveQuotedMacroFlag: String = String.replace("$(%s)" % Macro, MacroDefinitions[Macro]) else: Count = 0 for QuotedStringItem in QuotedStringList: Count += 1 if Count % 2 != 0: QuotedStringList[Count - 1] = QuotedStringList[ Count - 1].replace("$(%s)" % Macro, MacroDefinitions[Macro]) elif Count == len(QuotedStringList) and Count % 2 == 0: QuotedStringList[Count - 1] = QuotedStringList[ Count - 1].replace("$(%s)" % Macro, MacroDefinitions[Macro]) RetString = '' if HaveQuotedMacroFlag: Count = 0 for QuotedStringItem in QuotedStringList: Count += 1 if Count != len(QuotedStringList): RetString += QuotedStringList[Count - 1] + "\"" else: RetString += QuotedStringList[Count - 1] String = RetString # # in case there's macro not defined # if String == LastString: break LastString = String return String
def _GenBinaries(self): Logger.Debug(2, "Generate %s ..." % DT.TAB_BINARIES) BinariesDict = {} # # Get all Binary data # BinaryObj = self.Parser.InfBinariesSection.GetBinary() BinaryData = BinaryObj.keys() # # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section, # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute # if BinaryObj and not self.Parser.InfSourcesSection.GetSources(): self.BinaryModule = True else: self.BinaryModule = False BinaryFileObjectList = [] AsBuildLibraryClassList = [] AsBuildBuildOptionList = [] AsBuildIns = AsBuiltObject() # # Library AsBuild Info # for LibItem in self.Parser.InfLibraryClassSection.GetLibraryClasses(): AsBuildLibIns = AsBuildLibraryClassObject() AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid()) AsBuildLibIns.SetLibVersion(LibItem.GetVersion()) AsBuildLibraryClassList.append(AsBuildLibIns) AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList) # # BuildOption AsBuild Info # for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions( ): AsBuildBuildOptionList += BuildOptionItem.GetAsBuildList() AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList) # # PatchPcd and PcdEx # AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(), AsBuildIns) BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData( BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, self.GetSupArchList(), self.BinaryModule) BinariesDict2 = {} for Key in BinariesDict: ValueList = BinariesDict[Key] if len(ValueList) > 1: BinariesDict2[Key] = ValueList else: # # if there is no TagName, ToolCode, HelpStr, # then do not need to put them into userextension # (Target, Family, TagName, HelpStr) = ValueList[0] if not (Target or Family or TagName or HelpStr): continue else: BinariesDict2[Key] = ValueList self.SetBinaryFileList(self.GetBinaryFileList() + BinaryFileObjectList) if BinariesDict2: UserExtension = CommonObject.UserExtensionObject() UserExtension.SetBinariesDict(BinariesDict2) UserExtension.SetIdentifier('BinaryFileModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])