From 8065cafe1d4b143b22c3823b53d6ba4703346fe9 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Wed, 8 May 2019 21:18:24 +0800 Subject: [PATCH] Restore app.confg rule in makefile for debug and test --- Makefile | 39 +++++++++++++++++++++++++++++++-------- vars | 8 ++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 vars diff --git a/Makefile b/Makefile index c5619892c..0296f7bb9 100644 --- a/Makefile +++ b/Makefile @@ -20,11 +20,7 @@ CT_NODE_NAME = emqxct@127.0.0.1 compile: @rebar3 compile -clean: gen-clean - -.PHONY: gen-clean -gen-clean: - @rm -f etc/emqx.conf.rendered +clean: distclean ## Cuttlefish escript is built by default when cuttlefish app (as dependency) was built CUTTLEFISH_SCRIPT := _build/default/lib/cuttlefish/cuttlefish @@ -66,7 +62,34 @@ ct: ct-setup ct-one-suite: ct-setup @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(suite)_SUITE -.PHONY: clean -clean: +.PHONY: app.config +app.config: $(CUTTLEFISH_SCRIPT) etc/gen.emqx.conf + $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/ + +$(CUTTLEFISH_SCRIPT): + @rebar3 get-deps + @if [ ! -f cuttlefish ]; then make -C _build/default/lib/cuttlefish; fi + +bbmustache: + @git clone https://github.com/soranoba/bbmustache.git && cd bbmustache && ./rebar3 compile && cd .. + +# This hack is to generate a conf file for testing +# relx overlay is used for release +etc/gen.emqx.conf: bbmustache etc/emqx.conf + @erl -noshell -pa bbmustache/_build/default/lib/bbmustache/ebin -eval \ + "{ok, Temp} = file:read_file('etc/emqx.conf'), \ + {ok, Vars0} = file:consult('vars'), \ + Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \ + Targ = bbmustache:render(Temp, Vars), \ + ok = file:write_file('etc/gen.emqx.conf', Targ), \ + halt(0)." + +.PHONY: gen-clean +gen-clean: + @rm -rf bbmustache + @rm -f etc/gen.emqx.conf etc/emqx.conf.rendered + +.PHONY: distclean +distclean: gen-clean @rm -rf _build cover deps logs log data - @rm -f rebar.lock compile_commands.json cuttlefish + @rm -f rebar.lock compile_commands.json cuttlefish erl_crash.dump diff --git a/vars b/vars new file mode 100644 index 000000000..359c27c22 --- /dev/null +++ b/vars @@ -0,0 +1,8 @@ +%% vars here are for test only, not intended for release + +{platform_bin_dir, "bin"}. +{platform_data_dir, "data"}. +{platform_etc_dir, "etc"}. +{platform_lib_dir, "lib"}. +{platform_log_dir, "log"}. +{platform_plugins_dir, "plugins"}.