]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance error handling for external tool.
authorYingke Liu <yingke.d.liu@intel.com>
Mon, 1 Dec 2014 08:22:07 +0000 (08:22 +0000)
committeryingke <yingke@Edk2>
Mon, 1 Dec 2014 08:22:07 +0000 (08:22 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yingke Liu <yingke.d.liu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16458 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/GenFds/GuidSection.py

index 0e5bb3b27072289c43c58e1de59fd0e4047ccaf4..006cf0f2169bb7ce2ea754fcc0a769d081c8bb2d 100644 (file)
@@ -159,6 +159,13 @@ class GuidSection(GuidSectionClassObject) :
                        SecNum     + \\r
                        '.tmp'\r
             TempFile = os.path.normpath(TempFile)\r
+            #\r
+            # Remove temp file if its time stamp is older than dummy file\r
+            # Just in case the external tool fails at this time but succeeded before\r
+            # Error should be reported if the external tool does not generate a new output based on new input\r
+            #\r
+            if os.path.exists(TempFile) and os.path.exists(DummyFile) and os.path.getmtime(TempFile) < os.path.getmtime(DummyFile):\r
+                os.remove(TempFile)\r
 \r
             FirstCall = False\r
             CmdOption = '-e'\r
@@ -183,6 +190,12 @@ class GuidSection(GuidSectionClassObject) :
                 FirstCall = False\r
                 ReturnValue[0] = 0\r
                 GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)\r
+            #\r
+            # There is external tool which does not follow standard rule which return nonzero if tool fails\r
+            # The output file has to be checked\r
+            #\r
+            if not os.path.exists(TempFile):\r
+                EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %s, no output file was generated' % ExternalTool)\r
 \r
             FileHandleIn = open(DummyFile,'rb')\r
             FileHandleIn.seek(0,2)\r
@@ -257,6 +270,7 @@ class GuidSection(GuidSectionClassObject) :
 \r
         ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary\r
         ToolPathTmp = None\r
+        ToolOption = None\r
         for ToolDef in ToolDefinition.items():\r
             if self.NameGuid == ToolDef[1]:\r
                 KeyList = ToolDef[0].split('_')\r