summaryrefslogtreecommitdiff
path: root/rabbitmqctl.bzl
blob: 4b35da95b6963130637b47fda0fed0ce7e4cffd4 (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
load(":rabbitmq_home.bzl", "RabbitmqHomeInfo", "rabbitmq_home_short_path")

def _impl(ctx):
    rabbitmq_home_path = rabbitmq_home_short_path(ctx.attr.home)

    script = """
    exec ./{home}/sbin/{cmd} "$@"
    """.format(
        home = rabbitmq_home_path,
        cmd = ctx.label.name,
    )

    ctx.actions.write(
        output = ctx.outputs.executable,
        content = script,
    )

    return [DefaultInfo(
        runfiles = ctx.runfiles(ctx.attr.home[DefaultInfo].files.to_list()),
    )]

rabbitmqctl = rule(
    implementation = _impl,
    attrs = {
        "home": attr.label(providers = [RabbitmqHomeInfo]),
    },
    executable = True,
)