This is an automated email from the ASF dual-hosted git repository.

ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-fast-pbkdf2.git

commit 485d8333d3e0429ab98293054bd8832909bc307b
Author: Ronny Berndt <[email protected]>
AuthorDate: Wed Nov 8 08:58:41 2023 +0100

    Update rebar.config to allow compilation on Windows
    
    Add compiler flags for Windows (MSVC).
---
 Makefile            |  5 +----
 rebar.config        | 64 +++++++++++++++++++++++++++--------------------------
 rebar.config.script |  8 +++++++
 3 files changed, 42 insertions(+), 35 deletions(-)

diff --git a/Makefile b/Makefile
index b4457cc..43482d7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,6 @@
 .PHONY: rel deps test
 
-REBARVER = 3.13.2
-ifeq ($(OTPVER),24.0)
-       REBARVER = 3.15.1
-endif
+REBARVER = 3.15.2
 
 all: deps compile
 
diff --git a/rebar.config b/rebar.config
index a0ef529..f73d7a5 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,6 +1,6 @@
 {erl_opts, [
   deterministic
- ]}.
+]}.
 
 {deps, []}.
 
@@ -10,49 +10,51 @@
     {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"}]},
+      {port_env,
+        [
+          {"CFLAGS", "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC 
-I/opt/homebrew/include -I/usr/local/include --coverage"},
+          {"LDLIBS", "$LDLIBS -lcrypto -L/opt/homebrew/lib/ -L/usr/local/lib 
--coverage"}
+        ]
+      }
+  ]}
+]
 }.
 
 {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/opt/homebrew/include 
-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}.
diff --git a/rebar.config.script b/rebar.config.script
new file mode 100644
index 0000000..7b602ec
--- /dev/null
+++ b/rebar.config.script
@@ -0,0 +1,8 @@
+Artifacts =  case os:type() of
+    {win32, _} ->
+        [{artifacts, ["priv/fast_pbkdf2.dll"]}];
+    _ ->
+        [{artifacts, ["priv/fast_pbkdf2.so"]}]
+end,
+
+CONFIG ++ Artifacts.

Reply via email to