Skip to content

Commit 0be0b7f

Browse files
authored
Merge pull request #7692 from rabbitmq/rin/rabbitmq-cli-branch-switching
fix up bazel build of rabbitmq_cli when branch switching
2 parents 8baaa86 + 5d27b3c commit 0be0b7f

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/diagnostics_helpers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Helpers do
2525
check_port_connectivity(port, node_name, hostname, timeout)
2626
end
2727

28-
def check_port_connectivity(port, node_name, hostname_or_ip, timeout) do
28+
def check_port_connectivity(port, _node_name, hostname_or_ip, timeout) do
2929
try do
3030
IO.puts("Will connect to #{hostname_or_ip}:#{port}")
3131

deps/rabbitmq_cli/rabbitmqctl.bzl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ export ERL_COMPILER_OPTIONS=deterministic
122122
"${{ABS_ELIXIR_HOME}}"/bin/mix local.hex --force
123123
"${{ABS_ELIXIR_HOME}}"/bin/mix local.rebar --force
124124
"${{ABS_ELIXIR_HOME}}"/bin/mix deps.get --only prod
125-
if [ ! -d _build/${{MIX_ENV}}/lib/rabbit_common ]; then
126-
cp -r ${{DEPS_DIR}}/* _build/${{MIX_ENV}}/lib
127-
fi
125+
for d in {precompiled_deps}; do
126+
mkdir _build/${{MIX_ENV}}/lib/$d
127+
ln -s ${{DEPS_DIR}}/$d/ebin _build/${{MIX_ENV}}/lib/$d
128+
ln -s ${{DEPS_DIR}}/$d/include _build/${{MIX_ENV}}/lib/$d
129+
done
128130
"${{ABS_ELIXIR_HOME}}"/bin/mix deps.compile
129131
"${{ABS_ELIXIR_HOME}}"/bin/mix compile
130132
"${{ABS_ELIXIR_HOME}}"/bin/mix escript.build
@@ -151,6 +153,10 @@ find . -type l -delete
151153
ebin_dir = ebin.path,
152154
consolidated_dir = consolidated.path,
153155
fetched_srcs = fetched_srcs.path,
156+
precompiled_deps = " ".join([
157+
dep[ErlangAppInfo].app_name
158+
for dep in ctx.attr.deps
159+
]),
154160
)
155161

156162
inputs = depset(

deps/rabbitmq_cli/rabbitmqctl_test.bzl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def _impl(ctx):
5454
ctx.label.package,
5555
)
5656

57+
precompiled_deps = " ".join([
58+
dep[ErlangAppInfo].app_name
59+
for dep in ctx.attr.deps
60+
])
61+
5762
if not ctx.attr.is_windows:
5863
output = ctx.actions.declare_file(ctx.label.name)
5964
script = """set -euo pipefail
@@ -94,9 +99,11 @@ export ERL_COMPILER_OPTIONS=deterministic
9499
"${{ABS_ELIXIR_HOME}}"/bin/mix local.hex --force
95100
"${{ABS_ELIXIR_HOME}}"/bin/mix local.rebar --force
96101
"${{ABS_ELIXIR_HOME}}"/bin/mix deps.get
97-
if [ ! -d _build/${{MIX_ENV}}/lib/rabbit_common ]; then
98-
cp -r ${{DEPS_DIR}}/* _build/${{MIX_ENV}}/lib
99-
fi
102+
for d in {precompiled_deps}; do
103+
mkdir _build/${{MIX_ENV}}/lib/$d
104+
ln -s ${{DEPS_DIR}}/$d/ebin _build/${{MIX_ENV}}/lib/$d
105+
ln -s ${{DEPS_DIR}}/$d/include _build/${{MIX_ENV}}/lib/$d
106+
done
100107
"${{ABS_ELIXIR_HOME}}"/bin/mix deps.compile
101108
"${{ABS_ELIXIR_HOME}}"/bin/mix compile
102109
@@ -131,6 +138,7 @@ set -x
131138
elixir_home = elixir_home,
132139
package_dir = package_dir,
133140
deps_dir = deps_dir,
141+
precompiled_deps = precompiled_deps,
134142
rabbitmq_run_cmd = ctx.attr.rabbitmq_run[DefaultInfo].files_to_run.executable.short_path,
135143
)
136144
else:
@@ -162,6 +170,11 @@ set MIX_ENV=test
162170
echo y | "{elixir_home}\\bin\\mix" local.hex --force || goto :error
163171
echo y | "{elixir_home}\\bin\\mix" local.rebar --force || goto :error
164172
"{elixir_home}\\bin\\mix" deps.get || goto :error
173+
for %%d in ({precompiled_deps}) do (
174+
mkdir _build\\%MIX_ENV%\\lib\\%%d
175+
robocopy %DEPS_DIR%\\%%d\\ebin _build\\%MIX_ENV%\\lib\\%%d /E /NFL /NDL /NJH /NJS /nc /ns /np
176+
robocopy %DEPS_DIR%\\%%d\\include _build\\%MIX_ENV%\\lib\\%%d /E /NFL /NDL /NJH /NJS /nc /ns /np
177+
)
165178
"{elixir_home}\\bin\\mix" deps.compile || goto :error
166179
"{elixir_home}\\bin\\mix" compile || goto :error
167180
@@ -179,6 +192,7 @@ exit /b 1
179192
elixir_home = windows_path(elixir_home),
180193
package_dir = windows_path(ctx.label.package),
181194
deps_dir = deps_dir,
195+
precompiled_deps = precompiled_deps,
182196
rabbitmq_run_cmd = ctx.attr.rabbitmq_run[DefaultInfo].files_to_run.executable.short_path,
183197
)
184198

0 commit comments

Comments
 (0)