aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/core.mk10
-rw-r--r--core/erlc.mk35
-rw-r--r--plugins/dialyzer.mk2
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)