From 495fcb30d65cfc1d69c079dcb45e042cc7e25f5f Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Thu, 31 Oct 2019 12:49:32 +0100 Subject: [PATCH] WIP: AE_DISABLE_CUCKOO env var support revert rebar.lock to original --- rebar.config.script | 20 ++++++++++++++++++++ src/aeminer.app.src.script | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 rebar.config.script create mode 100644 src/aeminer.app.src.script diff --git a/rebar.config.script b/rebar.config.script new file mode 100644 index 0000000..87c02e4 --- /dev/null +++ b/rebar.config.script @@ -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. diff --git a/src/aeminer.app.src.script b/src/aeminer.app.src.script new file mode 100644 index 0000000..a4b3ce7 --- /dev/null +++ b/src/aeminer.app.src.script @@ -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.