From e8e82533d29613da941f0d18991f7761c29f490e Mon Sep 17 00:00:00 2001 From: Christopher Meiklejohn Date: Thu, 22 Oct 2015 10:35:17 -0700 Subject: [PATCH] Add makefile and other targets. --- Makefile | 28 +++++++++++++++++++++++++ tools.mk | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 Makefile create mode 100644 tools.mk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f51d10e --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +REBAR = $(shell pwd)/rebar +.PHONY: deps test + +all: deps compile + +## +## Compilation targets +## + +compile: deps + $(REBAR) compile + +deps: + $(REBAR) get-deps + +clean: + $(REBAR) clean + +distclean: clean + $(REBAR) delete-deps + +DIALYZER_APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ + xmerl webtool eunit syntax_tools compiler mnesia public_key snmp + +include tools.mk + +typer: + typer --annotate -I ../ --plt $(PLT) -r src diff --git a/tools.mk b/tools.mk new file mode 100644 index 0000000..d35bd1d --- /dev/null +++ b/tools.mk @@ -0,0 +1,62 @@ +REBAR ?= ./rebar + +test: compile + ${REBAR} eunit skip_deps=true + +docs: + ${REBAR} doc skip_deps=true + +xref: compile + ${REBAR} xref skip_deps=true + +PLT ?= $(PWD)/.combo_dialyzer_plt +LOCAL_PLT = $(PWD)/.local_dialyzer_plt +DIALYZER_FLAGS ?= -Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspecs + +${PLT}: compile + @if [ -f $(PLT) ]; then \ + 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; \ + fi + +${LOCAL_PLT}: compile + @if [ -d deps ]; then \ + if [ -f $(LOCAL_PLT) ]; then \ + dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin riak_test/ebin && \ + dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin riak_test/ebin ; test $$? -ne 1; \ + else \ + dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin riak_test/ebin ; test $$? -ne 1; \ + fi \ + fi + +dialyzer: ${PLT} ${LOCAL_PLT} + @echo "==> $(shell basename $(shell pwd)) (dialyzer)" + @if [ -f $(LOCAL_PLT) ]; then \ + PLTS="$(PLT) $(LOCAL_PLT)"; \ + else \ + PLTS=$(PLT); \ + fi; \ + if [ -f dialyzer.ignore-warnings ]; then \ + if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \ + echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \ + exit 1; \ + fi; \ + dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \ + egrep -v "^[[:space:]]*(done|Checking|Proceeding|Compiling)" dialyzer_warnings | grep -F -f dialyzer.ignore-warnings -v > dialyzer_unhandled_warnings ; \ + cat dialyzer_unhandled_warnings ; \ + [ $$(cat dialyzer_unhandled_warnings | wc -l) -eq 0 ] ; \ + else \ + dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -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) +