Synchronize mixed versions approach with v3.8.x

This commit is contained in:
Philip Kuryloski 2021-09-09 13:50:22 +02:00
parent d01b01663b
commit 8cc9806f07
5 changed files with 40 additions and 26 deletions

View File

@ -4,12 +4,18 @@ load("@//:rabbitmqctl.bzl", "rabbitmqctl")
rabbitmq_package_generic_unix(
name = "broker-home",
sbin = glob(["sbin/*"]),
escript = glob(["escript/*"]),
plugins = [
"//plugins:standard_plugins",
"//plugins:inet_tcp_proxy_ez",
],
additional_files =
glob(
[
"sbin/*",
"escript/*",
],
exclude = ["sbin/rabbitmqctl"],
) + [
"//plugins:standard_plugins",
"//plugins:inet_tcp_proxy_ez",
],
rabbitmqctl = "sbin/rabbitmqctl",
)
rabbitmq_run(
@ -27,7 +33,6 @@ rabbitmq_run_command(
rabbitmqctl(
name = "rabbitmqctl",
home = ":broker-home",
# visibility = ["//visibility:public"],
)
rabbitmqctl(

View File

@ -3,9 +3,7 @@ load("@bazel-erlang//:bazel_erlang_lib.bzl", "ErlangLibInfo", "flat_deps", "path
RabbitmqHomeInfo = provider(
doc = "An assembled RABBITMQ_HOME dir",
fields = {
"sbin": "Files making up the sbin dir",
"escript": "Files making up the escript dir",
"plugins": "Files making up the plugins dir",
"rabbitmqctl": "rabbitmqctl script from the sbin directory",
},
)
@ -112,11 +110,16 @@ def _impl(ctx):
plugins = _flatten([_plugins_dir_links(ctx, plugin) for plugin in plugins])
rabbitmqctl = None
for script in scripts:
if script.basename == "rabbitmqctl":
rabbitmqctl = script
if rabbitmqctl == None:
fail("could not find rabbitmqct among", scripts)
return [
RabbitmqHomeInfo(
sbin = scripts,
escript = escripts,
plugins = plugins,
rabbitmqctl = rabbitmqctl,
),
DefaultInfo(
files = depset(scripts + escripts + plugins),
@ -147,7 +150,7 @@ def _dirname(p):
return p.rpartition("/")[0]
def rabbitmq_home_short_path(rabbitmq_home):
short_path = rabbitmq_home[RabbitmqHomeInfo].sbin[0].short_path
short_path = rabbitmq_home[RabbitmqHomeInfo].rabbitmqctl.short_path
if rabbitmq_home.label.workspace_root != "":
short_path = path_join(rabbitmq_home.label.workspace_root, short_path)
return _dirname(_dirname(short_path))

View File

@ -1,26 +1,19 @@
load("@//:rabbitmq_home.bzl", "RabbitmqHomeInfo")
def _impl(ctx):
scripts = ctx.files.sbin
escripts = ctx.files.escript
plugins = ctx.files.plugins
return [
RabbitmqHomeInfo(
sbin = scripts,
escript = escripts,
plugins = plugins,
rabbitmqctl = ctx.file.rabbitmqctl,
),
DefaultInfo(
files = depset(scripts + escripts + plugins),
files = depset(ctx.files.rabbitmqctl + ctx.files.additional_files),
),
]
rabbitmq_package_generic_unix = rule(
implementation = _impl,
attrs = {
"sbin": attr.label_list(allow_files = True),
"escript": attr.label_list(allow_files = True),
"plugins": attr.label_list(allow_files = True),
"rabbitmqctl": attr.label(allow_single_file = True),
"additional_files": attr.label_list(allow_files = True),
},
)

View File

@ -6,6 +6,7 @@ load(":rabbitmq_home.bzl", "RabbitmqHomeInfo", "rabbitmq_home_short_path")
def _impl(ctx):
rabbitmq_home_path = rabbitmq_home_short_path(ctx.attr.home)
# the rabbitmq-run.sh template only allows a single erl_libs currently
erl_libs = [path_join(rabbitmq_home_path, "plugins")]
ctx.actions.expand_template(

View File

@ -1,6 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
rmq_realpath() {
local path=$1
if [ -d "$path" ]; then
cd "$path" && pwd
elif [ -f "$path" ]; then
cd "$(dirname "$path")" && echo $(pwd)/$(basename "$path")
else
echo "$path"
fi
}
if [ -z ${TEST_SRCDIR+x} ]; then
BASE_DIR=$PWD
else
@ -41,7 +53,7 @@ if [ ! -z ${EXTRA_PLUGINS_DIR+x} ]; then
fi
TEST_TMPDIR=${TEST_TMPDIR:=${TMPDIR}/rabbitmq-test-instances}
RABBITMQ_SCRIPTS_DIR=${BASE_DIR}/{RABBITMQ_HOME}/sbin
RABBITMQ_SCRIPTS_DIR="$(rmq_realpath ${BASE_DIR}/{RABBITMQ_HOME}/sbin)"
RABBITMQ_PLUGINS=${RABBITMQ_SCRIPTS_DIR}/rabbitmq-plugins
RABBITMQ_SERVER=${RABBITMQ_SCRIPTS_DIR}/rabbitmq-server
RABBITMQCTL=${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl