From nobody Sun Apr 28 11:03:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1510823638239279.10304068587936; Thu, 16 Nov 2017 01:13:58 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E4E58202E5E62; Thu, 16 Nov 2017 01:09:46 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8EDBA220D4BE9 for ; Thu, 16 Nov 2017 01:09:45 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 01:13:54 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.121]) by orsmga002.jf.intel.com with ESMTP; 16 Nov 2017 01:13:53 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="8300884" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Thu, 16 Nov 2017 17:13:51 +0800 Message-Id: <1510823631-4744-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Antipov , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update Guid.xref to contain information from FILE statements in FDF file. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D778 Cc: Liming Gao Cc: Dmitry Antipov Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/Python/GenFds/GenFds.py | 88 ++++++++++++++++++++++++++++= +++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 277da35..c19dc40 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -40,10 +40,13 @@ from Common.Misc import ClearDuplicatedInf from Common.Misc import GuidStructureStringToGuidString from Common.Misc import CheckPcdDatum from Common.Misc import BuildOptionPcdValueFormat from Common.BuildVersion import gBUILD_VERSION from Common.MultipleWorkspace import MultipleWorkspace as mws +import FfsFileStatement +import glob +from struct import unpack =20 ## Version and Copyright versionNumber =3D "1.0" + ' ' + gBUILD_VERSION __version__ =3D "%prog Version " + versionNumber __copyright__ =3D "Copyright (c) 2007 - 2017, Intel Corporation All right= s reserved." @@ -325,11 +328,11 @@ def main(): =20 """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) =20 """Generate GUID cross reference file""" - GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList) + GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) =20 """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) =20 except FdfParser.Warning, X: @@ -722,25 +725,106 @@ class GenFds : ModuleDict =3D BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobal= Variable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules for Key in ModuleDict: ModuleObj =3D BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag] print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType =20 - def GenerateGuidXRefFile(BuildDb, ArchList): + def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj): GuidXRefFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, "Gui= d.xref") GuidXRefFile =3D StringIO.StringIO('') GuidDict =3D {} + ModuleList =3D [] + FileGuidList =3D [] for Arch in ArchList: PlatformDataBase =3D BuildDb.BuildObject[GenFdsGlobalVariable.= ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable= .ToolChainTag] for ModuleFile in PlatformDataBase.Modules: Module =3D BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlo= balVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + if Module in ModuleList: + continue + else: + ModuleList.append(Module) GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseNa= me)) for key, item in Module.Protocols.items(): GuidDict[key] =3D item for key, item in Module.Guids.items(): GuidDict[key] =3D item for key, item in Module.Ppis.items(): GuidDict[key] =3D item + for FvName in FdfParserObj.Profile.FvDict: + for FfsObj in FdfParserObj.Profile.FvDict[FvName].FfsList: + if not isinstance(FfsObj, FfsFileStatement.FileStateme= nt): + InfPath =3D PathClass(NormPath(mws.join(GenFdsGlob= alVariable.WorkSpaceDir, FfsObj.InfFileName))) + FdfModule =3D BuildDb.BuildObject[InfPath, Arch, G= enFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + if FdfModule in ModuleList: + continue + else: + ModuleList.append(FdfModule) + GuidXRefFile.write("%s %s\n" % (FdfModule.Guid, Fd= fModule.BaseName)) + for key, item in FdfModule.Protocols.items(): + GuidDict[key] =3D item + for key, item in FdfModule.Guids.items(): + GuidDict[key] =3D item + for key, item in FdfModule.Ppis.items(): + GuidDict[key] =3D item + else: + FileStatementGuid =3D FfsObj.NameGuid + if FileStatementGuid in FileGuidList: + continue + else: + FileGuidList.append(FileStatementGuid) + Name =3D [] + FfsPath =3D os.path.join(GenFdsGlobalVariable.FvDi= r, 'Ffs') + FfsPath =3D glob.glob(os.path.join(FfsPath, FileSt= atementGuid) + '*') + if not FfsPath: + continue + if not os.path.exists(FfsPath[0]): + continue + MatchDict =3D {} + ReFileEnds =3D re.compile('\S+(.ui)$|\S+(fv.sec.tx= t)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.tx= t)$') + FileList =3D os.listdir(FfsPath[0]) + for File in FileList: + Match =3D ReFileEnds.search(File) + if Match: + for Index in range(1, 8): + if Match.group(Index) and Match.group(= Index) in MatchDict: + MatchDict[Match.group(Index)].appe= nd(File) + elif Match.group(Index): + MatchDict[Match.group(Index)] =3D = [File] + if not MatchDict: + continue + if '.ui' in MatchDict: + for File in MatchDict['.ui']: + with open(os.path.join(FfsPath[0], File), = 'rb') as F: + F.read() + length =3D F.tell() + F.seek(4) + TmpStr =3D unpack('%dh' % ((length - 4= ) / 2), F.read()) + Name =3D ''.join([chr(c) for c in TmpS= tr[:-1]]) + else: + FileList =3D [] + if 'fv.sec.txt' in MatchDict: + FileList =3D MatchDict['fv.sec.txt'] + elif '.pe32.txt' in MatchDict: + FileList =3D MatchDict['.pe32.txt'] + elif '.te.txt' in MatchDict: + FileList =3D MatchDict['.te.txt'] + elif '.pic.txt' in MatchDict: + FileList =3D MatchDict['.pic.txt'] + elif '.raw.txt' in MatchDict: + FileList =3D MatchDict['.raw.txt'] + elif '.ffs.txt' in MatchDict: + FileList =3D MatchDict['.ffs.txt'] + else: + pass + for File in FileList: + with open(os.path.join(FfsPath[0], File), = 'r') as F: + Name.append((F.read().split()[-1])) + if not Name: + continue + + Name =3D ' '.join(Name) if type(Name) =3D=3D type(= []) else Name + GuidXRefFile.write("%s %s\n" %(FileStatementGuid, = Name)) + # Append GUIDs, Protocols, and PPIs to the Xref file GuidXRefFile.write("\n") for key, item in GuidDict.items(): GuidXRefFile.write("%s %s\n" % (GuidStructureStringToGuidStrin= g(item).upper(), key)) =20 --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel