-
Notifications
You must be signed in to change notification settings - Fork 2
/
compile
executable file
·47 lines (40 loc) · 1.2 KB
/
compile
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
#!/usr/bin/env escript
main(Args) ->
mkdir("ebin"),
%% Check for force=1 flag to force a rebuild
case lists:member("force=1", Args) of
true ->
rm("ebin/*.beam");
false ->
ok
end,
%% Add check for debug flag
DebugFlag = case lists:member("debug", Args) of
true -> debug_info;
false -> undefined
end,
%% Extract the system info of the version of OTP we use to compile
OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n),
%% Compile all src/*.erl to ebin
case make:files(filelib:wildcard("src/*.erl"),
[{outdir, "ebin"}, {i, "include"},
DebugFlag,
{d, 'OTP_INFO', OtpInfo}
]) of
up_to_date ->
ok;
error ->
io:format("Failed to compile orbit files!\n"),
halt(1)
end.
rm(Path) ->
NativePath = filename:nativename(Path),
Cmd = case os:type() of
{unix,_} -> "rm -f ";
{win32,_} -> "del /q "
end,
[] = os:cmd(Cmd ++ NativePath),
ok.
mkdir(Dir) ->
filelib:ensure_dir(Dir++"/"),
ok.