Skip to content
Permalink
Browse files
Detect FDB_API_VERSION from fdbcli --version
  • Loading branch information
kocolosk committed Nov 8, 2021
1 parent 77f3ff2 commit 67b73e168462e83e7b66598f83f2845d750364c7
Showing 2 changed files with 35 additions and 23 deletions.
@@ -17,29 +17,7 @@
{"priv/erlfdb_nif.so", ["c_src/*.c"]}
]}.

{port_env, [
{
"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
"CFLAGS",
"$CFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror"
},
{
"win32",
"CFLAGS",
"$CFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG"
},

{
"(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"
}
]}.
% port_env compile / link flags dynamically generated in rebar.config.script

{profiles, [
{devcontainer, [
@@ -0,0 +1,34 @@
% 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.

[{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"
}
]}] ++ CONFIG.

0 comments on commit 67b73e1

Please sign in to comment.