pw_build: Add `enable_if` to missing backend error

A dependency on a facade in a toolchain with a missing backend commonly
occurs by depending on the facade in a test. This change suggests using
`enable_if` to enable the test only when a backend is provided.

Tested: removed an existing `enable_if` and saw this error:

ERR Build error for //pw_chrono:system_clock.NO_BACKEND_SET(//targets/stm32f429i_disc1:stm32f429i_disc1_debug):
ERR
ERR   Attempted to build the //pw_chrono:system_clock facade with no backend.
ERR
ERR   If you are using this facade, ensure you have configured a backend
ERR   properly. The build arg for the facade must be set to a valid
ERR   backend in the toolchain. For example, you may need to add a line
ERR   like the following to the toolchain's .gni file:
ERR
ERR     pw_chrono_<FACADE_NAME>_BACKEND = "//path/to/the:backend"
ERR
ERR   Alternatively, if the target depending on this facade is a
<wrapped> `pw_test`
ERR   which should only be built in toolchains with a provided backend,
ERR   consider adding an `enable_if` to the dependent target:
ERR
ERR     pw_test(...) {
ERR       enable_if = pw_chrono_<FACADE_NAME>_BACKEND != ""
ERR       ...
ERR     }
ERR
ERR   If you are NOT using this facade, this error may have been
<wrapped> triggered
ERR   by trying to build all targets.
ERR
ERR Dependency path to this target:
ERR
ERR   gn path out //:default "//pw_chrono:system_clock.NO_BACKEND_SET(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)"

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