Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ERL=erl
  2. ERLC=erlc
  3. REBAR=./rebar $(REBAR_ARGS)
  4. all: compile
  5. compile: check-slex get-deps
  6. @$(REBAR) compile
  7. check-slex: src/erlydtl_scanner.erl
  8. src/erlydtl_scanner.erl: src/erlydtl_scanner.slex
  9. @echo Notice: $@ is outdated by $<, consider running "'make slex'".
  10. get-deps:
  11. @$(REBAR) get-deps
  12. update-deps:
  13. @$(REBAR) update-deps
  14. .PHONY: tests
  15. tests: export EXTRA_CONFIG=rebar-tests.config
  16. tests: src/erlydtl_parser.erl
  17. @$(REBAR) eunit
  18. check: tests dialyze
  19. ## dialyzer
  20. PLT_FILE = ~/erlydtl.plt
  21. PLT_APPS ?= kernel stdlib compiler erts eunit syntax_tools
  22. DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions -Wunmatched_returns \
  23. -Wunderspecs --verbose --fullpath
  24. .PHONY: dialyze
  25. dialyze: compile
  26. @[ -f $(PLT_FILE) ] || $(MAKE) plt
  27. @dialyzer --plt $(PLT_FILE) $(DIALYZER_OPTS) ebin || [ $$? -eq 2 ];
  28. ## In case you are missing a plt file for dialyzer,
  29. ## you can run/adapt this command
  30. .PHONY: plt
  31. plt: compile
  32. # we need to remove second copy of file
  33. rm -f deps/merl/priv/merl_transform.beam
  34. @echo "Building PLT, may take a few minutes"
  35. @dialyzer --build_plt --output_plt $(PLT_FILE) --apps \
  36. $(PLT_APPS) deps/* || [ $$? -eq 2 ];
  37. clean:
  38. @[ ! -d deps/merl ] || { echo "Clean merl..." ; $(MAKE) -C deps/merl clean ;}
  39. @$(REBAR) -C rebar-slex.config clean
  40. rm -fv erl_crash.dump
  41. really-clean: clean
  42. rm -f $(PLT_FILE)
  43. # rebuild any .slex files as well.. not included by default to avoid
  44. # the slex dependency, which is only needed in case the .slex file has
  45. # been modified locally.
  46. slex: REBAR_DEPS ?= get-deps update-deps
  47. slex: slex-compile
  48. slex-skip-deps: REBAR_DEPS:=
  49. slex-skip-deps: slex-compile
  50. slex-compile:
  51. @$(REBAR) -C rebar-slex.config $(REBAR_DEPS) compile
  52. shell:
  53. @$(ERL) -pz ebin deps/*/ebin
  54. # this file must exist for rebar eunit to work
  55. # but is only built when running rebar compile
  56. src/erlydtl_parser.erl: compile
  57. committed:
  58. @git diff --no-ext-diff --quiet --exit-code || { echo "there are uncommitted changes in the repo." ; false ;}
  59. release: committed check
  60. @{ \
  61. V1=$$(grep vsn src/erlydtl.app.src | sed -e 's/.*vsn,.*"\(.*\)".*/\1/') && \
  62. read -e -p "OK, all tests passed, current version is $$V1, which version should we release now? " V2 && \
  63. echo "$$V2 it is..." && \
  64. sed -i -e 's/vsn,.*}/vsn, "'$$V2'"}/' src/erlydtl.app.src && \
  65. echo git ci -m "release v$$V2" src/erlydtl.app.src && \
  66. echo git tag $$V2 && \
  67. echo 'Updated src/erlydtl.app.src and tagged, run `git push master --tags` when ready' \
  68. ;}