Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. V0=$$(grep vsn src/erlydtl.app.src | sed -e 's/.*vsn,.*"\(.*\)".*/\1/') && \
  62. V1=$$(grep '##' -m 1 NEWS.md | sed -e 's/##[^0-9]*\([0-9.-]*\).*/\1/') && \
  63. read -e -p "OK, all tests passed, current version is $$V0, which version should we release now? ($$V1)" V2 && \
  64. : $${V2:=$$V1} && \
  65. echo "$$V2 it is..." && \
  66. sed -i -e 's/vsn,.*}/vsn, "'$$V2'"}/' src/erlydtl.app.src && \
  67. git ci -m "release v$$V2" src/erlydtl.app.src && \
  68. git tag $$V2 && \
  69. echo 'Updated src/erlydtl.app.src and tagged, run `git push origin master --tags` when ready' \
  70. ;}