forked from hamer/erlang-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebar.config.script
26 lines (24 loc) · 1.06 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
{Tgt,Ext} = case os:type() of
{win32, _} -> {".win", ".dll"};
{unix,linux} -> {".linux",".so"};
_ -> {"", ""}
end,
Arch = case erlang:system_info(wordsize) of
4 -> ".x86";
8 -> ".x64"
end,
Driver = "priv/sqlite3_drv" ++ Tgt ++ Arch ++ Ext,
case {filelib:is_regular(Driver), os:getenv("REBUILD")} of
{true, false} ->
io:format("No need to rebuild '~s'\n", [Driver]),
{port_specs,[{V,_}|_]} = lists:keyfind(port_specs, 1, CONFIG),
Cfg1 = lists:keyreplace(port_specs, 1, CONFIG, {port_specs, [{V, []}]}),
[{artifacts, [Driver]} | Cfg1];
_ ->
PortSpec = {port_specs, [{Driver, ["c_src/*.c", "sqlite3_amalgamation/sqlite3.c"]}]},
PortEnv = proplists:get_value(port_env, CONFIG),
PortEnv1 = [{"CFLAGS", "-DDRIVER_SFX=\\\""++Tgt++Arch++"\\\""} | PortEnv],
Cfg1 = lists:keyreplace(port_env, 1, CONFIG, {port_env, PortEnv1}),
Cfg2 = lists:keyreplace(port_specs, 1, Cfg1, PortSpec),
[{artifacts, [Driver]} | Cfg2]
end.