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/wpilib/BUILD b/frc971/wpilib/BUILD
index 21472f8..e7c52bf 100644
--- a/frc971/wpilib/BUILD
+++ b/frc971/wpilib/BUILD
@@ -9,6 +9,7 @@
"logging.fbs",
],
gen_reflections = 1,
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -19,7 +20,7 @@
hdrs = [
"encoder_and_potentiometer.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":dma",
":dma_edge_counting",
@@ -37,7 +38,7 @@
hdrs = [
"dma_edge_counting.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":dma",
"//aos/logging",
@@ -53,7 +54,7 @@
hdrs = [
"interrupt_edge_counting.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos:init",
"//aos/logging",
@@ -73,7 +74,7 @@
"buffered_pcm.h",
"buffered_solenoid.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos/logging",
"//third_party:wpilib",
@@ -90,7 +91,7 @@
],
# This library uses some deprecated parts of the SPI API.
copts = ["-Wno-deprecated-declarations"],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos/logging",
"//aos/time",
@@ -106,7 +107,7 @@
hdrs = [
"gyro_sender.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":gyro_interface",
"//aos:init",
@@ -128,6 +129,7 @@
"loop_output_handler_test.fbs",
],
gen_reflections = 1,
+ target_compatible_with = ["@platforms//os:linux"],
)
aos_config(
@@ -137,6 +139,7 @@
":pdp_values_fbs",
":logging_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
aos_config(
@@ -145,6 +148,7 @@
flatbuffers = [
":loop_output_handler_test_fbs",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/events:config",
],
@@ -158,6 +162,7 @@
hdrs = [
"loop_output_handler.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos:init",
"//aos/events:event_loop",
@@ -176,6 +181,7 @@
data = [
":loop_output_handler_test_config",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
":loop_output_handler",
":loop_output_handler_test_fbs",
@@ -193,7 +199,7 @@
hdrs = [
"joystick_sender.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos:init",
"//aos/events:shm_event_loop",
@@ -212,7 +218,7 @@
hdrs = [
"wpilib_interface.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos/events:event_loop",
"//aos/robot_state:robot_state_fbs",
@@ -226,6 +232,7 @@
"pdp_values.fbs",
],
gen_reflections = 1,
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -236,7 +243,7 @@
hdrs = [
"pdp_fetcher.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":pdp_values_fbs",
"//aos:init",
@@ -252,7 +259,7 @@
hdrs = [
"wpilib_robot_base.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//third_party:wpilib",
],
@@ -264,6 +271,7 @@
"imu.fbs",
],
gen_reflections = 1,
+ target_compatible_with = ["@platforms//os:linux"],
)
flatbuffer_cc_library(
@@ -275,6 +283,7 @@
includes = [
":imu_fbs_includes",
],
+ target_compatible_with = ["@platforms//os:linux"],
)
cc_library(
@@ -285,7 +294,7 @@
hdrs = [
"ADIS16470.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":fpga_time_conversion",
":imu_batch_fbs",
@@ -309,7 +318,7 @@
],
# This library uses some deprecated parts of the SPI API.
copts = ["-Wno-deprecated-declarations"],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":fpga_time_conversion",
":imu_fbs",
@@ -332,7 +341,7 @@
hdrs = [
"dma.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//third_party:wpilib",
],
@@ -346,6 +355,7 @@
hdrs = [
"spi_rx_clearer.h",
],
+ target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/logging",
],
@@ -359,7 +369,7 @@
hdrs = [
"sensor_reader.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":dma",
":dma_edge_counting",
@@ -386,7 +396,7 @@
hdrs = [
"drivetrain_writer.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
":loop_output_handler",
"//aos:math",
@@ -404,7 +414,7 @@
hdrs = [
"fpga_time_conversion.h",
],
- restricted_to = ["//tools:roborio"],
+ target_compatible_with = ["//tools/platforms/hardware:roborio"],
deps = [
"//aos/time",
"//aos/util:compiler_memory_barrier",