Skip to content

Commit

Permalink
Update rebar.config to allow compilation on Windows
Browse files Browse the repository at this point in the history
Add compiler flags for Windows (MSVC).
  • Loading branch information
big-r81 committed Nov 16, 2023
1 parent f47dc6c commit f73c9d0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
59 changes: 28 additions & 31 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{erl_opts, [
deterministic
]}.
]}.

{deps, []}.

Expand All @@ -10,49 +10,46 @@
{deps, [
{base16, "2.0.1"},
{proper, "1.4.0"}
]},
]},
{plugins, [
{rebar3_codecov, "0.3.0"}
]},
{port_env,
[
{"CFLAGS", "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC --coverage"},
{"LDFLAGS", "$LDFLAGS --coverage"},
{"LDLIBS", "$LDLIBS -lcrypto"},
{"DRV_LINK_TEMPLATE", "$DRV_LINK_TEMPLATE $LDLIBS"}
]}
]}
]
{rebar3_codecov, "0.3.0"}
]}
]}
]
}.

{plugins, [pc, rebar3_hex]}.

{artifacts, ["priv/fast_pbkdf2.so"]}.
{port_env,
[
{"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)", "CFLAGS", "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC -I /usr/local/include"},
{"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)", "LDLIBS", "$LDLIBS -lcrypto -L /opt/homebrew/lib/ -L /usr/local/lib"},
{"win32", "CFLAGS", "$CFLAGS /O2 /DNDEBUG /Wall"},
{"win32", "LDLIBS", "$LDLIBS libcrypto.lib"},
{"DRV_LINK_TEMPLATE", "$DRV_LINK_TEMPLATE $LDLIBS"}
]
}.

{port_specs,
[
[
{
% Any arch
".*",
% Create library
"priv/fast_pbkdf2.so",
% From files
["c_src/*.c"],
% Using options
[ {env, [{"CFLAGS", "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC"},
{"LDLIBS", "$LDLIBS -lcrypto"},
{"DRV_LINK_TEMPLATE", "$DRV_LINK_TEMPLATE $LDLIBS"}]}]
}
]}.
% Any arch
".*",
% Create library
"priv/fast_pbkdf2.so",
% From files
["c_src/*.c"]
}
]}.

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

{cover_enabled, true}.
{cover_export_enabled, true}.
8 changes: 8 additions & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Artifacts = case os:type() of
{win32, _} ->
[{artifacts, ["priv/fast_pbkdf2.dll"]}];
_ ->
[{artifacts, ["priv/fast_pbkdf2.so"]}]
end,

CONFIG ++ Artifacts.

0 comments on commit f73c9d0

Please sign in to comment.