pw_presubmit: Add substep support

Add support for substeps to pw_presubmit. Steps can now define substeps
which will be listed in the output of --only-list-steps and can be read
by recipe code (or other automated tooling). Much of this logic is
handled by the new SubStepCheck subclass of Check. Example
--only-list-steps output is below.

  [
    {
      "name": "gn_combined_build_check",
      "paths": [...],
      "substeps": [
        "gn gen",
        "ninja stm32f429i_debug stm32f429i_size_optimized stm32f429i_speed_optimiz..."
      ]
    }
  ]

Substeps can be run with a new '--substep' argument:
'pw presubmit --step <step> --substep <substep>'. The '--substep'
argument is only valid when there is only one step. Running substeps out
of order is not prevented.

Step names are shown in the output as they are executed.

  $ pw presubmit --step gn_combined_build_check
  <...>
  1/1      gn_combined_build_check   4 files
  20221227 07:43:03 INF gn gen
  20221227 07:43:07 INF ninja stm32f429i_debug stm32f429i_size_optimized stm32f429i_speed_optimiz...
  PASSED   gn_combined_build_check   0:36.7

  $ pw presubmit --step gn_combined_build_check --substep 'gn gen'
  <...>
  1/1      gn_combined_build_check   4 files
  20221227 07:43:03 INF gn gen
  PASSED   gn_combined_build_check   0:03.9

Implement GnGenNinja subclass of SubStepCheck that has substeps for
installing packages, running gn gen, and running ninja (possibly with a
context manager). Since gn args sometime require details from the
PresubmitContext, values can be expressed as a str or as a lambda that
takes a PresubmitContext object.

  dir_pw_third_party_nanopb=lambda ctx: '"{}"'.format(
    ctx.package_root / 'nanopb'
  )

Convert the gn_combined_build_check and gn_nanopb_build presubmit checks
to use GnGenNinja. (Other steps will follow.)

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