aboutsummaryrefslogtreecommitdiff
path: root/tools/qemu.bzl
blob: 94933065315795c71eb03bba42b2f63929ef7056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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,
)