-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrebar.config.script
58 lines (53 loc) · 2.68 KB
/
rebar.config.script
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
49
50
51
52
53
54
55
56
57
58
%%
%% Generate src/egraph_version.erl automatically
%%
CommitShortHash = string:strip(os:cmd("git show --format='%h' -s"), right, 10).
LastUpdate = string:strip(os:cmd("git show --format='%cD' -s"), right, 10).
CommitTitle = string:strip(os:cmd("git show --format='%s' -s"), right, 10).
CurrentBranch = string:strip(os:cmd("git rev-parse --abbrev-ref HEAD"), right, 10).
LocalChanges = string:strip(os:cmd("git status -s"), right, 10).
CleanedCommitTitle = re:replace(CommitTitle, "\"", "'", [global, {return, list}]).
{ok, Fd} = file:open("src/egraph_version.erl", write),
io:format(Fd, "%% This file is autogenerated and any changes will\n", []).
io:format(Fd, "%% be lost upon next build.\n\n", []).
io:format(Fd, "-module(egraph_version).\n\n-export([hash/0, last_update/0, title/0, branch/0, status/0]).\n\n", []).
io:format(Fd, "hash() -> <<\"~s\">>.\n\n", [CommitShortHash]).
io:format(Fd, "last_update() -> <<\"~s\">>.\n\n", [LastUpdate]).
io:format(Fd, "title() -> <<\"~s\">>.\n\n", [CleanedCommitTitle]).
io:format(Fd, "branch() -> <<\"~s\">>.\n\n", [CurrentBranch]).
io:format(Fd, "status() -> <<\"~s\">>.\n\n", [LocalChanges]).
file:close(Fd).
case os:type() of
{win32, _} ->
ok;
{osx, _} ->
JiffyDbOverride = {overrides , [
{override , eleveldb, [{ pre_hooks , [{ compile , "make" }]}]}
]},
OsxProdProfile = {prod, [{relx, [{dev_mode, false},
{include_src, false},
{include_erts, true}]}
]},
Config2 = lists:keystore(overrides, 1, CONFIG, {overrides, [JiffyDbOverride]}),
lists:keystore(profiles, 1, Config2, {profiles, [OsxProdProfile]});
_ ->
JiffyOverride = {override, jiffy, [
{plugins, [pc]},
% for linux|unix
{artifacts, ["priv/jiffy.so"]},
{provider_hooks, [
{post,
[
{compile, {pc, compile}},
{clean, {pc, clean}}
]
}]
}
]},
Config2 = lists:keystore(overrides, 1, CONFIG, {overrides, [JiffyOverride]}),
LinuxProdProfile = {prod, [{relx, [{dev_mode, false},
{include_src, false},
{include_erts, true}]}
]},
lists:keystore(profiles, 1, Config2, {profiles, [LinuxProdProfile]})
end.