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/y2020/BUILD b/y2020/BUILD
index 59642fe..e54c168 100644
--- a/y2020/BUILD
+++ b/y2020/BUILD
@@ -21,6 +21,7 @@
"//y2020/control_loops/drivetrain:drivetrain",
"//y2020/control_loops/superstructure:superstructure",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
robot_downloader(
@@ -34,13 +35,13 @@
dirs = [
"//y2020/www:www_files",
],
- restricted_to = ["//tools:armhf-debian"],
start_binaries = [
"//aos/network:message_bridge_client",
"//aos/network:message_bridge_server",
"//aos/network:web_proxy_main",
"//y2020/vision:camera_reader",
],
+ target_compatible_with = ["//tools/platforms/hardware:raspberry_pi"],
target_type = "pi",
)
@@ -52,6 +53,7 @@
hdrs = [
"constants.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
"//aos/logging",
@@ -75,7 +77,7 @@
srcs = [
"wpilib_interface.cc",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":constants",
"//aos:init",
@@ -117,6 +119,7 @@
srcs = [
":joystick_reader.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":setpoint_fbs",
"//aos:init",
@@ -146,6 +149,7 @@
"//y2020/vision/sift:sift_training_fbs",
"//y2020/vision:vision_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
":config_laptop",
@@ -170,6 +174,7 @@
"//y2020/vision:vision_fbs",
"//aos/events/logging:logger_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
"//aos/events:config",
@@ -197,6 +202,7 @@
"//y2020/vision:vision_fbs",
"//aos/events/logging:logger_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
"//aos/events:config",
@@ -220,6 +226,7 @@
"//y2020/control_loops/superstructure:superstructure_position_fbs",
"//y2020/control_loops/superstructure:superstructure_status_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/events:config",
"//aos/robot_state:config",
@@ -232,6 +239,7 @@
py_library(
name = "python_init",
srcs = ["__init__.py"],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
)
@@ -245,6 +253,7 @@
"//y2020/www:field_main_bundle.min.js",
"//y2020/www:files",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
@@ -255,11 +264,13 @@
"setpoint.fbs",
],
gen_reflections = 1,
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_binary(
name = "setpoint_setter",
srcs = ["setpoint_setter.cc"],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":setpoint_fbs",
"//aos:init",
@@ -272,6 +283,7 @@
name = "y2020_pi" + str(num) + ".json",
src = "y2020_pi_template.json",
parameters = {"NUM": str(num)},
+ target_compatible_with = ["@platforms//os:linux"],
)
for num in range(1, 5)
]