aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-29 15:03:34 +0200
committerLoïc Hoguin <[email protected]>2015-09-29 15:03:34 +0200
commitfe5c42fb818acf9ad6ca6589ea182dfbfbaa5427 (patch)
tree5ca924e351e7cb325e179be273febe52ab7f1208
parent41ea5e7fe740625899cd9553f5d9faf25cf5425a (diff)
downloaderlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.tar.gz
erlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.tar.bz2
erlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.zip
Add support for APPS_DIR
This changes adds Rebar-like "apps/" functionality. From this commit onward, Erlang.mk supports 4 types of repositories: - Repo with an Erlang app at root level + deps/ - Repo with an Erlang app at root level + apps/ deps/ - Repo with no app at root level + deps/ - Repo with no app at root level + apps/ deps/ Example usage: - make new-app in=webchat - make new t=gen_server n=my_chat in=webchat - make Replace new-app with new-lib to create an OTP library instead of an OTP application.
-rw-r--r--core/core.mk3
-rw-r--r--core/deps.mk45
-rw-r--r--core/erlc.mk4
-rw-r--r--plugins/bootstrap.mk72
-rw-r--r--plugins/dialyzer.mk2
-rw-r--r--test/core_deps.mk371
6 files changed, 473 insertions, 24 deletions
diff --git a/core/core.mk b/core/core.mk
index 34aad7b..1d0012d 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -181,6 +181,9 @@ core_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,
# @todo On Windows: $(shell dir /B $(1)); make sure to handle when no file exists.
core_ls = $(filter-out $(1),$(shell echo $(1)))
+# @todo Use a solution that does not require using perl.
+core_relpath = $(shell perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' $1 $2)
+
# Automated update.
ERLANG_MK_REPO ?= https://github.com/ninenines/erlang.mk
diff --git a/core/deps.mk b/core/deps.mk
index 814e7db..6a14114 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -1,26 +1,34 @@
# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: distclean-deps distclean-pkg
+.PHONY: distclean-deps
# Configuration.
+ifdef OTP_DEPS
+$(warning The variable OTP_DEPS is deprecated in favor of LOCAL_DEPS.)
+endif
+
IGNORE_DEPS ?=
export IGNORE_DEPS
+APPS_DIR ?= $(CURDIR)/apps
+export APPS_DIR
+
DEPS_DIR ?= $(CURDIR)/deps
export DEPS_DIR
REBAR_DEPS_DIR = $(DEPS_DIR)
export REBAR_DEPS_DIR
+ALL_APPS_DIRS = $(if $(wildcard $(APPS_DIR)/),$(filter-out $(APPS_DIR),$(shell find $(APPS_DIR) -maxdepth 1 -type d)))
ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(filter-out $(IGNORE_DEPS),$(BUILD_DEPS) $(DEPS)))
-ifeq ($(filter $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
+ifeq ($(filter $(APPS_DIR) $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
ifeq ($(ERL_LIBS),)
- ERL_LIBS = $(DEPS_DIR)
+ ERL_LIBS = $(APPS_DIR):$(DEPS_DIR)
else
- ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)
+ ERL_LIBS := $(ERL_LIBS):$(APPS_DIR):$(DEPS_DIR)
endif
endif
export ERL_LIBS
@@ -36,6 +44,11 @@ ifneq ($(SKIP_DEPS),)
deps::
else
deps:: $(ALL_DEPS_DIRS)
+ifndef IS_APP
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep IS_APP=1 || exit $$?; \
+ done
+endif
ifneq ($(IS_DEP),1)
$(verbose) rm -f $(ERLANG_MK_TMP)/deps.log
endif
@@ -55,8 +68,6 @@ endif
done
endif
-distclean:: distclean-deps distclean-pkg
-
# Deps related targets.
# @todo rename GNUmakefile and makefile into Makefile first, if they exist
@@ -538,6 +549,10 @@ dep_commit = $(if $(dep_$(1)_commit),$(dep_$(1)_commit),$(if $(dep_$(1)),$(word
define dep_target
$(DEPS_DIR)/$(1):
+ $(verbose) if test -d $(APPS_DIR)/$1; then \
+ echo "Error: Dependency $1 conflicts with application found in $(APPS_DIR)/$1."; \
+ exit 17; \
+ fi
$(verbose) mkdir -p $(DEPS_DIR)
$(dep_verbose) $(call dep_fetch_$(strip $(call dep_fetch,$(1))),$(1))
$(verbose) if [ -f $(DEPS_DIR)/$(1)/configure.ac -o -f $(DEPS_DIR)/$(1)/configure.in ]; then \
@@ -572,6 +587,24 @@ endef
$(foreach dep,$(BUILD_DEPS) $(DEPS),$(eval $(call dep_target,$(dep))))
+ifndef IS_APP
+clean:: clean-apps
+
+clean-apps:
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep clean IS_APP=1 || exit $$?; \
+ done
+
+distclean:: distclean-apps
+
+distclean-apps:
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep distclean IS_APP=1 || exit $$?; \
+ done
+endif
+
+distclean:: distclean-deps
+
distclean-deps:
$(gen_verbose) rm -rf $(DEPS_DIR)
diff --git a/core/erlc.mk b/core/erlc.mk
index fbba7ae..7ca24bb 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -60,7 +60,7 @@ define app_file
$(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, []},
- {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]}
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS))]}
]}.
endef
else
@@ -71,7 +71,7 @@ define app_file
$(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, [$(call comma_list,$(PROJECT)_sup $(PROJECT_REGISTERED))]},
- {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]},
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS))]},
{mod, {$(PROJECT)_app, []}}
]}.
endef
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 44f10ea..019e697 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -11,13 +11,16 @@ help::
" bootstrap Generate a skeleton of an OTP application" \
" bootstrap-lib Generate a skeleton of an OTP library" \
" bootstrap-rel Generate the files needed to build a release" \
+ " new-app n=NAME Create a new local OTP application NAME" \
+ " new-lib n=NAME Create a new local OTP library NAME" \
" new t=TPL n=NAME Generate a module NAME based on the template TPL" \
+ " new t=T n=N in=APP Generate a module NAME based on the template TPL in APP" \
" list-templates List available templates"
# Bootstrap templates.
define bs_appsrc
-{application, $(PROJECT), [
+{application, $p, [
{description, ""},
{vsn, "0.1.0"},
{id, "git"},
@@ -27,13 +30,13 @@ define bs_appsrc
kernel,
stdlib
]},
- {mod, {$(PROJECT)_app, []}},
+ {mod, {$p_app, []}},
{env, []}
]}.
endef
define bs_appsrc_lib
-{application, $(PROJECT), [
+{application, $p, [
{description, ""},
{vsn, "0.1.0"},
{id, "git"},
@@ -48,7 +51,7 @@ endef
ifdef SP
define bs_Makefile
-PROJECT = $(PROJECT)
+PROJECT = $p
PROJECT_DESCRIPTION = New project
PROJECT_VERSION = 0.0.1
@@ -59,27 +62,32 @@ include erlang.mk
endef
else
define bs_Makefile
-PROJECT = $(PROJECT)
+PROJECT = $p
include erlang.mk
endef
endif
+define bs_apps_Makefile
+PROJECT = $p
+include $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(APPS_DIR)/app)/erlang.mk
+endef
+
define bs_app
--module($(PROJECT)_app).
+-module($p_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
- $(PROJECT)_sup:start_link().
+ $p_sup:start_link().
stop(_State) ->
ok.
endef
define bs_relx_config
-{release, {$(PROJECT)_release, "1"}, [$(PROJECT)]}.
+{release, {$p_release, "1"}, [$p]}.
{extended_start_script, true}.
{sys_config, "rel/sys.config"}.
{vm_args, "rel/vm.args"}.
@@ -91,8 +99,8 @@ define bs_sys_config
endef
define bs_vm_args
--name $(PROJECT)@127.0.0.1
--setcookie $(PROJECT)
+-setcookie $p
-heart
endef
@@ -355,19 +363,21 @@ bootstrap:
ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
+ $(eval p := $(PROJECT))
+ $(eval n := $(PROJECT)_sup)
$(call render_template,bs_Makefile,Makefile)
$(verbose) mkdir src/
ifdef LEGACY
$(call render_template,bs_appsrc,src/$(PROJECT).app.src)
endif
$(call render_template,bs_app,src/$(PROJECT)_app.erl)
- $(eval n := $(PROJECT)_sup)
$(call render_template,tpl_supervisor,src/$(PROJECT)_sup.erl)
bootstrap-lib:
ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
+ $(eval p := $(PROJECT))
$(call render_template,bs_Makefile,Makefile)
$(verbose) mkdir src/
ifdef LEGACY
@@ -381,25 +391,61 @@ endif
ifneq ($(wildcard rel/),)
$(error Error: rel/ directory already exists)
endif
+ $(eval p := $(PROJECT))
$(call render_template,bs_relx_config,relx.config)
$(verbose) mkdir rel/
$(call render_template,bs_sys_config,rel/sys.config)
$(call render_template,bs_vm_args,rel/vm.args)
+new-app:
+ifndef in
+ $(error Usage: $(MAKE) new-app in=APP)
+endif
+ifneq ($(wildcard $(APPS_DIR)/$in),)
+ $(error Error: Application $in already exists)
+endif
+ $(eval p := $(in))
+ $(eval n := $(in)_sup)
+ $(verbose) mkdir -p $(APPS_DIR)/$p/src/
+ $(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
+ifdef LEGACY
+ $(call render_template,bs_appsrc,$(APPS_DIR)/$p/src/$p.app.src)
+endif
+ $(call render_template,bs_app,$(APPS_DIR)/$p/src/$p_app.erl)
+ $(call render_template,tpl_supervisor,$(APPS_DIR)/$p/src/$p_sup.erl)
+
+new-lib:
+ifndef in
+ $(error Usage: $(MAKE) new-lib in=APP)
+endif
+ifneq ($(wildcard $(APPS_DIR)/$in),)
+ $(error Error: Application $in already exists)
+endif
+ $(eval p := $(in))
+ $(verbose) mkdir -p $(APPS_DIR)/$p/src/
+ $(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
+ifdef LEGACY
+ $(call render_template,bs_appsrc_lib,$(APPS_DIR)/$p/src/$p.app.src)
+endif
+
new:
ifeq ($(wildcard src/),)
$(error Error: src/ directory does not exist)
endif
ifndef t
- $(error Usage: $(MAKE) new t=TEMPLATE n=NAME)
+ $(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
endif
ifndef tpl_$(t)
$(error Unknown template)
endif
ifndef n
- $(error Usage: $(MAKE) new t=TEMPLATE n=NAME)
+ $(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
endif
+ifdef in
+ $(verbose) $(MAKE) -C $(APPS_DIR)/$(in)/ new t=$t n=$n in=
+else
$(call render_template,tpl_$(t),src/$(n).erl)
+endif
list-templates:
$(verbose) echo Available templates: $(sort $(patsubst tpl_%,%,$(filter tpl_%,$(.VARIABLES))))
diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk
index ddced75..709b43f 100644
--- a/plugins/dialyzer.mk
+++ b/plugins/dialyzer.mk
@@ -28,7 +28,7 @@ help::
# Plugin-specific targets.
$(DIALYZER_PLT): deps app
- $(verbose) dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(ALL_DEPS_DIRS)
+ $(verbose) dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS)
plt: $(DIALYZER_PLT)
diff --git a/test/core_deps.mk b/test/core_deps.mk
index 4eb5924..0ae1bdf 100644
--- a/test/core_deps.mk
+++ b/test/core_deps.mk
@@ -1,6 +1,6 @@
# Core: Packages and dependencies.
-CORE_DEPS_CASES = build-c-8cc build-c-imagejs build-erl build-js dep-commit dir doc fetch-cp fetch-custom fetch-fail-bad fetch-fail-unknown fetch-git fetch-hex fetch-hg fetch-legacy fetch-svn ignore order-first order-top otp pkg rel search shell test
+CORE_DEPS_CASES = apps apps-conflict apps-deep-conflict apps-dir apps-new-app apps-new-lib apps-new-tpl apps-only build-c-8cc build-c-imagejs build-erl build-js dep-commit dir doc fetch-cp fetch-custom fetch-fail-bad fetch-fail-unknown fetch-git fetch-hex fetch-hg fetch-legacy fetch-svn ignore order-first order-top otp pkg rel search shell test
CORE_DEPS_TARGETS = $(addprefix core-deps-,$(CORE_DEPS_CASES))
CORE_DEPS_CLEAN_TARGETS = $(addprefix clean-,$(CORE_DEPS_TARGETS))
@@ -13,6 +13,373 @@ $(CORE_DEPS_CLEAN_TARGETS):
core-deps: $(CORE_DEPS_TARGETS)
+core-deps-apps: build clean-core-deps-apps
+
+ $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
+
+# Bootstrap the application manually to make sure it works as intended.
+ $i "Bootstrap a repository-local application my_app"
+ $t mkdir -p $(APP)/apps/my_app/src/
+ $t touch $(APP)/apps/file.erl
+ $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
+ $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
+ $t echo "-module(boy)." > $(APP)/apps/my_app/src/boy.erl
+ $t echo "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/apps/my_app/my_app.d
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/boy.beam
+ $t test -f $(APP)/apps/my_app/ebin/girl.beam
+ $t test -d $(APP)/deps/cowlib
+
+# Applications in apps are compiled automatically but not added
+# to the application resource file unless they are listed in LOCAL_DEPS.
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
+ [ok = application:load(App) || App <- [$(APP), my_app]], \
+ {ok, Deps} = application:get_key($(APP), applications), \
+ false = lists:member(my_app, Deps), \
+ {ok, MyAppDeps} = application:get_key(my_app, applications), \
+ true = lists:member(cowlib, MyAppDeps), \
+ {ok, []} = application:get_key($(APP), modules), \
+ {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Clean the application"
+ $t $(MAKE) -C $(APP) clean $v
+
+ $i "Check that Cowlib is still here"
+ $t test -d $(APP)/deps/cowlib
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/$(APP).d
+ $t test ! -e $(APP)/ebin/$(APP).app
+ $t test ! -e $(APP)/apps/my_app/my_app.d
+ $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
+ $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
+ $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
+
+ $i "Distclean the application"
+ $t $(MAKE) -C $(APP) distclean $v
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/deps
+
+ $i "Add my_app to the local dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app\n"}' $(APP)/Makefile
+
+ifdef LEGACY
+ $i "Add my_app to the applications key in the .app.src file"
+ $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_app,\n"}' $(APP)/src/$(APP).app.src
+endif
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/apps/my_app/my_app.d
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/boy.beam
+ $t test -f $(APP)/apps/my_app/ebin/girl.beam
+ $t test -d $(APP)/deps/cowlib
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
+ [ok = application:load(App) || App <- [$(APP), my_app]], \
+ {ok, Deps} = application:get_key($(APP), applications), \
+ true = lists:member(my_app, Deps), \
+ {ok, MyAppDeps} = application:get_key(my_app, applications), \
+ true = lists:member(cowlib, MyAppDeps), \
+ {ok, []} = application:get_key($(APP), modules), \
+ {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+core-deps-apps-conflict: build clean-core-deps-apps-conflict
+
+ $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 "Add Cowlib to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
+
+ $i "Create a new library Cowlib"
+ $t $(MAKE) -C $(APP) new-lib in=cowlib $v
+
+ $i "Check that building the application fails because of a conflict"
+ $t if $(MAKE) -C $(APP) $v; then false; fi
+
+ $i "Check that Cowlib wasn't fetched"
+ $t test ! -e $(APP)/deps/cowlib
+
+core-deps-apps-deep-conflict: build clean-core-deps-apps-deep-conflict
+
+ $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 "Add Cowboy to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
+
+ $i "Create a new library Cowlib"
+ $t $(MAKE) -C $(APP) new-lib in=cowlib $v
+
+ $i "Check that building the application fails because of a conflict"
+ $t if $(MAKE) -C $(APP) $v; then false; fi
+
+ $i "Check that Cowlib wasn't fetched"
+ $t test ! -e $(APP)/deps/cowlib
+
+core-deps-apps-dir: build clean-core-deps-apps-dir
+
+ $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 "Set a custom APPS_DIR"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "APPS_DIR = \$$(CURDIR)/deep/libs\n"}' $(APP)/Makefile
+
+ $i "Create a new library my_app"
+ $t $(MAKE) -C $(APP) new-lib in=my_app $v
+
+ $i "Add Cowlib as a dependency to my_app"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/deep/libs/my_app/Makefile
+
+ifdef LEGACY
+ $i "Add Cowlib to the applications key in the .app.src file"
+ $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/deep/libs/my_app/src/my_app.app.src
+endif
+
+ $i "Generate .erl files in my_app"
+ $t echo "-module(boy)." > $(APP)/deep/libs/my_app/src/boy.erl
+ $t echo "-module(girl)." > $(APP)/deep/libs/my_app/src/girl.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/deep/libs/my_app/my_app.d
+ $t test -f $(APP)/deep/libs/my_app/ebin/my_app.app
+ $t test -f $(APP)/deep/libs/my_app/ebin/boy.beam
+ $t test -f $(APP)/deep/libs/my_app/ebin/girl.beam
+ $t test -d $(APP)/deps/cowlib
+
+# Applications in apps are compiled automatically but not added
+# to the application resource file unless they are listed in LOCAL_DEPS.
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/deep/libs/*/ebin/ -eval " \
+ [ok = application:load(App) || App <- [$(APP), my_app]], \
+ {ok, Deps} = application:get_key($(APP), applications), \
+ false = lists:member(my_app, Deps), \
+ {ok, MyAppDeps} = application:get_key(my_app, applications), \
+ true = lists:member(cowlib, MyAppDeps), \
+ {ok, []} = application:get_key($(APP), modules), \
+ {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Clean the application"
+ $t $(MAKE) -C $(APP) clean $v
+
+ $i "Check that Cowlib is still here"
+ $t test -d $(APP)/deps/cowlib
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/$(APP).d
+ $t test ! -e $(APP)/ebin/$(APP).app
+ $t test ! -e $(APP)/libs/my_app/my_app.d
+ $t test ! -e $(APP)/libs/my_app/ebin/my_app.app
+ $t test ! -e $(APP)/libs/my_app/ebin/boy.beam
+ $t test ! -e $(APP)/libs/my_app/ebin/girl.beam
+
+ $i "Distclean the application"
+ $t $(MAKE) -C $(APP) distclean $v
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/deps
+
+core-deps-apps-new-app: build clean-core-deps-apps-new-app
+
+ $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 "Create a new application my_app"
+ $t $(MAKE) -C $(APP) new-app in=my_app $v
+
+ $i "Check that all bootstrapped files exist"
+ $t test -f $(APP)/apps/my_app/Makefile
+ifdef LEGACY
+ $t test -f $(APP)/apps/my_app/src/my_app.app.src
+endif
+ $t test -f $(APP)/apps/my_app/src/my_app_app.erl
+ $t test -f $(APP)/apps/my_app/src/my_app_sup.erl
+
+ $i "Create a new module my_server in my_app"
+ $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
+
+ $i "Check that the file exists"
+ $t test -f $(APP)/apps/my_app/src/my_server.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/apps/my_app/my_app.d
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
+ $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
+ $t test -f $(APP)/apps/my_app/ebin/my_server.beam
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
+ ok = application:start(my_app), \
+ {ok, [my_app_app, my_app_sup, my_server]} = application:get_key(my_app, modules), \
+ {module, my_app_app} = code:load_file(my_app_app), \
+ {module, my_app_sup} = code:load_file(my_app_sup), \
+ {module, my_server} = code:load_file(my_server), \
+ halt()"
+
+core-deps-apps-new-lib: build clean-core-deps-apps-new-lib
+
+ $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 "Create a new application my_app"
+ $t $(MAKE) -C $(APP) new-lib in=my_app $v
+
+ $i "Check that all bootstrapped files exist"
+ $t test -f $(APP)/apps/my_app/Makefile
+ifdef LEGACY
+ $t test -f $(APP)/apps/my_app/src/my_app.app.src
+endif
+
+ $i "Create a new module my_server in my_app"
+ $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
+
+ $i "Check that the file exists"
+ $t test -f $(APP)/apps/my_app/src/my_server.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/apps/my_app/my_app.d
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/my_server.beam
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
+ ok = application:start(my_app), \
+ {ok, [my_server]} = application:get_key(my_app, modules), \
+ {module, my_server} = code:load_file(my_server), \
+ halt()"
+
+core-deps-apps-new-tpl: build clean-core-deps-apps-new-tpl
+
+ $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 "Create a new library my_app"
+ $t $(MAKE) -C $(APP) new-lib in=my_app $v
+
+ $i "Generate one of each template"
+ $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_fsm n=my_fsm
+ $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_server n=my_server
+ $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=supervisor n=my_sup
+
+# Here we disable warnings because templates contain missing behaviors.
+ $i "Build the application"
+ $t $(MAKE) -C $(APP)/apps/my_app ERLC_OPTS=+debug_info $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/my_fsm.beam
+ $t test -f $(APP)/apps/my_app/ebin/my_server.beam
+ $t test -f $(APP)/apps/my_app/ebin/my_sup.beam
+
+ $i "Check that all the modules can be loaded"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
+ ok = application:start(my_app), \
+ {ok, Mods = [my_fsm, my_server, my_sup]} = application:get_key(my_app, modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+core-deps-apps-only: build clean-core-deps-apps-only
+
+ $i "Create a multi application repository with no root application"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t echo "include erlang.mk" > $(APP)/Makefile
+
+ $i "Create a new application my_app"
+ $t $(MAKE) -C $(APP) new-app in=my_app $v
+
+ $i "Add Cowlib to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/apps/my_app/Makefile
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/apps/my_app/my_app.d
+ $t test -f $(APP)/apps/my_app/ebin/my_app.app
+ $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
+ $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
+ $t test -d $(APP)/deps/cowlib/
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
+ ok = application:load(my_app), \
+ {ok, Mods = [my_app_app, my_app_sup]} = application:get_key(my_app, modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Clean the application"
+ $t $(MAKE) -C $(APP) clean $v
+
+ $i "Check that Cowlib is still here"
+ $t test -d $(APP)/deps/cowlib
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/apps/my_app/my_app.d
+ $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
+ $t test ! -e $(APP)/apps/my_app/ebin/my_app_app.beam
+ $t test ! -e $(APP)/apps/my_app/ebin/my_app_sup.beam
+
+ $i "Distclean the application"
+ $t $(MAKE) -C $(APP) distclean $v
+
+ $i "Check that all relevant files were removed"
+ $t test ! -e $(APP)/deps
+
ifneq ($(PLATFORM),msys2)
core-deps-build-c-8cc: build clean-core-deps-build-c-8cc
@@ -550,7 +917,7 @@ core-deps-otp: build clean-core-deps-otp
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add Crypto to the list of OTP dependencies"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "OTP_DEPS = crypto\n"}' $(APP)/Makefile
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = crypto\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v