From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.13986.1594704642579791351 for ; Mon, 13 Jul 2020 22:30:42 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: yuwei.chen@intel.com) IronPort-SDR: 1w9WOx03IlGIEoZ8sTbAALxg22zqsO4TbziYCg6iYp0eeCcyqrJmFn/LwzOMtAhHQfxpDtUYke WJ7bhq0mT3VA== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="233663547" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="233663547" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 22:30:41 -0700 IronPort-SDR: Y95dMDz/1XElXqv/e7V7u2HKH1QIEkVsrPGlcsjwqND1/beGnx52D+N+a6de7PEOZOK0aNdJUh 2AAy+RZGImCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="459558476" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.23]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2020 22:30:40 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Subject: [Patch v4] BaseTools: Add Guid name support in GenFfs. Date: Tue, 14 Jul 2020 13:30:40 +0800 Message-Id: <20200714053040.1561-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- .../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