diff options
author | Loïc Hoguin <[email protected]> | 2015-10-22 14:24:32 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-10-22 14:24:32 +0200 |
commit | 312f9c646ed83f6bf5bccc237e7903f2705a8c08 (patch) | |
tree | 9faf45e967bfd24ec7a6beeee6ea658e9199af84 | |
parent | d07357f52ad8a0b67aef6d95506bb2df0a068ad3 (diff) | |
download | erlang.mk-312f9c646ed83f6bf5bccc237e7903f2705a8c08.tar.gz erlang.mk-312f9c646ed83f6bf5bccc237e7903f2705a8c08.tar.bz2 erlang.mk-312f9c646ed83f6bf5bccc237e7903f2705a8c08.zip |
Add git-submodule fetch method
Initially submitted by Daniel White.
-rw-r--r-- | core/deps.mk | 4 | ||||
-rw-r--r-- | doc/src/guide/deps.asciidoc | 8 | ||||
-rw-r--r-- | test/core_deps.mk | 56 |
3 files changed, 67 insertions, 1 deletions
diff --git a/core/deps.mk b/core/deps.mk index b9ddfab..cc5a34f 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -500,6 +500,10 @@ define dep_fetch_git cd $(DEPS_DIR)/$(call dep_name,$(1)) && git checkout -q $(call dep_commit,$(1)); endef +define dep_fetch_git-submodule + git submodule update --init -- $(DEPS_DIR)/$1; +endef + define dep_fetch_hg hg clone -q -U $(call dep_repo,$(1)) $(DEPS_DIR)/$(call dep_name,$(1)); \ cd $(DEPS_DIR)/$(call dep_name,$(1)) && hg update -q $(call dep_commit,$(1)); diff --git a/doc/src/guide/deps.asciidoc b/doc/src/guide/deps.asciidoc index 882a70d..9335439 100644 --- a/doc/src/guide/deps.asciidoc +++ b/doc/src/guide/deps.asciidoc @@ -162,6 +162,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-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 | cp | cp path/to/repo | Recursively copy a local directory @@ -184,6 +185,13 @@ Or to fetch Ehsa tag 4.0.3 from Mercurial: [source,make] dep_ehsa = hg https://bitbucket.org/a12n/ehsa 4.0.3 +Git also comes with a concept of submodules. Erlang.mk can +automatically initializes and updates submodules for dependencies, +as long as they were added beforehand using `git submodule add`: + +[source,make] +dep_cowboy = git-submodule + The `svn` method only has a repository value, but that's simply because the SVN repository URL can also contain the path and commit. diff --git a/test/core_deps.mk b/test/core_deps.mk index f986ea8..4c734f9 100644 --- a/test/core_deps.mk +++ b/test/core_deps.mk @@ -1,6 +1,6 @@ # Core: Packages and dependencies. -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 mv mv-rebar no-autopatch no-autopatch-erlang-mk no-autopatch-rebar order-first order-top otp pkg rel search shell skip 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-git-submodule fetch-hex fetch-hg fetch-legacy fetch-svn ignore mv mv-rebar no-autopatch no-autopatch-erlang-mk no-autopatch-rebar order-first order-top otp pkg rel search shell skip test CORE_DEPS_TARGETS = $(addprefix core-deps-,$(CORE_DEPS_CASES)) CORE_DEPS_CLEAN_TARGETS = $(addprefix clean-,$(CORE_DEPS_TARGETS)) @@ -710,6 +710,60 @@ endif {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \ halt()" +core-deps-fetch-git-submodule: build clean-core-deps-fetch-git-submodule + + $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 inside $(APP)" + $t mkdir $(APP)/my_dep + $t cp ../erlang.mk $(APP)/my_dep/ + $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v +# Create an empty file so src/ gets committed. + $t touch $(APP)/my_dep/src/README + $t cd $(APP)/my_dep && \ + git init -q && \ + git config user.email "[email protected]" && \ + git config user.name "test suite" && \ + git add . && \ + git commit -q -m "Tests" + + $i "Add the submodule to my_dep" + $t mkdir $(APP)/deps + $t cd $(APP) && \ + git init -q && \ + git submodule -q add file://$(abspath $(APP)/my_dep) deps/my_dep && \ + git config user.email "[email protected]" && \ + git config user.name "test suite" && \ + git add . && \ + git commit -q -m "Tests" + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $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-submodule\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 all dependencies were 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-hex: build clean-core-deps-fetch-hex $i "Bootstrap a new OTP library named $(APP)" |