Skip to content

Ninja: Prevent silent failures in bat files created for long commands on windows

Mark O'Neill requested to merge mark0/cmake:ninja-win-long-commands into master

Split in 3 commits:

  • Propagate the failure
  • Output line number of failed command
  • Suppress noisy echo'ing of batchfile command

Third commit is not strictly the part of the reported issue, but the noisy echoing of the batch file commands seems very un-CMake-like and unnecessary.

Verification using cmake project attached to original issue

$ cmake -GNinja -DLONG_CMD=1 -DFAIL_CMD=1 ../cmake-issue/ && cmake --build . && echo "** Demo Broken **" || echo "BUILD NOW CORRECTLY REPORTS FAILURE"

-- Configuring done
-- Generating done
-- Build files have been written to: C:/Work/Code/ci-build
[1/2] Demoing ninja batch issue
[2/2] Running utility command for demo
FAILED: CMakeFiles/demo.util
CMakeFiles\demo.dir\utility.bat 1539adaedcc6e8d9
C:/Work/Code/cmake-issue/does_not_exist.txt: No such file or directory
.bat failure at line 403
ninja: build stopped: subcommand failed.
BUILD NOW CORRECTLY REPORTS FAILURE

Fixes: #18676 (closed)

Edited by Brad King

Merge request reports