From 3acdef8ed9063b07c777970b264cef67592f90ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 4 Dec 2018 17:32:07 +0100 Subject: Fix and document Dialyzer against beam files --- doc/src/guide/dialyzer.asciidoc | 13 +++++++++++++ plugins/dialyzer.mk | 2 +- test/plugin_dialyzer.mk | 10 ++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/src/guide/dialyzer.asciidoc b/doc/src/guide/dialyzer.asciidoc index 58fe53f..6031113 100644 --- a/doc/src/guide/dialyzer.asciidoc +++ b/doc/src/guide/dialyzer.asciidoc @@ -71,3 +71,16 @@ it doesn't exist. This is normally not necessary as Dialyzer creates it automatically. The PLT file will be removed when you run `make distclean`. + +=== Dialyzing beam files + +By default Erlang.mk will run Dialyzer against the source +code. It is possible to configure Erlang.mk to use the +compiled source files instead. This is done using the +`DIALYZER_DIRS` variable: + +[source,make] +DIALYZER_DIRS = -r ebin + +This value must be set before including Erlang.mk to +function properly. diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk index 4c2c81d..41e5871 100644 --- a/plugins/dialyzer.mk +++ b/plugins/dialyzer.mk @@ -54,7 +54,7 @@ distclean-plt: $(gen_verbose) rm -f $(DIALYZER_PLT) ifneq ($(wildcard $(DIALYZER_PLT)),) -dialyze: +dialyze: $(if $(filter --src,$(DIALYZER_DIRS)),,deps app) else dialyze: $(DIALYZER_PLT) endif diff --git a/test/plugin_dialyzer.mk b/test/plugin_dialyzer.mk index c0229eb..a487fae 100644 --- a/test/plugin_dialyzer.mk +++ b/test/plugin_dialyzer.mk @@ -6,7 +6,7 @@ ifneq ($(shell which sem 2>/dev/null),) DIALYZER_MUTEX = sem --fg --id dialyzer endif -.PHONY: dialyzer $(C_SRC_TARGETS) +.PHONY: dialyzer $(DIALYZER_TARGETS) dialyzer: $(DIALYZER_TARGETS) @@ -109,7 +109,7 @@ dialyzer-beam: build clean $t echo "ERLC_OPTS += +'{parse_transform, lager_transform}'" >> $(APP)/Makefile $i "Make Dialyzer use the beam files" - $t echo "DIALYZER_DIRS = -r ebin" >> $(APP)/Makefile + $t perl -ni.bak -e 'print;if ($$.==1) {print "DIALYZER_DIRS = -r ebin\n"}' $(APP)/Makefile $i "Create a module that calls lager" $t printf "%s\n" \ @@ -120,6 +120,12 @@ dialyzer-beam: build clean $i "Run Dialyzer" $t $(DIALYZER_MUTEX) $(MAKE) -C $(APP) dialyze $v + $i "Clean the application" + $t $(MAKE) -C $(APP) clean $v + + $i "Run Dialyzer again using the produced PLT file" + $t $(DIALYZER_MUTEX) $(MAKE) -C $(APP) dialyze $v + dialyzer-check: build clean $i "Bootstrap a new OTP application named $(APP)" -- cgit v1.2.3