From 16b49390a11dadbcd0854a5e82007659c285eb9b Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Fri, 2 Jul 2021 05:00:57 -0700 Subject: [PATCH] Allow overiding of ./enc location --- Makefile | 2 +- rebar.config.script | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b982251..b375c2b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ REBAR?=./rebar - +ENC?=./enc all: build diff --git a/rebar.config.script b/rebar.config.script index a5da769..0befe87 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -17,7 +17,7 @@ Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of CONFIG ++ [{erl_opts, ErlOpts}] end, -case os:type() of +Config2 = case os:type() of {unix, _} -> CC = case os:getenv("CC") of false -> "cc"; @@ -36,4 +36,14 @@ case os:type() of end; _ -> Config1 +end, + +case os:getenv("ENC") of + false -> + Config2; + ENC -> + PreHook = {pre_hooks, [{"", compile, "escript " ++ ENC ++ " compile"}]}, + PostHook = {post_hooks, [{"", clean, "escript " ++ ENC ++ " compile"}]}, + Config3 = lists:keyreplace(post_hooks, 1, Config2, PostHook), + lists:keyreplace(pre_hooks, 1, Config3, PreHook) end.