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/frc971/control_loops/BUILD b/frc971/control_loops/BUILD
index 7d3b915..1945db9 100644
--- a/frc971/control_loops/BUILD
+++ b/frc971/control_loops/BUILD
@@ -1,7 +1,6 @@
package(default_visibility = ["//visibility:public"])
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
-load("//tools:environments.bzl", "mcu_cpus")
cc_library(
name = "team_number_test_environment",
@@ -12,6 +11,7 @@
hdrs = [
"team_number_test_environment.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/network:team_number",
"//aos/testing:googletest",
@@ -23,6 +23,7 @@
srcs = [
"hybrid_state_feedback_loop_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":hybrid_state_feedback_loop",
"//aos/testing:googletest",
@@ -32,6 +33,7 @@
cc_library(
name = "pose",
hdrs = ["pose.h"],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/util:math",
"@org_tuxfamily_eigen//:eigen",
@@ -41,6 +43,7 @@
cc_test(
name = "pose_test",
srcs = ["pose_test.cc"],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":pose",
"//aos/testing:googletest",
@@ -52,6 +55,7 @@
hdrs = [
"hall_effect_tracker.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":control_loops_fbs",
],
@@ -62,7 +66,6 @@
srcs = [
"control_loops.fbs",
],
- compatible_with = mcu_cpus,
)
cc_test(
@@ -70,6 +73,7 @@
srcs = [
"position_sensor_sim_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":control_loops_fbs",
":position_sensor_sim",
@@ -90,6 +94,7 @@
linkopts = [
"-lm",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":control_loops_fbs",
":gaussian_noise",
@@ -108,21 +113,7 @@
linkopts = [
"-lm",
],
-)
-
-cc_library(
- name = "coerce_goal_uc",
- srcs = [
- "coerce_goal.cc",
- ],
- hdrs = [
- "coerce_goal.h",
- ],
- restricted_to = mcu_cpus,
- deps = [
- "//aos/controls:polytope_uc",
- "@org_tuxfamily_eigen//:eigen",
- ],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -133,9 +124,10 @@
hdrs = [
"coerce_goal.h",
],
- linkopts = [
- "-lm",
- ],
+ linkopts = select({
+ "@platforms//os:linux": ["-lm"],
+ "//conditions:default": [],
+ }),
deps = [
"//aos/controls:polytope",
"@org_tuxfamily_eigen//:eigen",
@@ -150,6 +142,7 @@
linkopts = [
"-lm",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":coerce_goal",
"//aos/controls:polytope",
@@ -158,20 +151,6 @@
],
)
-# TODO(austin): Select isn't working right. We should be able to remove
-# logging conditionally with select and have CPU constraints work correctly.
-cc_library(
- name = "state_feedback_loop_uc",
- hdrs = [
- "state_feedback_loop.h",
- ],
- restricted_to = mcu_cpus,
- deps = [
- "//aos:macros",
- "@org_tuxfamily_eigen//:eigen",
- ],
-)
-
cc_library(
name = "state_feedback_loop",
hdrs = [
@@ -179,9 +158,11 @@
],
deps = [
"//aos:macros",
- "//aos/logging",
"@org_tuxfamily_eigen//:eigen",
- ],
+ ] + select({
+ "@platforms//os:linux": ["//aos/logging"],
+ "//conditions:default": [],
+ }),
)
cc_library(
@@ -189,6 +170,7 @@
hdrs = [
"hybrid_state_feedback_loop.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":c2d",
":state_feedback_loop",
@@ -204,6 +186,7 @@
hdrs = [
"simple_capped_state_feedback_loop.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":state_feedback_loop",
"@org_tuxfamily_eigen//:eigen",
@@ -215,6 +198,7 @@
hdrs = [
"runge_kutta.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"@org_tuxfamily_eigen//:eigen",
],
@@ -225,6 +209,7 @@
srcs = [
"runge_kutta_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":runge_kutta",
"//aos/testing:googletest",
@@ -237,6 +222,7 @@
hdrs = [
"fixed_quadrature.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -244,6 +230,7 @@
srcs = [
"fixed_quadrature_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":fixed_quadrature",
"//aos/testing:googletest",
@@ -258,6 +245,7 @@
includes = [
":control_loops_fbs_includes",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -268,6 +256,7 @@
hdrs = [
"profiled_subsystem.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":control_loops_fbs",
":profiled_subsystem_fbs",
@@ -284,6 +273,7 @@
hdrs = [
"jacobian.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"@org_tuxfamily_eigen//:eigen",
],
@@ -294,6 +284,7 @@
srcs = [
"jacobian_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":jacobian",
"//aos/testing:googletest",
@@ -306,6 +297,7 @@
srcs = [
"c2d_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
":c2d",
@@ -319,6 +311,7 @@
hdrs = [
"c2d.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
"//aos/time",
@@ -331,6 +324,7 @@
hdrs = [
"dlqr.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
"@org_tuxfamily_eigen//:eigen",
@@ -341,6 +335,7 @@
py_library(
name = "python_init",
srcs = ["__init__.py"],
+ target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = ["//frc971:python_init"],
)
@@ -348,6 +343,7 @@
cc_library(
name = "binomial",
hdrs = ["binomial.h"],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -355,6 +351,7 @@
srcs = [
"binomial_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":binomial",
"//aos/testing:googletest",
@@ -370,6 +367,7 @@
hdrs = [
"capped_test_plant.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":state_feedback_loop",
"//aos/testing:googletest",
@@ -381,6 +379,7 @@
hdrs = [
"static_zeroing_single_dof_profiled_subsystem.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//frc971/control_loops:profiled_subsystem",
],
@@ -395,6 +394,7 @@
"static_zeroing_single_dof_profiled_subsystem_test_integral_plant.cc",
],
cmd = "$(location //frc971/control_loops/python:static_zeroing_single_dof_profiled_subsystem_test) $(OUTS)",
+ target_compatible_with = ["@platforms//os:linux"],
tools = [
"//frc971/control_loops/python:static_zeroing_single_dof_profiled_subsystem_test",
],
@@ -410,6 +410,7 @@
"static_zeroing_single_dof_profiled_subsystem_test_integral_plant.h",
"static_zeroing_single_dof_profiled_subsystem_test_plant.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":state_feedback_loop",
],
@@ -424,6 +425,7 @@
":control_loops_fbs_includes",
":profiled_subsystem_fbs_includes",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_test(
@@ -431,6 +433,7 @@
srcs = [
"static_zeroing_single_dof_profiled_subsystem_test.cc",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":capped_test_plant",
":position_sensor_sim",