BaseTools: Add error message if Structure PCD value is wrong
authorLiming Gao <liming.gao@intel.com>
Fri, 15 Dec 2017 04:12:58 +0000 (12:12 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 25 Dec 2017 03:05:51 +0000 (11:05 +0800)
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Workspace/DscBuildData.py

index a2979ce..d8a7d09 100644 (file)
@@ -1264,7 +1264,7 @@ class DscBuildData(PlatformBuildClassObject):
             CApp = CApp + '{\n'\r
             CApp = CApp + '  UINT32  Size;\n'\r
             CApp = CApp + '  UINT32  FieldSize;\n'\r
-            CApp = CApp + '  UINT8   *Value;\n'\r
+            CApp = CApp + '  CHAR8   *Value;\n'\r
             CApp = CApp + '  UINT32  OriginalSize;\n'\r
             CApp = CApp + '  VOID    *OriginalPcd;\n'\r
             CApp = CApp + '  %s      *Pcd;\n' % (Pcd.DatumType)\r
@@ -1434,7 +1434,7 @@ class DscBuildData(PlatformBuildClassObject):
         else:\r
             MakeApp = MakeApp + PcdGccMakefile\r
             MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \\r
-                      'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'BUILD_CFLAGS += -Wno-error\n' + 'INCLUDE +='\r
+                      'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable\n' + 'INCLUDE +='\r
 \r
         PlatformInc = {}\r
         for Cache in self._Bdb._CACHE_.values():\r
@@ -1472,11 +1472,43 @@ class DscBuildData(PlatformBuildClassObject):
         File.write(InitByteValue)\r
         File.close()\r
 \r
+        Messages = ''\r
         if sys.platform == "win32":\r
             StdOut, StdErr = self.ExecuteCommand ('nmake clean & nmake -f %s' % (MakeFileName))\r
+            Messages = StdOut\r
         else:\r
             StdOut, StdErr = self.ExecuteCommand ('make clean & make -f %s' % (MakeFileName))\r
-        Messages = StdOut.split('\r')\r
+            Messages = StdErr\r
+        Messages = Messages.split('\n')\r
+        for Message in Messages:\r
+            if " error" in Message:\r
+                FileInfo = Message.strip().split('(')\r
+                if len (FileInfo) > 1:\r
+                    FileName = FileInfo [0]\r
+                    FileLine = FileInfo [1].split (')')[0]\r
+                else:\r
+                    FileInfo = Message.strip().split(':')\r
+                    FileName = FileInfo [0]\r
+                    FileLine = FileInfo [1]\r
+\r
+                File = open (FileName, 'r')\r
+                FileData = File.readlines()\r
+                File.close()\r
+                error_line = FileData[int (FileLine) - 1]\r
+                if r"//" in error_line:\r
+                    c_line,dsc_line = error_line.split(r"//")\r
+                else:\r
+                    dsc_line = error_line\r
+\r
+                message_itmes = Message.split(":")\r
+                Index = 0\r
+                for item in message_itmes:\r
+                    if "PcdValueInit.c" in item:\r
+                        Index = message_itmes.index(item)\r
+                        message_itmes[Index] = dsc_line.strip()\r
+                        break\r
+\r
+                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, ":".join(message_itmes[Index:]))\r
 \r
         PcdValueInitExe = PcdValueInitName\r
         if not sys.platform == "win32":\r