Skip to content

Commit

Permalink
Improve to build on older OSX and run tests thru rebar3
Browse files Browse the repository at this point in the history
  • Loading branch information
codeadict committed Feb 22, 2023
1 parent 63d7469 commit c2a8e14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ jobs:
with:
otp-version: ${{ matrix.otp }}
- name: Compile
run: make
- name: Run tests
run: make check
- name: rebar3 compile
run: ./rebar3 compile
- name: Run xref and dialyzer
run: ./rebar3 do xref, dialyzer
- name: Run eunit
- name: Run tests
run: ./rebar3 as gha do eunit
51 changes: 28 additions & 23 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
%%-*- mode: erlang -*-

AddPortEnv = fun(Config, Flags, NewValue) ->
{port_env, Vals} = lists:keyfind(port_env, 1, Config),
Fold = fun({Flag, Val}, Acc) ->
case lists:member(Flag, Flags) of
true ->
[{Flag, Val ++ NewValue} | Acc];
false ->
Acc
end
end,
NewVals = lists:foldl(Fold, [], Vals),
lists:keyreplace(port_env, 1, Config, {port_env, NewVals})
end.

%% Set the minimum Mac target to 10.8 for 10.9 or greater. This runtime
%% check is needed since rebar's system_architecture check looks only at
%% the version of the OS used to build the Erlang runtime, not the version
%% actually running.
case os:type() of
{unix,darwin} ->
DefaultOpt = " -mmacosx-version-min=10.8 -stdlib=libc++",
Opt = case os:find_executable("brew") of
false ->
DefaultOpt;
_Brew ->
HomebrewPrefix = string:trim(os:cmd("brew --prefix")),
DefaultOpt ++ " -L" ++ HomebrewPrefix ++ "/lib"
end,
[Mjr|_] = string:tokens(os:cmd("/usr/bin/uname -r"), "."),
{unix, darwin} ->
NewerOsxOpts = " -mmacosx-version-min=10.8 -stdlib=libc++",
BrewLibsOpts =
case os:find_executable("brew") of
false ->
"";
_Brew ->
HomebrewPrefix = string:trim(os:cmd("brew --prefix")),
" -L" ++ HomebrewPrefix ++ "/lib"
end,
[Mjr | _] = string:tokens(os:cmd("/usr/bin/uname -r"), "."),
Major = list_to_integer(Mjr),
Flags = ["CFLAGS", "CXXFLAGS", "LDFLAGS"],
if
Major >= 13 ->
Flags = ["CFLAGS", "CXXFLAGS", "LDFLAGS"],
{port_env, Vals} = lists:keyfind(port_env, 1, CONFIG),
Fold = fun({Flag,Val}, Acc) ->
case lists:member(Flag, Flags) of
true ->
[{Flag, Val++Opt}|Acc];
false ->
Acc
end
end,
NewVals = lists:foldl(Fold, [], Vals),
lists:keyreplace(port_env, 1, CONFIG, {port_env, NewVals});
AddPortEnv(CONFIG, Flags, NewerOsxOpts ++ BrewLibsOpts);
true ->
CONFIG
AddPortEnv(CONFIG, Flags, BrewLibsOpts)
end;
_ ->
CONFIG
Expand Down

0 comments on commit c2a8e14

Please sign in to comment.