public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Dmitry Antipov <dmanti@microsoft.com>
Subject: Re: [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF
Date: Mon, 20 Nov 2017 09:25:38 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E180A34@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1510823631-4744-1-git-send-email-yonghong.zhu@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----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 <dmanti@microsoft.com>; Gao, Liming
><liming.gao@intel.com>
>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=778
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Dmitry Antipov <dmanti@microsoft.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> 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 = "1.0" + ' ' + gBUILD_VERSION
> __version__ = "%prog Version " + versionNumber
> __copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation  All rights
>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, FdfParserObj)
>
>         """Display FV space info."""
>         GenFds.DisplayFvSpaceInfo(FdfParserObj)
>
>     except FdfParser.Warning, X:
>@@ -722,25 +725,106 @@ class GenFds :
>         ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON',
>GenFdsGlobalVariable.TargetName,
>GenFdsGlobalVariable.ToolChainTag].Modules
>         for Key in ModuleDict:
>             ModuleObj = BuildDb.BuildObject[Key, 'COMMON',
>GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
>             print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
>
>-    def GenerateGuidXRefFile(BuildDb, ArchList):
>+    def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
>         GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir,
>"Guid.xref")
>         GuidXRefFile = StringIO.StringIO('')
>         GuidDict = {}
>+        ModuleList = []
>+        FileGuidList = []
>         for Arch in ArchList:
>             PlatformDataBase =
>BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,
>GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
>             for ModuleFile in PlatformDataBase.Modules:
>                 Module = 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.BaseName))
>                 for key, item in Module.Protocols.items():
>                     GuidDict[key] = item
>                 for key, item in Module.Guids.items():
>                     GuidDict[key] = item
>                 for key, item in Module.Ppis.items():
>                     GuidDict[key] = item
>+            for FvName in FdfParserObj.Profile.FvDict:
>+                for FfsObj in FdfParserObj.Profile.FvDict[FvName].FfsList:
>+                    if not isinstance(FfsObj, FfsFileStatement.FileStatement):
>+                        InfPath =
>PathClass(NormPath(mws.join(GenFdsGlobalVariable.WorkSpaceDir,
>FfsObj.InfFileName)))
>+                        FdfModule = 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] = item
>+                        for key, item in FdfModule.Guids.items():
>+                            GuidDict[key] = item
>+                        for key, item in FdfModule.Ppis.items():
>+                            GuidDict[key] = item
>+                    else:
>+                        FileStatementGuid = FfsObj.NameGuid
>+                        if FileStatementGuid in FileGuidList:
>+                            continue
>+                        else:
>+                            FileGuidList.append(FileStatementGuid)
>+                        Name = []
>+                        FfsPath = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
>+                        FfsPath = glob.glob(os.path.join(FfsPath, FileStatementGuid) +
>'*')
>+                        if not FfsPath:
>+                            continue
>+                        if not os.path.exists(FfsPath[0]):
>+                            continue
>+                        MatchDict = {}
>+                        ReFileEnds =
>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 = os.listdir(FfsPath[0])
>+                        for File in FileList:
>+                            Match = 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)].append(File)
>+                                    elif Match.group(Index):
>+                                        MatchDict[Match.group(Index)] = [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 = F.tell()
>+                                    F.seek(4)
>+                                    TmpStr = unpack('%dh' % ((length - 4) / 2), F.read())
>+                                    Name = ''.join([chr(c) for c in TmpStr[:-1]])
>+                        else:
>+                            FileList = []
>+                            if 'fv.sec.txt' in MatchDict:
>+                                FileList = MatchDict['fv.sec.txt']
>+                            elif '.pe32.txt' in MatchDict:
>+                                FileList = MatchDict['.pe32.txt']
>+                            elif '.te.txt' in MatchDict:
>+                                FileList = MatchDict['.te.txt']
>+                            elif '.pic.txt' in MatchDict:
>+                                FileList = MatchDict['.pic.txt']
>+                            elif '.raw.txt' in MatchDict:
>+                                FileList = MatchDict['.raw.txt']
>+                            elif '.ffs.txt' in MatchDict:
>+                                FileList = 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 = ' '.join(Name) if type(Name) == 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


      reply	other threads:[~2017-11-20  9:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16  9:13 [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF Yonghong Zhu
2017-11-20  9:25 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E180A34@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox