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/y2019/BUILD b/y2019/BUILD
index ddc0a19..3f361a7 100644
--- a/y2019/BUILD
+++ b/y2019/BUILD
@@ -18,6 +18,7 @@
         "//y2019/actors:binaries",
         "//y2019/vision/server",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -28,6 +29,7 @@
     hdrs = [
         "constants.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/logging",
@@ -54,7 +56,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 = [
         ":camera_log_fbs",
         ":constants",
@@ -103,6 +105,7 @@
     hdrs = [
         "joystick_angle.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/input:drivetrain_input",
         "//frc971/zeroing:wrap",
@@ -114,6 +117,7 @@
     srcs = [
         "joystick_angle_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":joystick_angle",
         "//aos/testing:googletest",
@@ -125,6 +129,7 @@
     srcs = [
         ":joystick_reader.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":camera_log_fbs",
         ":vision_proto",
@@ -158,6 +163,7 @@
         "camera_log.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -167,6 +173,7 @@
         "status_light.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -183,6 +190,7 @@
         "//y2019/control_loops/superstructure:superstructure_status_fbs",
         ":camera_log_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/robot_state:config",
@@ -195,11 +203,13 @@
 cc_proto_library(
     name = "vision_proto",
     srcs = ["vision.proto"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/y2019/actors/BUILD b/y2019/actors/BUILD
index 3aa2a22..4a66b55 100644
--- a/y2019/actors/BUILD
+++ b/y2019/actors/BUILD
@@ -24,6 +24,7 @@
         "auto_splines.h",
         "autonomous_actor.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/events:event_loop",
         "//aos/logging",
@@ -44,6 +45,7 @@
     srcs = [
         "autonomous_actor_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":autonomous_action_lib",
         "//aos:init",
diff --git a/y2019/control_loops/BUILD b/y2019/control_loops/BUILD
index ddfdf61..0c1940b 100644
--- a/y2019/control_loops/BUILD
+++ b/y2019/control_loops/BUILD
@@ -1,6 +1,7 @@
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = ["//y2019:python_init"],
 )
diff --git a/y2019/control_loops/drivetrain/BUILD b/y2019/control_loops/drivetrain/BUILD
index c500ce6..78c602e 100644
--- a/y2019/control_loops/drivetrain/BUILD
+++ b/y2019/control_loops/drivetrain/BUILD
@@ -11,6 +11,7 @@
         "kalman_drivetrain_motor_plant.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:drivetrain) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:drivetrain",
     ],
@@ -27,6 +28,7 @@
         "hybrid_velocity_drivetrain.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:polydrivetrain) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:polydrivetrain",
     ],
@@ -46,6 +48,7 @@
         "kalman_drivetrain_motor_plant.h",
         "polydrivetrain_dog_motor_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
@@ -61,6 +64,7 @@
     hdrs = [
         "drivetrain_base.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":polydrivetrain_plants",
@@ -74,6 +78,7 @@
     srcs = [
         "drivetrain_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":drivetrain_base",
@@ -88,6 +93,7 @@
     name = "target_selector_fbs",
     srcs = ["target_selector.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -97,12 +103,14 @@
         "camera.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 cc_library(
     name = "localizer",
     hdrs = ["localizer.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//frc971/control_loops:pose",
         "//frc971/control_loops/drivetrain:camera",
@@ -114,6 +122,7 @@
     name = "target_selector",
     srcs = ["target_selector.cc"],
     hdrs = ["target_selector.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":target_selector_fbs",
         "//frc971/control_loops:pose",
@@ -128,6 +137,7 @@
     name = "target_selector_test",
     srcs = ["target_selector_test.cc"],
     data = ["//y2019:config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":target_selector",
         "//aos/events:simulated_event_loop",
@@ -140,6 +150,7 @@
     name = "event_loop_localizer",
     srcs = ["event_loop_localizer.cc"],
     hdrs = ["event_loop_localizer.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":camera_fbs",
         ":localizer",
@@ -161,6 +172,7 @@
         }),
     linkstatic = True,
     shard_count = 8,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":localizer",
         ":drivetrain_base",
@@ -182,6 +194,7 @@
 aos_config(
     name = "simulation_config",
     src = "drivetrain_simulation_config.json",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops/drivetrain:simulation_channels",
@@ -193,6 +206,7 @@
     name = "localized_drivetrain_test",
     srcs = ["localized_drivetrain_test.cc"],
     data = [":simulation_config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":camera_fbs",
         ":drivetrain_base",
@@ -211,6 +225,7 @@
     name = "drivetrain_replay",
     srcs = ["drivetrain_replay.cc"],
     data = ["//y2019:config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":drivetrain_base",
         ":event_loop_localizer",
diff --git a/y2019/control_loops/python/BUILD b/y2019/control_loops/python/BUILD
index 334bfd5..3d5e641 100644
--- a/y2019/control_loops/python/BUILD
+++ b/y2019/control_loops/python/BUILD
@@ -6,7 +6,7 @@
         "drivetrain.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -22,7 +22,7 @@
         "polydrivetrain.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -37,7 +37,7 @@
         "drivetrain.py",
         "polydrivetrain.py",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     visibility = ["//visibility:public"],
     deps = [
         ":python_init",
@@ -52,6 +52,7 @@
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = ["//y2019/control_loops:python_init"],
 )
@@ -62,7 +63,7 @@
         "elevator.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -78,7 +79,7 @@
         "wrist.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -94,7 +95,7 @@
         "intake.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -110,7 +111,7 @@
         "stilts.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
diff --git a/y2019/control_loops/superstructure/BUILD b/y2019/control_loops/superstructure/BUILD
index c352ba6..d89b1f3 100644
--- a/y2019/control_loops/superstructure/BUILD
+++ b/y2019/control_loops/superstructure/BUILD
@@ -12,6 +12,7 @@
         "//frc971/control_loops:control_loops_fbs_includes",
         "//frc971/control_loops:profiled_subsystem_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -20,6 +21,7 @@
         "superstructure_output.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -32,6 +34,7 @@
         "//frc971/control_loops:control_loops_fbs_includes",
         "//frc971/control_loops:profiled_subsystem_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -44,6 +47,7 @@
         "//frc971/control_loops:control_loops_fbs_includes",
         "//frc971/control_loops:profiled_subsystem_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -54,6 +58,7 @@
     hdrs = [
         "superstructure.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":collision_avoidance",
         ":superstructure_goal_fbs",
@@ -77,6 +82,7 @@
     data = [
         "//y2019:config",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_goal_fbs",
         ":superstructure_lib",
@@ -101,6 +107,7 @@
     srcs = [
         "superstructure_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_lib",
         "//aos:init",
@@ -116,6 +123,7 @@
     hdrs = [
         "collision_avoidance.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_goal_fbs",
         ":superstructure_status_fbs",
@@ -134,6 +142,7 @@
     hdrs = [
         "vacuum.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_goal_fbs",
         ":superstructure_output_fbs",
@@ -148,6 +157,7 @@
     srcs = [
         "collision_avoidance_tests.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":collision_avoidance",
         ":superstructure_goal_fbs",
diff --git a/y2019/control_loops/superstructure/elevator/BUILD b/y2019/control_loops/superstructure/elevator/BUILD
index f3d99fe..1084295 100644
--- a/y2019/control_loops/superstructure/elevator/BUILD
+++ b/y2019/control_loops/superstructure/elevator/BUILD
@@ -9,6 +9,7 @@
         "integral_elevator_plant.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:elevator) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:elevator",
     ],
@@ -24,6 +25,7 @@
         "elevator_plant.h",
         "integral_elevator_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
diff --git a/y2019/control_loops/superstructure/intake/BUILD b/y2019/control_loops/superstructure/intake/BUILD
index 4f7f6b0..9d09510 100644
--- a/y2019/control_loops/superstructure/intake/BUILD
+++ b/y2019/control_loops/superstructure/intake/BUILD
@@ -9,6 +9,7 @@
         "integral_intake_plant.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:intake) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:intake",
     ],
@@ -24,6 +25,7 @@
         "intake_plant.h",
         "integral_intake_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
diff --git a/y2019/control_loops/superstructure/stilts/BUILD b/y2019/control_loops/superstructure/stilts/BUILD
index a9c556e..346d88c 100644
--- a/y2019/control_loops/superstructure/stilts/BUILD
+++ b/y2019/control_loops/superstructure/stilts/BUILD
@@ -9,6 +9,7 @@
         "integral_stilts_plant.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:stilts) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:stilts",
     ],
@@ -24,6 +25,7 @@
         "integral_stilts_plant.h",
         "stilts_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
diff --git a/y2019/control_loops/superstructure/wrist/BUILD b/y2019/control_loops/superstructure/wrist/BUILD
index e960b1a..8abfad5 100644
--- a/y2019/control_loops/superstructure/wrist/BUILD
+++ b/y2019/control_loops/superstructure/wrist/BUILD
@@ -9,6 +9,7 @@
         "integral_wrist_plant.cc",
     ],
     cmd = "$(location //y2019/control_loops/python:wrist) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2019/control_loops/python:wrist",
     ],
@@ -24,6 +25,7 @@
         "integral_wrist_plant.h",
         "wrist_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
diff --git a/y2019/image_streamer/BUILD b/y2019/image_streamer/BUILD
index 4885da0..f394b91 100644
--- a/y2019/image_streamer/BUILD
+++ b/y2019/image_streamer/BUILD
@@ -3,6 +3,7 @@
 cc_binary(
     name = "image_streamer",
     srcs = ["image_streamer.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":flip_image",
         "//aos/logging",
@@ -28,6 +29,7 @@
         "-Wno-cast-qual",
         "-Wno-error=type-limits",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//third_party/cimg:CImg",
         "//third_party/libjpeg",
diff --git a/y2019/image_streamer/deploy.sh b/y2019/image_streamer/deploy.sh
index 584d09e..9cbf8ab 100755
--- a/y2019/image_streamer/deploy.sh
+++ b/y2019/image_streamer/deploy.sh
@@ -40,7 +40,7 @@
 echo -e "\n# Building image_streamer"
 (
 set -x
-bazel build -c opt //y2019/image_streamer:image_streamer --cpu=armhf-debian
+bazel build -c opt //y2019/image_streamer:image_streamer --config=armhf-debian
 )
 
 echo -e "\n# Copy files to ODROID"
diff --git a/y2019/jevois/BUILD b/y2019/jevois/BUILD
index f11c67c..d6d3dfc 100644
--- a/y2019/jevois/BUILD
+++ b/y2019/jevois/BUILD
@@ -1,4 +1,3 @@
-load("//tools:environments.bzl", "mcu_cpus")
 load("//motors:macros.bzl", "hex_from_elf")
 
 jevois_crc_args = [
@@ -47,7 +46,7 @@
             "$(location jevois_crc.c)",
         ]),
     ]),
-    compatible_with = mcu_cpus,
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//third_party/pycrc:pycrc_main",
     ],
@@ -61,7 +60,7 @@
     hdrs = [
         "jevois_crc.h",
     ],
-    compatible_with = mcu_cpus,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//third_party/GSL",
     ],
@@ -81,19 +80,6 @@
 )
 
 cc_library(
-    name = "structures_mcu",
-    hdrs = [
-        "structures.h",
-    ],
-    restricted_to = mcu_cpus,
-    deps = [
-        "//aos/containers:sized_array",
-        "//aos/time:time_mcu",
-        "@org_tuxfamily_eigen//:eigen",
-    ],
-)
-
-cc_library(
     name = "spi",
     srcs = [
         "spi.cc",
@@ -105,27 +91,12 @@
     deps = [
         ":jevois_crc",
         ":structures",
-        "//aos/logging",
         "//aos/util:bitpacking",
         "//third_party/GSL",
-    ],
-)
-
-cc_library(
-    name = "spi_mcu",
-    srcs = [
-        "spi.cc",
-    ],
-    hdrs = [
-        "spi.h",
-    ],
-    restricted_to = mcu_cpus,
-    deps = [
-        ":jevois_crc",
-        ":structures_mcu",
-        "//aos/util:bitpacking",
-        "//third_party/GSL",
-    ],
+    ] + select({
+        "@platforms//os:linux": ["//aos/logging"],
+        "//conditions:default": [],
+    }),
 )
 
 cc_library(
@@ -142,29 +113,12 @@
         ":jevois_crc",
         ":structures",
         "//aos/containers:sized_array",
-        "//aos/logging",
         "//aos/util:bitpacking",
         "//third_party/GSL",
-    ],
-)
-
-cc_library(
-    name = "uart_mcu",
-    srcs = [
-        "uart.cc",
-    ],
-    hdrs = [
-        "uart.h",
-    ],
-    restricted_to = mcu_cpus,
-    deps = [
-        ":cobs_mcu",
-        ":jevois_crc",
-        ":structures_mcu",
-        "//aos/containers:sized_array",
-        "//aos/util:bitpacking",
-        "//third_party/GSL",
-    ],
+    ] + select({
+        "@platforms//os:linux": ["//aos/logging"],
+        "//conditions:default": [],
+    }),
 )
 
 cc_test(
@@ -172,6 +126,7 @@
     srcs = [
         "uart_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":uart",
         "//aos/testing:googletest",
@@ -183,6 +138,7 @@
     srcs = [
         "spi_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":spi",
         "//aos/testing:googletest",
@@ -199,22 +155,12 @@
     ],
 )
 
-cc_library(
-    name = "cobs_mcu",
-    hdrs = [
-        "cobs.h",
-    ],
-    restricted_to = mcu_cpus,
-    deps = [
-        "//third_party/GSL",
-    ],
-)
-
 cc_test(
     name = "cobs_test",
     srcs = [
         "cobs_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":cobs",
         "//aos/testing:googletest",
@@ -227,6 +173,7 @@
     name = "serial",
     srcs = ["serial.cc"],
     hdrs = ["serial.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/logging",
@@ -238,12 +185,12 @@
     srcs = [
         "teensy.cc",
     ],
-    restricted_to = ["//tools:cortex-m4f"],
+    target_compatible_with = ["//tools/platforms/hardware:cortex_m4f"],
     deps = [
-        ":cobs_mcu",
-        ":spi_mcu",
-        ":uart_mcu",
-        "//aos/time:time_mcu",
+        ":cobs",
+        ":spi",
+        ":uart",
+        "//aos/time:time",
         "//motors:util",
         "//motors/core",
         "//motors/peripheral:configuration",
@@ -257,5 +204,5 @@
 
 hex_from_elf(
     name = "teensy",
-    restricted_to = ["//tools:cortex-m4f"],
+    target_compatible_with = ["//tools/platforms/hardware:cortex_m4f"],
 )
diff --git a/y2019/jevois/camera/BUILD b/y2019/jevois/camera/BUILD
index bf716a0..6bd2b99 100644
--- a/y2019/jevois/camera/BUILD
+++ b/y2019/jevois/camera/BUILD
@@ -4,6 +4,7 @@
     name = "reader",
     srcs = ["reader.cc"],
     hdrs = ["reader.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/time",
         "//aos/vision/image:camera_params",
@@ -17,6 +18,7 @@
     name = "image_stream",
     srcs = ["image_stream.cc"],
     hdrs = ["image_stream.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":reader",
         "//aos/logging",
diff --git a/y2019/jevois/deploy_teensy.sh b/y2019/jevois/deploy_teensy.sh
index 50d0571..87ea153 100755
--- a/y2019/jevois/deploy_teensy.sh
+++ b/y2019/jevois/deploy_teensy.sh
@@ -2,4 +2,4 @@
 
 cd "$(dirname "${BASH_SOURCE[0]}")"
 
-bazel build --cpu=cortex-m4f -c opt //y2019/jevois:teensy.hex -s && bazel run //motors/teensy_loader_cli -- --mcu=mk64fx512 -s $(readlink -f ../../bazel-bin/y2019/jevois/teensy.hex)
+bazel build --config=cortex-m4f -c opt //y2019/jevois:teensy.hex -s && bazel run //motors/teensy_loader_cli -- --mcu=mk64fx512 -s $(readlink -f ../../bazel-bin/y2019/jevois/teensy.hex)
diff --git a/y2019/vision/BUILD b/y2019/vision/BUILD
index 22b973a..e005e70 100644
--- a/y2019/vision/BUILD
+++ b/y2019/vision/BUILD
@@ -1,13 +1,12 @@
-load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_binary", "gtk_dependent_cc_library")
-load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
-load("//tools:environments.bzl", "mcu_cpus")
+load("//tools:platforms.bzl", "platforms")
+load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_binary")
 
 package(default_visibility = ["//visibility:public"])
 
-VISION_TARGETS = [
-    "//tools:k8",
-    "//tools:armhf-debian",
-]
+VISION_TARGETS = platforms.any_of([
+    "@platforms//cpu:x86_64",
+    "//tools/platforms/hardware:raspberry_pi",
+])
 
 cc_library(
     name = "constants",
@@ -16,13 +15,14 @@
         "constants_formatting.cc",
     ],
     hdrs = ["constants.h"],
-    compatible_with = mcu_cpus,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 cc_binary(
     name = "constants_formatting",
     srcs = ["constants_formatting_main.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":constants"],
 )
 
@@ -30,6 +30,7 @@
     name = "generate_constants",
     outs = ["validate_constants.cc"],
     cmd = "$(location :constants_formatting) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":constants_formatting"],
 )
 
@@ -37,6 +38,7 @@
     name = "image_writer",
     srcs = ["image_writer.cc"],
     hdrs = ["image_writer.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/image:image_types",
         "@com_github_google_glog//:glog",
@@ -54,6 +56,7 @@
         ":constants.cc",
         ":validate_constants.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -66,7 +69,7 @@
         "target_finder.h",
         "target_types.h",
     ],
-    restricted_to = VISION_TARGETS,
+    target_compatible_with = VISION_TARGETS,
     deps = [
         ":constants",
         "//aos/util:math",
@@ -84,7 +87,7 @@
 gtk_dependent_cc_binary(
     name = "debug_viewer",
     srcs = ["debug_viewer.cc"],
-    restricted_to = VISION_TARGETS,
+    target_compatible_with = VISION_TARGETS,
     deps = [
         ":target_finder",
         "//aos/vision/blob:move_scale",
@@ -99,7 +102,7 @@
 cc_binary(
     name = "target_sender",
     srcs = ["target_sender.cc"],
-    restricted_to = VISION_TARGETS,
+    target_compatible_with = VISION_TARGETS,
     deps = [
         ":image_writer",
         ":target_finder",
@@ -121,7 +124,7 @@
 cc_binary(
     name = "serial_waiter",
     srcs = ["serial_waiter.cc"],
-    restricted_to = VISION_TARGETS,
+    target_compatible_with = VISION_TARGETS,
     deps = [
         "//aos/time",
         "//y2019/jevois:serial",
@@ -131,6 +134,7 @@
 cc_binary(
     name = "debug_serial",
     srcs = ["debug_serial.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/logging:implementations",
@@ -145,7 +149,7 @@
     srcs = [
         "global_calibration.cc",
     ],
-    restricted_to = VISION_TARGETS,
+    target_compatible_with = VISION_TARGETS,
     deps = [
         ":target_finder",
         "//aos/logging",
diff --git a/y2019/vision/server/BUILD b/y2019/vision/server/BUILD
index 3d63e09..c20357f 100644
--- a/y2019/vision/server/BUILD
+++ b/y2019/vision/server/BUILD
@@ -9,6 +9,7 @@
     srcs = [
         "demo.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 gen_embedded(
@@ -17,6 +18,7 @@
         include = ["www_defaults/**/*"],
         exclude = ["www/**/*"],
     ),
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_downloader_dir(
@@ -26,12 +28,14 @@
         "//y2019/vision/server/www:visualizer_bundle",
     ],
     dir = "www",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 cc_proto_library(
     name = "server_data_proto",
     srcs = ["server_data.proto"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_binary(
@@ -43,6 +47,7 @@
         "//y2019/vision/server/www:files",
         "//y2019/vision/server/www:visualizer_bundle",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":gen_embedded",
diff --git a/y2019/vision/server/www/BUILD b/y2019/vision/server/www/BUILD
index 7631d5e..62c1f13 100644
--- a/y2019/vision/server/www/BUILD
+++ b/y2019/vision/server/www/BUILD
@@ -15,11 +15,13 @@
     srcs = glob([
         "*.ts",
     ]) + ["camera_constants.ts"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_binary(
     name = "generate_camera",
     srcs = ["generate_camera.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = ["//y2019:constants"],
 )
 
@@ -27,6 +29,7 @@
     name = "gen_cam_ts",
     outs = ["camera_constants.ts"],
     cmd = "$(location :generate_camera) $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":generate_camera"],
 )
 
@@ -34,6 +37,7 @@
     name = "visualizer_bundle",
     enable_code_splitting = False,
     entry_point = "main.ts",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":visualizer",
     ],
diff --git a/y2019/vision/tools/deploy.sh b/y2019/vision/tools/deploy.sh
index 2538239..c3bf9b9 100755
--- a/y2019/vision/tools/deploy.sh
+++ b/y2019/vision/tools/deploy.sh
@@ -15,7 +15,7 @@
 fi
 
 echo "Building executables"
-readonly BAZEL_OPTIONS="-c opt --cpu=armhf-debian"
+readonly BAZEL_OPTIONS="-c opt --config=armhf-debian"
 readonly BAZEL_BIN="$(bazel info ${BAZEL_OPTIONS} bazel-bin)"
 readonly TARGET_DIR=/media/$USER/JEVOIS