From a7e05f57d1134243cb4506f1cf9581b29af62da8 Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Sat, 31 May 2014 16:45:44 +0400 Subject: [PATCH] Fix build for 17.0 using the solutiong proposed by @tsloughter We use namespaced_types option to choose between dict() and dict:dict() types. --- rebar.config | 6 +++++- src/rebar_config.erl | 16 ++++++++++++---- src/rebar_erlc_compiler.erl | 14 +++++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/rebar.config b/rebar.config index 9028737..bf4ef4f 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,11 @@ %% escript_incl_extra is for internal rebar-private use only. %% Do not use outside rebar. Config interface is not stable. {escript_incl_extra, [{"priv/templates/*", "."}]}. -{erl_opts, [warnings_as_errors]}. +%% Types dict:dict() and digraph:digraph() have been introduced in Erlang 17. +%% At the same time, their counterparts dict() and digraph() are to be deprecated +%% in Erlang 18. namespaced_types option is used to select proper type name +%% depending of the OTP version used. +{erl_opts, [{platform_define, "^[0-9]+", namespaced_types}, warnings_as_errors]}. {xref_checks, []}. {xref_queries, [{"(XC - UC) || (XU - X - B diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 10c6483..1c90d22 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -39,13 +39,21 @@ -include("rebar.hrl"). +-ifdef(namespaced_types). +% dict:dict() exists starting from Erlang 17. +-type rebar_dict() :: dict:dict(). +-else. +% dict() has been obsoleted in Erlang 17 and deprecated in 18. +-type rebar_dict() :: dict(). +-endif. + -record(config, { dir :: file:filename(), opts = [] :: list(), - globals = new_globals() :: dict(), - envs = new_env() :: dict(), + globals = new_globals() :: rebar_dict(), + envs = new_env() :: rebar_dict(), %% cross-directory/-command config - skip_dirs = new_skip_dirs() :: dict(), - xconf = new_xconf() :: dict() }). + skip_dirs = new_skip_dirs() :: rebar_dict(), + xconf = new_xconf() :: rebar_dict() }). -export_type([config/0]). diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index f7753c7..5f541d9 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -47,6 +47,14 @@ info = {[], []} :: erlc_info() }). +-ifdef(namespaced_types). +% digraph:digraph() exists starting from Erlang 17. +-type rebar_digraph() :: digraph:digraph(). +-else. +% digraph() has been obsoleted in Erlang 17 and deprecated in 18. +-type rebar_digraph() :: digraph(). +-endif. + %% =================================================================== %% Public API %% =================================================================== @@ -522,19 +530,19 @@ expand_file_names(Files, Dirs) -> end end, Files). --spec get_parents(digraph(), file:filename()) -> [file:filename()]. +-spec get_parents(rebar_digraph(), file:filename()) -> [file:filename()]. get_parents(G, Source) -> %% Return all files which the Source depends upon. digraph_utils:reachable_neighbours([Source], G). --spec get_children(digraph(), file:filename()) -> [file:filename()]. +-spec get_children(rebar_digraph(), file:filename()) -> [file:filename()]. get_children(G, Source) -> %% Return all files dependent on the Source. digraph_utils:reaching_neighbours([Source], G). -spec internal_erl_compile(rebar_config:config(), file:filename(), file:filename(), list(), - digraph()) -> 'ok' | 'skipped'. + rebar_digraph()) -> 'ok' | 'skipped'. internal_erl_compile(Config, Source, OutDir, ErlOpts, G) -> %% Determine the target name and includes list by inspecting the source file Module = filename:basename(Source, ".erl"),