"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
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
# 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
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
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