Skip to content

Instantly share code, notes, and snippets.

@dreid
Created August 11, 2011 06:45
Show Gist options
  • Save dreid/1139033 to your computer and use it in GitHub Desktop.
Save dreid/1139033 to your computer and use it in GitHub Desktop.
A second pass at making using dialyzer a little easier. This time as a Makefile.
##
## dialyzer.mk: Useful make targets for working with erlang's
## dialyzer. Manages a per-OTP version PLT which is then copied
## to your project directory and adds your dependencies to the
## plt. By default the OTP plt is stored in ~/.dialyzer so that
## it is used by all dialyzer.mk using projects. This can be
## changed with the PLT_BASE variable.
##
## Recommended usage is to add `include dialyzer.mk` to your
## projects Makefile.
##
## Author: David Reid <[email protected]>
##
DEPS_DIR=deps
PLT_BASE?=$(HOME)/.dialyzer
ERL=$(shell type -Pf erl)
ERL_LIB=$(shell dirname $(shell dirname ${ERL}))/lib/erlang/lib
OTP_VERSION=$(shell ${ERL} \
-noinput \
-noshell \
-eval 'io:fwrite(erlang:system_info(otp_release)).' \
-s init stop)
PLT_DIR=${PLT_BASE}/${OTP_VERSION}
OTP_PLT=${PLT_DIR}/otp_plt
DEPS_PLT=ebin/.deps_plt
DIALYZER_WARNINGS?=
OTP_APPS?=$(wildcard ${ERL_LIB}/*/ebin)
${PLT_DIR}:
@echo "Creating plt directory: ${PLT_DIR}"
@mkdir -p $@
${OTP_PLT}: ${PLT_DIR}
@echo "Generating OTP plt at ${OTP_PLT}"
@dialyzer --build_plt --output_plt $@ --apps $(OTP_APPS)
${DEPS_PLT}: ${OTP_PLT}
cp ${OTP_PLT} ${DEPS_PLT}
dialyzer --add_to_plt --plt ${DEPS_PLT} ${DEPS_DIR}/*/ebin
.PHONY: analyze
analyze: ${DEPS_PLT}
dialyzer --plt ${DEPS_PLT} $(DIALYZER_WARNINGS) -r src --src
@dreid
Copy link
Author

dreid commented Aug 21, 2011

@wardbekker Runs the analysis over the source, instead of the beam files. Basically lets you run the analysis without having to compile first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment