]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index b0801c787acc97f80076846fcd768781372ceb92..06ff84b4cdbc02d57d29d1053e7243cdc7b3f7da 100644 (file)
 ## Import Modules\r
 #\r
 from __future__ import print_function\r
+from __future__ import absolute_import\r
 import Common.LongFilePathOs as os\r
 import re\r
 import os.path as path\r
 import copy\r
 import uuid\r
 \r
-import GenC\r
-import GenMake\r
-import GenDepex\r
+from . import GenC\r
+from . import GenMake\r
+from . import GenDepex\r
 from io import BytesIO\r
 \r
-from StrGather import *\r
-from BuildEngine import BuildRule\r
+from .StrGather import *\r
+from .BuildEngine import BuildRule\r
 \r
 from Common.LongFilePathSupport import CopyLongFilePath\r
 from Common.BuildToolError import *\r
@@ -41,14 +42,14 @@ from CommonDataClass.CommonClass import SkuInfoClass
 from Workspace.BuildClassObject import *\r
 from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile\r
 import Common.VpdInfoFile as VpdInfoFile\r
-from GenPcdDb import CreatePcdDatabaseCode\r
+from .GenPcdDb import CreatePcdDatabaseCode\r
 from Workspace.MetaFileCommentParser import UsageList\r
 from Workspace.WorkspaceCommon import GetModuleLibInstances\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
-import InfSectionParser\r
+from . import InfSectionParser\r
 import datetime\r
 import hashlib\r
-from GenVar import VariableMgr, var_info\r
+from .GenVar import VariableMgr, var_info\r
 from collections import OrderedDict\r
 from collections import defaultdict\r
 from Workspace.WorkspaceCommon import OrderedListDict\r
@@ -568,7 +569,7 @@ class WorkspaceAutoGen(AutoGen):
                     DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2]))\r
 \r
             Platform.SkuName = self.SkuId\r
-            for Name, Guid in PcdSet:\r
+            for Name, Guid,Fileds in PcdSet:\r
                 if (Name, Guid) not in DecPcds:\r
                     EdkLogger.error(\r
                         'build',\r
@@ -582,7 +583,6 @@ class WorkspaceAutoGen(AutoGen):
                     if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \\r
                         or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in DecPcdsKey \\r
                         or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecPcdsKey:\r
-                        Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r
                         continue\r
                     elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:\r
                         EdkLogger.error(\r
@@ -1292,13 +1292,18 @@ class PlatformAutoGen(AutoGen):
             FixedAtBuildPcds = {}\r
             ShareFixedAtBuildPcdsSameValue = {}\r
             for Module in LibAuto._ReferenceModules:\r
-                for Pcd in Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds:\r
+                for Pcd in set(Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds):\r
+                    DefaultValue = Pcd.DefaultValue\r
+                    # Cover the case: DSC component override the Pcd value and the Pcd only used in one Lib\r
+                    if Pcd in Module.LibraryPcdList:\r
+                        Index = Module.LibraryPcdList.index(Pcd)\r
+                        DefaultValue = Module.LibraryPcdList[Index].DefaultValue\r
                     key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
                     if key not in FixedAtBuildPcds:\r
                         ShareFixedAtBuildPcdsSameValue[key] = True\r
-                        FixedAtBuildPcds[key] = Pcd.DefaultValue\r
+                        FixedAtBuildPcds[key] = DefaultValue\r
                     else:\r
-                        if FixedAtBuildPcds[key] != Pcd.DefaultValue:\r
+                        if FixedAtBuildPcds[key] != DefaultValue:\r
                             ShareFixedAtBuildPcdsSameValue[key] = False\r
             for Pcd in LibAuto.FixedAtBuildPcds:\r
                 key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
@@ -2747,6 +2752,10 @@ class ModuleAutoGen(AutoGen):
         self._FixedAtBuildPcds         = []\r
         self.ConstPcd                  = {}\r
 \r
+        ##Store the VOID* type FixedAtBuild Pcds\r
+        #\r
+        self._FixedPcdVoidTypeDict = {}\r
+\r
     def __repr__(self):\r
         return "%s [%s]" % (self.MetaFile, self.Arch)\r
 \r
@@ -2762,6 +2771,15 @@ class ModuleAutoGen(AutoGen):
 \r
         return self._FixedAtBuildPcds\r
 \r
+    def _GetFixedAtBuildVoidTypePcds(self):\r
+        if self._FixedPcdVoidTypeDict:\r
+            return self._FixedPcdVoidTypeDict\r
+        for Pcd in self.ModulePcdList:\r
+            if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType == TAB_VOID:\r
+                if '{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName) not in self._FixedPcdVoidTypeDict:\r
+                    self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)] = Pcd.DefaultValue\r
+        return self._FixedPcdVoidTypeDict\r
+\r
     def _GetUniqueBaseName(self):\r
         BaseName = self.Name\r
         for Module in self.PlatformInfo.ModuleAutoGenList:\r
