aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-06-09 12:34:59 +0200
committerLoïc Hoguin <[email protected]>2016-06-09 12:34:59 +0200
commit5de0a629f4b07b2f0f09f2aad1c73b8c4f35d97f (patch)
tree7bc3b513185ba28d44c6c7217df53db0c307862e
parent525e3d93e46705ba1f7303485744a93de30859d9 (diff)
parent8e7cfd408f984255bf92159dfe81f4b89e4d6d05 (diff)
downloaderlang.mk-5de0a629f4b07b2f0f09f2aad1c73b8c4f35d97f.tar.gz
erlang.mk-5de0a629f4b07b2f0f09f2aad1c73b8c4f35d97f.tar.bz2
erlang.mk-5de0a629f4b07b2f0f09f2aad1c73b8c4f35d97f.zip
Merge branch 'var-app-mod' of https://github.com/jflatow/erlang.mk
-rw-r--r--core/core.mk1
-rw-r--r--core/erlc.mk4
-rw-r--r--doc/src/guide/app.asciidoc2
-rw-r--r--test/core_app.mk22
4 files changed, 26 insertions, 3 deletions
diff --git a/core/core.mk b/core/core.mk
index 5733496..8188bc3 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -24,6 +24,7 @@ PROJECT ?= $(notdir $(CURDIR))
PROJECT := $(strip $(PROJECT))
PROJECT_VERSION ?= rolling
+PROJECT_MOD ?= $(PROJECT)_app
# Verbosity.
diff --git a/core/erlc.mk b/core/erlc.mk
index 695cc83..e231cc8 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -59,7 +59,7 @@ app:: clean deps $(PROJECT).d
$(verbose) $(MAKE) --no-print-directory app-build
endif
-ifeq ($(wildcard src/$(PROJECT)_app.erl),)
+ifeq ($(wildcard src/$(PROJECT_MOD).erl),)
define app_file
{application, $(PROJECT), [
{description, "$(PROJECT_DESCRIPTION)"},
@@ -79,7 +79,7 @@ define app_file
{modules, [$(call comma_list,$(2))]},
{registered, [$(call comma_list,$(PROJECT)_sup $(PROJECT_REGISTERED))]},
{applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS))]},
- {mod, {$(PROJECT)_app, []}}
+ {mod, {$(PROJECT_MOD), []}}
]}.
endef
endif
diff --git a/doc/src/guide/app.asciidoc b/doc/src/guide/app.asciidoc
index 99ff052..eef5d45 100644
--- a/doc/src/guide/app.asciidoc
+++ b/doc/src/guide/app.asciidoc
@@ -126,6 +126,8 @@ your situation.
Short description of the project.
`PROJECT_VERSION`::
Current version of the project.
+`PROJECT_MOD`::
+ The application callback module.
`PROJECT_REGISTERED`::
List of the names of all registered processes.
`LOCAL_DEPS`::
diff --git a/test/core_app.mk b/test/core_app.mk
index 4570d9d..bc972f1 100644
--- a/test/core_app.mk
+++ b/test/core_app.mk
@@ -1,6 +1,6 @@
# Core: Building applications.
-CORE_APP_CASES = appsrc-change asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib no-app no-makedep pt pt-erlc-opts xrl xrl-include yrl yrl-include
+CORE_APP_CASES = appsrc-change asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-include yrl yrl-include
CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
.PHONY: core-app $(CORE_APP_TARGETS)
@@ -1010,6 +1010,26 @@ endif
[{module, M} = code:load_file(M) || M <- Mods], \
halt()"
+core-app-project-mod: build clean
+
+ $i "Bootstrap a new OTP library named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Generate an application module"
+ $t printf "%s\n" \
+ "-module(app_mod)." \
+ "-export([start/2, stop/1])." \
+ "start(_StartType, _StartArgs) -> {ok, self()}." \
+ "stop(_State) -> ok." > $(APP)/src/app_mod.erl
+
+ $i "Build the application with PROJECT_MOD"
+ $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
+
+ $i "Check that the application starts correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
+
core-app-pt: build clean
$i "Bootstrap a new OTP library named $(APP)"