Browse Source

Add a 'run' command to run the relx release

Should only be used during development. Stolen idea from
Tristan Sloughter who stole it from Ahmad Sherif.

This commit also introduces the 'erlang' function for
executing Erlang code written directly in the Makefile.
The rest of the project will eventually move to using it
as it's much cleaner than the previous solution.
Loïc Hoguin 10 years ago
parent
commit
5c5179dba6
2 changed files with 27 additions and 1 deletions
  1. 9 0
      core/core.mk
  2. 18 1
      plugins/relx.mk

+ 9 - 0
core/core.mk

@@ -85,6 +85,15 @@ help::
 
 # Core functions.
 
+define newline
+
+
+endef
+
+define erlang
+$(ERL) -eval "$(subst $(newline),,$(subst ",\\",$(1)))"
+endef
+
 ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
 define core_http_get
 	wget --no-check-certificate -O $(1) $(2)|| rm $(1)

+ 18 - 1
plugins/relx.mk

@@ -1,7 +1,7 @@
 # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
 # This file is part of erlang.mk and subject to the terms of the ISC License.
 
-.PHONY: relx-rel distclean-relx-rel distclean-relx
+.PHONY: relx-rel distclean-relx-rel distclean-relx run
 
 # Configuration.
 
@@ -46,3 +46,20 @@ distclean-relx-rel:
 
 distclean-relx:
 	$(gen_verbose) rm -rf $(RELX)
+
+ifeq ($(wildcard $(RELX_CONFIG)),)
+run:
+else
+
+define get_relx_release.erl
+{ok, Config} = file:consult("$(RELX_CONFIG)"),
+{release, {Name, _}, _} = lists:keyfind(release, 1, Config),
+io:format("~s", [Name]),
+halt(0).
+endef
+
+RELX_RELEASE = `$(call erlang,$(get_relx_release.erl))`
+
+run: all
+	@$(RELX_OUTPUT_DIR)/$(RELX_RELEASE)/bin/$(RELX_RELEASE) console
+endif