Antonio
Antonio

Reputation: 20306

CMake add_custom_target: Ninja suppressing output until command completed and therefore user interaction not possible

If I add

add_custom_target(dummy COMMAND dir && sleep 2)

And then

ninja dummy

The directory content is visualized only after the sleep is terminated. I understand that this mechanism has a valuable property that is to allow Ninja to show a very neat/sequential output even while executing several jobs in parallel.

However, this is a problem in the following practical case: my real add_custom_target would execute a program that at some point will prompt the user asking for a password, but Ninja basically blocks any interaction.

Is there a workaround for this?

Note: Using -v option (verbose) doesn't help, and also -j 1 (only one job at a time).

Another example:

add_custom_target(dummy COMMAND cmd /c time)

And:

D:\build> ninja dummy
[1/1] cmd.exe /c cd D:\build && cmd /c time
FAILED: cmd.exe /c cd D:\build && cmd /c time
The current time is: 13:06:08.57
Enter the new time: ninja: build stopped: subcommand failed.

Some hints:
ninja-build > Launching interactive apps from build rules

Upvotes: 0

Views: 1158

Answers (2)

Antonio
Antonio

Reputation: 20306

I got feedback from the Ninja mailing list.

There's an issue on this topic, and a patch (although I am not sure if by not caching it will also allow interaction; given the outcome of the test with time, probably not):

Issue. Patch.

Upvotes: 1

steveire
steveire

Reputation: 11084

This is part of the design of Ninja.

Related issue: 0014544: Remove edit_cache target from ninja output

Upvotes: 0

Related Questions