-
Notifications
You must be signed in to change notification settings - Fork 18
/
rebar.config.script
54 lines (51 loc) · 2.04 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
% Hacky means to extract API version from fdbcli protocol version output
% See https://github.com/apple/foundationdb/blob/master/flow/ProtocolVersion.h
MaxAPIVersion =
begin
VsnInfo = os:cmd("fdbcli --version"),
{match, [ProtocolStr]} = re:run(VsnInfo, "protocol ([a-f0-9]*)", [{capture, [1], list}]),
ProtocolVsn = list_to_integer(ProtocolStr, 16),
APIVersionBytes = (ProtocolVsn band 16#0000000FFF00000) bsr 20,
integer_to_list(APIVersionBytes, 16)
end.
% https://github.com/markusn/coveralls-erl#example-usage-rebar3-and-github-actions
CoverallConfig =
case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
{"true", Token} when is_list(Token) ->
CONFIG1 = [{coveralls_repo_token, Token},
{coveralls_service_job_id, os:getenv("GITHUB_RUN_ID")},
{coveralls_service_number, os:getenv("GITHUB_RUN_NUMBER")},
{coveralls_commit_sha, os:getenv("GITHUB_SHA")},
{coveralls_flag_name, os:getenv("COVERALLS_FLAG_NAME")} | CONFIG],
case os:getenv("GITHUB_EVENT_NAME") =:= "pull_request"
andalso string:tokens(os:getenv("GITHUB_REF"), "/") of
[_, "pull", PRNO, _] ->
[{coveralls_service_pull_request, PRNO} | CONFIG1];
_ ->
CONFIG1
end;
_ ->
CONFIG
end.
[{port_env, [
{
"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
"CFLAGS",
"$CFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror -DFDB_API_VERSION=" ++ MaxAPIVersion
},
{
"win32",
"CFLAGS",
"$CFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG /DFDB_API_VERSION=" ++ MaxAPIVersion
},
{
"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
"LDFLAGS",
"$LDFLAGS -L/usr/local/lib -lfdb_c"
},
{
"win32",
"LDFLAGS",
"$LDFLAGS /LIBPATH:\"c:/Program Files/foundationdb/lib/foundationdb\" fdb_c.lib"
}
]}] ++ CoverallConfig.