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/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"],
)