How can I make custom commands and targets flush their output immediately instead of waiting until the end when using the Ninja generator?

huangapple go评论57阅读模式
英文:

How can I make custom commands and targets flush their output immediately instead of waiting until the end when using the Ninja generator?

问题

"When I build using ninja on Windows, the output of some commands is only written to the console when the command finishes.

For example, if I run docker under ninja, there is some output, but there is none for doxygen. So it could be that the two commands are behaving differently, and this is not a ninja issue at all.

The only discussion about this I can find is: https://github.com/ninja-build/ninja/issues/545
It suggests that using a console pool it might be possible somehow.
I have tried things like:

set NINJA_STATUS="[%s/%t] %es %b (%ds)"
ninja -v -d stats -d keeprsp -j 1

to no avail."

英文:

When I build using ninja on windows the output of some commands is only written to the console when the command finishes.

For example if I run docker under ninja there is some output but there is not for doxygen. So it could be that the two commands are behaving differently and this is not a ninja issue at all.

The only discussion about this I can find is: https://github.com/ninja-build/ninja/issues/545
It suggests that using a console pool it might be possible somehow.
I have tried things like:

set NINJA_STATUS="[%s/%t] %es %b (%ds)"
ninja -v -d stats -d keeprsp -j 1

to no avail.

答案1

得分: 1

The clue is here in the ticket you linked to.

> Starting in CMake 3.2, you can use USES_TERMINAL (or JOB_POOL console starting in 3.15, but preferably the first one) option of add_custom_command() to specify Ninja uses the console pool.

add_custom_target(run_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
COMMAND echo > ${CMAKE_BINARY_DIR}/Doxyfile.ok
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating developer documentation with Doxygen"
JOB_POOL console
VERBATIM )

This helps when using CMake.
In the build.ninja file, JOB_POOL results in pool = console.

英文:

The clue is here in the ticket you linked to.

> Starting in CMake 3.2, you can use USES_TERMINAL (or JOB_POOL console starting in 3.15, but preferably the first one) option of add_custom_command() to specify Ninja uses the console pool.

add_custom_target(run_doxygen ALL
    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile 
    COMMAND echo > ${CMAKE_BINARY_DIR}/Doxyfile.ok
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    COMMENT "Generating developer documentation with Doxygen"
    JOB_POOL console
    VERBATIM )

This helps when using CMake.
In the build.ninja file, JOB_POOL results in pool = console.

huangapple
  • 本文由 发表于 2023年4月13日 19:45:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005036.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定