public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Re: [edk2-devel] [Patch v4] BaseTools: Add Guid name support in GenFfs.
  2020-07-13  7:39 Yuwei Chen
@ 2020-07-13 14:20 ` Bob Feng
  0 siblings, 0 replies; 4+ messages in thread
From: Bob Feng @ 2020-07-13 14:20 UTC (permalink / raw)
  To: devel@edk2.groups.io, Chen, Yuwei

Yuwei, please remove Change-Id.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuwei Chen
Sent: Monday, July 13, 2020 3:39 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 v4] 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.

v4 add comments for new function without functional modification.

Change-Id: I29b52663613286c6210d99eaaa09338677a21b31
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 668126aaac..d2e59ca34f 100644
--- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
@@ -109,6 +109,10 @@ class WorkspaceAutoGen(AutoGen):
         # Mark now build in AutoGen Phase         #         GlobalData.gAutoGenPhase = True+        #+        # Collect Platform Guids to support Guid name in Fdfparser.+        #+        self.CollectPlatformGuids()         self.ProcessModuleFromPdf()         self.ProcessPcdType()         self.ProcessMixedPcd()@@ -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 8ac29eb7a6..61ab3f7e24 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 9b04a76af8..ea2401b0e4 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]).upper()          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]).upper()             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]).upper()         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]).upper()                 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]).upper()                 GuidValue = self._Token              if self._IsKeyword("$(NAMED_GUID)"):-- 
2.27.0.windows.1


-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62399): https://edk2.groups.io/g/devel/message/62399
Mute This Topic: https://groups.io/mt/75472556/1768742
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [bob.c.feng@intel.com] -=-=-=-=-=-=


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Patch v4] BaseTools: Add Guid name support in GenFfs.
@ 2020-07-14  5:30 Yuwei Chen
  2020-07-15  0:53 ` [edk2-devel] " Bob Feng
       [not found] ` <1621C6E7ED5B7C55.2845@groups.io>
  0 siblings, 2 replies; 4+ messages in thread
From: Yuwei Chen @ 2020-07-14  5:30 UTC (permalink / raw)
  To: devel

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.

Signed-off-by: Yuwei Chen <yuwei.chen@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 668126aaac..f86c749c08 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 8ac29eb7a6..61ab3f7e24 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 9b04a76af8..ea2401b0e4 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]).upper()
 
         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]).upper()
             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]).upper()
         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]).upper()
                 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]).upper()
                 GuidValue = self._Token
 
             if self._IsKeyword("$(NAMED_GUID)"):
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [Patch v4] BaseTools: Add Guid name support in GenFfs.
  2020-07-14  5:30 [Patch v4] BaseTools: Add Guid name support in GenFfs Yuwei Chen
@ 2020-07-15  0:53 ` Bob Feng
       [not found] ` <1621C6E7ED5B7C55.2845@groups.io>
  1 sibling, 0 replies; 4+ messages in thread
From: Bob Feng @ 2020-07-15  0:53 UTC (permalink / raw)
  To: devel@edk2.groups.io, Chen, Christine

Reviewed-by: Bob Feng<bob.c.feng@intel.com> 

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuwei Chen
Sent: Tuesday, July 14, 2020 1:31 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [Patch v4] 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.

Signed-off-by: Yuwei Chen <yuwei.chen@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 668126aaac..f86c749c08 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 8ac29eb7a6..61ab3f7e24 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 9b04a76af8..ea2401b0e4 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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [Patch v4] BaseTools: Add Guid name support in GenFfs.
       [not found] ` <1621C6E7ED5B7C55.2845@groups.io>
@ 2020-07-21  3:39   ` Bob Feng
  0 siblings, 0 replies; 4+ messages in thread
From: Bob Feng @ 2020-07-21  3:39 UTC (permalink / raw)
  To: devel@edk2.groups.io, Feng, Bob C, Chen, Christine

Christine,

Please update the Bugzilla 2762 status.

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bob Feng
Sent: Wednesday, July 15, 2020 8:54 AM
To: devel@edk2.groups.io; Chen, Christine <yuwei.chen@intel.com>
Subject: Re: [edk2-devel] [Patch v4] BaseTools: Add Guid name support in GenFfs.

Reviewed-by: Bob Feng<bob.c.feng@intel.com> 

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuwei Chen
Sent: Tuesday, July 14, 2020 1:31 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [Patch v4] 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.

Signed-off-by: Yuwei Chen <yuwei.chen@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 668126aaac..f86c749c08 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 8ac29eb7a6..61ab3f7e24 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 9b04a76af8..ea2401b0e4 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








^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-21  3:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-14  5:30 [Patch v4] BaseTools: Add Guid name support in GenFfs Yuwei Chen
2020-07-15  0:53 ` [edk2-devel] " Bob Feng
     [not found] ` <1621C6E7ED5B7C55.2845@groups.io>
2020-07-21  3:39   ` Bob Feng
  -- strict thread matches above, loose matches on Subject: below --
2020-07-13  7:39 Yuwei Chen
2020-07-13 14:20 ` [edk2-devel] " Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox