mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
cmLocalNinjaGenerator: Report line of failure in ninja generated batch file
Fixes: 18676
This commit is contained in:
1 parent
2295040e85
commit
2c3f2dfa5a
1 file changed
+14
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user