@@ -3031,7 +3049,7 @@ class ModuleAutoGen(AutoGen):
                 return self._DepexDict\r
 \r
             self._DepexDict[self.ModuleType] = []\r
-\r
+            self._GetFixedAtBuildVoidTypePcds()\r
             for ModuleType in self._DepexDict:\r
                 DepexList = self._DepexDict[ModuleType]\r
                 #\r
@@ -3043,7 +3061,21 @@ class ModuleAutoGen(AutoGen):
                         if DepexList != []:\r
                             DepexList.append('AND')\r
                         DepexList.append('(')\r
-                        DepexList.extend(D)\r
+                        #replace D with value if D is FixedAtBuild PCD\r
+                        NewList = []\r
+                        for item in D:\r
+                            if '.' not in item:\r
+                                NewList.append(item)\r
+                            else:\r
+                                if item not in self._FixedPcdVoidTypeDict:\r
+                                    EdkLogger.error("build", FORMAT_INVALID, "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type in the module.".format(item))\r
+                                else:\r
+                                    Value = self._FixedPcdVoidTypeDict[item]\r
+                                    if len(Value.split(',')) != 16:\r
+                                        EdkLogger.error("build", FORMAT_INVALID,\r
+                                                        "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the module.".format(item))\r
+                                    NewList.append(Value)\r
+                        DepexList.extend(NewList)\r
                         if DepexList[-1] == 'END':  # no need of a END at this time\r
                             DepexList.pop()\r
                         DepexList.append(')')\r
@@ -4309,11 +4341,14 @@ class ModuleAutoGen(AutoGen):
     def CanSkipbyHash(self):\r
         if GlobalData.gUseHashCache:\r
             return not self.GenModuleHash()\r
+        return False\r
 \r
     ## Decide whether we can skip the ModuleAutoGen process\r
     #  If any source file is newer than the module than we cannot skip\r
     #\r
     def CanSkip(self):\r
+        if self.MakeFileDir in GlobalData.gSikpAutoGenCache:\r
+            return True\r
         if not os.path.exists(self.GetTimeStampPath()):\r
             return False\r
         #last creation time of the module\r
@@ -4332,6 +4367,7 @@ class ModuleAutoGen(AutoGen):
                     ModuleAutoGen.TimeDict[source] = os.stat(source)[8]\r
                 if ModuleAutoGen.TimeDict[source] > DstTimeStamp:\r
                     return False\r
+        GlobalData.gSikpAutoGenCache.add(self.MakeFileDir)\r
         return True\r
 \r
     def GetTimeStampPath(self):\r
@@ -4411,6 +4447,7 @@ class ModuleAutoGen(AutoGen):
 \r
     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)\r
     UniqueBaseName          = property(_GetUniqueBaseName)\r
+    FixedVoidTypePcds       = property(_GetFixedAtBuildVoidTypePcds)\r
 \r
 # This acts like the main() function for the script, unless it is 'import'ed into another script.\r
 if __name__ == '__main__':\r