Switch everything to platforms
This patch switches the codebase over from using the "cpu"
mechanism to using bazel platforms. See
https://docs.bazel.build/versions/master/platforms.html for some more
information.
Most of the substantial changes are in //tools. Instead of using
`cc_toolchain_suite` rules, we now use regular `toolchain` rules that
are registered in the WORKSPACE. That also means that bazel now uses
the target platform to select the compiler.
All --cpu=* arguments should now be --config=* arguments. For example,
`--cpu=roborio` should now be `--config=roborio`. The CI script and
all documentation has been updated to reflect that.
The remainder of the changes revolve around tagging all targets with
`target_compatible_with`. The old mechanism allowed us to specify
repo-wide defaults. The new mechanism does not. That means every
target that didn't have any compatibility specified, now requires
compatibility with `@platforms//os:linux`.
I used buildozer for the vast majority of `target_compatible_with`
changes. buildozer automatically buildifies any BUILD files it
touches. That means this patch also contains a few non-functional
changes that I was too lazy to remove.
Change-Id: I66d6e6ad9161520ee397597cdb492585820a3acd
diff --git a/aos/util/BUILD b/aos/util/BUILD
index 01be701..f0a65d9 100644
--- a/aos/util/BUILD
+++ b/aos/util/BUILD
@@ -1,13 +1,10 @@
package(default_visibility = ["//visibility:public"])
-load("//tools:environments.bzl", "mcu_cpus")
-
cc_library(
name = "bitpacking",
hdrs = [
"bitpacking.h",
],
- compatible_with = mcu_cpus,
visibility = ["//visibility:public"],
deps = [
"//third_party/GSL",
@@ -19,6 +16,7 @@
srcs = [
"bitpacking_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":bitpacking",
"//aos/testing:googletest",
@@ -30,6 +28,7 @@
srcs = [
"trapezoid_profile.py",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":python_init",
],
@@ -43,6 +42,7 @@
hdrs = [
"run_command.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/logging",
],
@@ -53,6 +53,7 @@
srcs = [
"run_command_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":run_command",
"//aos/logging",
@@ -63,6 +64,7 @@
cc_library(
name = "math",
hdrs = ["math.h"],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"@org_tuxfamily_eigen//:eigen",
],
@@ -71,6 +73,7 @@
cc_test(
name = "math_test",
srcs = ["math_test.cc"],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":math",
"//aos/testing:googletest",
@@ -82,6 +85,7 @@
hdrs = [
"death_test_log_implementation.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/logging:implementations",
],
@@ -95,6 +99,7 @@
hdrs = [
"inet_addr.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos:byteorder",
"//aos:network_port",
@@ -109,6 +114,7 @@
hdrs = [
"phased_loop.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/time",
"@com_github_google_glog//:glog",
@@ -120,6 +126,7 @@
hdrs = [
"log_interval.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/logging",
"//aos/time",
@@ -131,6 +138,7 @@
hdrs = [
"string_to_num.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -138,6 +146,7 @@
srcs = [
"string_to_num_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":string_to_num",
"//aos/testing:googletest",
@@ -155,6 +164,7 @@
linkopts = [
"-lm",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/logging",
"//aos/time",
@@ -167,6 +177,7 @@
srcs = [
"trapezoid_profile_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":trapezoid_profile",
"//aos/testing:googletest",
@@ -181,6 +192,7 @@
hdrs = [
"wrapping_counter.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -188,6 +200,7 @@
srcs = [
"wrapping_counter_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":wrapping_counter",
"//aos/testing:googletest",
@@ -199,6 +212,7 @@
hdrs = [
"options.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -206,6 +220,7 @@
srcs = [
"options_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":options",
"//aos/testing:googletest",
@@ -217,6 +232,7 @@
hdrs = [
"compiler_memory_barrier.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -224,6 +240,7 @@
hdrs = [
"global_factory.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -231,6 +248,7 @@
srcs = [
"global_factory_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":global_factory",
"//aos/testing:googletest",
@@ -242,6 +260,7 @@
srcs = [
"phased_loop_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":phased_loop",
"//aos/testing:googletest",
@@ -257,6 +276,7 @@
hdrs = [
"file.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/scoped:scoped_fd",
"@com_github_google_glog//:glog",
@@ -270,6 +290,7 @@
srcs = [
"file_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":file",
"//aos/testing:googletest",
@@ -279,6 +300,7 @@
py_library(
name = "python_init",
srcs = ["__init__.py"],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = ["//aos:python_init"],
)