2016-10-27 21:51:02 +08:00
|
|
|
PROJECT = rabbitmq_cli
|
|
|
|
|
2016-12-15 01:27:25 +08:00
|
|
|
BUILD_DEPS = rabbit_common
|
2019-05-10 23:34:51 +08:00
|
|
|
DEPS = observer_cli
|
2017-09-29 22:16:25 +08:00
|
|
|
TEST_DEPS = amqp_client rabbit
|
2016-10-27 21:51:02 +08:00
|
|
|
|
2017-05-17 00:02:10 +08:00
|
|
|
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
|
2016-10-27 21:51:02 +08:00
|
|
|
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
|
|
|
|
|
2016-12-08 00:08:29 +08:00
|
|
|
VERBOSE_TEST ?= true
|
2020-03-31 18:39:22 +08:00
|
|
|
MAX_CASES ?= 1
|
2020-03-31 01:27:51 +08:00
|
|
|
|
2020-09-07 20:14:10 +08:00
|
|
|
MIX_TEST_OPTS ?= ""
|
2021-09-17 15:34:50 +08:00
|
|
|
MIX_TEST = ERL_COMPILER_OPTIONS=deterministic mix test --max-cases=$(MAX_CASES)
|
2016-12-08 00:08:29 +08:00
|
|
|
|
2020-09-07 20:14:10 +08:00
|
|
|
ifneq ("",$(MIX_TEST_OPTS))
|
|
|
|
MIX_TEST := $(MIX_TEST) $(MIX_TEST_OPTS)
|
|
|
|
endif
|
|
|
|
|
2016-12-08 00:08:29 +08:00
|
|
|
ifeq ($(VERBOSE_TEST),true)
|
2020-03-31 01:27:51 +08:00
|
|
|
MIX_TEST := $(MIX_TEST) --trace
|
2016-12-08 00:08:29 +08:00
|
|
|
endif
|
|
|
|
|
2020-03-04 01:28:12 +08:00
|
|
|
# FIXME: Use erlang.mk patched for RabbitMQ, while waiting for PRs to be
|
|
|
|
# reviewed and merged.
|
|
|
|
|
|
|
|
ERLANG_MK_REPO = https://github.com/rabbitmq/erlang.mk.git
|
|
|
|
ERLANG_MK_COMMIT = rabbitmq-tmp
|
|
|
|
|
2018-01-19 19:28:28 +08:00
|
|
|
WITHOUT = plugins/cover \
|
|
|
|
plugins/ct \
|
|
|
|
plugins/dialyzer \
|
|
|
|
plugins/eunit \
|
|
|
|
plugins/proper \
|
|
|
|
plugins/triq
|
|
|
|
|
2021-03-22 17:38:17 +08:00
|
|
|
include ../../rabbitmq-components.mk
|
|
|
|
include ../../erlang.mk
|
2016-10-27 21:51:02 +08:00
|
|
|
|
2017-12-07 19:16:44 +08:00
|
|
|
# rabbitmq-mix.mk is generated during the creation of the RabbitMQ
|
|
|
|
# source archive. It sets some environment variables to allow
|
|
|
|
# rabbitmq_cli to build offline, using the bundled sources only.
|
|
|
|
-include rabbitmq-mix.mk
|
|
|
|
|
2017-02-09 18:47:14 +08:00
|
|
|
ACTUAL_ESCRIPTS = escript/rabbitmqctl
|
|
|
|
LINKED_ESCRIPTS = escript/rabbitmq-plugins \
|
2018-07-17 23:17:02 +08:00
|
|
|
escript/rabbitmq-diagnostics \
|
2019-09-18 18:37:18 +08:00
|
|
|
escript/rabbitmq-queues \
|
2020-03-17 01:30:14 +08:00
|
|
|
escript/rabbitmq-streams \
|
2019-09-18 18:37:18 +08:00
|
|
|
escript/rabbitmq-upgrade
|
2017-02-09 18:47:14 +08:00
|
|
|
ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)
|
|
|
|
|
|
|
|
# Record the build and link dependency: the target files are linked to
|
|
|
|
# their first dependency.
|
|
|
|
rabbitmq-plugins = escript/rabbitmqctl
|
|
|
|
rabbitmq-diagnostics = escript/rabbitmqctl
|
2018-07-17 23:17:02 +08:00
|
|
|
rabbitmq-queues = escript/rabbitmqctl
|
2020-03-17 01:30:14 +08:00
|
|
|
rabbitmq-streams = escript/rabbitmqctl
|
2019-09-18 18:37:18 +08:00
|
|
|
rabbitmq-upgrade = escript/rabbitmqctl
|
2020-03-17 01:30:14 +08:00
|
|
|
escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-streams escript/rabbitmq-upgrade: escript/rabbitmqctl
|
2017-02-09 18:47:14 +08:00
|
|
|
|
|
|
|
# We use hardlinks or symlinks in the `escript` directory and
|
|
|
|
# install's PREFIX when a single escript can have several names (eg.
|
|
|
|
# rabbitmq-plugins, rabbitmq-plugins and rabbitmq-diagnostics).
|
|
|
|
#
|
|
|
|
# Hardlinks and symlinks work on Windows. However, symlinks require
|
|
|
|
# privileges unlike hardlinks. That's why we default to hardlinks,
|
|
|
|
# unless USE_SYMLINKS_IN_ESCRIPTS_DIR is set.
|
|
|
|
#
|
|
|
|
# The link_escript function is called as:
|
|
|
|
# $(call link_escript,source,target)
|
|
|
|
#
|
|
|
|
# The function assumes all escripts live in the same directory and that
|
|
|
|
# the source was previously copied in that directory.
|
|
|
|
|
|
|
|
ifdef USE_SYMLINKS_IN_ESCRIPTS_DIR
|
2019-08-01 02:01:23 +08:00
|
|
|
link_escript = ln -sf "$(notdir $(1))" "$(2)"
|
2017-02-09 18:47:14 +08:00
|
|
|
else
|
2019-08-01 02:01:23 +08:00
|
|
|
link_escript = ln -f "$(dir $(2))$(notdir $(1))" "$(2)"
|
2017-02-09 18:47:14 +08:00
|
|
|
endif
|
2016-11-04 17:31:14 +08:00
|
|
|
|
|
|
|
app:: $(ESCRIPTS)
|
|
|
|
@:
|
|
|
|
|
|
|
|
rabbitmqctl_srcs := mix.exs \
|
|
|
|
$(shell find config lib -name "*.ex" -o -name "*.exs")
|
|
|
|
|
2017-01-10 22:45:15 +08:00
|
|
|
# Elixir dependencies are fetched and compiled as part of the alias
|
|
|
|
# `mix make_all`. We do not fetch and build them in `make deps` because
|
|
|
|
# mix(1) startup time is quite high. Thus we prefer to run it once, even
|
|
|
|
# though it kind of breaks the Erlang.mk model.
|
2017-01-16 20:50:02 +08:00
|
|
|
#
|
|
|
|
# We write `y` on mix stdin because it asks approval to install Hex if
|
|
|
|
# it's missing. Another way to do it is to use `mix local.hex` but it
|
|
|
|
# can't be integrated in an alias and doing it from the Makefile isn't
|
|
|
|
# practical.
|
2018-04-20 17:26:26 +08:00
|
|
|
#
|
|
|
|
# We also verify if the CLI is built from the RabbitMQ source archive
|
|
|
|
# (by checking if the Hex registry/cache is present). If it is, we use
|
|
|
|
# another alias. This alias does exactly the same thing as `make_all`,
|
|
|
|
# but calls `deps.get --only prod` instead of `deps.get`. This is what
|
|
|
|
# we do to create the source archive, and we must do the same here,
|
|
|
|
# otherwise mix(1) complains about missing dependencies (the non-prod
|
|
|
|
# ones).
|
2018-04-05 17:14:24 +08:00
|
|
|
$(ACTUAL_ESCRIPTS): $(rabbitmqctl_srcs)
|
2018-04-20 17:26:26 +08:00
|
|
|
$(gen_verbose) if test -d ../.hex; then \
|
2021-09-17 15:34:50 +08:00
|
|
|
echo y | ERL_COMPILER_OPTIONS=deterministic mix make_all_in_src_archive; \
|
2018-04-20 17:26:26 +08:00
|
|
|
else \
|
2021-09-17 15:34:50 +08:00
|
|
|
echo y | ERL_COMPILER_OPTIONS=deterministic mix make_all; \
|
2018-04-20 17:26:26 +08:00
|
|
|
fi
|
2016-10-27 21:51:02 +08:00
|
|
|
|
2017-02-09 18:47:14 +08:00
|
|
|
$(LINKED_ESCRIPTS):
|
2018-04-05 17:23:18 +08:00
|
|
|
$(verbose) rm -f "$@"
|
2017-02-09 18:47:14 +08:00
|
|
|
$(gen_verbose) $(call link_escript,$<,$@)
|
2016-11-04 17:31:14 +08:00
|
|
|
|
|
|
|
rel:: $(ESCRIPTS)
|
|
|
|
@:
|
|
|
|
|
2016-12-23 20:12:33 +08:00
|
|
|
tests:: $(ESCRIPTS)
|
2017-03-09 21:13:20 +08:00
|
|
|
$(gen_verbose) $(MIX_TEST) $(TEST_FILE)
|
2017-03-09 20:57:59 +08:00
|
|
|
|
2019-05-06 21:36:35 +08:00
|
|
|
.PHONY: test
|
|
|
|
|
2017-03-09 20:57:59 +08:00
|
|
|
test:: $(ESCRIPTS)
|
2017-03-09 21:13:20 +08:00
|
|
|
ifdef TEST_FILE
|
2016-12-30 00:49:58 +08:00
|
|
|
$(gen_verbose) $(MIX_TEST) $(TEST_FILE)
|
2017-03-09 21:13:20 +08:00
|
|
|
else
|
2020-03-25 05:22:24 +08:00
|
|
|
$(verbose) echo "TEST_FILE must be set, e.g. TEST_FILE=./test/ctl" 1>&2; false
|
2017-03-09 21:13:20 +08:00
|
|
|
endif
|
2016-10-31 19:21:10 +08:00
|
|
|
|
2017-08-14 21:36:38 +08:00
|
|
|
dialyzer:: $(ESCRIPTS)
|
2017-11-28 02:49:08 +08:00
|
|
|
MIX_ENV=test mix dialyzer
|
2017-08-14 21:36:38 +08:00
|
|
|
|
2017-02-09 18:47:14 +08:00
|
|
|
.PHONY: install
|
|
|
|
|
|
|
|
install: $(ESCRIPTS)
|
|
|
|
ifdef PREFIX
|
|
|
|
$(gen_verbose) mkdir -p "$(DESTDIR)$(PREFIX)"
|
|
|
|
$(verbose) $(foreach script,$(ACTUAL_ESCRIPTS), \
|
2019-08-01 02:01:23 +08:00
|
|
|
cmp -s "$(script)" "$(DESTDIR)$(PREFIX)/$(notdir $(script))" || \
|
|
|
|
cp "$(script)" "$(DESTDIR)$(PREFIX)/$(notdir $(script))";)
|
2017-02-09 18:47:14 +08:00
|
|
|
$(verbose) $(foreach script,$(LINKED_ESCRIPTS), \
|
|
|
|
$(call link_escript,$($(notdir $(script))),$(DESTDIR)$(PREFIX)/$(notdir $(script)));)
|
|
|
|
else
|
|
|
|
$(verbose) echo "You must specify a PREFIX" 1>&2; false
|
|
|
|
endif
|
|
|
|
|
2016-12-30 00:49:58 +08:00
|
|
|
clean:: clean-mix
|
|
|
|
|
2017-01-16 20:50:02 +08:00
|
|
|
clean-mix:
|
2016-12-30 00:49:58 +08:00
|
|
|
$(gen_verbose) rm -f $(ESCRIPTS)
|
2017-01-16 20:50:02 +08:00
|
|
|
$(verbose) echo y | mix clean
|
2016-10-31 19:21:10 +08:00
|
|
|
|
2019-01-31 03:15:28 +08:00
|
|
|
format:
|
|
|
|
$(verbose) mix format lib/**/*.ex
|
|
|
|
|
2016-10-31 19:21:10 +08:00
|
|
|
repl:
|
2019-01-22 16:35:59 +08:00
|
|
|
$(verbose) iex --sname repl -S mix
|