* [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF
@ 2017-11-16 9:13 Yonghong Zhu
2017-11-20 9:25 ` Gao, Liming
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-11-16 9:13 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Dmitry Antipov
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.txt)$|\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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] BaseTools: Guid.xref contain information from FILE statements in FDF
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
0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2017-11-20 9:25 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Dmitry Antipov
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-20 9:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox