]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: PcdDataBase Optimization for multiple SkuIds
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 008ad8ebc3ccdee3666dad91db942e9c4d8f5a44..5d6cce0dbb535a20050ee7c93d048fff7676f1b6 100644 (file)
@@ -44,6 +44,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
 import InfSectionParser\r
 import datetime\r
 import hashlib\r
+from GenVar import VariableMgr,var_info\r
 \r
 ## Regular expression for splitting Dependency Expression string into tokens\r
 gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r
@@ -316,8 +317,8 @@ class WorkspaceAutoGen(AutoGen):
 \r
         EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)\r
 \r
-        if Progress:\r
-            Progress.Start("\nProcessing meta-data")\r
+        if Progress:\r
+            Progress.Start("\nProcessing meta-data")\r
 \r
         if self.FdfFile:\r
             #\r
@@ -686,9 +687,6 @@ class WorkspaceAutoGen(AutoGen):
             content += 'Flash Image Definition: '\r
             content += str(self.FdfFile)\r
             content += os.linesep\r
-        if GlobalData.gBinCacheDest:\r
-            content += 'Cache of .efi location: '\r
-            content += str(GlobalData.gBinCacheDest)\r
         SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False)\r
 \r
         #\r
@@ -1227,6 +1225,7 @@ class PlatformAutoGen(AutoGen):
         self.AllPcdList = []\r
         # get the original module/package/platform objects\r
         self.BuildDatabase = Workspace.BuildDatabase\r
+        self.DscBuildDataObj = Workspace.Platform\r
 \r
         # flag indicating if the makefile/C-code file has been created or not\r
         self.IsMakeFileCreated  = False\r
@@ -1307,12 +1306,15 @@ class PlatformAutoGen(AutoGen):
     #   @param      CreateModuleMakeFile    Flag indicating if the makefile for\r
     #                                       modules will be created as well\r
     #\r
-    def CreateMakeFile(self, CreateModuleMakeFile=False):\r
+    def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r
         if CreateModuleMakeFile:\r
             for ModuleFile in self.Platform.Modules:\r
                 Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
                                    self.ToolChain, self.Arch, self.MetaFile)\r
-                Ma.CreateMakeFile(True)\r
+                if (ModuleFile.File, self.Arch) in FfsCommand:\r
+                    Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r
+                else:\r
+                    Ma.CreateMakeFile(True)\r
                 #Ma.CreateAsBuiltInf()\r
 \r
         # no need to create makefile for the platform more than once\r
@@ -1352,6 +1354,24 @@ class PlatformAutoGen(AutoGen):
                 if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]:                    \r
                     LibAuto.ConstPcd[key] = Pcd.DefaultValue\r
 \r
+    def CollectVariables(self, DynamicPcdSet):\r
+        VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(),self.DscBuildDataObj._GetSkuIds())\r
+        Index = 0\r
+        for Pcd in DynamicPcdSet:\r
+            pcdname = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r
+            for SkuName in Pcd.SkuInfoList:\r
+                Sku = Pcd.SkuInfoList[SkuName]\r
+                SkuId = Sku.SkuId\r
+                if SkuId == None or SkuId == '':\r
+                    continue\r
+                if len(Sku.VariableName) > 0:\r
+                    VariableGuidStructure = Sku.VariableGuidValue\r
+                    VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)\r
+                    if Pcd.Phase == "DXE":\r
+                        for StorageName in Sku.DefaultStoreDict:\r
+                            VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableAttribute , Pcd.DefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))\r
+            Index += 1\r
+        return VariableInfo\r
     ## Collect dynamic PCDs\r
     #\r
     #  Gather dynamic PCDs list from each module and their settings from platform\r
@@ -1557,12 +1577,19 @@ class PlatformAutoGen(AutoGen):
             if pcd not in self._PlatformPcds.keys():\r
                 self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r
 \r
+        for item in self._PlatformPcds:\r
+            if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+                self._PlatformPcds[item].DatumType = "VOID*"\r
+\r
         if (self.Workspace.ArchList[-1] == self.Arch): \r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
                 Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
 \r
+                if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+                    Pcd.DatumType = "VOID*"\r
+\r
                 PcdValue = Sku.DefaultValue\r
                 if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
                     # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
@@ -1575,6 +1602,20 @@ class PlatformAutoGen(AutoGen):
                 if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
                     VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd\r
 \r
+            #Collect DynamicHii PCD values and assign it to DynamicExVpd PCD gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer\r
+            PcdNvStoreDfBuffer = VpdPcdDict.get(("PcdNvStoreDefaultValueBuffer","gEfiMdeModulePkgTokenSpaceGuid"))\r
+            if PcdNvStoreDfBuffer:\r
+                var_info = self.CollectVariables(self._DynamicPcdList)\r
+                default_skuobj = PcdNvStoreDfBuffer.SkuInfoList.get("DEFAULT")\r
+                vardump = var_info.dump()\r
+                if vardump:\r
+                    default_skuobj.DefaultValue = vardump\r
+                    PcdNvStoreDfBuffer.DefaultValue = vardump\r
+                if default_skuobj:\r
+                    PcdNvStoreDfBuffer.SkuInfoList.clear()\r
+                    PcdNvStoreDfBuffer.SkuInfoList['DEFAULT'] = default_skuobj\r
+                    PcdNvStoreDfBuffer.MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))\r
+\r
             PlatformPcds = self._PlatformPcds.keys()\r
             PlatformPcds.sort()\r
             #\r
