英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论