WIP: AE_DISABLE_CUCKOO env var support #36

Draft
uwiger wants to merge 3 commits from GH-2959-running-on-termux into master
2 changed files with 38 additions and 0 deletions
Showing only changes of commit 495fcb30d6 - Show all commits

20
rebar.config.script Normal file
View File

@ -0,0 +1,20 @@
%% -*- mode:erlang; erlang-indent-level:4; indent-tabs-mode:nil -*-
io:fwrite("Running ~p~n", [SCRIPT]).
case os:getenv("AE_DISABLE_CUCKOO") =/= false of
true ->
RemoveApps = [aecuckoo, aecuckooprebuilt],
RemovePlugins = [rebar_aecuckooprebuilt_dep],
{_, Deps} = lists:keyfind(deps, 1, CONFIG),
NewDeps = [D || D <- Deps,
not lists:member(element(1,D), RemoveApps)],
Plugins = proplists:get_value(plugins, CONFIG, []),
CONFIG1 = lists:keyreplace(deps, 1, CONFIG, {deps, NewDeps}),
Plugins1 = [P || P <- Plugins,
not lists:member(element(1,P), RemovePlugins)],
CONFIG2 = lists:keystore(plugins, 1, CONFIG1, {plugins, Plugins1}),
io:fwrite("CONFIG2 = ~p~n", [CONFIG2]),
CONFIG2;
false ->
io:fwrite("Using cuckoo~n", []),
CONFIG
end.

View File

@ -0,0 +1,18 @@
%% -*- mode:erlang; erlang-indent-level:4; indent-tabs-mode:nil -*-
RemoveApps = [aecuckoo, aecuckooprebuilt].
Base = filename:basename(SCRIPT, ".script").
Dir = filename:dirname(SCRIPT).
{ok, [{application,_,Opts} = App]} = file:consult(filename:join(Dir, Base)).
case os:getenv("AE_DISABLE_CUCKOO") =/= false of
true ->
{_, Apps} = lists:keyfind(applications, 1, Opts),
Env = proplists:get_value(env, Opts, []),
Env1 = lists:keystore(use_cuckoo, 1, Env, {use_cuckoo, false}),
Apps1 = Apps -- RemoveApps,
Opts1 = lists:keyreplace(applications, 1, Opts, {applications, Apps1}),
Opts2 = lists:keystore(env, 1, Opts1, {env, Env1}),
setelement(3, App, Opts2);
false ->
App
end.