otp.mk 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. empty :=
  2. ROOTS := apps deps
  3. space := $(empty) $(empty)
  4. comma := $(empty),$(empty)
  5. VSN := $(shell git rev-parse HEAD | cut -c 1-6)
  6. DATE := $(shell git show -s --format="%ci" HEAD | sed -e 's/\+/Z/g' -e 's/-/./g' -e 's/ /-/g' -e 's/:/./g')
  7. ERL_LIBS := $(subst $(space),:,$(ROOTS))
  8. relx := "{release,{$(RELEASE),\"$(VER)\"},[$(subst $(space),$(comma),$(APPS))]}.\\n{include_erts,true}.\
  9. \\n{extended_start_script,true}.\\n{generate_start_script,true}.\\n{sys_config,\"$(SYS)\"}.\
  10. \\n{vm_args,\"$(VM)\"}.\\n{overlay,[{mkdir,\"log/sasl\"}]}."
  11. ifeq "$(NODEPS)" "1"
  12. rebar_skip_deps=skip_deps=true
  13. endif
  14. test: ct
  15. compile: get-deps static-link
  16. delete-deps get-deps compile clean update-deps:
  17. rebar $(rebar_skip_deps) $(REBAR_D) $@
  18. .applist:
  19. ./depman.erl $(APPS) > $@
  20. $(RUN_DIR) $(LOG_DIR):
  21. mkdir -p $(RUN_DIR) & mkdir -p $(LOG_DIR)
  22. console: .applist
  23. echo $(APPS)
  24. ERL_LIBS=$(ERL_LIBS) erl $(ERL_ARGS) -eval \
  25. '[ok = application:ensure_started(A, permanent) || A <- $(shell cat .applist)]'
  26. start: $(RUN_DIR) $(LOG_DIR) .applist
  27. RUN_ERL_LOG_GENERATIONS=1000 RUN_ERL_LOG_MAXSIZE=20000000 \
  28. ERL_LIBS=$(ERL_LIBS) run_erl -daemon $(RUN_DIR)/ $(LOG_DIR)/ "exec $(MAKE) console"
  29. attach:
  30. to_erl $(RUN_DIR)/
  31. release:
  32. echo $(shell echo $(relx) > relx.config) & relx
  33. stop:
  34. kill -9 `ps ax -o pid= -o command=|grep $(RELEASE)|grep $(COOKIE)|awk '{print $$1}'`
  35. $(PLT_NAME):
  36. ERL_LIBS=deps dialyzer --build_plt --output_plt $(PLT_NAME) --apps $(APPS) || true
  37. dialyze: $(PLT_NAME) compile
  38. dialyzer deps/*/ebin --plt $(PLT_NAME) --no_native -Werror_handling -Wunderspecs -Wrace_conditions
  39. tar:
  40. tar zcvf $(RELEASE)-$(VSN)-$(DATE).tar.gz _rel/lib/*/ebin _rel/lib/*/priv _rel/bin _rel/releases
  41. eunit:
  42. rebar eunit skip_deps=true
  43. ct:
  44. rebar ct skip_deps=true verbose=1
  45. .PHONY: delete-deps get-deps clean compile console start attach release update-deps dialyze ct eunit tar