From 5e83ea6d50a31897a6f50a36e312c563f764aa81 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 2 Dec 2012 03:12:19 +0100 Subject: [PATCH] Dialyzerized. --- Makefile | 92 +++++++++++++++++++++++++++------------------- dialyzer.mittigate | 4 ++ rebar.config | 1 + src/libhowl.erl | 9 ++--- 4 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 dialyzer.mittigate diff --git a/Makefile b/Makefile index d396a64..f78dda6 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,66 @@ -APP_NAME=libhowl -APP_DIR=. -OBJ=$(shell ls $(APP_DIR)/src/*.erl | sed -e 's/\.erl$$/.beam/' | sed -e 's;^$(APP_DIR)/src;$(APP_DIR)/ebin;g') $(shell ls $(APP_DIR)/src/*.app.src | sed -e 's/\.src$$//g' | sed -e 's;^$(APP_DIR)/src;$(APP_DIR)/ebin;g') -DEPS=$(shell cat rebar.config |sed -e 's/%.*//'| sed -e '/{\(\w\+\), [^,]\+, {\w\+, [^,]\+, {[^,]\+, [^}]\+}}},\?/!d' | sed -e 's;{\(\w\+\), [^,]\+, {\w\+, [^,]\+, {[^,]\+, [^}]\+}}},\?;deps/\1/rebar.config;') -ERL=erl -PA=$(shell pwd)/$(APP_DIR)/ebin -ERL_LIBS=`pwd`/deps/ -REBAR=./rebar +REBAR = $(shell pwd)/rebar -all: $(DEPS) $(OBJ) +.PHONY: deps rel package -test: - echo $(DEPS) - echo $(OBJ) +all: deps compile -doc: FORCE - $(REBAR) doc -clean: FORCE - $(REBAR) clean - -rm *.beam erl_crash.dump - -rm -r rel/$(APP_NAME) - -rm rel/$(APP_NAME).tar.bz2 +compile: + $(REBAR) compile -$(DEPS): +deps: $(REBAR) get-deps - $(REBAR) compile -$(APP_DIR)/ebin/%.app: $(APP_DIR)/src/%.app.src - $(REBAR) compile +clean: + $(REBAR) clean -$(APP_DIR)/ebin/%.beam: $(APP_DIR)/src/%.erl - $(REBAR) compile +distclean: clean + $(REBAR) delete-deps + +test: + $(REBAR) skip_deps=true eunit + +### +### Docs +### +docs: + $(REBAR) skip_deps=true doc + +## +## Developer targets +## + +xref: + $(REBAR) xref skip_deps=true + + +## +## Dialyzer +## +APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ + xmerl webtool snmp public_key mnesia eunit syntax_tools compiler +COMBO_PLT = $(HOME)/.libhowl_combo_dialyzer_plt + +check_plt: deps compile + dialyzer --check_plt --plt $(COMBO_PLT) --apps $(APPS) \ + deps/*/ebin ebin -shell: all - ERL_LIBS="$(ERL_LIBS)" $(ERL) -pa $(PA) deps/*/ebin -s libhowl - [ -f *.beam ] && rm *.beam || true - [ -f erl_crash.dump ] && rm erl_crash.dump || true +build_plt: deps compile + dialyzer --build_plt --output_plt $(COMBO_PLT) --apps $(APPS) \ + deps/*/ebin ebin -remove_trash: - -find . -name "*~" -exec rm {} \;. - -rm *.beam erl_crash.dump -FORCE: +dialyzer: deps 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 -Wno_return --plt $(COMBO_PLT) deps/*/ebin ebin | grep -v -f dialyzer.mittigate -clean-docs: - -rm doc/*.html doc/*.png doc/*.css doc/edoc-info -docs: clean-docs - @$(REBAR) doc skip_deps=true +cleanplt: + @echo + @echo "Are you sure? It takes about 1/2 hour to re-build." + @echo Deleting $(COMBO_PLT) in 5 seconds. + @echo + sleep 5 + rm $(COMBO_PLT) diff --git a/dialyzer.mittigate b/dialyzer.mittigate new file mode 100644 index 0000000..ec70f35 --- /dev/null +++ b/dialyzer.mittigate @@ -0,0 +1,4 @@ +^lager_stdlib.erl:453: +^lager_stdlib.erl:502: +^lager_trunc_io.erl:74: +^lager_trunc_io.erl:98: diff --git a/rebar.config b/rebar.config index 784aa05..0c3885d 100644 --- a/rebar.config +++ b/rebar.config @@ -3,5 +3,6 @@ {deps, [ {mdns_client_lib, ".*", {git, "https://github.com/Licenser/mdns_client_lib.git", {branch, master}}}, + {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {branch, master}}}, {lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "1.0.0"}}} ]}. diff --git a/src/libhowl.erl b/src/libhowl.erl index d7f2b37..56c9013 100644 --- a/src/libhowl.erl +++ b/src/libhowl.erl @@ -1,7 +1,7 @@ -module(libhowl). -export([ - start/0, + start/0, servers/0 ]). @@ -43,10 +43,7 @@ servers() -> %% @end %%-------------------------------------------------------------------- --spec send(Channel::term(), Message::term()) -> - {ok, Token::{token, binary()}} | - {error, not_found}. - +-spec send(Channel::term(), Message::term()) -> ok. send(Channel, Message) -> send({msg, Channel, Message}). @@ -61,6 +58,6 @@ send(Channel, Message) -> %% @end %%-------------------------------------------------------------------- --spec send(Msg::term()) -> {ok, Reply::term()} | {error, no_server}. +-spec send(Msg::term()) -> ok. send(Msg) -> libhowl_server:cast(Msg).