From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.14493.1594625956842993844 for ; Mon, 13 Jul 2020 00:39:17 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: yuwei.chen@intel.com) IronPort-SDR: kLDYwA6iwxxmPsU7YXR9qVVwaSN9XI9Q6I/rUwlT+3MnbDScfnJGLopLsHbMwT7yJasKC2Fp8H TFVKlC1hsyYg== X-IronPort-AV: E=McAfee;i="6000,8403,9680"; a="146605109" X-IronPort-AV: E=Sophos;i="5.75,346,1589266800"; d="scan'208";a="146605109" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 00:39:15 -0700 IronPort-SDR: PeLn/XVu5FTyJNmJwWBwOQ98/ADxs0tlM4fLP3zI3zk8eG8kb9Ijd8RwdPTBOCFTuvXPTnVCHz YbVUiVuyKl0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,346,1589266800"; d="scan'208";a="315982947" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.23]) by orsmga008.jf.intel.com with ESMTP; 13 Jul 2020 00:39:13 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [Patch v4] BaseTools: Add Guid name support in GenFfs. Date: Mon, 13 Jul 2020 15:39:13 +0800 Message-Id: <20200713073913.1970-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2762 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 Cc: Bob Feng Cc: Liming Gao --- .../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/BaseTool= s/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=0D #=0D GlobalData.gAutoGenPhase =3D True=0D + #=0D + # Collect Platform Guids to support Guid name in Fdfparser.=0D + #=0D + self.CollectPlatformGuids()=0D self.ProcessModuleFromPdf()=0D self.ProcessPcdType()=0D self.ProcessMixedPcd()=0D @@ -153,6 +157,26 @@ class WorkspaceAutoGen(AutoGen): EdkLogger.error("build", PARAMETER_INVALID,=0D ExtraData=3D"Build target [%s] is not supporte= d by the platform. [Valid target: %s]"=0D % (self.BuildTarget, " ".join(self.P= latform.BuildTargets)))=0D +=0D + def CollectPlatformGuids(self):=0D + oriInfList =3D []=0D + oriPkgSet =3D set()=0D + PlatformPkg =3D set()=0D + for Arch in self.ArchList:=0D + Platform =3D self.BuildDatabase[self.MetaFile, Arch, self.Buil= dTarget, self.ToolChain]=0D + oriInfList =3D Platform.Modules=0D + for ModuleFile in oriInfList:=0D + ModuleData =3D self.BuildDatabase[ModuleFile, Platform._Ar= ch, Platform._Target, Platform._Toolchain]=0D + oriPkgSet.update(ModuleData.Packages)=0D + for Pkg in oriPkgSet:=0D + Guids =3D Pkg.Guids=0D + GlobalData.gGuidDict.update(Guids)=0D + if Platform.Packages:=0D + PlatformPkg.update(Platform.Packages)=0D + for Pkg in PlatformPkg:=0D + Guids =3D Pkg.Guids=0D + GlobalData.gGuidDict.update(Guids)=0D +=0D @cached_property=0D def FdfProfile(self):=0D if not self.FdfFile:=0D diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/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 =3D '' gBuildingModule =3D ''=0D gSkuids =3D []=0D gDefaultStores =3D []=0D +gGuidDict =3D {}=0D =0D # definition for a MACRO name. used to create regular expressions below.= =0D _MacroNamePattern =3D "[A-Z][A-Z0-9_]*"=0D 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 =0D from Common.BuildToolError import *=0D from Common import EdkLogger=0D -from Common.Misc import PathClass, tdict, ProcessDuplicatedInf=0D +from Common.Misc import PathClass, tdict, ProcessDuplicatedInf, GuidStruct= ureStringToGuidString=0D from Common.StringUtils import NormPath, ReplaceMacro=0D from Common import GlobalData=0D from Common.Expression import *=0D @@ -1087,6 +1087,8 @@ class FdfParser: return False=0D if GlobalData.gGuidPattern.match(self._Token) is not None:=0D return True=0D + elif self._Token in GlobalData.gGuidDict:=0D + return True=0D else:=0D self._UndoToken()=0D return False=0D @@ -2248,6 +2250,8 @@ class FdfParser: =0D if not self._GetNextGuid():=0D raise Warning.Expected("GUID value", self.FileName, self.Curre= ntLineNumber)=0D + if self._Token in GlobalData.gGuidDict:=0D + self._Token =3D GuidStructureStringToGuidString(GlobalData.gGu= idDict[self._Token]).upper()=0D =0D FvObj.FvNameGuid =3D self._Token=0D =0D @@ -2459,6 +2463,8 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber)=0D if not self._GetNextGuid():=0D raise Warning.Expected("GUID value", self.FileName, self.C= urrentLineNumber)=0D + if self._Token in GlobalData.gGuidDict:=0D + self._Token =3D GuidStructureStringToGuidString(GlobalData= .gGuidDict[self._Token]).upper()=0D FfsInfObj.OverrideGuid =3D self._Token=0D =0D if self._IsKeyword("RuleOverride"):=0D @@ -2550,6 +2556,8 @@ class FdfParser: raise Warning.Expected("')'", self.FileName, self.Curr= entLineNumber)=0D self._Token =3D 'PCD('+PcdPair[1]+TAB_SPLIT+PcdPair[0]+')'= =0D =0D + if self._Token in GlobalData.gGuidDict:=0D + self._Token =3D GuidStructureStringToGuidString(GlobalData.gGu= idDict[self._Token]).upper()=0D FfsFileObj.NameGuid =3D self._Token=0D =0D self._GetFilePart(FfsFileObj)=0D @@ -2980,6 +2988,8 @@ class FdfParser: elif self._IsKeyword("GUIDED"):=0D GuidValue =3D None=0D if self._GetNextGuid():=0D + if self._Token in GlobalData.gGuidDict:=0D + self._Token =3D GuidStructureStringToGuidString(Global= Data.gGuidDict[self._Token]).upper()=0D GuidValue =3D self._Token=0D =0D AttribDict =3D self._GetGuidAttrib()=0D @@ -4049,6 +4059,8 @@ class FdfParser: elif self._IsKeyword("GUIDED"):=0D GuidValue =3D None=0D if self._GetNextGuid():=0D + if self._Token in GlobalData.gGuidDict:=0D + self._Token =3D GuidStructureStringToGuidString(Global= Data.gGuidDict[self._Token]).upper()=0D GuidValue =3D self._Token=0D =0D if self._IsKeyword("$(NAMED_GUID)"):=0D --=20 2.27.0.windows.1