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/y2017/BUILD b/y2017/BUILD
index 3c1fe21..a43654d 100644
--- a/y2017/BUILD
+++ b/y2017/BUILD
@@ -9,6 +9,7 @@
     hdrs = [
         "constants.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/logging",
@@ -30,6 +31,7 @@
     srcs = [
         "joystick_reader.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":constants",
         "//aos:init",
@@ -56,6 +58,7 @@
         "//y2017/control_loops/superstructure:superstructure_status_fbs",
         "//y2017/vision:vision_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/robot_state:config",
@@ -68,7 +71,7 @@
     srcs = [
         "wpilib_interface.cc",
     ],
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     deps = [
         ":constants",
         "//aos:init",
@@ -114,10 +117,12 @@
         "//y2017/control_loops/superstructure:superstructure",
         "//y2017/actors:autonomous_action",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/y2017/actors/BUILD b/y2017/actors/BUILD
index 3b3e0a2..de1c594 100644
--- a/y2017/actors/BUILD
+++ b/y2017/actors/BUILD
@@ -15,6 +15,7 @@
     hdrs = [
         "autonomous_actor.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/actions:action_lib",
         "//aos/events:event_loop",
@@ -34,6 +35,7 @@
     srcs = [
         "autonomous_actor_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":autonomous_action_lib",
         "//aos:init",
diff --git a/y2017/control_loops/BUILD b/y2017/control_loops/BUILD
index d34fcab..d88a2bf 100644
--- a/y2017/control_loops/BUILD
+++ b/y2017/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 = ["//y2017:python_init"],
 )
diff --git a/y2017/control_loops/drivetrain/BUILD b/y2017/control_loops/drivetrain/BUILD
index 46af643..86d923f 100644
--- a/y2017/control_loops/drivetrain/BUILD
+++ b/y2017/control_loops/drivetrain/BUILD
@@ -9,6 +9,7 @@
         "kalman_drivetrain_motor_plant.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:drivetrain) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:drivetrain",
     ],
@@ -26,6 +27,7 @@
         "hybrid_velocity_drivetrain.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:polydrivetrain) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:polydrivetrain",
     ],
@@ -46,6 +48,7 @@
         "kalman_drivetrain_motor_plant.h",
         "polydrivetrain_dog_motor_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
         "//frc971/control_loops:state_feedback_loop",
@@ -60,6 +63,7 @@
     hdrs = [
         "drivetrain_base.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":polydrivetrain_plants",
         "//frc971:shifter_hall_effect",
@@ -73,6 +77,7 @@
     srcs = [
         "drivetrain_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":drivetrain_base",
         "//aos:init",
diff --git a/y2017/control_loops/python/BUILD b/y2017/control_loops/python/BUILD
index 6afb242..4de8144 100644
--- a/y2017/control_loops/python/BUILD
+++ b/y2017/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"],
     deps = [
         "//external:python-gflags",
         "//external:python-glog",
@@ -52,7 +52,7 @@
         "shooter.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -68,7 +68,7 @@
         "indexer.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -83,7 +83,7 @@
         "intake.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//external:python-gflags",
@@ -99,7 +99,7 @@
         "turret.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//aos/util:py_trapezoid_profile",
@@ -116,7 +116,7 @@
         "hood.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":python_init",
         "//aos/util:py_trapezoid_profile",
@@ -132,7 +132,7 @@
     srcs = [
         "turret.py",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         "//aos/util:py_trapezoid_profile",
         "//external:python-gflags",
@@ -146,7 +146,7 @@
     srcs = [
         "indexer.py",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         "//external:python-gflags",
         "//external:python-glog",
@@ -160,7 +160,7 @@
         "column.py",
     ],
     legacy_create_init = False,
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     deps = [
         ":indexer_lib",
         ":python_init",
@@ -175,6 +175,7 @@
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = ["//y2017/control_loops:python_init"],
 )
diff --git a/y2017/control_loops/superstructure/BUILD b/y2017/control_loops/superstructure/BUILD
index 7107e23..fa835c1 100644
--- a/y2017/control_loops/superstructure/BUILD
+++ b/y2017/control_loops/superstructure/BUILD
@@ -11,6 +11,7 @@
     includes = [
         "//frc971/control_loops:control_loops_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -22,6 +23,7 @@
     includes = [
         "//frc971/control_loops:control_loops_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -34,6 +36,7 @@
         "//frc971/control_loops:control_loops_fbs_includes",
         "//frc971/control_loops:profiled_subsystem_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -42,6 +45,7 @@
         "superstructure_output.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -52,6 +56,7 @@
     hdrs = [
         "superstructure.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_goal_fbs",
         ":superstructure_output_fbs",
@@ -74,6 +79,7 @@
         "superstructure_lib_test.cc",
     ],
     data = ["//y2017:config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_goal_fbs",
         ":superstructure_lib",
@@ -98,6 +104,7 @@
     srcs = [
         "superstructure_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":superstructure_lib",
         "//aos:init",
@@ -113,6 +120,7 @@
     hdrs = [
         "vision_time_adjuster.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/containers:ring_buffer",
         "//frc971/control_loops:control_loops_fbs",
@@ -129,6 +137,7 @@
         "vision_time_adjuster_test.cc",
     ],
     data = ["//y2017:config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":vision_time_adjuster",
         "//aos/events:simulated_event_loop",
@@ -143,6 +152,7 @@
     hdrs = [
         "vision_distance_average.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/containers:ring_buffer",
         "//aos/time",
@@ -155,6 +165,7 @@
     srcs = [
         "vision_distance_average_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":vision_distance_average",
         "//aos:flatbuffers",
diff --git a/y2017/control_loops/superstructure/column/BUILD b/y2017/control_loops/superstructure/column/BUILD
index 63dd98c..e59d1e6 100644
--- a/y2017/control_loops/superstructure/column/BUILD
+++ b/y2017/control_loops/superstructure/column/BUILD
@@ -9,6 +9,7 @@
         "stuck_column_integral_plant.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:column) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:column",
     ],
@@ -26,6 +27,7 @@
         "column_plant.h",
         "stuck_column_integral_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:state_feedback_loop",
@@ -40,6 +42,7 @@
     hdrs = [
         "column.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":column_plants",
@@ -63,6 +66,7 @@
     hdrs = [
         "column_zeroing.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//frc971:constants",
         "//frc971/control_loops:profiled_subsystem_fbs",
@@ -79,6 +83,7 @@
     srcs = [
         "column_zeroing_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":column_zeroing",
         "//aos/testing:test_shm",
diff --git a/y2017/control_loops/superstructure/hood/BUILD b/y2017/control_loops/superstructure/hood/BUILD
index c3f6ef0..8f162a7 100644
--- a/y2017/control_loops/superstructure/hood/BUILD
+++ b/y2017/control_loops/superstructure/hood/BUILD
@@ -7,6 +7,7 @@
         "hood_integral_plant.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:hood) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:hood",
     ],
@@ -22,6 +23,7 @@
         "hood_integral_plant.h",
         "hood_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:state_feedback_loop",
@@ -36,6 +38,7 @@
     hdrs = [
         "hood.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":hood_plants",
diff --git a/y2017/control_loops/superstructure/intake/BUILD b/y2017/control_loops/superstructure/intake/BUILD
index 43f4927..550c241 100644
--- a/y2017/control_loops/superstructure/intake/BUILD
+++ b/y2017/control_loops/superstructure/intake/BUILD
@@ -7,6 +7,7 @@
         "intake_integral_plant.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:intake) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:intake",
     ],
@@ -22,6 +23,7 @@
         "intake_integral_plant.h",
         "intake_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:state_feedback_loop",
@@ -36,6 +38,7 @@
     hdrs = [
         "intake.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":intake_plants",
diff --git a/y2017/control_loops/superstructure/shooter/BUILD b/y2017/control_loops/superstructure/shooter/BUILD
index d83e34b..49fa341 100644
--- a/y2017/control_loops/superstructure/shooter/BUILD
+++ b/y2017/control_loops/superstructure/shooter/BUILD
@@ -9,6 +9,7 @@
         "shooter_integral_plant.cc",
     ],
     cmd = "$(location //y2017/control_loops/python:shooter) $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "//y2017/control_loops/python:shooter",
     ],
@@ -24,6 +25,7 @@
         "shooter_integral_plant.h",
         "shooter_plant.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:hybrid_state_feedback_loop",
@@ -39,6 +41,7 @@
     hdrs = [
         "shooter.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":shooter_plants",
diff --git a/y2017/vision/BUILD b/y2017/vision/BUILD
index a71fc8a..62e2278 100644
--- a/y2017/vision/BUILD
+++ b/y2017/vision/BUILD
@@ -1,5 +1,5 @@
 load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
-load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_binary", "gtk_dependent_cc_library")
+load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_binary")
 load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
 
 package(default_visibility = ["//visibility:public"])
@@ -10,17 +10,20 @@
         "vision.fbs",
     ],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 cc_proto_library(
     name = "vision_result",
     srcs = ["vision_result.proto"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_proto_library(
     name = "vision_config",
     srcs = ["vision_config.proto"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/image:camera_params",
     ],
@@ -31,6 +34,7 @@
     srcs = [
         "target_sender.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":target_finder",
         ":vision_config",
@@ -56,6 +60,7 @@
     srcs = [
         "target_receiver.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":target_finder",
@@ -73,6 +78,7 @@
     name = "target_finder",
     srcs = ["target_finder.cc"],
     hdrs = ["target_finder.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/blob:threshold",
         "//aos/vision/blob:transpose",
@@ -84,6 +90,7 @@
 gtk_dependent_cc_binary(
     name = "debug_viewer",
     srcs = ["debug_viewer.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":target_finder",
         "//aos/vision/blob:move_scale",