]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Move gPlatformFinalPcd to Datapipe and optimize size
authorLi, Yi1 <yi1.li@intel.com>
Mon, 18 Apr 2022 08:15:21 +0000 (16:15 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 22 Apr 2022 13:55:16 +0000 (13:55 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3828

This is a bugfix of
bf9230a9f3dde065c3c8b4175ccd32e44e8f0362.

1.In the current code, gPlatformFinalPcd will save all PCDs used at
whole compile process, which wastes runtime memory and is unnecessary.

This patch makes gPlatformFinalPcd save only the PCDes which are
assigned in the DSC file, and the PCD that has not been assigned will
use the default value in DEC.

2.During the compilation process, gPlatformFinalPcd may be lost, and
the current code cannot selectively assign PCD in DSC by specifying ARCH.

This patch moves gPlatformFinalPcd into datapipe and modifies the
assignment logicto fix this.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: yi1 li <yi1.li@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/AutoGen/AutoGenWorker.py
BaseTools/Source/Python/AutoGen/DataPipe.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/Workspace/InfBuildData.py
BaseTools/Source/Python/Workspace/WorkspaceCommon.py

index eea15239d42a06ba4ef8cc2db2d6832e06037399..0ba2339bed64d7ac365e76857ada09eab4bb6205 100755 (executable)
@@ -216,6 +216,7 @@ class AutoGenWorkerInProcess(mp.Process):
             GlobalData.gModuleHashFile = dict()\r
             GlobalData.gFileHashDict = dict()\r
             GlobalData.gEnableGenfdsMultiThread = self.data_pipe.Get("EnableGenfdsMultiThread")\r
+            GlobalData.gPlatformFinalPcds = self.data_pipe.Get("gPlatformFinalPcds")\r
             GlobalData.file_lock = self.file_lock\r
             CommandTarget = self.data_pipe.Get("CommandTarget")\r
             pcd_from_build_option = []\r
index 41af343f62516a7cf8cac97ef2ea62c08f50c13c..848c7a82963ea3dede29e80d7fa248c6471661ef 100755 (executable)
@@ -169,3 +169,5 @@ class MemoryDataPipe(DataPipe):
         self.DataContainer = {"BinCacheDest":GlobalData.gBinCacheDest}\r
 \r
         self.DataContainer = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}\r
+\r
+        self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}\r
index fc1e773417de26039e7840da58f1fa93312dd5cc..a9fdc5cafa064ed78cd1a6db8247876e4572ad70 100644 (file)
@@ -976,6 +976,7 @@ class DscBuildData(PlatformBuildClassObject):
         if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds:\r
             if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != ValueList[Index]:\r
                 GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = ValueList[Index]\r
+            GlobalData.gPlatformFinalPcds[TokenSpaceGuid + '.' + PcdCName] = ValueList[Index]\r
         return ValueList\r
 \r
     def _FilterPcdBySkuUsage(self, Pcds):\r
index cd23065b0c8e84a169e32e0d76fe8496843c4f94..5b9b3d7b4f014ea2f7277d7a5b7f44cec66a1f34 100644 (file)
@@ -1054,17 +1054,20 @@ class InfBuildData(ModuleBuildClassObject):
             return True\r
         return False\r
     def CheckFeatureFlagPcd(self,Instance):\r
-        Pcds = {}\r
-        if GlobalData.gPlatformFinalPcds.get(self.Arch):\r
-            Pcds = GlobalData.gPlatformFinalPcds[self.Arch].copy()\r
+        Pcds = GlobalData.gPlatformFinalPcds.copy()\r
         if PcdPattern.search(Instance):\r
             PcdTuple = tuple(Instance.split('.')[::-1])\r
             if PcdTuple in self.Pcds:\r
-                if not (self.Pcds[PcdTuple].Type == 'FeatureFlag' or self.Pcds[PcdTuple].Type == 'FixedAtBuild') and Instance not in Pcds:\r
+                if not (self.Pcds[PcdTuple].Type == 'FeatureFlag' or self.Pcds[PcdTuple].Type == 'FixedAtBuild'):\r
                     EdkLogger.error('build', FORMAT_INVALID,\r
-                                    "\nit must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file or [FeaturePcd] or [FixedPcd] of Inf file",\r
+                                    "\nFeatureFlagPcd must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file",\r
                                     File=str(self), ExtraData=Instance)\r
-                Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue\r
+                if not Instance in Pcds:\r
+                    Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue\r
+            else: #if PcdTuple not in self.Pcds:\r
+                EdkLogger.error('build', FORMAT_INVALID,\r
+                                "\nFeatureFlagPcd must be defined in [FeaturePcd] or [FixedPcd] of Inf file",\r
+                                File=str(self), ExtraData=Instance)\r
             if Instance in Pcds:\r
                 if Pcds[Instance] == '0':\r
                     return False\r
index 6564a34ba7241316f893bdb85cb9bada77a06948..53027a0e30f59a637136cd74a4c6ac94340a7e49 100644 (file)
@@ -75,11 +75,6 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalP
                         break\r
             if (PcdCName, PcdTokenName) not in DecPcds:\r
                 DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]\r
-    if not GlobalData.gPlatformFinalPcds.get(Arch):\r
-        GlobalData.gPlatformFinalPcds[Arch] = OrderedDict()\r
-    for Name,Guid in DecPcds:\r
-        if DecPcds[Name,Guid].Type == 'FeatureFlag' or DecPcds[Name, Guid].Type == 'FixedAtBuild':\r
-            GlobalData.gPlatformFinalPcds[Arch]['%s.%s'%(Guid, Name)]=DecPcds[Name, Guid].DefaultValue\r
     return DecPcds, GuidDict\r
 \r
 ## Get all dependent libraries for a module\r