Skip to content

Add makefile and other targets. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions tools.mk
Original file line number Diff line number Diff line change
@@ -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)