Browse Source

Print a changelog when updating Erlang.mk

Loïc Hoguin 6 years ago
parent
commit
2163fef859
4 changed files with 46 additions and 8 deletions
  1. 9 0
      CHANGELOG.asciidoc
  2. 6 1
      Makefile
  3. 7 7
      core/core.mk
  4. 24 0
      test/core_upgrade.mk

+ 9 - 0
CHANGELOG.asciidoc

@@ -0,0 +1,9 @@
+2018/12/03: Changelog introduced.
+
+2018/12/03: Relx has been updated to v3.27.0.
+
+2018/12/03: Dependencies are no longer always rebuilt by
+            default. Please check the documentation for
+            information. A quick fix if this causes an
+            issue is to add `FULL = 1` at the top of your
+            Makefile.

+ 6 - 1
Makefile

@@ -30,7 +30,12 @@ ERLANG_MK_VERSION = $(shell git describe --dirty --tags --always)
 .PHONY: all check
 .PHONY: all check
 
 
 all:
 all:
-	export LC_COLLATE=C; \
+# Temporarily force the printing of the CHANGELOG.
+# The required variable hadn't been introduced yet.
+#ifdef UPGRADE
+	@cat CHANGELOG.asciidoc
+#endif
+	@export LC_COLLATE=C; \
 	awk 'FNR==1 && NR!=1{print ""}1' $(patsubst %,%.mk,$(BUILD_CONFIG)) \
 	awk 'FNR==1 && NR!=1{print ""}1' $(patsubst %,%.mk,$(BUILD_CONFIG)) \
 		| sed 's/^ERLANG_MK_VERSION =.*/ERLANG_MK_VERSION = $(ERLANG_MK_VERSION)/' \
 		| sed 's/^ERLANG_MK_VERSION =.*/ERLANG_MK_VERSION = $(ERLANG_MK_VERSION)/' \
 		| sed 's:^ERLANG_MK_WITHOUT =.*:ERLANG_MK_WITHOUT = $(WITHOUT):' > $(ERLANG_MK)
 		| sed 's:^ERLANG_MK_WITHOUT =.*:ERLANG_MK_WITHOUT = $(WITHOUT):' > $(ERLANG_MK)

+ 7 - 7
core/core.mk

@@ -196,15 +196,15 @@ ERLANG_MK_BUILD_DIR ?= .erlang.mk.build
 erlang-mk: WITHOUT ?= $(ERLANG_MK_WITHOUT)
 erlang-mk: WITHOUT ?= $(ERLANG_MK_WITHOUT)
 erlang-mk:
 erlang-mk:
 ifdef ERLANG_MK_COMMIT
 ifdef ERLANG_MK_COMMIT
-	git clone $(ERLANG_MK_REPO) $(ERLANG_MK_BUILD_DIR)
-	cd $(ERLANG_MK_BUILD_DIR) && git checkout $(ERLANG_MK_COMMIT)
+	$(verbose) git clone $(ERLANG_MK_REPO) $(ERLANG_MK_BUILD_DIR)
+	$(verbose) cd $(ERLANG_MK_BUILD_DIR) && git checkout $(ERLANG_MK_COMMIT)
 else
 else
-	git clone --depth 1 $(ERLANG_MK_REPO) $(ERLANG_MK_BUILD_DIR)
+	$(verbose) git clone --depth 1 $(ERLANG_MK_REPO) $(ERLANG_MK_BUILD_DIR)
 endif
 endif
-	if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR)/build.config; fi
-	$(MAKE) -C $(ERLANG_MK_BUILD_DIR) WITHOUT='$(strip $(WITHOUT))'
-	cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
-	rm -rf $(ERLANG_MK_BUILD_DIR)
+	$(verbose) if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR)/build.config; fi
+	$(gen_verbose) $(MAKE) --no-print-directory -C $(ERLANG_MK_BUILD_DIR) WITHOUT='$(strip $(WITHOUT))' UPGRADE=1
+	$(verbose) cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
+	$(verbose) rm -rf $(ERLANG_MK_BUILD_DIR)
 
 
 # The erlang.mk package index is bundled in the default erlang.mk build.
 # The erlang.mk package index is bundled in the default erlang.mk build.
 # Search for the string "copyright" to skip to the rest of the code.
 # Search for the string "copyright" to skip to the rest of the code.

+ 24 - 0
test/core_upgrade.mk

@@ -6,6 +6,30 @@ CORE_UPGRADE_TARGETS = $(call list_targets,core-upgrade)
 
 
 core-upgrade: $(CORE_UPGRADE_TARGETS)
 core-upgrade: $(CORE_UPGRADE_TARGETS)
 
 
+core-upgrade-changelog: 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 "Fork erlang.mk locally and set a test CHANGELOG.asciidoc"
+	$t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
+	$t echo "$(APP)$(APP)" > $(APP)/alt-erlangmk-repo/CHANGELOG.asciidoc
+# Since part of this functionality needs the main Makefile, copy it.
+	$t cp ../Makefile $(APP)/alt-erlangmk-repo/
+	$t (cd $(APP)/alt-erlangmk-repo && \
+		git config user.email "testsuite@erlang.mk" && \
+		git config user.name "test suite" && \
+		git add CHANGELOG.asciidoc Makefile && \
+		git commit -q --no-gpg-sign -a -m 'Add test changelog')
+
+	$i "Point application to an alternate erlang.mk repository"
+	$t perl -ni.bak -e 'print;if ($$.==1) {print "ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\n"}' $(APP)/Makefile
+
+	$i "Update erlang.mk; CHANGELOG.asciidoc should be printed"
+	$t $(MAKE) -C $(APP) erlang-mk | grep -c "$(APP)$(APP)" | grep -q 1
+
 core-upgrade-conflicting-configs: build clean
 core-upgrade-conflicting-configs: build clean
 
 
 	$i "Bootstrap a new OTP library named $(APP)"
 	$i "Bootstrap a new OTP library named $(APP)"