-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·51 lines (43 loc) · 1.28 KB
/
run
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
#!/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,
%% Add ebin/ to our path
true = code:add_path("ebin"),
init_bench:main().
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.