o/t/ktest: switch to proper rule
This was previously implemented as a macro, lacking proper transitions.
Reimplement it as a proper test rule.
Change-Id: I237a2fcc29ea6dfbb294ce6313c9ff457def12b8
Reviewed-on: https://review.monogon.dev/c/monogon/+/3722
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/osbase/build/def.bzl b/osbase/build/def.bzl
index 57a7dab..73752f7 100644
--- a/osbase/build/def.bzl
+++ b/osbase/build/def.bzl
@@ -49,9 +49,9 @@
},
)
-def _fsspec_core_impl(ctx, tool, output_file):
+def fsspec_core_impl(ctx, tool, output_file, extra_files = [], extra_fsspecs = []):
"""
- _fsspec_core_impl implements the core of an fsspec-based rule. It takes
+ fsspec_core_impl implements the core of an fsspec-based rule. It takes
input from the `files`,`files_cc`, `symlinks` and `fsspecs` attributes
and calls `tool` with the `-out` parameter pointing to `output_file`
and paths to all fsspecs as positional arguments.
@@ -61,7 +61,7 @@
fs_files = []
inputs = []
- for label, p in ctx.attr.files.items() + ctx.attr.files_cc.items():
+ for label, p in ctx.attr.files.items() + ctx.attr.files_cc.items() + extra_files:
if not p.startswith("/"):
fail("file {} invalid: must begin with /".format(p))
@@ -97,7 +97,7 @@
extra_specs = []
- for fsspec in ctx.attr.fsspecs:
+ for fsspec in ctx.attr.fsspecs + extra_fsspecs:
if FSSpecInfo in fsspec:
fsspec_info = fsspec[FSSpecInfo]
extra_specs.append(fsspec_info.spec)
@@ -121,7 +121,7 @@
initramfs_name = ctx.label.name + ".cpio.zst"
initramfs = ctx.actions.declare_file(initramfs_name)
- _fsspec_core_impl(ctx, ctx.executable._mkcpio, initramfs)
+ fsspec_core_impl(ctx, ctx.executable._mkcpio, initramfs)
# TODO(q3k): Document why this is needed
return [DefaultInfo(runfiles = ctx.runfiles(files = [initramfs]), files = depset([initramfs]))]
@@ -184,7 +184,7 @@
fs_name = ctx.label.name + ".img"
fs_out = ctx.actions.declare_file(fs_name)
- _fsspec_core_impl(ctx, ctx.executable._mkerofs, fs_out)
+ fsspec_core_impl(ctx, ctx.executable._mkerofs, fs_out)
return [DefaultInfo(files = depset([fs_out]))]