aboutsummaryrefslogtreecommitdiffstats
path: root/core/erlc.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-06-14 10:38:32 +0200
committerLoïc Hoguin <[email protected]>2015-06-14 10:38:32 +0200
commit752d2a69fe93523aa0b400f30e096f39e1b1eb27 (patch)
treef20f67e54a92ecab1d435d8e109479ce63bb95f6 /core/erlc.mk
parent553442b0f140f963fff9c07ac2ec8f4770096483 (diff)
downloaderlang.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.
Diffstat (limited to 'core/erlc.mk')
-rw-r--r--core/erlc.mk35
1 files changed, 34 insertions, 1 deletions
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 \