Repository navigation
Expand file tree
/
Copy pathrebar.config.script
More file actions
48 lines (48 loc) · 1.71 KB
/
Copy pathrebar.config.script
File metadata and controls
48 lines (48 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
%% -*- erlang -*-
%% sequence: rebar3 reads rebar.config before Forge plugins run.
%% load shared_rebar.config here, then install-template render the same file into
%% `rebar3 new device`.
ScriptDir = filename:dirname(SCRIPT),
{ok, SharedConfig} =
file:consult(
filename:join(ScriptDir, "shared_rebar.config")
),
Merged =
lists:foldl(
fun({Key, _} = Term, Acc) -> lists:keystore(Key, 1, Acc, Term) end,
CONFIG,
SharedConfig
),
%% rebar3 only compiles `.xrl' and `.yrl' files at the top level of `src', but
%% the grammar of `hb_singleton' sits beside it in `src/core/resolver'. We
%% generate its lexer and parser modules next to their sources here, whenever
%% a source is newer than its module, and rebar3 then compiles them with the
%% rest of `src/core'.
lists:foreach(
fun({Source, Generate}) ->
Src = filename:join([ScriptDir, "src/core/resolver", Source]),
Erl = filename:rootname(Src) ++ ".erl",
case filelib:last_modified(Erl) < filelib:last_modified(Src) of
true -> {ok, _} = Generate(Src, Erl);
false -> ok
end
end,
[
{"hb_singleton_lexer.xrl",
fun(Src, Erl) -> leex:file(Src, [{scannerfile, Erl}]) end},
{"hb_singleton_parser.yrl",
fun(Src, Erl) -> yecc:file(Src, [{parserfile, Erl}]) end}
]
),
%% `HB_VERBOSE=1' turns on the `?event_debug' trace macros for this build,
%% the same effect as the `verbose' rebar3 profile.
case os:getenv("HB_VERBOSE") of
"1" ->
ErlOpts = proplists:get_value(erl_opts, Merged, []),
lists:keystore(
erl_opts, 1, Merged,
{erl_opts, [{d, 'HB_VERBOSE', true} | ErlOpts]}
);
_ ->
Merged
end.