Permalink
Browse files

Use tools.mk for dialyzer support

  • Loading branch information...
1 parent fe4cf90 commit 849ed4c773995eabd4124d636c4d21f468b536e4 @reiddraper reiddraper committed Jan 16, 2014
Showing with 50 additions and 12 deletions.
  1. +1 −1 .gitignore
  2. +4 −11 Makefile
  3. +45 −0 tools.mk
View
2 .gitignore
@@ -5,4 +5,4 @@ priv/*.so
*.o
*.beam
*~
-#*#
+.local_dialyzer_plt
View
15 Makefile
@@ -86,15 +86,8 @@ pkgclean:
export BITCASK_TAG PKG_VERSION REPO REVISION
-APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \
- xmerl webtool snmp public_key mnesia eunit syntax_tools compiler
-PLT = $(HOME)/.bitcask_dialyzer_plt
+DIALYZER_APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools \
+ crypto inets xmerl webtool snmp public_key mnesia eunit \
+ syntax_tools compiler
-build_plt: deps compile
- dialyzer --build_plt --output_plt $(PLT) --apps $(APPS) deps/*/ebin
-
-dialyzer: deps compile
- dialyzer -Wno_return --plt $(PLT) ebin
-
-clean_plt:
- rm $(PLT)
+include tools.mk
View
45 tools.mk
@@ -0,0 +1,45 @@
+test: compile
+ ./rebar eunit skip_deps=true
+
+docs:
+ ./rebar doc skip_deps=true
+
+PLT ?= $(HOME)/.riak_combo_dialyzer_plt
+LOCAL_PLT = .local_dialyzer_plt
+DIALYZER_FLAGS ?= -Wunmatched_returns
+
+${PLT}: compile
+ifneq (,$(wildcard $(PLT)))
+ dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \
+ dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1
+else
+ dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1
+endif
+
+${LOCAL_PLT}: compile
+ifneq (,$(wildcard deps/*))
+ifneq (,$(wildcard $(LOCAL_PLT)))
+ dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \
+ dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
+else
+ dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
+endif
+endif
+
+dialyzer: ${PLT} ${LOCAL_PLT}
+ @echo "==> $(shell basename $(shell pwd)) (dialyzer)"
+ifeq (,$(wildcard $(LOCAL_PLT)))
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) -c ebin
+else
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin
+endif
+
+cleanplt:
+ @echo
+ @echo "Are you sure? It takes several minutes to re-build."
+ @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds.
+ @echo
+ sleep 5
+ rm $(PLT)
+ rm $(LOCAL_PLT)
+

0 comments on commit 849ed4c

Please sign in to comment.