Skip to content

Commit

Permalink
Add settings for port compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
codeadict committed Jan 2, 2020
1 parent 39ff9b5 commit 6aedc84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
3 changes: 2 additions & 1 deletion c_src/build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
fi
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well

LEVELDB_VSN="develop"
# TODO: Should we use/trust "develop" as the most recent maintained version.
LEVELDB_VSN="2.0.35"

set -e

Expand Down
40 changes: 26 additions & 14 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@

{xref_checks, [undefined_function_calls]}.

{port_sources, ["c_src/*.cc"]}.

{erl_opts, [warnings_as_errors, {parse_transform, lager_transform}, debug_info]}.

{deps, [
{lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "2.1.1"}}}
]}.

{pre_hooks, [{'get-deps', "c_src/build_deps.sh get-deps"},
{compile, "c_src/build_deps.sh"},
{"(linux|darwin|solaris)", compile, "make -C c_src"},
{"freebsd", compile, "gmake -C c_src"}]}.

{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.
{port_specs, [{ "priv/eleveldb.so", ["c_src/*.cc"] }]}.

{erl_opts, [debug_info]}.

{port_env, [
%% Make sure to set -fPIC when compiling leveldb
{"CFLAGS", "$CFLAGS -Wall -O3 -fPIC"},
{"CXXFLAGS", "$CXXFLAGS -Wall -O3 -fPIC"},
{"DRV_CFLAGS", "$DRV_CFLAGS -O3 -Wall -I c_src/leveldb/include -I c_src/leveldb -I c_src/system/include"},
{"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/leveldb/libleveldb.a -lsnappy -lstdc++"}
]}.

{pre_hooks, [
{"(linux|darwin|solaris|freebsd)", compile, "c_src/build_deps.sh get-deps"},
{"(linux|darwin|solaris|freebsd)", compile, "c_src/build_deps.sh"}
]}.

{provider_hooks, [
{post,
[
{compile, {pc, compile}},
{clean, {pc, clean}}
]
}
]
}.

0 comments on commit 6aedc84

Please sign in to comment.