dialyzer.mk 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: plt distclean-plt dialyze
  4. # Configuration.
  5. DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt
  6. export DIALYZER_PLT
  7. PLT_APPS ?=
  8. DIALYZER_DIRS ?= --src -r $(wildcard src) $(ALL_APPS_DIRS)
  9. DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs
  10. # Core targets.
  11. check:: dialyze
  12. distclean:: distclean-plt
  13. help::
  14. $(verbose) printf "%s\n" "" \
  15. "Dialyzer targets:" \
  16. " plt Build a PLT file for this project" \
  17. " dialyze Analyze the project using Dialyzer"
  18. # Plugin-specific targets.
  19. define filter_opts.erl
  20. Opts = binary:split(<<"$1">>, <<"-">>, [global]),
  21. Filtered = lists:reverse(lists:foldl(fun
  22. (O = <<"pa ", _/bits>>, Acc) -> [O|Acc];
  23. (O = <<"D ", _/bits>>, Acc) -> [O|Acc];
  24. (O = <<"I ", _/bits>>, Acc) -> [O|Acc];
  25. (_, Acc) -> Acc
  26. end, [], Opts)),
  27. io:format("~s~n", [[["-", O] || O <- Filtered]]),
  28. halt().
  29. endef
  30. $(DIALYZER_PLT): deps app
  31. $(verbose) dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS)
  32. plt: $(DIALYZER_PLT)
  33. distclean-plt:
  34. $(gen_verbose) rm -f $(DIALYZER_PLT)
  35. ifneq ($(wildcard $(DIALYZER_PLT)),)
  36. dialyze:
  37. else
  38. dialyze: $(DIALYZER_PLT)
  39. endif
  40. $(verbose) dialyzer --no_native `$(call erlang,$(call filter_opts.erl,$(ERLC_OPTS)))` $(DIALYZER_DIRS) $(DIALYZER_OPTS)