aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/deps.mk10
-rw-r--r--doc/src/guide/deps.asciidoc1
-rw-r--r--test/core_deps.mk41
3 files changed, 52 insertions, 0 deletions
diff --git a/core/deps.mk b/core/deps.mk
index 2b14c4f..19a2410 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -544,6 +544,16 @@ define dep_fetch_git
cd $(DEPS_DIR)/$(call dep_name,$(1)) && git checkout -q $(call dep_commit,$(1));
endef
+define dep_fetch_git-subfolder
+ mkdir -p $(ERLANG_MK_TMP)/git-subfolder; \
+ git clone -q -n -- $(call dep_repo,$1) \
+ $(ERLANG_MK_TMP)/git-subfolder/$(call dep_name,$1); \
+ cd $(ERLANG_MK_TMP)/git-subfolder/$(call dep_name,$1) \
+ && git checkout -q $(call dep_commit,$1); \
+ ln -s $(ERLANG_MK_TMP)/git-subfolder/$(call dep_name,$1)/$(word 4,$(dep_$(1))) \
+ $(DEPS_DIR)/$(call dep_name,$1);
+endef
+
define dep_fetch_git-submodule
git submodule update --init -- $(DEPS_DIR)/$1;
endef
diff --git a/doc/src/guide/deps.asciidoc b/doc/src/guide/deps.asciidoc
index 84a53de..47e1bee 100644
--- a/doc/src/guide/deps.asciidoc
+++ b/doc/src/guide/deps.asciidoc
@@ -163,6 +163,7 @@ The following table lists all existing methods:
|===
| Name | Format | Description
| git | git repo commit | Clone the Git repository and checkout the given version
+| git-subfolder | git repo commit subfolder | Clone the Git repository, checkout the given version and use one of its subfolders as a dependency
| git-submodule | git-submodule | Initialize and update the Git submodule
| hg | hg repo commit | Clone the Mercurial repository and update to the given version
| svn | svn repo | Checkout the given SVN repository
diff --git a/test/core_deps.mk b/test/core_deps.mk
index 922c69b..3403f58 100644
--- a/test/core_deps.mk
+++ b/test/core_deps.mk
@@ -342,6 +342,47 @@ endif
{ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
halt()"
+core-deps-fetch-git-subfolder: 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 "Bootstrap a new OTP library named my_dep as a subfolder inside $(APP)"
+ $t mkdir -p $(APP)/git_repo/my_dep
+ $t cp ../erlang.mk $(APP)/git_repo/my_dep/
+ $t $(MAKE) -C $(APP)/git_repo/my_dep/ -f erlang.mk bootstrap-lib $v
+# Create an empty file so src/ gets committed.
+ $t touch $(APP)/git_repo/my_dep/src/README
+ $t cd $(APP)/git_repo && \
+ git init -q && \
+ git config user.email "[email protected]" && \
+ git config user.name "test suite" && \
+ git add . && \
+ git commit -q --no-gpg-sign -m "Tests"
+
+ $i "Add my_dep to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = git-subfolder file://$(abspath $(APP)/git_repo) master my_dep\n"}' $(APP)/Makefile
+
+ifdef LEGACY
+ $i "Add my_dep to the applications key in the .app.src file"
+ $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
+endif
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that the dependency was fetched"
+ $t test -d $(APP)/deps/my_dep
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
+ [ok = application:load(App) || App <- [$(APP), my_dep]], \
+ {ok, Deps} = application:get_key($(APP), applications), \
+ true = lists:member(my_dep, Deps), \
+ halt()"
+
core-deps-fetch-git-submodule: build clean
$i "Bootstrap a new OTP library named $(APP)"