Skip to content

Commit 8ead9a9

Browse files
Use port_compiler to build nif
1 parent 7869753 commit 8ead9a9

File tree

2 files changed

+36
-90
lines changed

2 files changed

+36
-90
lines changed

c_src/Makefile

Lines changed: 0 additions & 80 deletions
This file was deleted.

rebar.config

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
1-
{erl_opts, [debug_info]}.
1+
{erl_opts, [debug_info,
2+
{platform_define, "^(R14|R15|R16B|17)", 'random_module_available'},
3+
{if_version_below, "23", {d, 'INCLUDE_ERL_INTERFACE'}}
4+
]}.
25
{deps, [{prometheus, "~> 4.0"}]}.
36

4-
{pre_hooks,
5-
[{"linux|darwin", compile, "make -C c_src"},
6-
{"freebsd", compile, "gmake -C c_src"}]}.
7-
{post_hooks,
8-
[{"linux|darwin", clean, "make -C c_src clean"},
9-
{"freebsd", clean, "gmake -C c_src clean"}]}.
10-
11-
{plugins, [{rebar3_archive_plugin, "0.0.2"},
12-
rebar3_hex]}.
7+
{plugins, [
8+
{pc, {git, "https://github.com/blt/port_compiler.git", {branch, "master"}}}
9+
]}.
10+
{port_specs, [
11+
{".*-apple-darwin.*", "priv/prometheus_process_collector.so",
12+
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_macos.cc"]
13+
},
14+
{".*-linux", "priv/prometheus_process_collector.so",
15+
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_linux.cc"]
16+
},
17+
{".*-freebsd.*", "priv/prometheus_process_collector.so",
18+
["c_src/prometheus_process_collector_nif.cc", "c_src/prometheus_process_info_freebsd.cc"]
19+
}
20+
]}.
21+
{port_env, [
22+
{"CXXFLAGS", "-std=c++11 -Wall -O3 -arch x86_64 -finline-functions"},
23+
{".*-linux", "CXX", "g++"},
24+
{".*-apple-darwin.*", "CXX", "c++"},
25+
{".*-freebsd.*", "CXX", "c++"}
26+
]}.
27+
{so_name, "prometheus_process_collector.so"}.
28+
{artifacts, ["priv/prometheus_process_collector.so"]}.
29+
{provider_hooks, [
30+
{pre, [
31+
{compile,
32+
{pc, compile}
33+
},
34+
{clean,
35+
{pc, clean}
36+
}
37+
]}
38+
]}.

0 commit comments

Comments
 (0)