I have a Rebar-based Erlang application that builds a port program. This port program is Linux-specific, so compilation fails on Mac OS. However, I’d like Rebar to just skip the port program when building on Mac OS. How can I do that?
The current spec in rebar.config looks like this:
{port_specs, [{"priv/my_port", ["c_src/foo.c", "c_src/bar.c"]}]}.
As documented in comments in rebar_port_compiler.erl, the list elements for
port_specshave an alternative form{ArchRegex, TargetFile, Sources}. So write your Rebar configuration like this:“What is that regex matched against?”, you might ask. It is matched against the return value of rebar_utils:get_arch, which consists of the following parts, separated by hyphens:
erlang:system_info(otp_release), e.g."R15B02"erlang:system_info(system_architecture). For Unix-like systems, this is the CPU-vendor-OS triplet determined by the configure script, e.g."i386-apple-darwin10.8.0"or"x86_64-unknown-linux-gnu".erlang:system_info({wordsize, external}).unixorwin32. (The first element of the tuple returned byos:type/0)So the end result will be something like
"R15B01-i386-apple-darwin10.8.0-32-unix"or"R15B02-x86_64-unknown-linux-gnu-64-unix".