diff --git a/MODULE.bazel b/MODULE.bazel index ec8bf1377f26be714951a85230ab244f523f6bc5..c36b49693556fa2280637e0d5788187ef1e90730 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -18,10 +18,10 @@ resolved = use_repo_rule("@toolchain_utils//toolchain/resolved:defs.bzl", "toolc resolved( name = "resolved-executor", - toolchain_type = "//labgrid/toolchain/executor:type", + toolchain_type = "//bazel/labgrid/toolchain/executor:type", ) -register_toolchains("//labgrid/toolchain/...") +register_toolchains("//bazel/labgrid/toolchain/...") # We need to pin to Python 3.11 python = use_extension("@rules_python//python/extensions:python.bzl", "python") diff --git a/labgrid/client/BUILD.bazel b/bazel/labgrid/client/BUILD.bazel similarity index 100% rename from labgrid/client/BUILD.bazel rename to bazel/labgrid/client/BUILD.bazel diff --git a/bazel/labgrid/crossbar/BUILD.bazel b/bazel/labgrid/crossbar/BUILD.bazel new file mode 100644 index 0000000000000000000000000000000000000000..86f050a2c4032d86369365e2f41fa5b76c2eae3a --- /dev/null +++ b/bazel/labgrid/crossbar/BUILD.bazel @@ -0,0 +1,8 @@ +load("@python_versions//3.11:defs.bzl", "py_console_script_binary") + +py_console_script_binary( + name = "crossbar", + pkg = "@pip//crossbar", + script = "crossbar", + visibility = ["//visibility:public"], +) diff --git a/labgrid/executor/BUILD.bazel b/bazel/labgrid/executor/BUILD.bazel similarity index 89% rename from labgrid/executor/BUILD.bazel rename to bazel/labgrid/executor/BUILD.bazel index b75b764d4fb96ee5fa53e11e8bd0be8646585ce8..ba8efc1cfdddb7ecee8b4561fb134c674a63c5b8 100644 --- a/labgrid/executor/BUILD.bazel +++ b/bazel/labgrid/executor/BUILD.bazel @@ -34,7 +34,7 @@ py_test( srcs = ["executor.py"], args = [ "--manager", - "labgrid.executor.host:manager", + "bazel.labgrid.executor.host:manager", "echo", "$${DATA}", ], @@ -50,7 +50,7 @@ py_test( "$${DATA}", ], env = { - "LABGRID_EXECUTOR_MANAGER": "labgrid.executor.host:manager", + "LABGRID_EXECUTOR_MANAGER": "bazel.labgrid.executor.host:manager", }, main = "executor.py", deps = ["host"], diff --git a/labgrid/executor/defs.bzl b/bazel/labgrid/executor/defs.bzl similarity index 100% rename from labgrid/executor/defs.bzl rename to bazel/labgrid/executor/defs.bzl diff --git a/labgrid/executor/executor.py b/bazel/labgrid/executor/executor.py similarity index 98% rename from labgrid/executor/executor.py rename to bazel/labgrid/executor/executor.py index 0bc77bf9a819ee67c64c03849e449a50287ccc71..220cd1ad91f9e9e5fa91bfcab8334998602dc161 100644 --- a/labgrid/executor/executor.py +++ b/bazel/labgrid/executor/executor.py @@ -13,7 +13,7 @@ from shutil import which from subprocess import CalledProcessError, run from sys import argv, stderr -from labgrid.executor.manager import Manager +from bazel.labgrid.executor.manager import Manager def load(value: str) -> Manager: diff --git a/labgrid/executor/hello-world.txt b/bazel/labgrid/executor/hello-world.txt similarity index 100% rename from labgrid/executor/hello-world.txt rename to bazel/labgrid/executor/hello-world.txt diff --git a/labgrid/executor/host.py b/bazel/labgrid/executor/host.py similarity index 71% rename from labgrid/executor/host.py rename to bazel/labgrid/executor/host.py index 1e412cb7e5921997d240402086bc769bf2f3e96c..ff864bc8291a3695e586c80e740086ea06ae46a6 100644 --- a/labgrid/executor/host.py +++ b/bazel/labgrid/executor/host.py @@ -5,13 +5,13 @@ from typing import Iterator from python.runfiles import Runfiles -from labgrid.executor.manager import Data, Manager +from bazel.labgrid.executor.manager import Data, Manager @contextmanager def manager() -> Iterator[Run]: runfiles = Runfiles.Create() - path = runfiles.Rlocation("_main/labgrid/executor/hello-world.txt") + path = runfiles.Rlocation("_main/bazel/labgrid/executor/hello-world.txt") with open(path) as stream: data = stream.read() env = {"DATA": data} diff --git a/labgrid/executor/macro.bzl b/bazel/labgrid/executor/macro.bzl similarity index 100% rename from labgrid/executor/macro.bzl rename to bazel/labgrid/executor/macro.bzl diff --git a/labgrid/executor/manager.py b/bazel/labgrid/executor/manager.py similarity index 100% rename from labgrid/executor/manager.py rename to bazel/labgrid/executor/manager.py diff --git a/labgrid/genrule/BUILD.bazel b/bazel/labgrid/genrule/BUILD.bazel similarity index 100% rename from labgrid/genrule/BUILD.bazel rename to bazel/labgrid/genrule/BUILD.bazel diff --git a/labgrid/genrule/defs.bzl b/bazel/labgrid/genrule/defs.bzl similarity index 100% rename from labgrid/genrule/defs.bzl rename to bazel/labgrid/genrule/defs.bzl diff --git a/labgrid/genrule/rule.bzl b/bazel/labgrid/genrule/rule.bzl similarity index 90% rename from labgrid/genrule/rule.bzl rename to bazel/labgrid/genrule/rule.bzl index 01e99fa2ac413e0e399214beb53b63ae1996341a..2f9add0c1b4219037a05fa6335a5782d8ae51b62 100644 --- a/labgrid/genrule/rule.bzl +++ b/bazel/labgrid/genrule/rule.bzl @@ -4,7 +4,7 @@ visibility("//...") DOC = """Executes a Shell command on the host within a LabGrid environment. -The "@rules_labgrid//labgrid/toolchain/executor:type` toolchain is used to create the environment that the command runs under. +The "@rules_labgrid//bazel/labgrid/toolchain/executor:type` toolchain is used to create the environment that the command runs under. `@ape//:bash` is used to provide a hermetic, consistent, shell environment for the command. """ @@ -62,7 +62,7 @@ def _substitutions(ctx): return substitutions def implementation(ctx): - executor = ctx.toolchains["//labgrid/toolchain/executor:type"] + executor = ctx.toolchains["//bazel/labgrid/toolchain/executor:type"] cmd = ctx.expand_location(ctx.attr.cmd) for key, value in _substitutions(ctx).items(): @@ -91,7 +91,7 @@ labgrid_genrule = rule( doc = DOC, attrs = ATTRS, implementation = implementation, - toolchains = ["//labgrid/toolchain/executor:type"], + toolchains = ["//bazel/labgrid/toolchain/executor:type"], ) genrule = labgrid_genrule diff --git a/labgrid/python/BUILD.bazel b/bazel/labgrid/python/BUILD.bazel similarity index 87% rename from labgrid/python/BUILD.bazel rename to bazel/labgrid/python/BUILD.bazel index 7092e0b85270b4ec4fc018264933ae2efedaa32e..d2acc6aa30bdffcefb656949d435dc01d9c452ec 100644 --- a/labgrid/python/BUILD.bazel +++ b/bazel/labgrid/python/BUILD.bazel @@ -6,7 +6,7 @@ load("@rules_python//python:defs.bzl", "py_library") actual = "@pip//{}".format(pkg), visibility = ["//visibility:public"], ) - for pkg in ("labgrid", "docker") + for pkg in ("labgrid","docker") ] py_library( @@ -15,5 +15,4 @@ py_library( deps = [ ":docker", ":labgrid", - ], -) + ],) diff --git a/labgrid/toolchain/executor/BUILD.bazel b/bazel/labgrid/toolchain/executor/BUILD.bazel similarity index 100% rename from labgrid/toolchain/executor/BUILD.bazel rename to bazel/labgrid/toolchain/executor/BUILD.bazel diff --git a/labgrid/transition/BUILD.bazel b/bazel/labgrid/transition/BUILD.bazel similarity index 100% rename from labgrid/transition/BUILD.bazel rename to bazel/labgrid/transition/BUILD.bazel diff --git a/labgrid/transition/defs.bzl b/bazel/labgrid/transition/defs.bzl similarity index 100% rename from labgrid/transition/defs.bzl rename to bazel/labgrid/transition/defs.bzl diff --git a/labgrid/transition/platform/BUILD.bazel b/bazel/labgrid/transition/platform/BUILD.bazel similarity index 100% rename from labgrid/transition/platform/BUILD.bazel rename to bazel/labgrid/transition/platform/BUILD.bazel diff --git a/labgrid/transition/platform/transition.bzl b/bazel/labgrid/transition/platform/transition.bzl similarity index 100% rename from labgrid/transition/platform/transition.bzl rename to bazel/labgrid/transition/platform/transition.bzl diff --git a/labgrid/transition/rule.bzl b/bazel/labgrid/transition/rule.bzl similarity index 87% rename from labgrid/transition/rule.bzl rename to bazel/labgrid/transition/rule.bzl index baf3366ec7491c19934bc46779b9359dfa25fccf..81addd15b8d99918277a01f827f696f8222071ad 100644 --- a/labgrid/transition/rule.bzl +++ b/bazel/labgrid/transition/rule.bzl @@ -1,4 +1,4 @@ -load("//labgrid/transition/platform:transition.bzl", _transition = "platform") +load("//bazel/labgrid/transition/platform:transition.bzl", _transition = "platform") visibility("//...") diff --git a/e2e/docker/BUILD.bazel b/e2e/docker/BUILD.bazel index cc34f9a0b8aa5d21f9c005a71d20e94d4d3c880a..72d828127e69f6274c458e3223b19865ab16842c 100644 --- a/e2e/docker/BUILD.bazel +++ b/e2e/docker/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library") -load("@rules_labgrid//labgrid/genrule:defs.bzl", "labgrid_genrule") -load("@rules_labgrid//labgrid/executor:defs.bzl", "labgrid_executor") -load("@rules_labgrid//labgrid/transition:defs.bzl", "labgrid_transition") +load("@rules_labgrid//bazel/labgrid/genrule:defs.bzl", "labgrid_genrule") +load("@rules_labgrid//bazel/labgrid/executor:defs.bzl", "labgrid_executor") +load("@rules_labgrid//bazel/labgrid/transition:defs.bzl", "labgrid_transition") load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test") load("@toolchain_utils//toolchain/info:defs.bzl", "toolchain_info") @@ -24,7 +24,7 @@ py_binary( args = ["--lg-env=$(location local-ubuntu.16.04-gnu.yaml)"], data = ["local-ubuntu.16.04-gnu.yaml"], tags = ["manual"], - deps = ["@rules_labgrid//labgrid/python"], + deps = ["@rules_labgrid//bazel/labgrid/python"], ) # An execution manager that is responsible for setting up the LabGrid environment @@ -32,7 +32,7 @@ py_library( name = "manager", srcs = ["manager.py"], data = ["local-ubuntu.16.04-gnu.yaml"], - deps = ["@rules_labgrid//labgrid/executor:manager"], + deps = ["@rules_labgrid//bazel/labgrid/executor:manager"], ) # Create the LabGrid executor binary using our manager @@ -73,7 +73,7 @@ toolchain( "@toolchain_utils//toolchain/constraint/os:linux", ], toolchain = ":info", - toolchain_type = "@rules_labgrid//labgrid/toolchain/executor:type", + toolchain_type = "@rules_labgrid//bazel/labgrid/toolchain/executor:type", ) # Run within the LabGrid environment diff --git a/e2e/docker/manager.py b/e2e/docker/manager.py index cca44f05f35c9ace1eaa2ca58ba93bdb4fb053e0..a0af7772fc44cd345d47ec07e38145299d78856e 100644 --- a/e2e/docker/manager.py +++ b/e2e/docker/manager.py @@ -5,11 +5,11 @@ from typing import Iterator from python.runfiles import Runfiles -from labgrid.executor.manager import Data, Manager +from bazel.labgrid.executor.manager import Data, Manager @contextmanager -def manager() -> Iterator[Run]: +def manager() -> Iterator[Run]: runfiles = Runfiles.Create() config = runfiles.Rlocation("_main/docker/local-ubuntu.16.04-gnu.yaml") env = {"LG_ENV": config} diff --git a/e2e/executor/BUILD.bazel b/e2e/executor/BUILD.bazel index 8ae8f4b518c2cc217330dae0345a8087152d2f90..82678297b131bb166f61c829937052baf533e76b 100644 --- a/e2e/executor/BUILD.bazel +++ b/e2e/executor/BUILD.bazel @@ -2,5 +2,5 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") build_test( name = "type", - targets = ["@rules_labgrid//labgrid/toolchain/executor:type"], + targets = ["@rules_labgrid//bazel/labgrid/toolchain/executor:type"], ) diff --git a/e2e/python/BUILD.bazel b/e2e/python/BUILD.bazel index c478ae8e703eb3570f855142248ff5ccfb82d265..f0e93e0d50fed620fc75fe76ec1239730d4a5e3d 100644 --- a/e2e/python/BUILD.bazel +++ b/e2e/python/BUILD.bazel @@ -2,10 +2,10 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") build_test( name = "python", - targets = ["@rules_labgrid//labgrid/python"], + targets = ["@rules_labgrid//bazel/labgrid/python"], ) build_test( name = "pkgs", - targets = ["@rules_labgrid//labgrid/python:{}".format(p) for p in ("labgrid", "docker")], + targets = ["@rules_labgrid//bazel/labgrid/python:{}".format(p) for p in ("labgrid", "docker")], ) diff --git a/e2e/remote/BUILD.bazel b/e2e/remote/BUILD.bazel index 103f77ed613162ac562f45511636e625a00de0b3..454eaa8827aac088a46c7b6822ec37dd597aef1f 100644 --- a/e2e/remote/BUILD.bazel +++ b/e2e/remote/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library") -load("@rules_labgrid//labgrid/genrule:defs.bzl", "labgrid_genrule") -load("@rules_labgrid//labgrid/executor:defs.bzl", "labgrid_executor") -load("@rules_labgrid//labgrid/transition:defs.bzl", "labgrid_transition") +load("@rules_labgrid//bazel/labgrid/genrule:defs.bzl", "labgrid_genrule") +load("@rules_labgrid//bazel/labgrid/executor:defs.bzl", "labgrid_executor") +load("@rules_labgrid//bazel/labgrid/transition:defs.bzl", "labgrid_transition") load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test") load("@toolchain_utils//toolchain/info:defs.bzl", "toolchain_info") @@ -11,19 +11,19 @@ py_binary( args = ["--lg-env=$(location config.yaml)"], data = ["config.yaml"], tags = ["manual"], - deps = ["@rules_labgrid//labgrid/python"], + deps = ["@rules_labgrid//bazel/labgrid/python"], ) py_library( name = "reserve", srcs = ["reserve.py"], - data = ["@rules_labgrid//labgrid/client"], + data = ["@rules_labgrid//bazel/labgrid/client"], ) py_library( name = "lock", srcs = ["lock.py"], - data = ["@rules_labgrid//labgrid/client"], + data = ["@rules_labgrid//bazel/labgrid/client"], deps = [":reserve"], ) @@ -33,7 +33,7 @@ py_library( data = ["config.yaml"], deps = [ ":lock", - "@rules_labgrid//labgrid/executor:manager", + "@rules_labgrid//bazel/labgrid/executor:manager", ], ) @@ -81,7 +81,7 @@ toolchain( "@toolchain_utils//toolchain/constraint/os:linux", ], toolchain = ":info", - toolchain_type = "@rules_labgrid//labgrid/toolchain/executor:type", + toolchain_type = "@rules_labgrid//bazel/labgrid/toolchain/executor:type", ) labgrid_genrule( diff --git a/e2e/remote/lock.py b/e2e/remote/lock.py index c2c40091e94fd2d2b90f4a37c56915895ba4599f..4e1fe2d48d61a5d86bd3fddb4360f36f940b1b9e 100644 --- a/e2e/remote/lock.py +++ b/e2e/remote/lock.py @@ -13,7 +13,7 @@ from .reserve import reserve @contextmanager def lock(tags: Mapping[str, str]) -> Iterator[str]: runfiles = Runfiles.Create() - client = runfiles.Rlocation("rules_labgrid/labgrid/client/client") + client = runfiles.Rlocation("rules_labgrid/bazel/labgrid/client/client") with reserve(tags) as reservation: env = environ | {"LG_TOKEN": reservation.token} run((client, "-p", "+", "lock"), check=True, env=env, stdout=DEVNULL) diff --git a/e2e/remote/manager.py b/e2e/remote/manager.py index 7c460b08e8e037546026044134b4f00a4574b8e8..26fed975906ba0e14689281d5f54943d6dfc1c17 100644 --- a/e2e/remote/manager.py +++ b/e2e/remote/manager.py @@ -8,7 +8,7 @@ from typing import Iterator from python.runfiles import Runfiles from remote.lock import lock -from labgrid.executor.manager import Data, Manager +from bazel.labgrid.executor.manager import Data, Manager @contextmanager diff --git a/e2e/remote/reserve.py b/e2e/remote/reserve.py index c6465444212cd86982dca78a5cf9035d3dc1ddc0..ec43c2f873bebd4f5397e5a8ee6c5ca426908f0d 100644 --- a/e2e/remote/reserve.py +++ b/e2e/remote/reserve.py @@ -18,7 +18,7 @@ class Reservation: @contextmanager def reserve(tags: Mapping[str, str]) -> Iterator[Reservation]: runfiles = Runfiles.Create() - client = runfiles.Rlocation("rules_labgrid/labgrid/client/client") + client = runfiles.Rlocation("rules_labgrid/bazel/labgrid/client/client") # FIXME: no way to provide a timeout to the CLI # FIXME: no way to know if tags will ever be satisfied # FIXME: will not be allocated if other reservations are cancelled