Skip to content

Commit

Permalink
Amend README
Browse files Browse the repository at this point in the history
  • Loading branch information
crownedgrouse committed Apr 9, 2020
1 parent cb82420 commit 665896a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This is an erlang.mk plugin to use the `esh` template engine.

See [esh project](https://github.com/jirutka/esh) and [esh man page](https://github.com/jirutka/esh/blob/master/esh.1.adoc) .

This plugin can be used to generate any Erlang file which content can depends of OS or environment.

## Install

```make
Expand All @@ -22,11 +24,26 @@ dep_esh.mk = git https://github.com/crownedgrouse/esh.mk master # for branch ma
include erlang.mk
```

## Usage

Once esh plugin declared in your project's Makefile, simply run :

```shell
$> make esh
```
First call will show the wget command output to download `esh` tarball. If some proxy parameters are needed, considere use of [`wgetrc` file](https://www.gnu.org/software/wget/manual/html_node/Startup-File.html#Startup-File).

Any file with suffix `.esh` found under project's root directory will be treated and a target file generated in same directory with same name without `.esh` suffix.

For instance :
- `.config` files
- `vm.args` file

No output is displayed unless a syntax error occurs. In such case error will be printed.

## Override environment variables

If environment variables need to be overidden, variable `ESH_VARS` can be used.
If environment variables need to be overridden, variable `ESH_VARS` can be used.
Declaration can to be done before make command, or set in `Makefile` file.

```shell
Expand All @@ -40,3 +57,13 @@ ESH_VARS="logs_dir=/var/log tmp_dir=/tmp "

include erlang.mk
```
See also next section Help for other esh variables.

## Help

Using erlang.mk `help` target will tell you than target `esh_help` will output `esh` script help. This help will show you other variables available to tune `esh`.

## Force update/install

In order to force install or update again, considere removing `.erlang.mk/esh.mk/` and `deps/esh.mk/` directories.

13 changes: 9 additions & 4 deletions mk/esh.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#
# ESH template engine plugin for Erlang.mk
# Licence : https://github.com/crownedgrouse/esh.mk/blob/master/LICENCE
# Author : Eric Pailleau <[email protected]>
#
# Author : Eric Pailleau <esh.mk@crownegrous
# Version : 1.0.0
TMPDIR != mktemp -d
esh_dir = $(PWD)/.erlang.mk/esh.mk
esh_script = $(esh_dir)/esh
esh_version = 0.3.0
Expand All @@ -11,12 +12,16 @@ esh_templates != find $(PWD) -name '*.esh'

esh_init:
@mkdir -p $(esh_dir)
@test -f $(esh_script) || (cd /tmp/ && wget $(esh_tarball) && tar -xzf esh-$(esh_version).tar.gz && cd esh-$(esh_version) && mv -f esh $(esh_dir) && chmod +x $(esh_script) )
@test -f $(esh_script) || (mkdir -p $(TMPDIR) && cd $(TMPDIR) && wget $(esh_tarball) && tar -xzf esh-$(esh_version).tar.gz && cd esh-$(esh_version) && mv -f esh $(esh_dir) && chmod +x $(esh_script))
@rm -rf $(TMPDIR)

app:: esh

esh: esh_init
$(foreach target,$(esh_templates),$(shell $(esh_script) -o $(target).out -- $(target) $(ESH_VARS) && mv -f $(target).out $(dirname $(target))/$(basename $(target) .esh)))
$(foreach target,$(esh_templates), $(shell $(esh_script) -o $(target).out -- $(target) $(ESH_VARS) && mv -f $(target).out $(dirname $(target))/$(basename $(target) .esh)))

esh_help:
@$(esh_script) -h



3 changes: 2 additions & 1 deletion plugins.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# ESH template engine plugin for Erlang.mk
# Licence : https://github.com/crownedgrouse/esh.mk/blob/master/LICENCE
# Author : Eric Pailleau <[email protected]>
#
# Version : 1.0.0

help::
@printf "%s\n" " esh Apply esh template engine plugin"
@printf "%s\n" " esh_help Help of esh template engine"


THIS := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
Expand Down

0 comments on commit 665896a

Please sign in to comment.