public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bob Feng" <bob.c.feng@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Chen, Yuwei" <yuwei.chen@intel.com>
Cc: "Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [Patch v5 1/1] BaseTools: Add Guid name support in GenFfs.
Date: Tue, 14 Jul 2020 06:12:05 +0000	[thread overview]
Message-ID: <BN6PR11MB00686B8BAB9E0BF87944AAE9C9610@BN6PR11MB0068.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200714054234.597-1-yuwei.chen@intel.com>

Hi Yuwei,

The change history info need to be added below --- so that it will not go to commit message.

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuwei Chen
Sent: Tuesday, July 14, 2020 1:43 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [edk2-devel] [Patch v5 1/1] BaseTools: Add Guid name support in GenFfs.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2762

The Fv Section in the FDF files use hard coding Guid values which is inconvenient to manage. This patch adds Guid name support in GenFfs to solve this problem.

v5 modified the format without fuctional change. 

Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 .../Source/Python/AutoGen/WorkspaceAutoGen.py | 24 +++++++++++++++++++  BaseTools/Source/Python/Common/GlobalData.py  |  1 +
 BaseTools/Source/Python/GenFds/FdfParser.py   | 14 ++++++++++-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
index 668126aaac42..f86c749c08c3 100644
--- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
@@ -108,6 +108,10 @@ class WorkspaceAutoGen(AutoGen):
         #
         # Mark now build in AutoGen Phase
         #
+        #
+        # Collect Platform Guids to support Guid name in Fdfparser.
+        #
+        self.CollectPlatformGuids()
         GlobalData.gAutoGenPhase = True
         self.ProcessModuleFromPdf()
         self.ProcessPcdType()
@@ -153,6 +157,26 @@ class WorkspaceAutoGen(AutoGen):
             EdkLogger.error("build", PARAMETER_INVALID,
                             ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"
                                       % (self.BuildTarget, " ".join(self.Platform.BuildTargets)))
+
+    def CollectPlatformGuids(self):
+        oriInfList = []
+        oriPkgSet = set()
+        PlatformPkg = set()
+        for Arch in self.ArchList:
+            Platform = self.BuildDatabase[self.MetaFile, Arch, self.BuildTarget, self.ToolChain]
+            oriInfList = Platform.Modules
+            for ModuleFile in oriInfList:
+                ModuleData = self.BuildDatabase[ModuleFile, Platform._Arch, Platform._Target, Platform._Toolchain]
+                oriPkgSet.update(ModuleData.Packages)
+                for Pkg in oriPkgSet:
+                    Guids = Pkg.Guids
+                    GlobalData.gGuidDict.update(Guids)
+            if Platform.Packages:
+                PlatformPkg.update(Platform.Packages)
+                for Pkg in PlatformPkg:
+                    Guids = Pkg.Guids
+                    GlobalData.gGuidDict.update(Guids)
+
     @cached_property
     def FdfProfile(self):
         if not self.FdfFile:
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index 8ac29eb7a6fb..61ab3f7e24cd 100755
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -29,6 +29,7 @@ gProcessingFile = ''
 gBuildingModule = ''
 gSkuids = []
 gDefaultStores = []
+gGuidDict = {}
 
 # definition for a MACRO name.  used to create regular expressions below.
 _MacroNamePattern = "[A-Z][A-Z0-9_]*"
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 9b04a76af8c5..ea2401b0e4fc 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -18,7 +18,7 @@ from uuid import UUID
 
 from Common.BuildToolError import *
 from Common import EdkLogger
-from Common.Misc import PathClass, tdict, ProcessDuplicatedInf
+from Common.Misc import PathClass, tdict, ProcessDuplicatedInf, 
+GuidStructureStringToGuidString
 from Common.StringUtils import NormPath, ReplaceMacro  from Common import GlobalData  from Common.Expression import * @@ -1087,6 +1087,8 @@ class FdfParser:
             return False
         if GlobalData.gGuidPattern.match(self._Token) is not None:
             return True
+        elif self._Token in GlobalData.gGuidDict:
+            return True
         else:
             self._UndoToken()
             return False
@@ -2248,6 +2250,8 @@ class FdfParser:
 
         if not self._GetNextGuid():
             raise Warning.Expected("GUID value", self.FileName, self.CurrentLineNumber)
+        if self._Token in GlobalData.gGuidDict:
+            self._Token = 
+ GuidStructureStringToGuidString(GlobalData.gGuidDict[self._Token]).upp
+ er()
 
         FvObj.FvNameGuid = self._Token
 
@@ -2459,6 +2463,8 @@ class FdfParser:
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
             if not self._GetNextGuid():
                 raise Warning.Expected("GUID value", self.FileName, self.CurrentLineNumber)
+            if self._Token in GlobalData.gGuidDict:
+                self._Token = 
+ GuidStructureStringToGuidString(GlobalData.gGuidDict[self._Token]).upp
+ er()
             FfsInfObj.OverrideGuid = self._Token
 
         if self._IsKeyword("RuleOverride"):
@@ -2550,6 +2556,8 @@ class FdfParser:
                     raise Warning.Expected("')'", self.FileName, self.CurrentLineNumber)
                 self._Token = 'PCD('+PcdPair[1]+TAB_SPLIT+PcdPair[0]+')'
 
+        if self._Token in GlobalData.gGuidDict:
+            self._Token = 
+ GuidStructureStringToGuidString(GlobalData.gGuidDict[self._Token]).upp
+ er()
         FfsFileObj.NameGuid = self._Token
 
         self._GetFilePart(FfsFileObj)
@@ -2980,6 +2988,8 @@ class FdfParser:
         elif self._IsKeyword("GUIDED"):
             GuidValue = None
             if self._GetNextGuid():
+                if self._Token in GlobalData.gGuidDict:
+                    self._Token = 
+ GuidStructureStringToGuidString(GlobalData.gGuidDict[self._Token]).upp
+ er()
                 GuidValue = self._Token
 
             AttribDict = self._GetGuidAttrib() @@ -4049,6 +4059,8 @@ class FdfParser:
         elif self._IsKeyword("GUIDED"):
             GuidValue = None
             if self._GetNextGuid():
+                if self._Token in GlobalData.gGuidDict:
+                    self._Token = 
+ GuidStructureStringToGuidString(GlobalData.gGuidDict[self._Token]).upp
+ er()
                 GuidValue = self._Token
 
             if self._IsKeyword("$(NAMED_GUID)"):
--
2.27.0.windows.1





      reply	other threads:[~2020-07-14  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14  5:42 [Patch v5 1/1] BaseTools: Add Guid name support in GenFfs Yuwei Chen
2020-07-14  6:12 ` Bob Feng [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=BN6PR11MB00686B8BAB9E0BF87944AAE9C9610@BN6PR11MB0068.namprd11.prod.outlook.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