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>
1 file changed
tree: 039b5264aea27e7ba20a66201b4ee01d6559d677
  1. .allstar/
  2. .vscode/
  3. build_overrides/
  4. docker/
  5. docs/
  6. pw_allocator/
  7. pw_analog/
  8. pw_android_toolchain/
  9. pw_arduino_build/
  10. pw_assert/
  11. pw_assert_basic/
  12. pw_assert_log/
  13. pw_assert_tokenized/
  14. pw_assert_zephyr/
  15. pw_async/
  16. pw_base64/
  17. pw_bloat/
  18. pw_blob_store/
  19. pw_bluetooth/
  20. pw_bluetooth_hci/
  21. pw_boot/
  22. pw_boot_cortex_m/
  23. pw_build/
  24. pw_build_info/
  25. pw_build_mcuxpresso/
  26. pw_bytes/
  27. pw_checksum/
  28. pw_chrono/
  29. pw_chrono_embos/
  30. pw_chrono_freertos/
  31. pw_chrono_stl/
  32. pw_chrono_threadx/
  33. pw_chrono_zephyr/
  34. pw_cli/
  35. pw_compilation_testing/
  36. pw_console/
  37. pw_containers/
  38. pw_cpu_exception/
  39. pw_cpu_exception_cortex_m/
  40. pw_crypto/
  41. pw_digital_io/
  42. pw_docgen/
  43. pw_doctor/
  44. pw_env_setup/
  45. pw_file/
  46. pw_function/
  47. pw_fuzzer/
  48. pw_hdlc/
  49. pw_hex_dump/
  50. pw_i2c/
  51. pw_i2c_mcuxpresso/
  52. pw_ide/
  53. pw_interrupt/
  54. pw_interrupt_cortex_m/
  55. pw_interrupt_zephyr/
  56. pw_intrusive_ptr/
  57. pw_kvs/
  58. pw_libc/
  59. pw_log/
  60. pw_log_android/
  61. pw_log_basic/
  62. pw_log_null/
  63. pw_log_rpc/
  64. pw_log_string/
  65. pw_log_tokenized/
  66. pw_log_zephyr/
  67. pw_malloc/
  68. pw_malloc_freelist/
  69. pw_metric/
  70. pw_minimal_cpp_stdlib/
  71. pw_module/
  72. pw_multisink/
  73. pw_package/
  74. pw_perf_test/
  75. pw_persistent_ram/
  76. pw_polyfill/
  77. pw_preprocessor/
  78. pw_presubmit/
  79. pw_protobuf/
  80. pw_protobuf_compiler/
  81. pw_random/
  82. pw_result/
  83. pw_ring_buffer/
  84. pw_router/
  85. pw_rpc/
  86. pw_rust/
  87. pw_snapshot/
  88. pw_software_update/
  89. pw_span/
  90. pw_spi/
  91. pw_status/
  92. pw_stm32cube_build/
  93. pw_stream/
  94. pw_string/
  95. pw_symbolizer/
  96. pw_sync/
  97. pw_sync_baremetal/
  98. pw_sync_embos/
  99. pw_sync_freertos/
  100. pw_sync_stl/
  101. pw_sync_threadx/
  102. pw_sync_zephyr/
  103. pw_sys_io/
  104. pw_sys_io_arduino/
  105. pw_sys_io_baremetal_lm3s6965evb/
  106. pw_sys_io_baremetal_stm32f429/
  107. pw_sys_io_emcraft_sf2/
  108. pw_sys_io_mcuxpresso/
  109. pw_sys_io_pico/
  110. pw_sys_io_stdio/
  111. pw_sys_io_stm32cube/
  112. pw_sys_io_zephyr/
  113. pw_system/
  114. pw_target_runner/
  115. pw_thread/
  116. pw_thread_embos/
  117. pw_thread_freertos/
  118. pw_thread_stl/
  119. pw_thread_threadx/
  120. pw_tls_client/
  121. pw_tls_client_boringssl/
  122. pw_tls_client_mbedtls/
  123. pw_tokenizer/
  124. pw_tool/
  125. pw_toolchain/
  126. pw_trace/
  127. pw_trace_tokenized/
  128. pw_transfer/
  129. pw_unit_test/
  130. pw_varint/
  131. pw_watch/
  132. pw_web/
  133. pw_work_queue/
  134. seed/
  135. targets/
  136. third_party/
  137. ts/
  138. zephyr/
  139. .bazelignore
  140. .bazelrc
  141. .black.toml
  142. .clang-format
  143. .clang-tidy
  144. .eslintrc.json
  145. .git-blame-ignore-revs
  146. .gitattributes
  147. .gitignore
  148. .gn
  149. .mypy.ini
  150. .prettierrc.js
  151. .pw_ide.yaml
  152. .pylintrc
  153. activate.bat
  154. Android.bp
  155. AUTHORS
  156. bootstrap.bat
  157. bootstrap.sh
  158. BUILD.bazel
  159. BUILD.gn
  160. BUILDCONFIG.gn
  161. CMakeLists.txt
  162. jest.config.ts
  163. Kconfig.zephyr
  164. LICENSE
  165. modules.gni
  166. OWNERS
  167. package-lock.json
  168. package.json
  169. PIGWEED_MODULES
  170. PW_PLUGINS
  171. README.md
  172. rollup.config.js
  173. tsconfig.json
  174. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links