otp.mk 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. VM := rels/web/files/vm.args
  2. SYS := rels/web/files/sys.config
  3. PLT_NAME := ~/.n2o_dialyzer.plt
  4. ERL_ARGS := -args_file $(VM) -config $(SYS)
  5. RUN_DIR ?= rels/web/devbox
  6. LOG_DIR ?= rels/web/devbox/logs
  7. empty :=
  8. ROOTS := apps deps
  9. space := $(empty) $(empty)
  10. comma := $(empty),$(empty)
  11. VSN := $(shell git rev-parse HEAD | head -c 6)
  12. DATE := $(shell date "+%Y%m%d-%H%M%S")
  13. ERL_LIBS := $(subst $(space),:,$(ROOTS))
  14. relx := "{release,{$(RELEASE),\"$(VER)\"},[$(RELEASE)]}.\\n{include_erts,true}.\
  15. \\n{extended_start_script,true}.\\n{generate_start_script,true}.\\n{sys_config,\"$(SYS)\"}.\
  16. \\n{vm_args,\"$(VM)\"}.\\n{overlay,[{mkdir,\"log/sasl\"}]}."
  17. test: eunit ct
  18. compile: get-deps static-link
  19. delete-deps get-deps compile clean update-deps:
  20. rebar $@
  21. .applist:
  22. $(eval APPS := $(subst deps/,,$(subst apps/,,$(shell find apps deps -maxdepth 1 -mindepth 1 -type d))))
  23. ./orderapps.erl $(APPS) > $@
  24. $(RUN_DIR) $(LOG_DIR):
  25. mkdir -p $(RUN_DIR) & mkdir -p $(LOG_DIR)
  26. console: .applist
  27. ERL_LIBS=$(ERL_LIBS) erl $(ERL_ARGS) -eval '[application:start(A) || A <- $(shell cat .applist)]'
  28. start: $(RUN_DIR) $(LOG_DIR) .applist
  29. RUN_ERL_LOG_GENERATIONS=1000 RUN_ERL_LOG_MAXSIZE=20000000 \
  30. ERL_LIBS=$(ERL_LIBS) run_erl -daemon $(RUN_DIR)/ $(LOG_DIR)/ "exec $(MAKE) console"
  31. attach:
  32. to_erl $(RUN_DIR)/
  33. release:
  34. echo $(relx) > relx.config && relx
  35. stop:
  36. @kill -9 $(shell ps ax -o pid= -o command=|grep $(RELEASE)|grep $(COOKIE)|awk '{print $$1}')
  37. $(PLT_NAME):
  38. $(eval APPS := $(subst deps/,,$(subst apps/,,$(shell find apps deps -maxdepth 1 -mindepth 1 -type d))))
  39. ERL_LIBS=$(ERL_LIBS) dialyzer --build_plt --output_plt $(PLT_NAME) --apps $(APPS) || true
  40. dialyze: $(PLT_NAME) compile
  41. $(eval APPS := $(shell find apps deps -maxdepth 1 -mindepth 1 -type d))
  42. @$(foreach var,$(APPS),(echo "Process $(var)"; dialyzer -q $(var)/ebin --plt $(PLT_NAME) --no_native -Werror_handling -Wunderspecs -Wrace_conditions -Wno_undefined_callbacks);)
  43. tar: release
  44. tar zcvf $(RELEASE)-$(VSN)-$(DATE).tar.gz _rel/lib/*/ebin _rel/lib/*/priv _rel/bin _rel/releases
  45. eunit:
  46. rebar eunit skip_deps=true
  47. ct:
  48. rebar ct skip_deps=true verbose=1
  49. .PHONY: delete-deps get-deps compile clean console start attach release update-deps dialyze ct eunit tar