diff --git a/BUILD.package_generic_unix b/BUILD.package_generic_unix index 4cc8056e7acf..c319e6fe4482 100644 --- a/BUILD.package_generic_unix +++ b/BUILD.package_generic_unix @@ -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"], ) diff --git a/rabbitmq_run.bzl b/rabbitmq_run.bzl index b2e5debae1e9..e344f9fe1b09 100644 --- a/rabbitmq_run.bzl +++ b/rabbitmq_run.bzl @@ -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) @@ -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, @@ -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, ) @@ -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, diff --git a/scripts/bazel/rabbitmq-run.sh b/scripts/bazel/rabbitmq-run.sh index 051bd5987606..bfce7f4be398 100755 --- a/scripts/bazel/rabbitmq-run.sh +++ b/scripts/bazel/rabbitmq-run.sh @@ -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