Make it compile correctly on rebar3
This commit is contained in:
@@ -1,35 +1,118 @@
|
|||||||
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
|
%%%----------------------------------------------------------------------
|
||||||
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
|
%%% File : rebar.config.script
|
||||||
{value, {_, V1}, V2} -> {V1, V2};
|
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
|
%%% Purpose : Rebar build script. Compliant with rebar and rebar3.
|
||||||
end,
|
%%% Created : 8 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
case Tail of
|
%%%
|
||||||
[] ->
|
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
|
||||||
[{Key, Op(OldVal)} | PartCfg];
|
%%%
|
||||||
_ ->
|
%%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
|
%%% you may not use this file except in compliance with the License.
|
||||||
end
|
%%% You may obtain a copy of the License at
|
||||||
end,
|
%%%
|
||||||
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end.
|
%%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%%
|
||||||
|
%%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%%% See the License for the specific language governing permissions and
|
||||||
|
%%% limitations under the License.
|
||||||
|
%%%
|
||||||
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%% Rebar3 support for hex.pm support:
|
|
||||||
%% - Add rebar3_hex plugin
|
|
||||||
IsRebar3 = case application:get_key(rebar, vsn) of
|
IsRebar3 = case application:get_key(rebar, vsn) of
|
||||||
{ok, VSN} ->
|
{ok, VSN} ->
|
||||||
[VSN1 | _] = string:tokens(VSN, "-"),
|
[VSN1 | _] = string:tokens(VSN, "-"),
|
||||||
[Maj, Min, Patch] = string:tokens(VSN1, "."),
|
[Maj, Min, Patch] = string:tokens(VSN1, "."),
|
||||||
(list_to_integer(Maj) >= 3);
|
(list_to_integer(Maj) >= 3);
|
||||||
undefined ->
|
undefined ->
|
||||||
lists:keymember(mix, 1, application:loaded_applications())
|
lists:keymember(mix, 1, application:loaded_applications())
|
||||||
end,
|
end,
|
||||||
Cfg = case IsRebar3 of
|
|
||||||
true ->
|
|
||||||
ModCfg(CONFIG, [plugins], fun(V) -> V ++ [rebar3_hex] end, []);
|
|
||||||
false ->
|
|
||||||
CONFIG
|
|
||||||
end,
|
|
||||||
|
|
||||||
Cfg.
|
JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end,
|
||||||
|
|
||||||
|
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
|
||||||
|
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
|
||||||
|
{value, {_, V1}, V2} -> {V1, V2};
|
||||||
|
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
|
||||||
|
end,
|
||||||
|
case Tail of
|
||||||
|
[] ->
|
||||||
|
[{Key, Op(OldVal)} | PartCfg];
|
||||||
|
_ ->
|
||||||
|
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op,
|
||||||
|
Default) end,
|
||||||
|
|
||||||
|
ModCfgS = fun(Cfg, Keys, Val) -> ModCfg0(ModCfg0, Cfg, Keys, fun(_V) ->
|
||||||
|
Val end, "") end,
|
||||||
|
|
||||||
|
|
||||||
|
FilterConfig = fun(F, Cfg, [{Path, true, ModFun, Default} | Tail]) ->
|
||||||
|
F(F, ModCfg0(ModCfg0, Cfg, Path, ModFun, Default), Tail);
|
||||||
|
(F, Cfg, [_ | Tail]) ->
|
||||||
|
F(F, Cfg, Tail);
|
||||||
|
(F, Cfg, []) ->
|
||||||
|
Cfg
|
||||||
|
end,
|
||||||
|
|
||||||
|
AppendStr = fun(Append) ->
|
||||||
|
fun("") ->
|
||||||
|
Append;
|
||||||
|
(Val) ->
|
||||||
|
Val ++ " " ++ Append
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
AppendList = fun(Append) ->
|
||||||
|
fun(Val) ->
|
||||||
|
Val ++ Append
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
Rebar3DepsFilter = fun(DepsList) ->
|
||||||
|
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
|
||||||
|
{DepName, Version};
|
||||||
|
(Dep) ->
|
||||||
|
Dep
|
||||||
|
end, DepsList)
|
||||||
|
end,
|
||||||
|
|
||||||
|
GlobalDepsFilter = fun(Deps) ->
|
||||||
|
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
|
||||||
|
({DepName, _}) -> DepName
|
||||||
|
end, Deps),
|
||||||
|
lists:filtermap(fun(Dep) ->
|
||||||
|
case code:lib_dir(Dep) of
|
||||||
|
{error, _} ->
|
||||||
|
{true,"Unable to locate dep '"++atom_to_list(Dep)++"' in system deps."};
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end, DepNames)
|
||||||
|
end,
|
||||||
|
|
||||||
|
Rules = [
|
||||||
|
{[deps], IsRebar3,
|
||||||
|
Rebar3DepsFilter, []},
|
||||||
|
{[plugins], IsRebar3,
|
||||||
|
AppendList([rebar3_hex, pc]), []},
|
||||||
|
{[provider_hooks], IsRebar3,
|
||||||
|
AppendList([{pre, [
|
||||||
|
{compile, {pc, compile}},
|
||||||
|
{clean, {pc, clean}}
|
||||||
|
]}]), []},
|
||||||
|
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
|
||||||
|
GlobalDepsFilter, []}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
Config = FilterConfig(FilterConfig, CONFIG, Rules),
|
||||||
|
|
||||||
|
%io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]),
|
||||||
|
|
||||||
|
Config.
|
||||||
|
|
||||||
%% Local Variables:
|
%% Local Variables:
|
||||||
%% mode: erlang
|
%% mode: erlang
|
||||||
|
|||||||
Reference in New Issue
Block a user