diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 93 |
1 files changed, 61 insertions, 32 deletions
@@ -1,59 +1,88 @@ # See LICENSE for licensing information. PROJECT = cowboy +RANCH_VSN = 0.6.0 +ERLC_OPTS = -Werror +debug_info +warn_export_all # +bin_opt_info +warn_missing_spec -DIALYZER = dialyzer -REBAR = rebar +DEPS_DIR ?= $(CURDIR)/deps +export DEPS_DIR -all: app +# Makefile tweaks. + +V ?= 0 + +appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src; +appsrc_verbose = $(appsrc_verbose_$(V)) + +erlc_verbose_0 = @echo " ERLC " $(?F); +erlc_verbose = $(erlc_verbose_$(V)) + +gen_verbose_0 = @echo " GEN " $@; +gen_verbose = $(gen_verbose_$(V)) + +.PHONY: all clean-all app clean docs clean-docs tests autobahn build-plt dialyze # Application. +all: app + +clean-all: clean clean-docs + $(gen_verbose) rm -rf .$(PROJECT).plt $(DEPS_DIR) logs + deps/ranch: - @$(REBAR) get-deps + @mkdir -p $(DEPS_DIR) + git clone -n -- https://github.com/extend/ranch.git $(DEPS_DIR)/ranch + cd $(DEPS_DIR)/ranch ; git checkout -q $(RANCH_VSN) + +MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//') -app: deps/ranch - @$(REBAR) compile +app: deps/ranch ebin/$(PROJECT).app + $(appsrc_verbose) cat src/$(PROJECT).app.src \ + | sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \ + > ebin/$(PROJECT).app + @$(MAKE) -C $(DEPS_DIR)/ranch + +ebin/$(PROJECT).app: src/*.erl + @mkdir -p ebin/ + $(erlc_verbose) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ \ + src/$(PROJECT)_middleware.erl $? clean: - @$(REBAR) clean - rm -f test/*.beam - rm -f erl_crash.dump + -@$(MAKE) -C $(DEPS_DIR)/ranch clean + $(gen_verbose) rm -rf ebin/ test/*.beam erl_crash.dump + +# Documentation. docs: clean-docs - @$(REBAR) doc skip_deps=true + $(gen_verbose) erl -noshell \ + -eval 'edoc:application($(PROJECT), ".", []), init:stop().' clean-docs: - rm -f doc/*.css - rm -f doc/*.html - rm -f doc/*.png - rm -f doc/edoc-info + $(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info # Tests. -deps/proper: - @$(REBAR) -C rebar.tests.config get-deps - cd deps/proper && $(REBAR) compile - -tests: clean deps/proper app eunit ct - -inttests: clean deps/proper app eunit intct - -eunit: - @$(REBAR) -C rebar.tests.config eunit skip_deps=true +CT_RUN = ct_run \ + -pa ebin $(DEPS_DIR)/*/ebin \ + -dir test \ + -logdir logs \ + -cover test/cover.spec -ct: - @$(REBAR) -C rebar.tests.config ct skip_deps=true suites=http,ws +tests: ERLC_OPTS += -DTEST=1 +tests: clean app + @mkdir -p logs/ + @$(CT_RUN) -suite eunit_SUITE http_SUITE ws_SUITE -intct: - @$(REBAR) -C rebar.tests.config ct skip_deps=true suites=http,ws,autobahn +autobahn: clean app + @mkdir -p logs/ + @$(CT_RUN) -suite autobahn_SUITE # Dialyzer. -build-plt: - @$(DIALYZER) --build_plt --output_plt .$(PROJECT).plt \ - --apps kernel stdlib sasl inets crypto public_key ssl deps/* +build-plt: app + @dialyzer --build_plt --output_plt .$(PROJECT).plt \ + --apps erts kernel stdlib crypto public_key ssl $(DEPS_DIR)/ranch dialyze: - @$(DIALYZER) --src src --plt .$(PROJECT).plt --no_native \ + @dialyzer --src src --plt .$(PROJECT).plt --no_native \ -Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs |