pw_build: Add Pigweed specific Bazel platforms
This change adds a set of constraint_settings constraint_values and
platforms specific to pigweed. This is also tested on pw_boot_armv7m and
pw_sys_io_baremetal_stm32f429 packages.
Change-Id: I991aaff7a6208c6954555d4edd91142156a0db5c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/33580
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Akira Baruah <akira.baruah@gmail.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_build/docs.rst b/pw_build/docs.rst
index 18aadb1..96e7a37 100644
--- a/pw_build/docs.rst
+++ b/pw_build/docs.rst
@@ -542,16 +542,92 @@
The ARM Cortex-M Bazel toolchains are based around gcc-arm-non-eabi and are
entirely hermetic. You can target Cortex-M, by using the platforms command line
option. This set of toolchains is supported from hosts; Windows, Mac and Linux.
-The platforms that are currently supported are listed below.
+The platforms that are currently supported are listed below:
.. code-block:: sh
- bazel build //:your_target --platforms=@bazel_embedded//platforms:cortex_m0
- bazel build //:your_target --platforms=@bazel_embedded//platforms:cortex_m1
- bazel build //:your_target --platforms=@bazel_embedded//platforms:cortex_m3
- bazel build //:your_target --platforms=@bazel_embedded//platforms:cortex_m4
- bazel build //:your_target --platforms=@bazel_embedded//platforms:cortex_m7
+ bazel build //:your_target --platforms=@pigweed//pw_build/platforms:cortex_m0
+ bazel build //:your_target --platforms=@pigweed//pw_build/platforms:cortex_m1
+ bazel build //:your_target --platforms=@pigweed//pw_build/platforms:cortex_m3
+ bazel build //:your_target --platforms=@pigweed//pw_build/platforms:cortex_m4
+ bazel build //:your_target --platforms=@pigweed//pw_build/platforms:cortex_m7
bazel build //:your_target \
- --platforms=@bazel_embedded//platforms:cortex_m4_fpu
+ --platforms=@pigweed//pw_build/platforms:cortex_m4_fpu
bazel build //:your_target \
- --platforms=@bazel_embedded//platforms:cortex_m7_fpu
\ No newline at end of file
+ --platforms=@pigweed//pw_build/platforms:cortex_m7_fpu
+
+
+The above examples are cpu/fpu oriented platforms and can be used where
+applicable for your application. There some more specific platforms for the
+types of boards that are included as examples in Pigweed. It is strongly
+encouraged that you create your own set of platforms specific for your project,
+that implement the constraint_settings in this repository. e.g.
+
+New board constraint_value:
+
+.. code-block:: python
+
+ #your_repo/build_settings/constraints/board/BUILD
+ constraint_value(
+ name = "nucleo_l432kc",
+ constraint_setting = "@pigweed//pw_build/constraints/board",
+ )
+
+New chipset constraint_value:
+
+.. code-block:: python
+
+ # your_repo/build_settings/constraints/chipset/BUILD
+ constraint_value(
+ name = "stm32l432kc",
+ constraint_setting = "@pigweed//pw_build/constraints/chipset",
+ )
+
+New platforms for chipset and board:
+
+.. code-block:: python
+
+ #your_repo/build_settings/platforms/BUILD
+ # Works with all stm32l432kc
+ platforms(
+ name = "stm32l432kc",
+ parents = ["@pigweed//pw_build/platforms:cortex_m4"],
+ constraint_values =
+ ["@your_repo//build_settings/constraints/chipset:stm32l432kc"],
+ )
+
+ # Works with only the nucleo_l432kc
+ platforms(
+ name = "nucleo_l432kc",
+ parents = [":stm32l432kc"],
+ constraint_values =
+ ["@your_repo//build_settings/constraints/board:nucleo_l432kc"],
+ )
+
+In the above example you can build your code with the command line:
+
+.. code-block:: python
+
+ bazel build //:your_target_for_nucleo_l432kc \
+ --platforms=@your_repo//build_settings:nucleo_l432kc
+
+
+You can also specify that a specific target is only compatible with one
+platform:
+
+.. code-block:: python
+
+ cc_library(
+ name = "compatible_with_all_stm32l432kc",
+ srcs = ["tomato_src.c"],
+ target_compatible_with =
+ ["@your_repo//build_settings/constraints/chipset:stm32l432kc"],
+ )
+
+ cc_library(
+ name = "compatible_with_only_nucleo_l432kc",
+ srcs = ["bbq_src.c"],
+ target_compatible_with =
+ ["@your_repo//build_settings/constraints/board:nucleo_l432kc"],
+ )
+