evmar / n2

n2 ("into"), a ninja compatible build system
Apache License 2.0
338 stars 26 forks source link

proper `console` pool support #100

Open evmar opened 9 months ago

evmar commented 9 months ago

Ninja's console pool has a few different behaviors:

  1. it has direct access to the TTY which means it
    1. can access stdin
    2. it can print terminal escape codes
    3. if the command detects it has TTY access, it might vary its output to use escape codes
  2. because Ninja gives TTY control to the command, Ninja no longer prints its own status updates while the command is running
  3. it has depth=1, only one console-tagged step can run at once

Currently:

I think the implementation options here are either to do what Ninja does, which means giving direct console access and suppressing n2 status updates...

...or maybe try something fancy involving running the process with a pseudo tty (to make it believe 1.iii) and still rendering its progress live.

I think to do that we'd need to implement some terminal emulation behavior, but I expect there are two vague categories of tools here: the ones that just do some simple color printing and line overprinting, or the ones that go wild with complex screen updates. I think we could plausibly implement enough terminal emulation to handle the former and then bail to just letting the command run solo if we encounter any unexpected terminal escape codes. It's plausible to me that no commands actually depend on the latter. (Writing terminal emulators is a hobby of mine, maybe I am just too eager here...)

Forked from discussion in #68.