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/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