From 5dd640247dc1ceef3743fb0601e010e1b2b0b601 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Wed, 29 Jan 2014 12:50:33 -0500 Subject: [PATCH] Add tools.mk and xref check --- Makefile | 20 ++++++++++++++++++++ rebar.config | 3 +++ tools.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 Makefile create mode 100644 tools.mk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fef0f27 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.PHONY: all compile deps clean distclean test check_plt build_plt dialyzer \ + cleanplt + +all: deps compile + +compile: deps + ./rebar compile + +deps: + test -d deps || ./rebar get-deps + +clean: + ./rebar clean + +distclean: clean + ./rebar delete-deps + +DIALYZER_APPS = kernel stdlib erts sasl eunit + +include tools.mk diff --git a/rebar.config b/rebar.config index 5ae60a4..538033b 100644 --- a/rebar.config +++ b/rebar.config @@ -1,3 +1,6 @@ +{xref_checks, []}. +{xref_queries, [{"(XC - UC) || (XU - X - B - riak_core : Mod)", []}]}. + {deps, [ {canola, ".*", {git, "git://github.com/basho/canola.git", {branch, "develop"}}} ]}. diff --git a/tools.mk b/tools.mk new file mode 100644 index 0000000..8e0e1b9 --- /dev/null +++ b/tools.mk @@ -0,0 +1,48 @@ +test: compile + ./rebar eunit skip_deps=true + +docs: + ./rebar doc skip_deps=true + +xref: compile + ./rebar xref 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)" + @if [ -f $(LOCAL_PLT) ]; then \ + dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin; \ + else \ + dialyzer $(DIALYZER_FLAGS) --plts $(PLT) -c ebin; \ + fi + +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) +