From 20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec Mon Sep 17 00:00:00 2001 From: aqua Date: Fri, 8 Mar 2024 17:24:49 +0200 Subject: Bazel build --- tools/qemu.bzl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tools/qemu.bzl (limited to 'tools/qemu.bzl') diff --git a/tools/qemu.bzl b/tools/qemu.bzl new file mode 100644 index 0000000..9493306 --- /dev/null +++ b/tools/qemu.bzl @@ -0,0 +1,33 @@ +load("//toolchains:i386_qemu.bzl", qemu_i386 = "qemu_wrapper") + +def qemu(**kwargs): + _qemu( + wrapper_content = select({ + "@platforms//cpu:i386": qemu_i386(), + "//conditions:default": "/bin/false", + }), + **kwargs + ) + +def _qemu_impl(ctx): + print(ctx) + print(ctx.attr) + + wrapper = ctx.actions.declare_file("%s_wrapper" % ctx.label.name) + wrapper_content = ctx.attr.wrapper_content.format( + cdrom = ctx.file.cdrom.basename, + ) + ctx.actions.write(wrapper, wrapper_content, is_executable = True) + + runfiles = ctx.runfiles(files = [ctx.file.cdrom]) + + return [DefaultInfo(executable = wrapper, runfiles = runfiles)] + +_qemu = rule( + implementation = _qemu_impl, + attrs = { + "cdrom": attr.label(allow_single_file = True), + "wrapper_content": attr.string(), + }, + executable = True, +) -- cgit v1.2.1