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

Add release support to erlang.mk

No special configuration is needed, the release will be built
automatically if a relx.config file is found.
Loïc Hoguin 11 лет назад
Родитель
Сommit
cfcbcb5f40
2 измененных файлов с 49 добавлено и 3 удалено
  1. 20 1
      README.md
  2. 29 2
      erlang.mk

+ 20 - 1
README.md

@@ -73,6 +73,15 @@ for fetching the dependency.
 All packages featured in the index are compatible with erlang.mk
 with no extra work required.
 
+Releases
+--------
+
+If a `relx.config` file is present, erlang.mk will download `relx`
+automatically and build the release into the `_rel` folder. This
+is the default command when the file exists.
+
+No special configuration is required for this to work.
+
 Compiled files
 --------------
 
@@ -110,6 +119,8 @@ The following targets are defined:
 | `dialyze`    | Run Dialyzer on the application              |
 | `pkg-list`   | List packages in the index                   |
 | `pkg-search` | Search for packages in the index             |
+| `rel`        | Builds a release                             |
+| `clean-rel`  | Delete the previously built release          |
 
 Cleaning means removing all generated and temporary files.
 
@@ -122,7 +133,8 @@ targets. For example if you have a common_test suite named `spdy`
 and you want to run only this suite and not the others, you can
 use the `make test_spdy` command.
 
-The default target when calling `make` is `all`.
+The default target when calling `make` is `all` when no `relx.config`
+exists, and `rel` when it does exist.
 
 You can combine targets to perform many operations. For example, the
 shell command `make clean app` will have the effect of recompiling
@@ -170,6 +182,13 @@ on your system.
 `PKG_FILE_URL` allows you to change the URL from which the package index
 file is fetched.
 
+`RELX_CONFIG` is the location of the `relx.config` file, if any.
+
+`RELX` is the location of the `relx` executable for building releases.
+
+`RELX_URL` is the location where `relx` can be downloaded if it is
+not found locally.
+
 Extra targets
 -------------
 

+ 29 - 2
erlang.mk

@@ -46,8 +46,35 @@ dtl_verbose = $(dtl_verbose_$(V))
 gen_verbose_0 = @echo " GEN   " $@;
 gen_verbose = $(gen_verbose_$(V))
 
-.PHONY: all clean-all app clean deps clean-deps docs clean-docs \
-	build-tests tests build-plt dialyze
+.PHONY: rel clean-rel all clean-all app clean deps clean-deps \
+	docs clean-docs build-tests tests build-plt dialyze
+
+# Release.
+
+RELX_CONFIG ?= $(CURDIR)/relx.config
+
+ifneq ($(wildcard $(RELX_CONFIG)),)
+
+RELX ?= $(CURDIR)/relx
+export RELX
+
+RELX_URL ?= https://github.com/erlware/relx/releases/download/0.4.0/relx
+
+define get_relx
+	wget -O $(RELX) $(RELX_URL)
+	chmod +x $(RELX)
+endef
+
+rel: clean-rel all $(RELX)
+	$(RELX)
+
+$(RELX):
+	@$(call get_relx)
+
+clean-rel:
+	rm -rf _rel
+
+endif
 
 # Deps directory.