Skip to content

Instantly share code, notes, and snippets.

@dreid
Created August 10, 2011 20:52
Show Gist options
  • Save dreid/1138227 to your computer and use it in GitHub Desktop.
Save dreid/1138227 to your computer and use it in GitHub Desktop.
first pass at a shell script to make building dialysis plts easier to use.
#!/bin/sh
OTP_VERSION=$(erl -noinput \
-noshell \
-eval 'io:fwrite(erlang:system_info(otp_release)).' \
-s init stop)
PLT_DIR="$HOME/.dialyzer/${OTP_VERSION}"
CURRENT_APP=$(basename $(pwd));
OTP="${PLT_DIR}/otp"
APP="${PLT_DIR}/${CURRENT_APP}_deps"
mkdir -p "${PLT_DIR}"
echo "Using plt directory: ${PLT_DIR}..."
otp_plt() {
ERL=$(type -Pf erl);
ERL_BASE=$(dirname $(dirname $ERL));
ERL_LIB="${ERL_BASE}/lib/erlang/lib";
DEFAULT_APPS=$(find $ERL_LIB -depth 2 -name ebin -exec dirname {} \; | \
xargs basename | \
sed -e "s/-.*//");
echo "Generating comprehensive PLT: ${OTP}..."
dialyzer --output_plt $OTP --build_plt --apps ${DEFAULT_APPS};
}
app_plt() {
echo "Generating application dep PLT: ${APP}..."
cp $OTP $APP;
dialyzer --add_to_plt --plt $APP deps/*/ebin;
}
analyze() {
dialyzer --plt $APP ebin $@
}
CMD=$1; shift;
case $CMD in
app-plt*)
app_plt
;;
otp-plt*)
otp_plt
;;
plts*)
otp_plt
app_plt
;;
*)
analyze
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment