forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbitmqctl.bzl
35 lines (28 loc) · 992 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
33
34
35
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 ./{home}/sbin/{cmd} $@
""".format(
home = ctx.attr.home.label.name,
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 = {
"_erlang_version": attr.label(default = "@bazel-erlang//:erlang_version"),
"home": attr.label(providers = [RabbitmqHomeInfo]),
},
executable = True,
)