From 58f540f897af34d520d2301723088b5dcb10eaf9 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Fri, 13 Jun 2025 12:45:28 +0100 Subject: [PATCH] feat: use local toolchain as default The local toolchain no longer has any constraints specified for the target. This means that the `local` labgrid config toolchain is used when no platform is specified on a target. --- MODULE.bazel | 10 +++++++++- e2e/binary/BUILD.bazel | 1 - e2e/genrule/BUILD.bazel | 1 - e2e/run/BUILD.bazel | 10 ---------- e2e/run/binary/BUILD.bazel | 1 - e2e/test/BUILD.bazel | 9 --------- e2e/test/subdir/BUILD.bazel | 1 - examples/custom-runners/archive-transfer/BUILD.bazel | 1 - labgrid/constraint/device/BUILD.bazel | 6 ------ labgrid/platform/BUILD.bazel | 7 ------- .../toolchain/config/{localhost => local}/BUILD.bazel | 6 ++---- .../toolchain/config/{localhost => local}/config.yaml | 0 12 files changed, 11 insertions(+), 42 deletions(-) rename labgrid/toolchain/config/{localhost => local}/BUILD.bazel (75%) rename labgrid/toolchain/config/{localhost => local}/config.yaml (100%) diff --git a/MODULE.bazel b/MODULE.bazel index 1f3b1d9e..d4319c2a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -43,7 +43,15 @@ resolved = use_repo_rule("@toolchain_utils//toolchain/resolved:defs.bzl", "toolc for kind in ("qemu-system", "qemu-img") ] -register_toolchains("//labgrid/toolchain/...") +register_toolchains( + "//labgrid/toolchain/qemu-img/...", + "//labgrid/toolchain/qemu-system/...", + "//labgrid/toolchain/config/qemu/...", + "//labgrid/toolchain/config/ssh/...", +) + +#local config must be last to ensure correct resolution when no platform is set. +register_toolchains("//labgrid/toolchain/config/local/...") # We need to pin to Python 3.11 python = use_extension("@rules_python//python/extensions:python.bzl", "python") diff --git a/e2e/binary/BUILD.bazel b/e2e/binary/BUILD.bazel index 5c4716cd..eb5f2c3e 100644 --- a/e2e/binary/BUILD.bazel +++ b/e2e/binary/BUILD.bazel @@ -5,7 +5,6 @@ load("@rules_labgrid//labgrid/binary:defs.bzl", "labgrid_binary") labgrid_binary( name = "printenv", src = "@ape//ape:printenv", - platform = "@rules_labgrid//labgrid/platform:localhost", ) genrule( diff --git a/e2e/genrule/BUILD.bazel b/e2e/genrule/BUILD.bazel index 46b3699f..9b221c8c 100644 --- a/e2e/genrule/BUILD.bazel +++ b/e2e/genrule/BUILD.bazel @@ -6,7 +6,6 @@ labgrid_genrule( name = "actual", outs = ["stdout.actual"], cmd = "echo -n $LG_STATE > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", ) write_file( diff --git a/e2e/run/BUILD.bazel b/e2e/run/BUILD.bazel index 34cf2f09..eae006d0 100644 --- a/e2e/run/BUILD.bazel +++ b/e2e/run/BUILD.bazel @@ -9,7 +9,6 @@ labgrid_genrule( srcs = ["@ape//ape:echo"], outs = ["run.actual"], cmd = "$(location @rules_labgrid//labgrid/run) $(location @ape//ape:echo) world > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -24,7 +23,6 @@ labgrid_genrule( srcs = [":echo-with-runfiles"], outs = ["runfiles.actual"], cmd = "$(location @rules_labgrid//labgrid/run) $(locations :echo-with-runfiles) world > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -34,7 +32,6 @@ labgrid_genrule( srcs = ["@ape//ape:bash"], outs = ["transfer-file-back.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --get output.txt:$@ $(location @ape//ape:bash) -c 'echo world > output.txt'", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -44,7 +41,6 @@ labgrid_genrule( srcs = ["@ape//ape:bash"], outs = ["transfer-to-ruledir.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --get output.txt:$(RULEDIR)/transfer-to-ruledir.actual $(location @ape//ape:bash) -c 'echo world > output.txt'", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -54,7 +50,6 @@ labgrid_genrule( srcs = ["@ape//ape:bash"], outs = ["transfer-to-d.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --get output.txt:$D/transfer-to-d.actual $(location @ape//ape:bash) -c 'echo world > output.txt'", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -64,7 +59,6 @@ labgrid_genrule( srcs = ["@ape//ape:bash"], outs = ["nested/transfer-to-d.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --get output.txt:$D/transfer-to-d.actual $(location @ape//ape:bash) -c 'echo world > output.txt'", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -81,7 +75,6 @@ labgrid_genrule( ], outs = ["put-file-with-remote.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --put $(location :hello.txt):hello.txt $(location @ape//ape:cat) hello.txt > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -93,7 +86,6 @@ labgrid_genrule( ], outs = ["put-file-without-remote.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --put $(location :hello.txt) $(location @ape//ape:cat) $(location :hello.txt) > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -102,7 +94,6 @@ labgrid_genrule( srcs = ["@ape//ape:printenv"], outs = ["env.actual"], cmd = "$(location @rules_labgrid//labgrid/run) --env HELLO=world -- $(location @ape//ape:printenv) HELLO > $@", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = ["@rules_labgrid//labgrid/run"], ) @@ -120,7 +111,6 @@ labgrid_run_binary( "-c", "echo world > output.txt", ], - platform = "@rules_labgrid//labgrid/platform:localhost", tool = "@rules_labgrid//labgrid/run", ) diff --git a/e2e/run/binary/BUILD.bazel b/e2e/run/binary/BUILD.bazel index a66181f3..13211365 100644 --- a/e2e/run/binary/BUILD.bazel +++ b/e2e/run/binary/BUILD.bazel @@ -9,7 +9,6 @@ labgrid_run_binary( "-c", "echo -n $LG_STATE > $(location :stdout.actual)", ], - platform = "@rules_labgrid//labgrid/platform:localhost", tool = "@ape//ape:bash", ) diff --git a/e2e/test/BUILD.bazel b/e2e/test/BUILD.bazel index 7289279b..2ae4267d 100644 --- a/e2e/test/BUILD.bazel +++ b/e2e/test/BUILD.bazel @@ -15,7 +15,6 @@ labgrid_test( name = "test", size = "small", src = ":inner", - platform = "@rules_labgrid//labgrid/platform:localhost", ) # Regression test for: https://gitlab.arm.com/bazel/rules_labgrid/-/issues/77 @@ -23,7 +22,6 @@ labgrid_test( name = "src-in-subpackage", size = "small", src = "//test/subdir:inner", - platform = "@rules_labgrid//labgrid/platform:localhost", ) write_file( @@ -46,7 +44,6 @@ labgrid_test( name = "src-env", size = "small", src = ":inner-with-env", - platform = "@rules_labgrid//labgrid/platform:localhost", ) py_binary( @@ -60,7 +57,6 @@ labgrid_test( size = "small", src = ":inner-without-env", env = {"GREETING": "hello"}, - platform = "@rules_labgrid//labgrid/platform:localhost", ) py_binary( @@ -75,7 +71,6 @@ labgrid_test( size = "small", src = ":inner-with-override-env", env = {"GREETING": "hello"}, - platform = "@rules_labgrid//labgrid/platform:localhost", ) write_file( @@ -101,7 +96,6 @@ labgrid_test( "hello", "world", ], - platform = "@rules_labgrid//labgrid/platform:localhost", ) py_binary( @@ -116,7 +110,6 @@ labgrid_test( size = "small", src = ":inner-without-data", data = [":hello.txt"], - platform = "@rules_labgrid//labgrid/platform:localhost", ) write_file( @@ -144,7 +137,6 @@ labgrid_test( env = { "HELLO_PATH": "$(location :hello.txt)", }, - platform = "@rules_labgrid//labgrid/platform:localhost", ) write_file( @@ -170,6 +162,5 @@ labgrid_test( name = "sharding", size = "small", src = ":inner-sharding", - platform = "@rules_labgrid//labgrid/platform:localhost", shard_count = 2, ) diff --git a/e2e/test/subdir/BUILD.bazel b/e2e/test/subdir/BUILD.bazel index 3a2dc240..2713f71f 100644 --- a/e2e/test/subdir/BUILD.bazel +++ b/e2e/test/subdir/BUILD.bazel @@ -15,5 +15,4 @@ labgrid_test( name = "src-in-upper-package", size = "small", src = "//test:inner", - platform = "@rules_labgrid//labgrid/platform:localhost", ) diff --git a/examples/custom-runners/archive-transfer/BUILD.bazel b/examples/custom-runners/archive-transfer/BUILD.bazel index d2742d68..615722a6 100644 --- a/examples/custom-runners/archive-transfer/BUILD.bazel +++ b/examples/custom-runners/archive-transfer/BUILD.bazel @@ -32,7 +32,6 @@ labgrid_genrule( ], outs = ["actual.out"], cmd = "$(location :run) --put=$(location data.txt) --out=$(location :actual.out) $(location @ape//ape:cat) data.txt", - platform = "@rules_labgrid//labgrid/platform:localhost", tools = [":run"], ) diff --git a/labgrid/constraint/device/BUILD.bazel b/labgrid/constraint/device/BUILD.bazel index 5cb7ef79..1a16d128 100644 --- a/labgrid/constraint/device/BUILD.bazel +++ b/labgrid/constraint/device/BUILD.bazel @@ -3,12 +3,6 @@ constraint_setting( visibility = ["//visibility:public"], ) -constraint_value( - name = "localhost", - constraint_setting = ":device", - visibility = ["//visibility:public"], -) - constraint_value( name = "qemu", constraint_setting = ":device", diff --git a/labgrid/platform/BUILD.bazel b/labgrid/platform/BUILD.bazel index bc30a062..80e02fde 100644 --- a/labgrid/platform/BUILD.bazel +++ b/labgrid/platform/BUILD.bazel @@ -1,12 +1,5 @@ CPUS = ("amd64", "arm64") -platform( - name = "localhost", - constraint_values = ["//labgrid/constraint/device:localhost"], - parents = ["@local_config_platform//:host"], - visibility = ["//visibility:public"], -) - [ platform( name = "qemu-{}-linux".format(cpu), diff --git a/labgrid/toolchain/config/localhost/BUILD.bazel b/labgrid/toolchain/config/local/BUILD.bazel similarity index 75% rename from labgrid/toolchain/config/localhost/BUILD.bazel rename to labgrid/toolchain/config/local/BUILD.bazel index 8cf578d1..12146d0c 100644 --- a/labgrid/toolchain/config/localhost/BUILD.bazel +++ b/labgrid/toolchain/config/local/BUILD.bazel @@ -7,12 +7,10 @@ labgrid_state( ) labgrid_config_toolchain( - name = "localhost", + name = "local", src = "config.yaml", state = ":state", - target_compatible_with = [ - "//labgrid/constraint/device:localhost", - ], + target_compatible_with = [], deps = [ "//bazel/labgrid/driver", "//bazel/labgrid/strategy", diff --git a/labgrid/toolchain/config/localhost/config.yaml b/labgrid/toolchain/config/local/config.yaml similarity index 100% rename from labgrid/toolchain/config/localhost/config.yaml rename to labgrid/toolchain/config/local/config.yaml -- GitLab