pw_build: Ensure TERM is set by pw-wrap-ninja when invoking Ninja

pw-wrap-ninja relies on scraping terminal output from Ninja.
Specifically, it relies on the feature of Ninja where it outputs a
status line both when edge starts running and when an edge finishes
running.

Ninja only has this behavior when it detects that it's running
in a "smart terminal", the logic for which is: stdout must be connected
to a tty *and* the TERM environment variable is set *and* the TERM
environment variable is not 'dumb'.

pw-wrap-ninja always runs Ninja with a pty to satisfy the first part of
the condition, but if it's running without TERM set, Ninja will think
it's in a dumb terminal, and only outputs the "edge finished" line,
which confuses the script (it makes it look like the edge started and
finished running immediately).

This commit rectifies this behavior by ensuring that it sets TERM to
vt100 if no TERM is set. We don't *always* set it, because we would want
to suppress subcommands' colors if we're not actually running in a real
smart terminal (e.g. in a CI job).

Tested: Manually unset TERM. Invoked pw-wrap-ninja, ensured that it was able
  to properly detect edge start/finish, and any output had the terminal
  codes expected.
Change-Id: I8a4399b39b3da3f00f50c85273d4e72e4132a379
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126920
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Eli Lipsitz <elipsitz@google.com>
diff --git a/pw_build/py/pw_build/wrap_ninja.py b/pw_build/py/pw_build/wrap_ninja.py
index fd82a35..0af55fa 100644
--- a/pw_build/py/pw_build/wrap_ninja.py
+++ b/pw_build/py/pw_build/wrap_ninja.py
@@ -248,6 +248,8 @@
         ptty_file = os.fdopen(ptty_parent, 'r')
         env = dict(os.environ)
         env['NINJA_STATUS'] = _NINJA_STATUS
+        if 'TERM' not in env:
+            env['TERM'] = 'vt100'
         command = ['ninja'] + args
         self.process = subprocess.Popen(
             command,