forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbitmqctl.bzl
32 lines (25 loc) · 942 Bytes
/
rabbitmqctl.bzl
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
load("@bazel-erlang//:erlang_home.bzl", "ErlangVersionProvider")
load(":rabbitmq_home.bzl", "RabbitmqHomeInfo")
def _impl(ctx):
erlang_version = ctx.attr._erlang_version[ErlangVersionProvider].version
rabbitmq_home = ctx.attr.home[RabbitmqHomeInfo]
if rabbitmq_home.erlang_version != erlang_version:
fail("Mismatched erlang versions", erlang_version, rabbitmq_home.erlang_version)
script = """
exec ./{}/sbin/rabbitmqctl $@
""".format(ctx.attr.home.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 = {
"_erlang_version": attr.label(default = "@bazel-erlang//:erlang_version"),
"home": attr.label(providers = [RabbitmqHomeInfo]),
},
executable = True,
)