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/aos/BUILD b/aos/BUILD
index 9a62e66..beeb2b0 100644
--- a/aos/BUILD
+++ b/aos/BUILD
@@ -1,4 +1,3 @@
-load("//tools:environments.bzl", "mcu_cpus")
 load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library", "flatbuffer_ts_library")
 
 filegroup(
@@ -43,7 +42,6 @@
     hdrs = [
         "commonmath.h",
     ],
-    compatible_with = mcu_cpus,
     visibility = ["//visibility:public"],
 )
 
@@ -52,12 +50,14 @@
     hdrs = [
         "byteorder.h",
     ],
+    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"],
 )
 
@@ -66,7 +66,6 @@
     hdrs = [
         "macros.h",
     ],
-    compatible_with = mcu_cpus,
     visibility = ["//visibility:public"],
 )
 
@@ -75,6 +74,7 @@
     hdrs = [
         "gtest_prod.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -83,6 +83,7 @@
     hdrs = [
         "network_port.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -91,6 +92,7 @@
     hdrs = [
         "unique_malloc_ptr.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -102,6 +104,7 @@
     hdrs = [
         "condition.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/ipc_lib:aos_sync",
@@ -115,6 +118,7 @@
     srcs = [
         "condition_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":condition",
         "//aos:die",
@@ -137,6 +141,7 @@
     hdrs = [
         "die.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:macros",
@@ -149,6 +154,7 @@
     srcs = [
         "die_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":die",
         "//aos/testing:googletest",
@@ -163,6 +169,7 @@
     hdrs = [
         "event.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/ipc_lib:aos_sync",
@@ -177,6 +184,7 @@
     srcs = [
         "event_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event",
         "//aos/testing:googletest",
@@ -190,6 +198,7 @@
     srcs = [
         "dump_rtprio.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/logging:implementations",
@@ -205,6 +214,7 @@
     hdrs = [
         "complex_thread_local.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:die",
@@ -217,6 +227,7 @@
     srcs = [
         "complex_thread_local_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":complex_thread_local",
         "//aos/logging",
@@ -232,6 +243,7 @@
     hdrs = [
         "init.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":realtime",
@@ -248,6 +260,7 @@
     hdrs = [
         "realtime.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":thread_local",
@@ -259,12 +272,14 @@
     name = "configuration_fbs",
     srcs = ["configuration.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 flatbuffer_ts_library(
     name = "configuration_ts_fbs",
     srcs = ["configuration.fbs"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -279,6 +294,7 @@
         "Map",
         "Node",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -290,6 +306,7 @@
     hdrs = [
         "configuration.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":configuration_fbs",
@@ -310,12 +327,14 @@
     hdrs = [
         "make_unique.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
 flatbuffer_ts_library(
     name = "json_to_flatbuffer_flatbuffer_ts",
     srcs = ["json_to_flatbuffer.fbs"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//aos:__subpackages__"],
 )
 
@@ -323,6 +342,7 @@
     name = "json_to_flatbuffer_flatbuffer",
     srcs = ["json_to_flatbuffer.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//aos:__subpackages__"],
 )
 
@@ -330,6 +350,7 @@
     name = "flatbuffer_utils",
     srcs = ["flatbuffer_utils.cc"],
     hdrs = ["flatbuffer_utils.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_github_google_flatbuffers//:flatbuffers",
     ],
@@ -339,6 +360,7 @@
     name = "json_tokenizer",
     srcs = ["json_tokenizer.cc"],
     hdrs = ["json_tokenizer.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_github_google_glog//:glog",
         "@com_google_absl//absl/strings",
@@ -352,6 +374,7 @@
         "json_to_flatbuffer.cc",
     ],
     hdrs = ["json_to_flatbuffer.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":fast_string_builder",
@@ -369,6 +392,7 @@
     srcs = [
         "json_to_flatbuffer_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":json_to_flatbuffer",
         ":json_to_flatbuffer_flatbuffer",
@@ -384,6 +408,7 @@
     data = [
         ":json_to_flatbuffer_flatbuffer_reflection_out",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":json_to_flatbuffer",
         ":json_to_flatbuffer_flatbuffer",
@@ -398,6 +423,7 @@
     srcs = ["flatbuffer_merge.cc"],
     hdrs = ["flatbuffer_merge.h"],
     copts = ["-Wno-cast-align"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":flatbuffer_utils",
@@ -411,6 +437,7 @@
     srcs = [
         "flatbuffer_merge_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":flatbuffer_merge",
         ":json_to_flatbuffer",
@@ -427,6 +454,7 @@
     hdrs = [
         "flatbuffers.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:macros",
@@ -448,6 +476,7 @@
         "//aos/events:pong.bfbs",
         "//aos/testdata:test_configs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":configuration",
         "//aos/testing:googletest",
@@ -460,6 +489,7 @@
     srcs = [
         "config_flattener.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":configuration",
@@ -474,6 +504,7 @@
     srcs = [
         "aos_dump.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":configuration",
@@ -489,6 +520,7 @@
     srcs = [
         "aos_graph_nodes.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":configuration",
@@ -507,6 +539,7 @@
     hdrs = [
         "ftrace.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@com_github_google_glog//:glog",
@@ -521,6 +554,7 @@
     hdrs = [
         "fast_string_builder.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_github_google_glog//:glog",
         "@com_google_absl//absl/strings",
@@ -533,6 +567,7 @@
     hdrs = [
         "thread_local.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -541,6 +576,7 @@
     srcs = [
         "realtime_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":realtime",
diff --git a/aos/actions/BUILD b/aos/actions/BUILD
index 14592cf..7898353 100644
--- a/aos/actions/BUILD
+++ b/aos/actions/BUILD
@@ -13,6 +13,7 @@
         "actions.h",
         "actor.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":actions_fbs",
         "//aos/controls:control_loop",
@@ -26,18 +27,21 @@
     name = "actions_fbs",
     srcs = ["actions.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
     name = "test_action_fbs",
     srcs = ["test_action.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
     name = "test_action2_fbs",
     srcs = ["test_action2.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_config(
@@ -48,6 +52,7 @@
         ":test_action_fbs",
         ":test_action2_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/events:config",
     ],
@@ -59,6 +64,7 @@
         "action_test.cc",
     ],
     data = [":action_test_config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":action_lib",
         ":actions_fbs",
diff --git a/aos/config.bzl b/aos/config.bzl
index a11efd5..57d6af3 100644
--- a/aos/config.bzl
+++ b/aos/config.bzl
@@ -5,7 +5,7 @@
     "transitive_src",
 ])
 
-def aos_config(name, src, flatbuffers = [], deps = [], visibility = None, testonly = False):
+def aos_config(name, src, flatbuffers = [], deps = [], visibility = None, testonly = False, target_compatible_with = None):
     _aos_config(
         name = name,
         src = src,
@@ -13,6 +13,7 @@
         flatbuffers = [expand_label(flatbuffer) + "_reflection_out" for flatbuffer in flatbuffers],
         visibility = visibility,
         testonly = testonly,
+        target_compatible_with = target_compatible_with,
     )
 
 def _aos_config_impl(ctx):
diff --git a/aos/containers/BUILD b/aos/containers/BUILD
index 9e527cd..70d98f1 100644
--- a/aos/containers/BUILD
+++ b/aos/containers/BUILD
@@ -1,12 +1,11 @@
 package(default_visibility = ["//visibility:public"])
 
-load("//tools:environments.bzl", "mcu_cpus")
-
 cc_library(
     name = "ring_buffer",
     hdrs = [
         "ring_buffer.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -14,6 +13,7 @@
     srcs = [
         "ring_buffer_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":ring_buffer",
         "//aos/testing:googletest",
@@ -25,6 +25,7 @@
     hdrs = [
         "priority_queue.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -32,6 +33,7 @@
     srcs = [
         "priority_queue_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":priority_queue",
         "//aos/testing:googletest",
@@ -43,7 +45,6 @@
     hdrs = [
         "sized_array.h",
     ],
-    compatible_with = mcu_cpus,
 )
 
 cc_test(
@@ -51,6 +52,7 @@
     srcs = [
         "sized_array_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":sized_array",
         "//aos/testing:googletest",
@@ -62,6 +64,7 @@
     hdrs = [
         "resizeable_buffer.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_github_google_glog//:glog",
     ],
@@ -72,6 +75,7 @@
     srcs = [
         "resizeable_buffer_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":resizeable_buffer",
         "//aos/testing:googletest",
diff --git a/aos/controls/BUILD b/aos/controls/BUILD
index 7172cbb..14890d4 100644
--- a/aos/controls/BUILD
+++ b/aos/controls/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 = "control_loop_test",
@@ -12,6 +11,7 @@
     hdrs = [
         "control_loop_test.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:flatbuffers",
         "//aos:json_to_flatbuffer",
@@ -25,27 +25,20 @@
 )
 
 cc_library(
-    name = "polytope_uc",
-    hdrs = [
-        "polytope.h",
-    ],
-    restricted_to = mcu_cpus,
-    deps = [
-        "@org_tuxfamily_eigen//:eigen",
-    ],
-)
-
-cc_library(
     name = "polytope",
     hdrs = [
         "polytope.h",
     ],
     deps = [
-        "//aos/logging",
-        "//third_party/cddlib",
-        "@com_github_google_glog//:glog",
         "@org_tuxfamily_eigen//:eigen",
-    ],
+    ] + select({
+        "@platforms//os:linux": [
+            "//aos/logging",
+            "//third_party/cddlib",
+            "@com_github_google_glog//:glog",
+        ],
+        "//conditions:default": [],
+    }),
 )
 
 cc_test(
@@ -53,6 +46,7 @@
     srcs = [
         "polytope_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":polytope",
         "//aos/testing:googletest",
@@ -66,6 +60,7 @@
     srcs = [
         "control_loops.fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -77,6 +72,7 @@
     hdrs = [
         "control_loop.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/events:event_loop",
         "//aos/events:shm_event_loop",
@@ -96,6 +92,7 @@
     hdrs = [
         "quaternion_utils.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_github_google_glog//:glog",
         "@org_tuxfamily_eigen//:eigen",
@@ -107,6 +104,7 @@
     srcs = [
         "quaternion_utils_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":quaternion_utils",
         "//aos/testing:googletest",
diff --git a/aos/events/BUILD b/aos/events/BUILD
index c408b7b..95e6cdc 100644
--- a/aos/events/BUILD
+++ b/aos/events/BUILD
@@ -7,6 +7,7 @@
     name = "test_message_fbs",
     srcs = ["test_message.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -16,29 +17,34 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
     name = "ping_fbs",
     srcs = ["ping.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_ts_library(
     name = "ping_ts_fbs",
     srcs = ["ping.fbs"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
     name = "pong_fbs",
     srcs = ["pong.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
     name = "epoll",
     srcs = ["epoll.cc"],
     hdrs = ["epoll.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/time",
@@ -49,6 +55,7 @@
 cc_test(
     name = "epoll_test",
     srcs = ["epoll_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":epoll",
         "//aos/testing:googletest",
@@ -67,6 +74,7 @@
         "channel_preallocated_allocator.h",
         "event_loop.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":event_loop_fbs",
@@ -92,6 +100,7 @@
     hdrs = [
         "ping_lib.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop",
         ":ping_fbs",
@@ -107,6 +116,7 @@
         "ping.cc",
     ],
     data = [":pingpong_config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":ping_lib",
         ":shm_event_loop",
@@ -126,6 +136,7 @@
         "//aos/starter:starter_fbs",
         "//aos/starter:starter_rpc_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_config(
@@ -135,6 +146,7 @@
         ":ping_fbs",
         ":pong_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":config"],
 )
 
@@ -149,6 +161,7 @@
         "//aos/network:timestamp_fbs",
         "//aos/network:message_bridge_server_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":config"],
 )
 
@@ -160,6 +173,7 @@
     hdrs = [
         "pong_lib.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop",
         ":ping_fbs",
@@ -174,6 +188,7 @@
         "pong.cc",
     ],
     data = [":pingpong_config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":ping_fbs",
         ":pong_fbs",
@@ -190,6 +205,7 @@
     name = "pingpong_test",
     srcs = ["pingpong_test.cc"],
     data = [":pingpong_config"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":ping_lib",
         ":pong_lib",
@@ -204,6 +220,7 @@
     name = "timing_statistics",
     srcs = ["timing_statistics.cc"],
     hdrs = ["timing_statistics.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop_fbs",
         "//aos:configuration",
@@ -214,6 +231,7 @@
 cc_test(
     name = "timing_statistics_test",
     srcs = ["timing_statistics_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":timing_statistics",
         "//aos:configuration",
@@ -226,6 +244,7 @@
     name = "shm_event_loop",
     srcs = ["shm_event_loop.cc"],
     hdrs = ["shm_event_loop.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":aos_logging",
@@ -248,6 +267,7 @@
     name = "shm_event_loop_test",
     srcs = ["shm_event_loop_test.cc"],
     shard_count = 16,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop_param_test",
         ":shm_event_loop",
@@ -260,6 +280,7 @@
     testonly = True,
     srcs = ["event_loop_param_test.cc"],
     hdrs = ["event_loop_param_test.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop",
         ":test_message_fbs",
@@ -273,6 +294,7 @@
     srcs = ["simulated_event_loop_test.cc"],
     data = [":multinode_pingpong_config"],
     shard_count = 4,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":event_loop_param_test",
         ":message_counter",
@@ -287,6 +309,7 @@
     name = "simple_channel",
     srcs = ["simple_channel.cc"],
     hdrs = ["simple_channel.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:configuration_fbs",
         "@com_github_google_flatbuffers//:flatbuffers",
@@ -307,6 +330,7 @@
         "simulated_event_loop.h",
         "simulated_network_bridge.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":aos_logging",
@@ -326,6 +350,7 @@
 cc_test(
     name = "event_scheduler_test",
     srcs = ["event_scheduler_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":simulated_event_loop",
         "//aos/testing:googletest",
@@ -341,6 +366,7 @@
     hdrs = [
         "aos_logging.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":event_loop",
@@ -352,6 +378,7 @@
 cc_library(
     name = "message_counter",
     hdrs = ["message_counter.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":event_loop",
diff --git a/aos/events/logging/BUILD b/aos/events/logging/BUILD
index f4c4ceb..40e6626 100644
--- a/aos/events/logging/BUILD
+++ b/aos/events/logging/BUILD
@@ -8,6 +8,7 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -21,11 +22,13 @@
         "logfile_sorting.h",
         "logfile_utils.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":buffer_encoder",
         ":uuid",
         ":logger_fbs",
+        ":lzma_encoder",
         "//aos:configuration",
         "//aos:flatbuffer_merge",
         "//aos:flatbuffers",
@@ -36,11 +39,7 @@
         "@com_github_google_flatbuffers//:flatbuffers",
         "@com_github_google_glog//:glog",
         "@com_google_absl//absl/types:span",
-    ] + select({
-        "//tools:cpu_k8": [":lzma_encoder"],
-        "//tools:cpu_aarch64": [":lzma_encoder"],
-        "//conditions:default": [],
-    }),
+    ],
 )
 
 cc_binary(
@@ -49,6 +48,7 @@
     srcs = [
         "logfile_utils_out_of_space_test_runner.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logfile_utils",
         "//aos:init",
@@ -65,6 +65,7 @@
     data = [
         ":logfile_utils_out_of_space_test_runner",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@bazel_tools//tools/bash/runfiles",
     ],
@@ -78,6 +79,7 @@
     hdrs = [
         "buffer_encoder.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":logger_fbs",
@@ -94,6 +96,7 @@
         "buffer_encoder_test.cc",
     ],
     shard_count = 4,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":buffer_encoder",
         ":buffer_encoder_param_test",
@@ -102,29 +105,15 @@
     ],
 )
 
-# TODO(Brian): Properly restrict this to specific platforms and
-# un-conditionalize the srcs and hdrs once we have support for that which
-# interacts with select properly.
 cc_library(
     name = "lzma_encoder",
-    srcs = select({
-        "//tools:cpu_k8": [
-            "lzma_encoder.cc",
-        ],
-        "//tools:cpu_aarch64": [
-            "lzma_encoder.cc",
-        ],
-        "//conditions:default": [],
-    }),
-    hdrs = select({
-        "//tools:cpu_k8": [
-            "lzma_encoder.h",
-        ],
-        "//tools:cpu_aarch64": [
-            "lzma_encoder.h",
-        ],
-        "//conditions:default": [],
-    }),
+    srcs = [
+        "lzma_encoder.cc",
+    ],
+    hdrs = [
+        "lzma_encoder.h",
+    ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":buffer_encoder",
@@ -143,11 +132,8 @@
     srcs = [
         "lzma_encoder_test.cc",
     ],
-    restricted_to = [
-        "//tools:k8",
-        "//tools:aarch64",
-    ],
     shard_count = 4,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":buffer_encoder_param_test",
         ":lzma_encoder",
@@ -165,6 +151,7 @@
     hdrs = [
         "buffer_encoder_param_test.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logfile_utils",
         ":logger_fbs",
@@ -186,6 +173,7 @@
         "log_namer.h",
         "logger.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":logfile_utils",
@@ -211,6 +199,7 @@
     srcs = [
         "log_cat.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":logger",
@@ -229,6 +218,7 @@
     srcs = [
         "log_edit.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logger",
         "//aos:configuration",
@@ -245,6 +235,7 @@
     srcs = [
         "log_stats.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logger",
         "//aos:configuration",
@@ -262,6 +253,7 @@
     srcs = [
         "logger_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":logger",
@@ -285,6 +277,7 @@
         "//aos/network:message_bridge_server_fbs",
         "//aos/network:timestamp_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = ["//aos/events:config"],
 )
 
@@ -301,6 +294,7 @@
         "//aos/events:pingpong_config",
     ],
     shard_count = 5,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logger",
         "//aos/events:message_counter",
@@ -316,11 +310,13 @@
     name = "uuid",
     srcs = ["uuid.cc"],
     hdrs = ["uuid.h"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
     name = "uuid_test",
     srcs = ["uuid_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":uuid",
         "//aos/testing:googletest",
@@ -330,6 +326,7 @@
 cc_test(
     name = "logfile_utils_test",
     srcs = ["logfile_utils_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":logfile_utils",
         ":test_message_fbs",
@@ -342,4 +339,5 @@
     name = "test_message_fbs",
     srcs = ["test_message.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
diff --git a/aos/input/BUILD b/aos/input/BUILD
index 24e6381..fafe39d 100644
--- a/aos/input/BUILD
+++ b/aos/input/BUILD
@@ -8,6 +8,7 @@
     hdrs = [
         "joystick_input.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/events:event_loop",
         "//aos/input:driver_station_data",
@@ -24,6 +25,7 @@
     hdrs = [
         "drivetrain_input.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:math",
         "//aos/input:driver_station_data",
@@ -44,6 +46,7 @@
     hdrs = [
         "driver_station_data.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/robot_state:joystick_state_fbs",
         "@com_github_google_glog//:glog",
@@ -54,6 +57,7 @@
     name = "action_joystick_input",
     srcs = ["action_joystick_input.cc"],
     hdrs = ["action_joystick_input.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":drivetrain_input",
         "//aos:init",
diff --git a/aos/ipc_lib/BUILD b/aos/ipc_lib/BUILD
index 0fb307a..7799cdc 100644
--- a/aos/ipc_lib/BUILD
+++ b/aos/ipc_lib/BUILD
@@ -9,6 +9,7 @@
     linkopts = [
         "-lpthread",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:macros",
@@ -27,6 +28,7 @@
     hdrs = [
         "core_lib.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":aos_sync",
@@ -45,6 +47,7 @@
     linkopts = [
         "-lrt",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":aos_sync",
@@ -61,6 +64,7 @@
     hdrs = [
         "shared_mem_types.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":aos_sync",
     ],
@@ -74,6 +78,7 @@
     tags = [
         "manual",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":core_lib",
         "//aos:die",
@@ -93,6 +98,7 @@
         "ipc_comparison.cc",
     ],
     linkopts = ["-lrt"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:condition",
         "//aos:event",
@@ -112,6 +118,7 @@
     hdrs = [
         "signalfd.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@com_github_google_glog//:glog",
@@ -123,6 +130,7 @@
     srcs = [
         "signalfd_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":signalfd",
         "//aos/testing:googletest",
@@ -135,6 +143,7 @@
     name = "index",
     srcs = ["index.cc"],
     hdrs = ["index.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@com_github_google_glog//:glog",
@@ -144,6 +153,7 @@
 cc_test(
     name = "index_test",
     srcs = ["index_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":index",
         "//aos/testing:googletest",
@@ -158,6 +168,7 @@
         "lockless_queue_memory.h",
     ],
     hdrs = ["lockless_queue.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":aos_sync",
@@ -181,6 +192,7 @@
     hdrs = [
         "queue_racer.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":lockless_queue",
         "//aos:event",
@@ -192,6 +204,7 @@
     name = "lockless_queue_test",
     timeout = "eternal",
     srcs = ["lockless_queue_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":lockless_queue",
         ":queue_racer",
@@ -206,6 +219,7 @@
 cc_test(
     name = "lockless_queue_death_test",
     srcs = ["lockless_queue_death_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":lockless_queue",
         ":queue_racer",
@@ -224,6 +238,7 @@
     hdrs = [
         "data_alignment.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@com_github_google_glog//:glog",
@@ -234,6 +249,7 @@
     name = "latency_lib",
     srcs = ["latency_lib.cc"],
     hdrs = ["latency_lib.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:realtime",
         "//aos/logging",
@@ -247,6 +263,7 @@
     srcs = [
         "signal_stress.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":latency_lib",
         "//aos:init",
@@ -260,6 +277,7 @@
     srcs = [
         "futex_latency.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":latency_lib",
         "//aos:condition",
@@ -274,6 +292,7 @@
     srcs = [
         "named_pipe_latency.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":latency_lib",
         "//aos:init",
@@ -287,6 +306,7 @@
     srcs = [
         "eventfd_latency.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":latency_lib",
         "//aos:init",
@@ -300,6 +320,7 @@
     srcs = [
         "print_lockless_queue_memory.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":lockless_queue",
diff --git a/aos/libc/BUILD b/aos/libc/BUILD
index 35b6629..cc54670 100644
--- a/aos/libc/BUILD
+++ b/aos/libc/BUILD
@@ -8,6 +8,7 @@
     hdrs = [
         "aos_strsignal.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:thread_local",
         "@com_github_google_glog//:glog",
@@ -19,6 +20,7 @@
     srcs = [
         "aos_strsignal_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":aos_strsignal",
         "//aos/testing:googletest",
@@ -33,6 +35,7 @@
     hdrs = [
         "dirname.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -40,6 +43,7 @@
     srcs = [
         "dirname_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":dirname",
         "//aos/testing:googletest",
@@ -54,6 +58,7 @@
     hdrs = [
         "aos_strerror.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:thread_local",
     ],
@@ -64,6 +69,7 @@
     srcs = [
         "aos_strerror_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":aos_strerror",
         "//aos/testing:googletest",
diff --git a/aos/logging/BUILD b/aos/logging/BUILD
index a9fcb14..cf0c370 100644
--- a/aos/logging/BUILD
+++ b/aos/logging/BUILD
@@ -14,6 +14,7 @@
         "interface.h",
         "logging.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":printf_formats",
@@ -36,6 +37,7 @@
     srcs = ["log_namer.cc"],
     hdrs = ["log_namer.h"],
     copts = ["-Wno-format-nonliteral"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:configuration",
@@ -48,6 +50,7 @@
     hdrs = [
         "sizes.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -55,6 +58,7 @@
     srcs = [
         "implementations_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":implementations",
         ":logging",
@@ -68,6 +72,7 @@
     hdrs = [
         "printf_formats.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:macros",
@@ -76,6 +81,7 @@
 
 cc_library(
     name = "implementations",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":logging",
@@ -86,5 +92,6 @@
     name = "log_message_fbs",
     srcs = ["log_message.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/aos/mutex/BUILD b/aos/mutex/BUILD
index bdfb8fc..d079a02 100644
--- a/aos/mutex/BUILD
+++ b/aos/mutex/BUILD
@@ -8,6 +8,7 @@
     hdrs = [
         "mutex.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/ipc_lib:aos_sync",
         "//aos/type_traits",
@@ -20,6 +21,7 @@
     srcs = [
         "mutex_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mutex",
         "//aos/testing:googletest",
diff --git a/aos/network/BUILD b/aos/network/BUILD
index c725ab7..4818aa2 100644
--- a/aos/network/BUILD
+++ b/aos/network/BUILD
@@ -11,6 +11,7 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_ts_library(
@@ -19,6 +20,7 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -28,6 +30,7 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -38,6 +41,7 @@
         ":message_bridge_server_fbs_includes",
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
@@ -47,6 +51,7 @@
     includes = [
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -57,6 +62,7 @@
     hdrs = [
         "team_number.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/util:string_to_num",
         "@com_github_google_glog//:glog",
@@ -68,6 +74,7 @@
     srcs = [
         "team_number_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":team_number",
         "//aos:configuration",
@@ -87,6 +94,7 @@
         # The casts required to read datastructures from sockets trip -Wcast-align.
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:unique_malloc_ptr",
         "//aos/util:file",
@@ -106,6 +114,7 @@
     copts = [
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":sctp_lib",
         "//third_party/lksctp-tools:sctp",
@@ -120,6 +129,7 @@
     hdrs = [
         "message_bridge_protocol.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":connect_fbs",
         "//aos:configuration",
@@ -137,6 +147,7 @@
     hdrs = [
         "message_bridge_server_status.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":message_bridge_client_fbs",
         ":message_bridge_server_fbs",
@@ -160,6 +171,7 @@
     copts = [
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":connect_fbs",
         ":message_bridge_client_fbs",
@@ -181,6 +193,7 @@
     srcs = [
         "message_bridge_server.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":message_bridge_server_lib",
         "//aos:init",
@@ -200,6 +213,7 @@
     copts = [
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":sctp_lib",
         "//third_party/lksctp-tools:sctp",
@@ -214,6 +228,7 @@
     hdrs = [
         "message_bridge_client_status.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":message_bridge_client_fbs",
         ":message_bridge_server_fbs",
@@ -235,6 +250,7 @@
     copts = [
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":connect_fbs",
         ":message_bridge_client_fbs",
@@ -256,6 +272,7 @@
     copts = [
         "-Wno-cast-align",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":message_bridge_client_lib",
         "//aos:init",
@@ -275,18 +292,21 @@
         "//aos/network:message_bridge_server_fbs",
         "//aos/network:timestamp_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = ["//aos/events:config"],
 )
 
 aos_config(
     name = "message_bridge_test_server_config",
     src = "message_bridge_test_server.json",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":message_bridge_test_common_config"],
 )
 
 aos_config(
     name = "message_bridge_test_client_config",
     src = "message_bridge_test_client.json",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":message_bridge_test_common_config"],
 )
 
@@ -300,6 +320,7 @@
         ":message_bridge_test_server_config",
     ],
     shard_count = 5,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":message_bridge_client_lib",
         ":message_bridge_server_lib",
@@ -320,6 +341,7 @@
         ":connect_fbs_includes",
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_ts_library(
@@ -329,12 +351,14 @@
         ":connect_fbs_includes",
         "//aos:configuration_fbs_includes",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
     name = "web_proxy_utils",
     srcs = ["web_proxy_utils.cc"],
     hdrs = ["web_proxy_utils.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":connect_fbs",
         ":web_proxy_fbs",
@@ -352,6 +376,7 @@
         "-DWEBRTC_POSIX",
         "-Wno-unused-parameter",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":connect_fbs",
         ":web_proxy_fbs",
@@ -370,6 +395,7 @@
         include = ["www_defaults/**/*"],
         exclude = ["www/**/*"],
     ),
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_binary(
@@ -384,6 +410,7 @@
         "//aos/network/www:main_bundle.min.js",
         "@com_github_google_flatbuffers//:flatjs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":gen_embedded",
         ":web_proxy",
@@ -399,6 +426,7 @@
     name = "timestamp_filter",
     srcs = ["timestamp_filter.cc"],
     hdrs = ["timestamp_filter.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:configuration",
         "//aos/time",
@@ -412,6 +440,7 @@
     srcs = [
         "timestamp_filter_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":timestamp_filter",
         "//aos:json_to_flatbuffer",
diff --git a/aos/network/www/BUILD b/aos/network/www/BUILD
index 4987a30..8142e24 100644
--- a/aos/network/www/BUILD
+++ b/aos/network/www/BUILD
@@ -1,5 +1,5 @@
 load("@npm_bazel_typescript//:defs.bzl", "ts_library")
-load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "nodejs_binary")
+load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
 load("//aos:config.bzl", "aos_config")
 
 filegroup(
@@ -17,6 +17,7 @@
         "config_handler.ts",
         "proxy.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:configuration_ts_fbs",
@@ -32,6 +33,7 @@
         "main.ts",
         "ping_handler.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":proxy",
         "//aos/events:ping_ts_fbs",
@@ -42,6 +44,7 @@
     name = "main_bundle",
     enable_code_splitting = False,
     entry_point = "main.ts",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//aos:__subpackages__"],
     deps = [
         ":main",
@@ -57,6 +60,7 @@
         "flatbuffers.js",
     ],
     cmd = "cp $(location @com_github_google_flatbuffers//:flatjs) $@",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//aos:__subpackages__"],
 )
 
@@ -65,6 +69,7 @@
     srcs = [
         "reflection_test_main.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":reflection_ts",
         "//aos:configuration_ts_fbs",
@@ -77,6 +82,7 @@
 ts_library(
     name = "reflection_ts",
     srcs = ["reflection.ts"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:configuration_ts_fbs",
@@ -90,6 +96,7 @@
     srcs = [
         "plotter.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -98,6 +105,7 @@
     srcs = [
         "graph_main.ts",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":plotter",
         ":proxy",
@@ -112,6 +120,7 @@
     name = "graph_main_bundle",
     enable_code_splitting = False,
     entry_point = "graph_main.ts",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":graph_main",
     ],
@@ -124,6 +133,7 @@
         "//aos:configuration_fbs",
         "//aos:json_to_flatbuffer_flatbuffer",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/events:config",
     ],
@@ -133,6 +143,7 @@
     name = "reflection_test_bundle",
     enable_code_splitting = False,
     entry_point = "reflection_test_main.ts",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":reflection_test_main",
     ],
@@ -150,4 +161,5 @@
         "//aos/network:web_proxy_main",
         "//y2020:config",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
diff --git a/aos/protobuf/BUILD b/aos/protobuf/BUILD
index 4d6a107..6e61139 100644
--- a/aos/protobuf/BUILD
+++ b/aos/protobuf/BUILD
@@ -4,6 +4,7 @@
     name = "stack_arena",
     srcs = ["stack_arena.cc"],
     hdrs = ["stack_arena.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "@com_google_protobuf//:protobuf",
@@ -13,6 +14,7 @@
 cc_test(
     name = "stack_arena_test",
     srcs = ["stack_arena_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":stack_arena",
         "//aos/logging",
diff --git a/aos/robot_state/BUILD b/aos/robot_state/BUILD
index 9748e1b..663c8c6 100644
--- a/aos/robot_state/BUILD
+++ b/aos/robot_state/BUILD
@@ -7,12 +7,14 @@
     name = "robot_state_fbs",
     srcs = ["robot_state.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 flatbuffer_cc_library(
     name = "joystick_state_fbs",
     srcs = ["joystick_state.fbs"],
     gen_reflections = 1,
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_config(
@@ -22,6 +24,7 @@
         "//aos/robot_state:joystick_state_fbs",
         "//aos/robot_state:robot_state_fbs",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = ["//aos/events:config"],
 )
diff --git a/aos/scoped/BUILD b/aos/scoped/BUILD
index 1ec0f1b..fb867c6 100644
--- a/aos/scoped/BUILD
+++ b/aos/scoped/BUILD
@@ -8,6 +8,7 @@
     hdrs = [
         "scoped_fd.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:macros",
         "@com_github_google_glog//:glog",
diff --git a/aos/seasocks/BUILD b/aos/seasocks/BUILD
index ae8d402..e9a98c7 100644
--- a/aos/seasocks/BUILD
+++ b/aos/seasocks/BUILD
@@ -3,6 +3,7 @@
     srcs = [
         "gen_embedded.py",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -10,6 +11,7 @@
     name = "seasocks_logger",
     srcs = ["seasocks_logger.cc"],
     hdrs = ["seasocks_logger.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos/logging",
diff --git a/aos/seasocks/gen_embedded.bzl b/aos/seasocks/gen_embedded.bzl
index bb27e52..7d67249 100644
--- a/aos/seasocks/gen_embedded.bzl
+++ b/aos/seasocks/gen_embedded.bzl
@@ -41,11 +41,12 @@
   srcs: Files to allow loading.
 """
 
-def gen_embedded(name, srcs, visibility = None):
+def gen_embedded(name, srcs, visibility = None, target_compatible_with = None):
     _do_gen_embedded(
         name = name + "__do_gen",
         visibility = ["//visibility:private"],
         srcs = srcs,
+        target_compatible_with = target_compatible_with,
     )
     native.cc_library(
         name = name,
@@ -57,4 +58,5 @@
         deps = [
             "@//third_party/seasocks",
         ],
+        target_compatible_with = target_compatible_with,
     )
diff --git a/aos/starter/BUILD b/aos/starter/BUILD
index 401d421..52fd62a 100644
--- a/aos/starter/BUILD
+++ b/aos/starter/BUILD
@@ -15,6 +15,7 @@
     srcs = [
         "starter.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:init",
         "//aos:unique_malloc_ptr",
@@ -33,6 +34,7 @@
     name = "starterd_lib",
     srcs = ["starterd_lib.cc"],
     hdrs = ["starterd_lib.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":starter_fbs",
         ":starter_rpc_fbs",
@@ -51,6 +53,7 @@
         "//aos/events:pingpong_config",
         "//aos/events:pong",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":starter_rpc_lib",
         ":starterd_lib",
@@ -64,6 +67,7 @@
 cc_binary(
     name = "starterd",
     srcs = ["starterd.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":starterd_lib",
         "//aos:init",
@@ -74,6 +78,7 @@
     name = "starter_rpc_lib",
     srcs = ["starter_rpc_lib.cc"],
     hdrs = ["starter_rpc_lib.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":starter_fbs",
         ":starter_rpc_fbs",
@@ -86,6 +91,7 @@
 cc_binary(
     name = "starter_cmd",
     srcs = ["starter_cmd.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":starter_rpc_lib",
         "@com_github_google_glog//:glog",
@@ -96,6 +102,7 @@
     name = "starter_fbs",
     srcs = ["starter.fbs"],
     gen_reflections = True,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -103,5 +110,6 @@
     name = "starter_rpc_fbs",
     srcs = ["starter_rpc.fbs"],
     gen_reflections = True,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/aos/stl_mutex/BUILD b/aos/stl_mutex/BUILD
index 51229d4..bc1e428 100644
--- a/aos/stl_mutex/BUILD
+++ b/aos/stl_mutex/BUILD
@@ -5,6 +5,7 @@
     hdrs = [
         "stl_mutex.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/ipc_lib:aos_sync",
         "@com_github_google_glog//:glog",
@@ -16,6 +17,7 @@
     srcs = [
         "stl_mutex_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":stl_mutex",
         "//aos:die",
diff --git a/aos/testdata/BUILD b/aos/testdata/BUILD
index 816ad7e..2971664 100644
--- a/aos/testdata/BUILD
+++ b/aos/testdata/BUILD
@@ -35,21 +35,25 @@
     "empty.json"
   ]
 }""" + "'> $@",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_config(
     name = "empty_config",
     src = "empty.json",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 aos_config(
     name = "generated_config",
     src = "generated.json",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":empty_config"],
 )
 
 aos_config(
     name = "generated_config_flattener_test",
     src = "generated_config_test.json",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":generated_config"],
 )
diff --git a/aos/testing/BUILD b/aos/testing/BUILD
index 4b2631a..116acc0 100644
--- a/aos/testing/BUILD
+++ b/aos/testing/BUILD
@@ -4,6 +4,7 @@
     srcs = [
         "gtest_main.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//aos:init",
@@ -22,6 +23,7 @@
     hdrs = [
         "test_logging.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":googletest",
@@ -37,6 +39,7 @@
     srcs = [
         "test_logging_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":googletest",
         ":test_logging",
@@ -53,6 +56,7 @@
     hdrs = [
         "prevent_exit.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@com_github_google_glog//:glog",
@@ -68,6 +72,7 @@
     hdrs = [
         "test_shm.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":test_logging",
@@ -85,6 +90,7 @@
     hdrs = [
         "random_seed.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -93,5 +99,6 @@
     testonly = True,
     srcs = ["tmpdir.cc"],
     hdrs = ["tmpdir.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/aos/time/BUILD b/aos/time/BUILD
index c9f8d6d..c0bd99d 100644
--- a/aos/time/BUILD
+++ b/aos/time/BUILD
@@ -1,5 +1,3 @@
-load("//tools:environments.bzl", "mcu_cpus")
-
 cc_library(
     name = "time",
     srcs = [
@@ -9,25 +7,10 @@
         "time.h",
     ],
     visibility = ["//visibility:public"],
-    deps = [
-        "@com_github_google_glog//:glog",
-    ],
-)
-
-# TODO(Brian): Remove this hack once bazel chases deps through selects correctly.
-cc_library(
-    name = "time_mcu",
-    srcs = [
-        "time.cc",
-    ],
-    hdrs = [
-        "time.h",
-    ],
-    restricted_to = mcu_cpus,
-    visibility = ["//visibility:public"],
-    deps = [
-        "//motors/core",
-    ],
+    deps = select({
+        "@platforms//os:linux": ["@com_github_google_glog//:glog"],
+        "//conditions:default": ["//motors/core"],
+    }),
 )
 
 cc_test(
@@ -35,6 +18,7 @@
     srcs = [
         "time_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":time",
         "//aos/logging",
diff --git a/aos/type_traits/BUILD b/aos/type_traits/BUILD
index e5590b0..ce517b3 100644
--- a/aos/type_traits/BUILD
+++ b/aos/type_traits/BUILD
@@ -1,13 +1,10 @@
 package(default_visibility = ["//visibility:public"])
 
-load("//tools:environments.bzl", "mcu_cpus")
-
 cc_library(
     name = "type_traits",
     hdrs = [
         "type_traits.h",
     ],
-    compatible_with = mcu_cpus,
 )
 
 cc_test(
@@ -15,6 +12,7 @@
     srcs = [
         "type_traits_test.cpp",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":type_traits",
         "//aos/testing:googletest",
diff --git a/aos/util/BUILD b/aos/util/BUILD
index 01be701..f0a65d9 100644
--- a/aos/util/BUILD
+++ b/aos/util/BUILD
@@ -1,13 +1,10 @@
 package(default_visibility = ["//visibility:public"])
 
-load("//tools:environments.bzl", "mcu_cpus")
-
 cc_library(
     name = "bitpacking",
     hdrs = [
         "bitpacking.h",
     ],
-    compatible_with = mcu_cpus,
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/GSL",
@@ -19,6 +16,7 @@
     srcs = [
         "bitpacking_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":bitpacking",
         "//aos/testing:googletest",
@@ -30,6 +28,7 @@
     srcs = [
         "trapezoid_profile.py",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":python_init",
     ],
@@ -43,6 +42,7 @@
     hdrs = [
         "run_command.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
     ],
@@ -53,6 +53,7 @@
     srcs = [
         "run_command_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":run_command",
         "//aos/logging",
@@ -63,6 +64,7 @@
 cc_library(
     name = "math",
     hdrs = ["math.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@org_tuxfamily_eigen//:eigen",
     ],
@@ -71,6 +73,7 @@
 cc_test(
     name = "math_test",
     srcs = ["math_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":math",
         "//aos/testing:googletest",
@@ -82,6 +85,7 @@
     hdrs = [
         "death_test_log_implementation.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging:implementations",
     ],
@@ -95,6 +99,7 @@
     hdrs = [
         "inet_addr.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:byteorder",
         "//aos:network_port",
@@ -109,6 +114,7 @@
     hdrs = [
         "phased_loop.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/time",
         "@com_github_google_glog//:glog",
@@ -120,6 +126,7 @@
     hdrs = [
         "log_interval.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/time",
@@ -131,6 +138,7 @@
     hdrs = [
         "string_to_num.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -138,6 +146,7 @@
     srcs = [
         "string_to_num_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":string_to_num",
         "//aos/testing:googletest",
@@ -155,6 +164,7 @@
     linkopts = [
         "-lm",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/time",
@@ -167,6 +177,7 @@
     srcs = [
         "trapezoid_profile_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":trapezoid_profile",
         "//aos/testing:googletest",
@@ -181,6 +192,7 @@
     hdrs = [
         "wrapping_counter.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -188,6 +200,7 @@
     srcs = [
         "wrapping_counter_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":wrapping_counter",
         "//aos/testing:googletest",
@@ -199,6 +212,7 @@
     hdrs = [
         "options.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -206,6 +220,7 @@
     srcs = [
         "options_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":options",
         "//aos/testing:googletest",
@@ -217,6 +232,7 @@
     hdrs = [
         "compiler_memory_barrier.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -224,6 +240,7 @@
     hdrs = [
         "global_factory.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_test(
@@ -231,6 +248,7 @@
     srcs = [
         "global_factory_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":global_factory",
         "//aos/testing:googletest",
@@ -242,6 +260,7 @@
     srcs = [
         "phased_loop_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":phased_loop",
         "//aos/testing:googletest",
@@ -257,6 +276,7 @@
     hdrs = [
         "file.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/scoped:scoped_fd",
         "@com_github_google_glog//:glog",
@@ -270,6 +290,7 @@
     srcs = [
         "file_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":file",
         "//aos/testing:googletest",
@@ -279,6 +300,7 @@
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = ["//aos:python_init"],
 )
diff --git a/aos/vision/blob/BUILD b/aos/vision/blob/BUILD
index e025ed3..2efd99e 100644
--- a/aos/vision/blob/BUILD
+++ b/aos/vision/blob/BUILD
@@ -1,4 +1,5 @@
-load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_binary", "gtk_dependent_cc_library")
+load("//tools:platforms.bzl", "platforms")
+load("//tools/build_rules:gtk_dependent.bzl", "gtk_dependent_cc_library")
 
 package(default_visibility = ["//visibility:public"])
 
@@ -6,6 +7,7 @@
     name = "range_image",
     srcs = ["range_image.cc"],
     hdrs = ["range_image.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/debug:overlay",
         "//aos/vision/image:image_types",
@@ -18,12 +20,14 @@
 cc_library(
     name = "region_alloc",
     hdrs = ["region_alloc.h"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
     name = "contour",
     srcs = ["contour.cc"],
     hdrs = ["contour.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         ":region_alloc",
@@ -40,6 +44,7 @@
     hdrs = [
         "threshold.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         "//aos/logging",
@@ -52,6 +57,7 @@
     srcs = [
         "threshold_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         ":threshold",
@@ -64,10 +70,10 @@
     name = "hierarchical_contour_merge",
     srcs = ["hierarchical_contour_merge.cc"],
     hdrs = ["hierarchical_contour_merge.h"],
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
+    target_compatible_with = platforms.any_of([
+        "@platforms//cpu:x86_64",
+        "//tools/platforms/hardware:raspberry_pi",
+    ]),
     deps = [
         ":contour",
         ":disjoint_set",
@@ -79,12 +85,14 @@
 cc_library(
     name = "disjoint_set",
     hdrs = ["disjoint_set.h"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
     name = "find_blob",
     srcs = ["find_blob.cc"],
     hdrs = ["find_blob.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":disjoint_set",
         ":range_image",
@@ -98,6 +106,7 @@
     name = "codec",
     srcs = ["codec.cc"],
     hdrs = ["codec.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         "//aos/vision/debug:overlay",
@@ -109,6 +118,7 @@
 cc_test(
     name = "codec_test",
     srcs = ["codec_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":codec",
         "//aos/testing:googletest",
@@ -119,6 +129,7 @@
     name = "move_scale",
     srcs = ["move_scale.cc"],
     hdrs = ["move_scale.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         "//aos/vision/image:image_types",
@@ -129,6 +140,7 @@
     name = "test_utils",
     srcs = ["test_utils.cc"],
     hdrs = ["test_utils.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
     ],
@@ -138,6 +150,7 @@
     name = "transpose",
     srcs = ["transpose.cc"],
     hdrs = ["transpose.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
     ],
@@ -146,6 +159,7 @@
 cc_test(
     name = "transpose_test",
     srcs = ["transpose_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":test_utils",
         ":transpose",
@@ -156,6 +170,7 @@
 gtk_dependent_cc_library(
     name = "stream_view",
     hdrs = ["stream_view.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":range_image",
         "//aos/vision/debug:debug_window",
diff --git a/aos/vision/debug/BUILD b/aos/vision/debug/BUILD
index 05d93ad..08d549e 100644
--- a/aos/vision/debug/BUILD
+++ b/aos/vision/debug/BUILD
@@ -1,10 +1,11 @@
-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_library")
 
 package(default_visibility = ["//visibility:public"])
 
 cc_library(
     name = "overlay",
     hdrs = ["overlay.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/image:image_types",
         "//aos/vision/math:segment",
@@ -16,6 +17,7 @@
     name = "debug_window",
     srcs = ["debug_window.cc"],
     hdrs = ["debug_window.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":overlay",
         "//aos/vision/image:image_types",
@@ -34,6 +36,7 @@
         "tcp-source.cc",
     ],
     hdrs = ["debug_framework.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/logging:implementations",
diff --git a/aos/vision/download/BUILD b/aos/vision/download/BUILD
index f22c18b..1352713 100644
--- a/aos/vision/download/BUILD
+++ b/aos/vision/download/BUILD
@@ -3,5 +3,6 @@
     srcs = [
         "downloader.py",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/aos/vision/events/BUILD b/aos/vision/events/BUILD
index a991968..c722acc 100644
--- a/aos/vision/events/BUILD
+++ b/aos/vision/events/BUILD
@@ -1,4 +1,4 @@
-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_library")
 
 package(default_visibility = ["//visibility:public"])
 
@@ -6,6 +6,7 @@
     name = "epoll_events",
     srcs = ["epoll_events.cc"],
     hdrs = ["epoll_events.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/scoped:scoped_fd",
@@ -16,6 +17,7 @@
 cc_library(
     name = "socket_types",
     hdrs = ["socket_types.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/vision/events:tcp_server",
         "//aos/vision/image:image_types",
@@ -26,12 +28,14 @@
 cc_library(
     name = "intrusive_free_list",
     hdrs = ["intrusive_free_list.h"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
     name = "tcp_server",
     srcs = ["tcp_server.cc"],
     hdrs = ["tcp_server.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":epoll_events",
         ":intrusive_free_list",
@@ -42,6 +46,7 @@
     name = "tcp_client",
     srcs = ["tcp_client.cc"],
     hdrs = ["tcp_client.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":epoll_events"],
 )
 
@@ -49,6 +54,7 @@
     name = "udp",
     srcs = ["udp.cc"],
     hdrs = ["udp.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos:macros",
         "//aos/scoped:scoped_fd",
@@ -59,6 +65,7 @@
 cc_test(
     name = "udp_test",
     srcs = ["udp_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":udp",
         "//aos/testing:googletest",
@@ -68,6 +75,7 @@
 gtk_dependent_cc_library(
     name = "gtk_event",
     srcs = ["gtk_event.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":epoll_events",
         "//aos/logging",
diff --git a/aos/vision/image/BUILD b/aos/vision/image/BUILD
index 9b6d30a..054b262 100644
--- a/aos/vision/image/BUILD
+++ b/aos/vision/image/BUILD
@@ -5,6 +5,7 @@
 cc_library(
     name = "image_types",
     hdrs = ["image_types.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@com_google_absl//absl/strings",
     ],
@@ -13,6 +14,7 @@
 cc_proto_library(
     name = "camera_params",
     srcs = ["camera_params.proto"],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -22,6 +24,7 @@
         "V4L2.h",
         "reader.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":camera_params",
         ":image_types",
@@ -34,6 +37,7 @@
     name = "jpeg_routines",
     srcs = ["jpeg_routines.cc"],
     hdrs = ["jpeg_routines.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":image_types",
         "//aos/logging",
@@ -45,6 +49,7 @@
     name = "image_dataset",
     srcs = ["image_dataset.cc"],
     hdrs = ["image_dataset.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":image_types",
     ],
@@ -54,6 +59,7 @@
     name = "image_stream",
     srcs = ["image_stream.cc"],
     hdrs = ["image_stream.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/vision/events:epoll_events",
diff --git a/aos/vision/math/BUILD b/aos/vision/math/BUILD
index 2c71e8f..fd7d876 100644
--- a/aos/vision/math/BUILD
+++ b/aos/vision/math/BUILD
@@ -3,6 +3,7 @@
 cc_library(
     name = "segment",
     hdrs = ["segment.h"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":vector"],
 )
 
@@ -11,6 +12,7 @@
     hdrs = [
         "vector.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "@org_tuxfamily_eigen//:eigen",
     ],
@@ -22,6 +24,7 @@
     srcs = [
         "vector_test.cc",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":vector",
         "//aos/testing:googletest",
diff --git a/aos/vision/tools/BUILD b/aos/vision/tools/BUILD
index 2ef3244..4be7fd7 100644
--- a/aos/vision/tools/BUILD
+++ b/aos/vision/tools/BUILD
@@ -3,6 +3,7 @@
 gtk_dependent_cc_binary(
     name = "jpeg_vision_test",
     srcs = ["jpeg_vision_test.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/logging:implementations",
@@ -22,6 +23,7 @@
 cc_binary(
     name = "camera_primer",
     srcs = ["camera_primer.cc"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//aos/logging",
         "//aos/logging:implementations",