]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/VpdInfoFile.py
There is a limitation on WINDOWS OS for the length of entire file path can’t be large...
[mirror_edk2.git] / BaseTools / Source / Python / Common / VpdInfoFile.py
index 0111744cc045cc6c1a344f24ac28d82494315348..1a68e9bee1725c658ae9b533ef882e248ca9b5cd 100644 (file)
@@ -6,7 +6,7 @@
 # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt \r
 #\r
 #\r
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2014, 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
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 import Common.EdkLogger as EdkLogger\r
 import Common.BuildToolError as BuildToolError\r
 import subprocess\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 FILE_COMMENT_TEMPLATE = \\r
 """\r
@@ -135,13 +136,17 @@ class VpdInfoFile:
             fd.write(FILE_COMMENT_TEMPLATE)\r
 \r
             # write each of PCD in VPD type\r
-            for Pcd in self._VpdArray.keys():\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()[0]].DefaultValue).strip()\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  \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue))\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
@@ -172,21 +177,22 @@ class VpdInfoFile:
             # the line must follow output format defined in BPDG spec.\r
             #\r
             try:\r
-                PcdName, Offset, Size, Value = Line.split("#")[0].split("|")\r
+                PcdName, SkuId,Offset, Size, Value = Line.split("#")[0].split("|")\r
+                PcdName, SkuId,Offset, Size, Value = PcdName.strip(), SkuId.strip(),Offset.strip(), Size.strip(), Value.strip()\r
                 TokenSpaceName, PcdTokenName = PcdName.split(".")\r
             except:\r
                 EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath)\r
             \r
             Found = False\r
+            \r
             for VpdObject in self._VpdArray.keys():\r
-                if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip():\r
-                    if self._VpdArray[VpdObject][0] == "*":\r
-                        if Offset == "*":\r
-                            EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)\r
-                            \r
-                        self._VpdArray[VpdObject][0] = Offset\r
-                    Found = True\r
-                    break\r
+                for sku in VpdObject.SkuInfoList.keys(): \r
+                    if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip() and sku == SkuId:\r
+                        if self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] == "*":\r
+                            if Offset == "*":\r
+                                EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)                              \r
+                            self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] = Offset\r
+                        Found = True\r
             if not Found:\r
                 EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")\r
                 \r
@@ -219,28 +225,23 @@ class VpdInfoFile:
 #  @param ToolPath      The string path name for BPDG tool\r
 #  @param VpdFileName   The string path name for VPD information guid.txt\r
 # \r
-def CallExtenalBPDGTool(ToolPath, VpdFilePath, VpdFileName):\r
+def CallExtenalBPDGTool(ToolPath, VpdFileName):\r
     assert ToolPath != None, "Invalid parameter ToolPath"\r
-    assert VpdFilePath != None and os.path.exists(VpdFilePath), "Invalid parameter VpdFileName"\r
+    assert VpdFileName != None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"\r
     \r
-    OutputDir = os.path.dirname(VpdFilePath)\r
-    if (VpdFileName == None or VpdFileName == "") :\r
-        FileName = os.path.basename(VpdFilePath)\r
-        BaseName, ext = os.path.splitext(FileName)\r
-        OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)\r
-        OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)\r
-    else :\r
-        OutputMapFileName = os.path.join(OutputDir, "%s.map" % VpdFileName)\r
-        OutputBinFileName = os.path.join(OutputDir, "%s.bin" % VpdFileName)\r
+    OutputDir = os.path.dirname(VpdFileName)\r
+    FileName = os.path.basename(VpdFileName)\r
+    BaseName, ext = os.path.splitext(FileName)\r
+    OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)\r
+    OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)\r
           \r
     try:\r
         PopenObject = subprocess.Popen([ToolPath,\r
                                         '-o', OutputBinFileName, \r
                                         '-m', OutputMapFileName,\r
-                                        '-s',\r
+                                        '-q',\r
                                         '-f',\r
-                                        '-v',\r
-                                        VpdFilePath],\r
+                                        VpdFileName],\r
                                         stdout=subprocess.PIPE, \r
                                         stderr= subprocess.PIPE)\r
     except Exception, X:\r