From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 43E0E2034711C for ; Mon, 20 Nov 2017 01:21:27 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2017 01:25:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,426,1505804400"; d="scan'208";a="3792822" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 20 Nov 2017 01:25:40 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 20 Nov 2017 01:25:40 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Mon, 20 Nov 2017 17:25:38 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: Dmitry Antipov Thread-Topic: [edk2] [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF Thread-Index: AQHTXrs/tebC3NfEhE+gTD6H9QS62aMdBY+Q Date: Mon, 20 Nov 2017 09:25:38 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E180A34@SHSMSX104.ccr.corp.intel.com> References: <1510823631-4744-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1510823631-4744-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Mon, 20 Nov 2017 09:21:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Thursday, November 16, 2017 5:14 PM >To: edk2-devel@lists.01.org >Cc: Dmitry Antipov ; Gao, Liming > >Subject: [edk2] [Patch] BaseTools: Guid.xref contain information from FILE >statements in FDF > >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 >--- > 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/Python/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 > > ## Version and Copyright > versionNumber =3D "1.0" + ' ' + gBUILD_VERSION > __version__ =3D "%prog Version " + versionNumber > __copyright__ =3D "Copyright (c) 2007 - 2017, Intel Corporation All righ= ts >reserved." >@@ -325,11 +328,11 @@ def main(): > > """Call GenFds""" > GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) > > """Generate GUID cross reference file""" >- GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList) >+ GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserOb= j) > > """Display FV space info.""" > GenFds.DisplayFvSpaceInfo(FdfParserObj) > > except FdfParser.Warning, X: >@@ -722,25 +725,106 @@ class GenFds : > ModuleDict =3D BuildDb.BuildObject[DscFile, 'COMMON', >GenFdsGlobalVariable.TargetName, >GenFdsGlobalVariable.ToolChainTag].Modules > for Key in ModuleDict: > ModuleObj =3D BuildDb.BuildObject[Key, 'COMMON', >GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] > print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType > >- def GenerateGuidXRefFile(BuildDb, ArchList): >+ def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj): > GuidXRefFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, >"Guid.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, >GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] >+ if Module in ModuleList: >+ continue >+ else: >+ ModuleList.append(Module) > GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseN= ame)) > 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.FileStatem= ent): >+ InfPath =3D >PathClass(NormPath(mws.join(GenFdsGlobalVariable.WorkSpaceDir, >FfsObj.InfFileName))) >+ FdfModule =3D BuildDb.BuildObject[InfPath, Arch, >GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] >+ if FdfModule in ModuleList: >+ continue >+ else: >+ ModuleList.append(FdfModule) >+ GuidXRefFile.write("%s %s\n" % (FdfModule.Guid, >FdfModule.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.FvD= ir, 'Ffs') >+ FfsPath =3D glob.glob(os.path.join(FfsPath, FileS= tatementGuid) + >'*') >+ if not FfsPath: >+ continue >+ if not os.path.exists(FfsPath[0]): >+ continue >+ MatchDict =3D {} >+ ReFileEnds =3D >re.compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.= pic.t >xt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$') >+ 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)].app= end(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 Tmp= Str[:-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" % >(GuidStructureStringToGuidString(item).upper(), key)) > >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel