Created
August 11, 2011 06:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## 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 |
@wardbekker I'm not exactly sure what you mean by "add". This uses whatever erl is on your path, kerl changes the path so doing kerl activate R14B01 && make analyze
should do the right thing.
Current plan of attack: To prevent re-building the plt for the standard erlang/otp applications, I'm going to pre-generate those for every Erlang version during Travis Virtual Machine provisioning. That way only the deps plt needs to be created on every build before running dialyzer.
dreid, what's the advantage of the --src switch in the analyze target?
@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
Great, we use Kerl (https://github.com/spawngrid/kerl/tree/) for side by side Erlang installations, so this would be a good thing to add.