diff options
author | Loïc Hoguin <[email protected]> | 2015-06-14 10:38:32 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-06-14 10:38:32 +0200 |
commit | 752d2a69fe93523aa0b400f30e096f39e1b1eb27 (patch) | |
tree | f20f67e54a92ecab1d435d8e109479ce63bb95f6 | |
parent | 553442b0f140f963fff9c07ac2ec8f4770096483 (diff) | |
download | erlang.mk-752d2a69fe93523aa0b400f30e096f39e1b1eb27.tar.gz erlang.mk-752d2a69fe93523aa0b400f30e096f39e1b1eb27.tar.bz2 erlang.mk-752d2a69fe93523aa0b400f30e096f39e1b1eb27.zip |
Generate the .app file directly from the Makefile
This removes the need for a .app.src file entirely.
The PROJECT_* variables and the OTP_DEPS variable
allow us to specify everything we need.
REL_DEPS and BUILD_DEPS will be added later on to
allow users to cleanly specify those without adding
them to the .app file.
-rw-r--r-- | core/core.mk | 10 | ||||
-rw-r--r-- | core/erlc.mk | 35 | ||||
-rw-r--r-- | plugins/dialyzer.mk | 2 |
3 files changed, 45 insertions, 2 deletions
diff --git a/core/core.mk b/core/core.mk index dd66bec..46b12d1 100644 --- a/core/core.mk +++ b/core/core.mk @@ -21,6 +21,8 @@ ERLANG_MK_VERSION = 1 PROJECT ?= $(notdir $(CURDIR)) PROJECT := $(strip $(PROJECT)) +PROJECT_VERSION ?= rolling + # Verbosity. V ?= 0 @@ -117,11 +119,19 @@ help:: # Core functions. +empty := +space := $(empty) $(empty) +comma := , + define newline endef +define erlang_list +[$(subst $(space),$(comma),$(strip $(1)))] +endef + # Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy. define erlang $(ERL) -pa $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(subst ",\",$(1)))" -- erlang.mk diff --git a/core/erlc.mk b/core/erlc.mk index a646984..1aeab6c 100644 --- a/core/erlc.mk +++ b/core/erlc.mk @@ -18,6 +18,9 @@ COMPILE_MIB_FIRST_PATHS = $(addprefix mibs/,$(addsuffix .mib,$(COMPILE_MIB_FIRST # Verbosity. +app_verbose_0 = @echo " APP " $(PROJECT); +app_verbose = $(app_verbose_$(V)) + appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src; appsrc_verbose = $(appsrc_verbose_$(V)) @@ -42,18 +45,48 @@ else app:: clean app-build endif +ifeq ($(wildcard src/$(PROJECT)_app.erl),) +define app_file +{application, $(PROJECT), [ + {description, "$(PROJECT_DESCRIPTION)"}, + {vsn, "$(PROJECT_VERSION)"}, + {id, "$(1)"}, + {modules, [$(MODULES)]}, + {registered, []}, + {applications, $(call erlang_list,kernel stdlib $(OTP_DEPS) $(DEPS))} +]}. +endef +else +define app_file +{application, $(PROJECT), [ + {description, "$(PROJECT_DESCRIPTION)"}, + {vsn, "$(PROJECT_VERSION)"}, + {id, "$(1)"}, + {modules, [$(MODULES)]}, + {registered, $(call erlang_list,$(PROJECT)_sup $(PROJECT_REGISTERED))}, + {applications, $(call erlang_list,kernel stdlib $(OTP_DEPS) $(DEPS))}, + {mod, {$(PROJECT)_app, []}} +]}. +endef +endif + app-build: erlc-include ebin/$(PROJECT).app $(eval MODULES := $(shell find ebin -type f -name \*.beam \ | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//')) + $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true)) +ifeq ($(wildcard src/$(PROJECT).app.src),) + $(app_verbose) echo $(subst $(newline),,$(subst ",\",$(call app_file,$(GITDESCRIBE),$(MODULES)))) \ + > ebin/$(PROJECT).app +else @if [ -z "$$(grep -E '^[^%]*{\s*modules\s*,' src/$(PROJECT).app.src)" ]; then \ echo "Empty modules entry not found in $(PROJECT).app.src. Please consult the erlang.mk README for instructions." >&2; \ exit 1; \ fi - $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true)) $(appsrc_verbose) cat src/$(PROJECT).app.src \ | sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \ | sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \ > ebin/$(PROJECT).app +endif erlc-include: -@if [ -d ebin/ ]; then \ diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk index 23d16ee..c432d5b 100644 --- a/plugins/dialyzer.mk +++ b/plugins/dialyzer.mk @@ -28,7 +28,7 @@ help:: # Plugin-specific targets. $(DIALYZER_PLT): deps app - @dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS) + @dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(ALL_DEPS_DIRS) plt: $(DIALYZER_PLT) |