otp.mk 2.3 KB

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