-
Notifications
You must be signed in to change notification settings - Fork 1
/
otp.mk
62 lines (59 loc) · 2.19 KB
/
otp.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ifeq ($(OS),Windows_NT)
SEPARATOR=;
else
SEPARATOR=:
endif
MAD := ./mad
VM := vm.args
SYS := sys.config
PLT_NAME := ~/.n2o_dialyzer.plt
ERL_ARGS := -args_file $(VM) -config $(SYS) -setcookie $(COOKIE) -name $(NAME)@127.0.0.1
RUN_DIR := .
LOG_DIR := priv/static/log
empty :=
ROOTS := . deps
space := $(empty) $(empty)
comma := $(empty),$(empty)
VSN := $(shell git rev-parse HEAD | head -c 6)
DATE := $(shell date "+%Y%m%d-%H%M%S")
ERL_LIBS := $(subst $(space),$(SEPARATOR),$(ROOTS))
relx := "{release,{$(RELEASE),\"$(VER)\"},[$(RELEASE)]}.\\n{include_erts,true}.\
\\n{extended_start_script,true}.\\n{generate_start_script,true}.\\n{sys_config,\"$(SYS)\"}.\
\\n{vm_args,\"$(VM)\"}.\\n{overlay,[{mkdir,\"log/sasl\"}]}."
test: eunit ct
deps up:
$(MAD) $@
compile: deps
$(MAD) compile skip_deps=true
clean:
rm -f .applist
$(MAD) $@
.applist: compile
$(MAD) plan
$(RUN_DIR) $(LOG_DIR):
mkdir -p $(RUN_DIR) & mkdir -p $(LOG_DIR)
console: .applist
mkdir -p data
ERL_LIBS="$(ERL_LIBS)" erl $(ERL_ARGS) -eval '[application:start(A) || A <- $(shell cat .applist)]'
start: $(RUN_DIR) $(LOG_DIR) .applist
RUN_ERL_LOG_GENERATIONS=1000 RUN_ERL_LOG_MAXSIZE=20000000 \
ERL_LIBS=$(ERL_LIBS) run_erl -daemon $(RUN_DIR)/ $(LOG_DIR)/ "exec $(MAKE) console"
attach:
to_erl $(RUN_DIR)/
release:
echo $(relx) > relx.config && relx
stop:
@kill -9 $(shell ps ax -o pid= -o command=|grep $(RELEASE)|grep $(COOKIE)|awk '{print $$1}')
$(PLT_NAME):
$(eval APPS := $(subst deps/,,$(subst apps/,,$(shell find apps deps -maxdepth 1 -mindepth 1 -type d))))
ERL_LIBS=$(ERL_LIBS) dialyzer --build_plt --output_plt $(PLT_NAME) --apps $(APPS) || true
dialyze: $(PLT_NAME) compile
$(eval APPS := $(shell find apps deps -maxdepth 1 -mindepth 1 -type d))
@$(foreach var,$(APPS),(echo "Process $(var)"; dialyzer -q $(var)/ebin --plt $(PLT_NAME) --no_native -Werror_handling -Wunderspecs -Wrace_conditions -Wno_undefined_callbacks);)
tar: release
tar zcvf $(RELEASE)-$(VSN)-$(DATE).tar.gz _rel/lib/*/ebin _rel/lib/*/priv _rel/bin _rel/releases
eunit:
rebar eunit skip_deps=true
ct:
rebar ct skip_deps=true verbose=1
.PHONY: deps up compile clean console start attach release update-deps dialyze ct eunit tar