Skip to content

Commit

Permalink
Use port_compiler to build nif
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorzlyczba committed May 2, 2022
1 parent 7869753 commit 8ead9a9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 90 deletions.
80 changes: 0 additions & 80 deletions c_src/Makefile

This file was deleted.

46 changes: 36 additions & 10 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
{erl_opts, [debug_info]}.
{erl_opts, [debug_info,
{platform_define, "^(R14|R15|R16B|17)", 'random_module_available'},
{if_version_below, "23", {d, 'INCLUDE_ERL_INTERFACE'}}
]}.
{deps, [{prometheus, "~> 4.0"}]}.

{pre_hooks,
[{"linux|darwin", compile, "make -C c_src"},
{"freebsd", compile, "gmake -C c_src"}]}.
{post_hooks,
[{"linux|darwin", clean, "make -C c_src clean"},
{"freebsd", clean, "gmake -C c_src clean"}]}.

{plugins, [{rebar3_archive_plugin, "0.0.2"},
rebar3_hex]}.
{plugins, [
{pc, {git, "https://github.com/blt/port_compiler.git", {branch, "master"}}}
]}.
{port_specs, [
{".*-apple-darwin.*", "priv/prometheus_process_collector.so",
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_macos.cc"]
},
{".*-linux", "priv/prometheus_process_collector.so",
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_linux.cc"]
},
{".*-freebsd.*", "priv/prometheus_process_collector.so",
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_freebsd.cc"]
}
]}.
{port_env, [
{"CXXFLAGS", "-std=c++11 -Wall -O3 -arch x86_64 -finline-functions"},
{".*-linux", "CXX", "g++"},
{".*-apple-darwin.*", "CXX", "c++"},
{".*-freebsd.*", "CXX", "c++"}
]}.
{so_name, "prometheus_process_collector.so"}.
{artifacts, ["priv/prometheus_process_collector.so"]}.
{provider_hooks, [
{pre, [
{compile,
{pc, compile}
},
{clean,
{pc, clean}
}
]}
]}.

0 comments on commit 8ead9a9

Please sign in to comment.