]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:Incremental build not work if VPD values in DSC changed by -D
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 29 Jan 2016 04:48:55 +0000 (04:48 +0000)
committeryzhu52 <yzhu52@Edk2>
Fri, 29 Jan 2016 04:48:55 +0000 (04:48 +0000)
If a -D flag is passed into build that selects different lines in
[PcdsDynamicExVpd], then build does not see any changes to the timestamp
of the DSC file and the VPD tool is not used to regenerate the VPD
region based in the statements that are active. so we changed the detect
condition and use SaveFileOnChange function to generate VPD.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19767 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/Common/VpdInfoFile.py

index 55a59dabc07e917cd2796ffc10a62ff6ff9ed216..776743a710726e32ce5c02c19bb537adebbe9cbb 100644 (file)
@@ -1256,7 +1256,6 @@ class PlatformAutoGen(AutoGen):
                                 "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r
 \r
             if VpdFile.GetCount() != 0:\r
-                DscTimeStamp = self.Platform.MetaFile.TimeStamp\r
                 FvPath = os.path.join(self.BuildDir, "FV")\r
                 if not os.path.exists(FvPath):\r
                     try:\r
@@ -1264,13 +1263,9 @@ class PlatformAutoGen(AutoGen):
                     except:\r
                         EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
 \r
-\r
                 VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
 \r
-\r
-                if not os.path.exists(VpdFilePath) or os.path.getmtime(VpdFilePath) < DscTimeStamp:\r
-                    VpdFile.Write(VpdFilePath)\r
-\r
+                if VpdFile.Write(VpdFilePath):\r
                     # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r
                     BPDGToolName = None\r
                     for ToolDef in self.ToolDefinition.values():\r
index 1a68e9bee1725c658ae9b533ef882e248ca9b5cd..dc8ece9608a83111fb48a09a150a59eea7bf86fa 100644 (file)
@@ -6,7 +6,7 @@
 # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt \r
 #\r
 #\r
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -21,6 +21,7 @@ import Common.EdkLogger as EdkLogger
 import Common.BuildToolError as BuildToolError\r
 import subprocess\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.Misc import SaveFileOnChange\r
 \r
 FILE_COMMENT_TEMPLATE = \\r
 """\r
@@ -124,34 +125,21 @@ class VpdInfoFile:
         if not (FilePath != None or len(FilePath) != 0):\r
             EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,  \r
                             "Invalid parameter FilePath: %s." % FilePath)        \r
-        try:\r
-            fd = open(FilePath, "w")\r
-        except:\r
-            EdkLogger.error("VpdInfoFile", \r
-                            BuildToolError.FILE_OPEN_FAILURE, \r
-                            "Fail to open file %s for written." % FilePath)\r
-        \r
-        try:\r
-            # write file header\r
-            fd.write(FILE_COMMENT_TEMPLATE)\r
 \r
-            # write each of PCD in VPD type\r
-            Pcds = self._VpdArray.keys()\r
-            Pcds.sort()\r
-            for Pcd in Pcds:\r
-                i = 0\r
-                for Offset in self._VpdArray[Pcd]:\r
-                    PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[i]].DefaultValue).strip()\r
-                    if PcdValue == "" :\r
-                        PcdValue  = Pcd.DefaultValue\r
-                        \r
-                    fd.write("%s.%s|%s|%s|%s|%s  \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Pcd.SkuInfoList.keys()[i]),str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue))\r
-                    i += 1\r
-        except:\r
-            EdkLogger.error("VpdInfoFile",\r
-                            BuildToolError.FILE_WRITE_FAILURE,\r
-                            "Fail to write file %s" % FilePath) \r
-        fd.close()\r
+        Content = FILE_COMMENT_TEMPLATE\r
+        Pcds = self._VpdArray.keys()\r
+        Pcds.sort()\r
+        for Pcd in Pcds:\r
+            i = 0\r
+            for Offset in self._VpdArray[Pcd]:\r
+                PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[i]].DefaultValue).strip()\r
+                if PcdValue == "" :\r
+                    PcdValue  = Pcd.DefaultValue\r
+\r
+                Content += "%s.%s|%s|%s|%s|%s  \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Pcd.SkuInfoList.keys()[i]),str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue)\r
+                i += 1\r
+\r
+        return SaveFileOnChange(FilePath, Content, False)\r
 \r
     ## Read an existing VPD PCD info file.\r
     #\r