@@ -1751,6 +1792,13 @@ class PlatformAutoGen(AutoGen):
         self._DynamicPcdList.extend(UnicodePcdArray)\r
         self._DynamicPcdList.extend(HiiPcdArray)\r
         self._DynamicPcdList.extend(OtherPcdArray)\r
+        allskuset = [(SkuName,Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName,Sku) in pcd.SkuInfoList.items()]\r
+        for pcd in self._DynamicPcdList:\r
+            if len(pcd.SkuInfoList) == 1:\r
+                for (SkuName,SkuId) in allskuset:\r
+                    if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0:\r
+                        continue\r
+                    pcd.SkuInfoList[SkuName] = pcd.SkuInfoList['DEFAULT']\r
         self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
         \r
     ## Return the platform build data object\r
@@ -2344,7 +2392,7 @@ class PlatformAutoGen(AutoGen):
             else:\r
                 SkuName = 'DEFAULT'\r
             ToPcd.SkuInfoList = {\r
-                SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName], '', '', '', '', '', ToPcd.DefaultValue)\r
+                SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)\r
             }\r
 \r
     ## Apply PCD setting defined platform to a module\r
@@ -2760,6 +2808,7 @@ class ModuleAutoGen(AutoGen):
 \r
         self._BuildDir        = None\r
         self._OutputDir       = None\r
+        self._FfsOutputDir    = None\r
         self._DebugDir        = None\r
         self._MakeFileDir     = None\r
 \r
@@ -2876,6 +2925,7 @@ class ModuleAutoGen(AutoGen):
             self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir\r
             self._Macro["PLATFORM_DIR"          ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)\r
             self._Macro["PLATFORM_OUTPUT_DIR"   ] = self.PlatformInfo.OutputDir\r
+            self._Macro["FFS_OUTPUT_DIR"        ] = self.FfsOutputDir\r
         return self._Macro\r
 \r
     ## Return the module build data object\r
@@ -2966,6 +3016,15 @@ class ModuleAutoGen(AutoGen):
             CreateDirectory(self._OutputDir)\r
         return self._OutputDir\r
 \r
+    ## Return the directory to store ffs file\r
+    def _GetFfsOutputDir(self):\r
+        if self._FfsOutputDir == None:\r
+            if GlobalData.gFdfParser != None:\r
+                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)\r
+            else:\r
+                self._FfsOutputDir = ''\r
+        return self._FfsOutputDir\r
+\r
     ## Return the directory to store auto-gened source files of the mdoule\r
     def _GetDebugDir(self):\r
         if self._DebugDir == None:\r
@@ -3827,7 +3886,13 @@ class ModuleAutoGen(AutoGen):
 \r
     ## Create AsBuilt INF file the module\r
     #\r
-    def CreateAsBuiltInf(self):\r
+    def CreateAsBuiltInf(self, IsOnlyCopy = False):\r
+        self.OutputFile = []\r
+        if IsOnlyCopy:\r
+            if GlobalData.gBinCacheDest:\r
+                self.CopyModuleToCache()\r
+                return\r
+\r
         if self.IsAsBuiltInfCreated:\r
             return\r
             \r
@@ -3960,7 +4025,6 @@ class ModuleAutoGen(AutoGen):
             AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
 \r
         OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r
-        self.OutputFile = []\r
         for Item in self.CodaTargetList:\r
             File = Item.Target.Path.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r
             if File not in self.OutputFile:\r
@@ -4043,7 +4107,7 @@ class ModuleAutoGen(AutoGen):
                     elif BoolValue == 'FALSE':\r
                         Pcd.DefaultValue = '0'\r
 \r
-                if Pcd.DatumType != 'VOID*':\r
+                if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:\r
                     HexFormat = '0x%02x'\r
                     if Pcd.DatumType == 'UINT16':\r
                         HexFormat = '0x%04x'\r
@@ -4187,8 +4251,12 @@ class ModuleAutoGen(AutoGen):
             shutil.copy2(HashFile, FileDir)\r
         if os.path.exists(ModuleFile):\r
             shutil.copy2(ModuleFile, FileDir)\r
+        if not self.OutputFile:\r
+            Ma = self.Workspace.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r
+            self.OutputFile = Ma.Binaries\r
         if self.OutputFile:\r
             for File in self.OutputFile:\r
+                File = str(File)\r
                 if not os.path.isabs(File):\r
                     File = os.path.join(self.OutputDir, File)\r
                 if os.path.exists(File):\r
@@ -4222,14 +4290,14 @@ class ModuleAutoGen(AutoGen):
     #   @param      CreateLibraryMakeFile   Flag indicating if or not the makefiles of\r
     #                                       dependent libraries will be created\r
     #\r
-    def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+    def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):\r
         # Ignore generating makefile when it is a binary module\r
         if self.IsBinaryModule:\r
             return\r
 \r
         if self.IsMakeFileCreated:\r
             return\r
-\r
+        self.GenFfsList = GenFfsList\r
         if not self.IsLibrary and CreateLibraryMakeFile:\r
             for LibraryAutoGen in self.LibraryAutoGenList:\r
                 LibraryAutoGen.CreateMakeFile()\r
@@ -4457,6 +4525,7 @@ class ModuleAutoGen(AutoGen):
     IsBinaryModule  = property(_IsBinaryModule)\r
     BuildDir        = property(_GetBuildDir)\r
     OutputDir       = property(_GetOutputDir)\r
+    FfsOutputDir    = property(_GetFfsOutputDir)\r
     DebugDir        = property(_GetDebugDir)\r
     MakeFileDir     = property(_GetMakeFileDir)\r
     CustomMakefile  = property(_GetCustomMakefile)\r