Просмотр исходного кода

Use relative path to erlang.mk file in autopatched deps

Loïc Hoguin 9 лет назад
Родитель
Сommit
8d49f08a11
2 измененных файлов с 56 добавлено и 4 удалено
  1. 3 2
      core/deps.mk
  2. 53 2
      test/core_deps.mk

+ 3 - 2
core/deps.mk

@@ -122,7 +122,8 @@ endef
 # Overwrite erlang.mk with the current file by default.
 ifeq ($(NO_AUTOPATCH_ERLANG_MK),)
 define dep_autopatch_erlang_mk
-	echo "include $(ERLANG_MK_FILENAME)" > $(DEPS_DIR)/$(1)/erlang.mk
+	echo "include $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(DEPS_DIR)/app)/erlang.mk" \
+		> $(DEPS_DIR)/$1/erlang.mk
 endef
 else
 define dep_autopatch_erlang_mk
@@ -414,7 +415,7 @@ define dep_autopatch_rebar.erl
 			end,
 			[PortSpec(S) || S <- PortSpecs]
 	end,
-	Write("\ninclude $(ERLANG_MK_FILENAME)"),
+	Write("\ninclude $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(DEPS_DIR)/app)/erlang.mk"),
 	RunPlugin = fun(Plugin, Step) ->
 		case erlang:function_exported(Plugin, Step, 2) of
 			false -> ok;

+ 53 - 2
test/core_deps.mk

@@ -1,16 +1,22 @@
 # 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 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-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))
 
 .PHONY: core-deps $(CORE_DEPS_TARGETS) clean-core-deps $(CORE_DEPS_CLEAN_TARGETS)
 
-clean-core-deps: $(CORE_DEPS_CLEAN_TARGETS)
+clean-core-deps: $(CORE_DEPS_CLEAN_TARGETS) clean-core-deps-mv-moved clean-core-deps-mv-rebar-moved
 
 $(CORE_DEPS_CLEAN_TARGETS):
 	$t rm -rf $(APP_TO_CLEAN)/
 
+clean-core-deps-mv-moved:
+	$t rm -rf core_deps_mv-moved/
+
+clean-core-deps-mv-rebar-moved:
+	$t rm -rf core_deps_mv_rebar-moved/
+
 core-deps: $(CORE_DEPS_TARGETS)
 
 core-deps-apps: build clean-core-deps-apps
@@ -839,6 +845,51 @@ endif
 	$i "Check that the correct dependencies were fetched"
 	$t test -d $(APP)/deps/ranch
 
+core-deps-mv: build clean-core-deps-mv clean-core-deps-mv-moved
+
+	$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 "Build the application"
+	$t $(MAKE) -C $(APP) $v
+
+	$i "Check that all dependencies were fetched"
+	$t test -d $(APP)/deps/cowlib
+
+	$i "Move the application elsewhere"
+	$t mv $(APP) $(APP)-moved
+
+	$i "Build the application"
+	$t $(MAKE) -C $(APP)-moved $v
+
+core-deps-mv-rebar: build clean-core-deps-mv-rebar clean-core-deps-mv-rebar-moved
+
+	$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 Lager to the list of dependencies"
+	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\n"}' $(APP)/Makefile
+
+	$i "Build the application"
+	$t $(MAKE) -C $(APP) $v
+
+	$i "Check that all dependencies were fetched"
+	$t test -d $(APP)/deps/goldrush
+	$t test -d $(APP)/deps/lager
+
+	$i "Move the application elsewhere"
+	$t mv $(APP) $(APP)-moved
+
+	$i "Build the application"
+	$t $(MAKE) -C $(APP)-moved $v
+
 # A lower-level dependency of the first dependency always
 # wins over a lower-level dependency of the second dependency.
 core-deps-order-first: build clean-core-deps-order-first