Skip to content
Browse files
Upgrade to rebar3, add Windows support
This patch updates erlfdb to build using rebar3. It relies on rebar3's
`pc` plugin to build the NIF instead of the compiled copy of davisp's
erlang-native-compiler, which does essentially the same thing. I left
the rebar_gdb_plugin code in the repo, although I did not update that
plugin to make it compatible with rebar3 yet.

With rebar3 in place, I also made the changes necessary to support
Windows. One gotcha is that the unit tests will fail unless you set
the erlfdb test_cluster_file environment variable to point to a running
fdb.cluster file. I didn't get through all the hoops to make the
approach of spinning up an embedded fdbserver work in a x-platform way.
Apparently Windows doesn't let you supply a Python script for the
spawn_executable argument of erlang:open_port/2. I added a rebar3
profile to help here. The following command will cause the test suite
to connect to an FDB server that is managing its configuration in the
default location on Windows:

  rebar3 as win32_external_fdbserver eunit
  • Loading branch information
kocolosk committed Nov 6, 2021
1 parent 956920e commit 68211f31c26d4a42d27e59827a6507be7cbc2dc9
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 14 deletions.
@@ -1,12 +1,12 @@

# Unit testing


# Build artifacts

@@ -1,10 +1,11 @@
all: check

rebar compile
@rebar3 compile

check: build
rebar eunit
@rebar3 eunit

rebar clean
@rebar3 clean
@rm -rf _build
BIN -25.4 KB enc
Binary file not shown.
@@ -1,22 +1,43 @@
{plugins, [

{provider_hooks, [
{pre, [
{compile, {pc, compile}},
{clean, {pc, clean}}

{port_specs, [
{"priv/", ["c_src/*.c"]}

{plugins, [rebar_gdb_plugin]}.

{port_env, [
"CFLAGS", "$CFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror"},
"CXXFLAGS", "$CXXFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror"},
"CFLAGS", "$CFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG"},
"CXXFLAGS", "$CXXFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG"},

"LDFLAGS", "$LDFLAGS -L/usr/local/lib -lfdb_c"}
"LDFLAGS", "$LDFLAGS -L/usr/local/lib -lfdb_c"},
"LDFLAGS", "$LDFLAGS /LIBPATH:\"c:/Program Files/foundationdb/lib/foundationdb\" fdb_c.lib"}

{profiles, [
{win32_external_fdbserver, [
{eunit_opts, [
{sys_config, "win32_external_fdbserver.config"}

{eunit_opts, [

{pre_hooks, [{"", compile, "escript enc compile"}]}.
{post_hooks, [{"", clean, "escript enc clean"}]}.
@@ -0,0 +1 @@
@@ -215,9 +215,10 @@ init_fdb_db(ClusterFile, Options) ->
DefaultFDBCli = os:find_executable("fdbcli"),
FDBCli = case ?MODULE:get(Options, fdbcli_bin, DefaultFDBCli) of
false -> erlang:error(fdbcli_not_found);
DefaultFDBCli -> "fdbcli";
FDBCli0 -> FDBCli0
Fmt = "~s -C ~s --exec 'configure new single ssd'",
Fmt = "~s -C ~s --exec \"configure new single ssd\"",
Cmd = lists:flatten(io_lib:format(Fmt, [FDBCli, ClusterFile])),
case os:cmd(Cmd) of
"Database created" ++ _ -> ok;
@@ -0,0 +1,5 @@
{erlfdb, [
{test_cluster_file, <<"c:/ProgramData/foundationdb/fdb.cluster">>}

0 comments on commit 68211f3

Please sign in to comment.