Add platform mappings to make --cpu work again
Without using --cpu, changing the platform was resulting in a full
rebuild since the cache was per cpu, not per platform. I'm sure there's
a way to handle this, but I know that adding a platform mapping will
make the caches work again.
Change-Id: I5b9a64e0cc27465b04e5991c2c1b3d9c6dea41e6
diff --git a/.bazelrc b/.bazelrc
index 9a26282..fce2616 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -26,6 +26,9 @@
build:armhf-debian --platforms=//tools/platforms:linux_armhf
build:cortex-m4f --platforms=//tools/platforms:cortex_m4f
+# Without this, we end up rebuilding from scratch every time we change compilers. This is needed to make --cpu work (even though it shouldn't be used).
+build --crosstool_top=@//tools/cpp:toolchain --host_crosstool_top=@//tools/cpp:toolchain
+
build:asan --copt -fsanitize=address
build:asan --linkopt -fsanitize=address --linkopt -ldl
build:asan --platform_suffix=-asan
diff --git a/platform_mappings b/platform_mappings
new file mode 100644
index 0000000..04265dd
--- /dev/null
+++ b/platform_mappings
@@ -0,0 +1,26 @@
+# https://docs.bazel.build/versions/master/platforms-intro.html#platform-mappings
+platforms:
+ //tools/platforms:linux_x86
+ --cpu=k8
+
+ //tools/platforms:linux_roborio
+ --cpu=roborio
+
+ //tools/platforms:linux_armhf
+ --cpu=armhf-debian
+
+ //tools/platforms:cortex_m4f
+ --cpu=cortex-m4f
+
+flags:
+ --cpu=k8
+ //tools/platforms:linux_x86
+
+ --cpu=roborio
+ //tools/platforms:linux_roborio
+
+ --cpu=armhf-debian
+ //tools/platforms:linux_armhf
+
+ --cpu=cortex-m4f
+ //tools/platforms:cortex_m4f
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 4f0e6d9..ea25dd1 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -2,6 +2,17 @@
package(default_visibility = ["//visibility:public"])
+cc_toolchain_suite(
+ name = "toolchain",
+ toolchains = {
+ "k8": ":cc-compiler-k8",
+ "armhf-debian": ":cc-compiler-armhf-debian",
+ "roborio": ":cc-compiler-roborio",
+ "cortex-m4f": ":cc-compiler-cortex-m4f",
+ },
+ visibility = ["//visibility:public"],
+)
+
[
cc_toolchain_config(
name = "{}_toolchain_config".format(cpu),