From 58b99e7f457bc056e91d2d1721cbb65fcd517afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 28 May 2014 22:07:54 +0200 Subject: Cut erlang.mk into many small components * The build.config says what gets into the generated erlang.mk. * The default erlang.mk in the repository hasn't changed yet. * Clean targets were separated into "clean" and "distclean". * The "help" target was added to display some help message. I probably broke a couple things... --- plugins/ct.mk | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/dialyzer.mk | 34 ++++++++++++++++++++++++ plugins/edoc.mk | 21 +++++++++++++++ plugins/erlydtl.mk | 25 ++++++++++++++++++ plugins/relx.mk | 43 +++++++++++++++++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 plugins/ct.mk create mode 100644 plugins/dialyzer.mk create mode 100644 plugins/edoc.mk create mode 100644 plugins/erlydtl.mk create mode 100644 plugins/relx.mk (limited to 'plugins') diff --git a/plugins/ct.mk b/plugins/ct.mk new file mode 100644 index 0000000..e3e33f5 --- /dev/null +++ b/plugins/ct.mk @@ -0,0 +1,74 @@ +# Copyright (c) 2013-2014, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct + +# Configuration. + +CT_OPTS ?= +CT_SUITES ?= + +TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard +TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}' + +# Core targets. + +tests:: tests-ct + +clean:: clean-ct + +distclean:: distclean-ct + +help:: + @printf "%s\n" "" \ + "All your common_test suites have their associated targets." \ + "A suite named http_SUITE can be ran using the ct-http target." + +# Plugin-specific targets. + +ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS)) + +CT_RUN = ct_run \ + -no_auto_compile \ + -noshell \ + -pa $(realpath ebin) $(DEPS_DIR)/*/ebin \ + -dir test \ + -logdir logs \ + $(CT_OPTS) + +$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep)))) + +build-ct-deps: $(ALL_TEST_DEPS_DIRS) + @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done + +build-ct-suites: build-ct-deps + $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \ + $(wildcard test/*.erl test/*/*.erl) -pa ebin/ + +tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS) +tests-ct: clean deps app build-ct-suites + @if [ -d "test" ] ; \ + then \ + mkdir -p logs/ ; \ + $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) ; \ + fi + $(gen_verbose) rm -f test/*.beam + +define ct_suite_target +ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS) +ct-$(1): clean deps app build-tests + @if [ -d "test" ] ; \ + then \ + mkdir -p logs/ ; \ + $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) ; \ + fi + $(gen_verbose) rm -f test/*.beam +endef + +$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test)))) + +clean-ct: + $(gen_verbose) rm -rf test/*.beam + +distclean-ct: + $(gen_verbose) rm -rf logs/ diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk new file mode 100644 index 0000000..8754919 --- /dev/null +++ b/plugins/dialyzer.mk @@ -0,0 +1,34 @@ +# Copyright (c) 2013-2014, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: plt distclean-plt dialyze + +# Configuration. + +DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt +export DIALYZER_PLT + +PLT_APPS ?= +DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \ + -Wunmatched_returns # -Wunderspecs + +# Core targets. + +distclean:: distclean-plt + +help:: + @printf "%s\n" "" \ + "Dialyzer targets:" \ + " plt Build a PLT file for this project" \ + " dialyze Analyze the project using Dialyzer" + +# Plugin-specific targets. + +plt: deps app + @dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS) + +distclean-plt: + $(gen_verbose) rm -f $(DIALYZER_PLT) + +dialyze: + @dialyzer --src src --no_native $(DIALYZER_OPTS) diff --git a/plugins/edoc.mk b/plugins/edoc.mk new file mode 100644 index 0000000..5249d08 --- /dev/null +++ b/plugins/edoc.mk @@ -0,0 +1,21 @@ +# Copyright (c) 2013-2014, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: distclean-edoc + +# Configuration. + +EDOC_OPTS ?= + +# Core targets. + +docs:: distclean-edoc + $(gen_verbose) erl -noshell \ + -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), init:stop().' + +distclean:: distclean-edoc + +# Plugin-specific targets. + +distclean-edoc: + $(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info diff --git a/plugins/erlydtl.mk b/plugins/erlydtl.mk new file mode 100644 index 0000000..e288072 --- /dev/null +++ b/plugins/erlydtl.mk @@ -0,0 +1,25 @@ +# Copyright (c) 2013-2014, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +# Verbosity. + +dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F)); +dtl_verbose = $(dtl_verbose_$(V)) + +# Core targets. + +define compile_erlydtl + $(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \ + Compile = fun(F) -> \ + Module = list_to_atom( \ + string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \ + erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \ + end, \ + _ = [Compile(F) || F <- string:tokens("$(1)", " ")], \ + init:stop()' +endef + +ifneq ($(wildcard src/),) +ebin/$(PROJECT).app:: $(shell find templates -type f -name \*.dtl 2>/dev/null) + $(if $(strip $?),$(call compile_erlydtl,$?)) +endif diff --git a/plugins/relx.mk b/plugins/relx.mk new file mode 100644 index 0000000..5213318 --- /dev/null +++ b/plugins/relx.mk @@ -0,0 +1,43 @@ +# Copyright (c) 2013-2014, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: distclean-rel + +# Configuration. + +RELX_CONFIG ?= $(CURDIR)/relx.config + +ifneq ($(wildcard $(RELX_CONFIG)),) + +RELX ?= $(CURDIR)/relx +export RELX + +RELX_URL ?= https://github.com/erlware/relx/releases/download/v0.6.0/relx +RELX_OPTS ?= +RELX_OUTPUT_DIR ?= _rel + +ifneq ($(firstword $(subst -o,,$(RELX_OPTS))),) + RELX_OUTPUT_DIR = $(firstword $(subst -o,,$(RELX_OPTS))) +endif + +# Core targets. + +rel:: distclean-rel $(RELX) + @$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS) + +distclean:: distclean-rel + +# Plugin-specific targets. + +define relx_fetch + $(call core_http_get,$(RELX),$(RELX_URL)) + chmod +x $(RELX) +endef + +$(RELX): + @$(call relx_fetch) + +distclean-rel: + $(gen_verbose) rm -rf $(RELX_OUTPUT_DIR) + +endif -- cgit v1.2.3