summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorMark O'Neill <moneill@cayan.com>2018-12-04 12:35:35 (GMT)
committerMark O'Neill <moneill@cayan.com>2018-12-06 16:53:06 (GMT)
commit2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42 (patch)
tree837ad46202f512e1ec8693bfa1bdf5e1967a0415 /Source/cmLocalNinjaGenerator.cxx
parent2295040e85321911d65bd36704560725d9c2ad27 (diff)
downloadCMake-2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42.zip
CMake-2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42.tar.gz
CMake-2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42.tar.bz2
cmLocalNinjaGenerator: Report line of failure in ninja generated batch file
Fixes: 18676
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r--Source/cmLocalNinjaGenerator.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index ecea4ea..c88432b 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -318,7 +318,9 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
cmsys::ofstream script(scriptPath.c_str());
-#ifndef _WIN32
+#ifdef _WIN32
+ int line = 1;
+#else
script << "set -e\n\n";
#endif
@@ -329,12 +331,22 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
// for the raw shell script.
cmSystemTools::ReplaceString(cmd, "$$", "$");
#ifdef _WIN32
- script << cmd << " || exit /b 1" << '\n';
+ script << cmd << " || (set FAIL_LINE=" << ++line << "& goto :ABORT)"
+ << '\n';
#else
script << cmd << '\n';
#endif
}
+#ifdef _WIN32
+ script << "goto :EOF\n\n"
+ ":ABORT\n"
+ "set ERROR_CODE=%ERRORLEVEL%\n"
+ "echo Batch file failed at line %FAIL_LINE% "
+ "with errorcode %ERRORLEVEL%\n"
+ "exit /b %ERROR_CODE%";
+#endif
+
return scriptPath;
}