12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- # Copyright (c) 2015-2016, Loïc Hoguin <essen@ninenines.eu>
- # This file is part of erlang.mk and subject to the terms of the ISC License.
- .PHONY: test-deps test-dir test-build clean-test-dir
- # Configuration.
- TEST_DIR ?= $(CURDIR)/test
- ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
- TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
- TEST_ERLC_OPTS += -DTEST=1
- # Targets.
- $(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
- ifneq ($(SKIP_DEPS),)
- test-deps:
- else
- test-deps: $(ALL_TEST_DEPS_DIRS)
- $(verbose) set -e; for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep IS_DEP=1; done
- endif
- ifneq ($(wildcard $(TEST_DIR)),)
- test-dir:
- $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o $(TEST_DIR) \
- -pa ebin/ -I include/ $(call core_find,$(TEST_DIR)/,*.erl)
- endif
- test-build:: IS_TEST=1
- test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
- test-build:: $(if $(wildcard src),$(if $(wildcard ebin/test),,clean)) $(if $(IS_APP),,deps test-deps)
- # We already compiled everything when IS_APP=1.
- ifndef IS_APP
- ifneq ($(wildcard $(TEST_DIR)),)
- $(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- endif
- ifneq ($(wildcard src),)
- $(verbose) $(MAKE) --no-print-directory $(PROJECT).d ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- $(verbose) $(MAKE) --no-print-directory app-build ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- $(gen_verbose) touch ebin/test
- endif
- endif
- # Roughly the same as test-build, but when IS_APP=1.
- # We only care about compiling the current application.
- ifdef IS_APP
- test-build-app:: ERLC_OPTS=$(TEST_ERLC_OPTS)
- test-build-app:: test-deps
- ifneq ($(wildcard $(TEST_DIR)),)
- $(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- endif
- ifneq ($(wildcard src),)
- $(verbose) $(MAKE) --no-print-directory $(PROJECT).d ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- $(verbose) $(MAKE) --no-print-directory app-build ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
- $(gen_verbose) touch ebin/test
- endif
- endif
- clean:: clean-test-dir
- clean-test-dir:
- ifneq ($(wildcard $(TEST_DIR)/*.beam),)
- $(gen_verbose) rm -f $(TEST_DIR)/*.beam
- endif
|