diff options
Diffstat (limited to 'tools/qemu.bzl')
-rw-r--r-- | tools/qemu.bzl | 33 |
1 files changed, 33 insertions, 0 deletions
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, +) |