From c41ec3ede054c693af344c0c8ad68953755ae7de Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Tue, 14 Jan 2014 13:11:36 -0500 Subject: [PATCH 1/3] Rework how dialyzer PLTs are built and used This commit splits the PLTs into 2, one for all the required OTP applications that are in the stdlib, and the other for the rebar dependancies. Each one is created if it does not exist, then checked for validity and then --add_to_plt is used to add any missing files (this is very fast if nothing needs to be added). Then the application is dialyzed using both PLTs. The 'combo' PLT which resides in ~ is intended to be used by all of Riak's deps, so it can grow to cover the set of OTP applications that Riak depends on. Each project can only specify the ones it cares about. --- Makefile | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 6b78d1a..594e97f 100644 --- a/Makefile +++ b/Makefile @@ -24,30 +24,35 @@ test: docs: ./rebar doc -APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ - xmerl webtool snmp public_key mnesia eunit +APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto PLT ?= $(HOME)/.riak_combo_dialyzer_plt - -check_plt: compile - dialyzer --check_plt --plt $(PLT) --apps $(APPS) - -build_plt: compile - dialyzer --build_plt --output_plt $(PLT) --apps $(APPS) - -dialyzer: compile - @echo - @echo Use "'make check_plt'" to check PLT prior to using this target. - @echo Use "'make build_plt'" to build PLT prior to using this target. - @echo - @sleep 1 - dialyzer -Wunmatched_returns --plt $(PLT) ebin | \ - fgrep -v -f ./dialyzer.ignore-warnings +LOCAL_PLT = .lager_combo_dialyzer_plt + +${PLT}: compile +ifneq (,$(wildcard $(PLT))) + dialyzer --check_plt --plt $(PLT) --apps $(APPS) && \ + dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(APPS) ; test $$? -ne 1 +else + dialyzer --build_plt --output_plt $(PLT) --apps $(APPS); test $$? -ne 1 +endif + +${LOCAL_PLT}: compile +ifneq (,$(wildcard $(LOCAL_PLT))) + dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ + dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 +else + dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 +endif + +dialyzer: ${PLT} ${LOCAL_PLT} + dialyzer -Wunmatched_returns --plts $(PLT) $(LOCAL_PLT) -c ebin cleanplt: @echo - @echo "Are you sure? It takes about 1/2 hour to re-build." - @echo Deleting $(PLT) in 5 seconds. + @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) From 56a217cfee5199a2b5d08e8d12261467fb79c8d0 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Tue, 14 Jan 2014 14:58:03 -0500 Subject: [PATCH 2/3] Add plt to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3bde15b..02adf69 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ erl_crash.dump .project log deps +.lager_combo_dialyzer_plt From 58bf04318e57ff404ca7b4b7d86e297778c3f676 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Tue, 14 Jan 2014 15:30:40 -0500 Subject: [PATCH 3/3] Refactor into tools.mk --- .gitignore | 2 +- Makefile | 42 ++---------------------------------------- tools.mk | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 tools.mk diff --git a/.gitignore b/.gitignore index 02adf69..d053947 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ erl_crash.dump .project log deps -.lager_combo_dialyzer_plt +.local_dialyzer_plt diff --git a/Makefile b/Makefile index 594e97f..4c61dd6 100644 --- a/Makefile +++ b/Makefile @@ -15,44 +15,6 @@ clean: distclean: clean ./rebar delete-deps -test: - ./rebar compile eunit - -## -## Doc targets -## -docs: - ./rebar doc - -APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto -PLT ?= $(HOME)/.riak_combo_dialyzer_plt -LOCAL_PLT = .lager_combo_dialyzer_plt - -${PLT}: compile -ifneq (,$(wildcard $(PLT))) - dialyzer --check_plt --plt $(PLT) --apps $(APPS) && \ - dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(APPS) ; test $$? -ne 1 -else - dialyzer --build_plt --output_plt $(PLT) --apps $(APPS); test $$? -ne 1 -endif - -${LOCAL_PLT}: compile -ifneq (,$(wildcard $(LOCAL_PLT))) - dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ - dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 -else - dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 -endif - -dialyzer: ${PLT} ${LOCAL_PLT} - dialyzer -Wunmatched_returns --plts $(PLT) $(LOCAL_PLT) -c ebin - -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) +DIALYZER_APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto +include tools.mk diff --git a/tools.mk b/tools.mk new file mode 100644 index 0000000..7e73423 --- /dev/null +++ b/tools.mk @@ -0,0 +1,39 @@ +test: compile + ./rebar eunit skip_deps=true + +docs: + ./rebar doc skip_deps=true + +PLT ?= $(HOME)/.riak_combo_dialyzer_plt +LOCAL_PLT = .local_dialyzer_plt +DIALYZER_FLAGS ?= -Wunmatched_returns + +${PLT}: compile +ifneq (,$(wildcard $(PLT))) + 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 +endif + +${LOCAL_PLT}: compile +ifneq (,$(wildcard $(LOCAL_PLT))) + dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ + dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 +else + dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1 +endif + +dialyzer: ${PLT} ${LOCAL_PLT} + @echo "==> $(shell basename $(shell pwd)) (dialyzer)" + dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin + +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) +