]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: enhance error handling for DSC file
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 15 Apr 2016 08:46:48 +0000 (16:46 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 19 Apr 2016 10:32:35 +0000 (18:32 +0800)
Add logic for DSC file validation for Prebuild init. Add logic to detect
error for DSC parser when '{' is missing.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
BaseTools/Source/Python/build/build.py

index 3b6a3c0dfa5cf2a25162bcb99bb5d4946449f81a..2811fd1ba31e62bdb0cb5330cbac6f999266f20c 100644 (file)
@@ -915,6 +915,8 @@ class DscParser(MetaFileParser):
             elif Line[0] == '!':\r
                 self._DirectiveParser()\r
                 continue\r
+            if Line[0] == TAB_OPTION_START and not self._InSubsection:\r
+                EdkLogger.error("Parser", FILE_READ_FAILURE, "Missing the '{' before %s in Line %s" % (Line, Index+1),ExtraData=self.MetaFile)\r
 \r
             if self._InSubsection:\r
                 SectionType = self._SubsectionType\r
index 34bc48a0d35994ea012752c5eb8a06d72e2be8b4..6c548ac7090deb13c8f23322cc3f3e5025212b2f 100644 (file)
@@ -3012,10 +3012,9 @@ determine whether database file is out of date!\n")
         return PlatformList\r
 \r
     def _MapPlatform(self, Dscfile):\r
-        try:\r
-            Platform = self.BuildObject[PathClass(Dscfile), 'COMMON']\r
-        except:\r
-            Platform = None\r
+        Platform = self.BuildObject[PathClass(Dscfile), 'COMMON']\r
+        if Platform == None:\r
+            EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile)\r
         return Platform\r
 \r
     PlatformList = property(_GetPlatformList)\r
index 37ce8e16aa9d5aa24857a5a3db7f01315aeddab7..07891dafdb40ae3742acac7e94c42401cf1cce26 100644 (file)
@@ -920,6 +920,9 @@ class Build():
 \r
     def InitPreBuild(self):\r
         self.LoadConfiguration()\r
+        ErrorCode, ErrorInfo = self.PlatformFile.Validate(".dsc", False)\r
+        if ErrorCode != 0:\r
+            EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)\r
         if self.BuildTargetList:\r
             GlobalData.gGlobalDefines['TARGET'] = self.BuildTargetList[0]\r
         if self.ArchList:\r