Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add otp_release to erl_opts option for platform-specific defines #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rebar.config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
{erl_opts, [{i, "myinclude"}, {src_dirs, ["src1", "src2"]},
{platform_define,
"(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
{platform_define, "(linux|freebsd)", 'BACKLOG', 128}]}.
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
{platform_define, "R13", 'old_inets'}]}.

%% MIB Options?
{mib_opts, []}.
Expand Down
25 changes: 19 additions & 6 deletions src/rebar_erlc_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,29 @@
%%
%% * erl_opts - Erlang list of options passed to compile:file/2
%% It is also possible to specify platform specific
%% options by specifying a triplet where the first string
%% is a regex that is checked against Erlang's system
%% architecture string. E.g. to define HAVE_SENDFILE only
%% on systems with sendfile() and define BACKLOG on
%% Linux/FreeBSD as 128 do:
%% options by specifying a pair or a triplet where the
%% first string is a regex that is checked against the
%% string
%%
%% OtpRelease ++ "-" ++ SysArch ++ "-" ++ Words.
%%
%% where
%%
%% OtpRelease = erlang:system_info(otp_release).
%% SysArch = erlang:system_info(system_architecture).
%% Words = integer_to_list(8 * erlang:system_info(wordsize)).
%%
%% E.g. to define HAVE_SENDFILE only on systems with
%% sendfile(), to define BACKLOG on Linux/FreeBSD as 128,
%% and to define 'old_inets' for R13 OTP release do:
%%
%% {erl_opts, [{platform_define,
%% "(linux|solaris|freebsd|darwin)",
%% 'HAVE_SENDFILE'},
%% {platform_define, "(linux|freebsd)",
%% 'BACKLOG', 128}]}.
%% 'BACKLOG', 128},
%% {platform_define, "R13",
%% 'old_inets'}]}.
%%

-spec compile(Config::#config{}, AppFile::string()) -> 'ok'.
Expand Down
1 change: 1 addition & 0 deletions src/rebar_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ is_arch(ArchRegex) ->

get_arch() ->
Words = integer_to_list(8 * erlang:system_info(wordsize)),
erlang:system_info(otp_release) ++ "-" ++
erlang:system_info(system_architecture) ++ "-" ++ Words.

%%
Expand Down