Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.package_generic_unix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rabbitmq_package_generic_unix(
rabbitmq_run(
name = "rabbitmq-run",
home = ":broker-home",
otp = "@erlang_config//25_3:erlang_25_3_toolchain",
visibility = ["//visibility:public"],
)

Expand Down
21 changes: 19 additions & 2 deletions rabbitmq_run.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ def _impl(ctx):
path_join(rabbitmq_home_path, "plugins"),
])

(erlang_home, _, runfiles) = erlang_dirs(ctx)
if ctx.attr.otp != None:
info = ctx.attr.otp[platform_common.ToolchainInfo].otpinfo
runfiles = ctx.runfiles([
info.release_dir_tar,
info.version_file,
])
erlang_home = info.erlang_home
release_dir_tar = info.release_dir_tar
release_dir_tar_path = path_join(
ctx.attr.otp.label.workspace_root,
release_dir_tar.short_path,
)
else:
(erlang_home, release_dir_tar, runfiles) = erlang_dirs(ctx)
release_dir_tar_path = "/dev/null"

if not ctx.attr.is_windows:
output = ctx.actions.declare_file(ctx.label.name)
Expand All @@ -31,6 +45,7 @@ def _impl(ctx):
substitutions = {
"{RABBITMQ_HOME}": rabbitmq_home_path,
"{ERL_LIBS}": erl_libs,
"{ERLANG_TAR}": release_dir_tar_path,
"{ERLANG_HOME}": erlang_home,
},
is_executable = True,
Expand All @@ -43,7 +58,8 @@ def _impl(ctx):
substitutions = {
"{RABBITMQ_HOME}": windows_path(rabbitmq_home_path),
"{ERL_LIBS}": erl_libs,
"{ERLANG_HOME}": windows_path(erlang_home),
"{ERLANG_TAR}": windows_path(release_dir_tar_path),
"{ERLANG_HOME}": windows_path(erlang_home.short_path),
},
is_executable = True,
)
Expand All @@ -68,6 +84,7 @@ rabbitmq_run_private = rule(
),
"is_windows": attr.bool(mandatory = True),
"home": attr.label(providers = [RabbitmqHomeInfo]),
"otp": attr.label(), # Optional. e.g. @erlang_config//25_3:erlang_25_3_toolchain
},
toolchains = ["@rules_erlang//tools:toolchain_type"],
executable = True,
Expand Down
8 changes: 8 additions & 0 deletions scripts/bazel/rabbitmq-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ export RABBITMQ_SCRIPTS_DIR \

HOSTNAME="$(hostname -s)"

# install pre-built erlang if necessary
if [[ ! -d '{ERLANG_HOME}' ]]; then
printf 'Extracting OTP from {ERLANG_TAR}\n'
tar --extract --directory / --file "$BASE_DIR"/'{ERLANG_TAR}'
printf "done.\n"
export PATH='{ERLANG_HOME}/bin':$PATH
fi

case $CMD in
run-broker)
setup_node_env
Expand Down