mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Merge pull request #292 from matwey/namespaced_types
Namespaced types: fix build for 17.0
This commit is contained in:
commit
908028858f
5 changed files with 45 additions and 8 deletions
|
@ -7,4 +7,5 @@ otp_release:
|
||||||
- R15B
|
- R15B
|
||||||
- R14B04
|
- R14B04
|
||||||
- R14B03
|
- R14B03
|
||||||
|
- 17.0
|
||||||
script: "make travis"
|
script: "make travis"
|
||||||
|
|
16
bootstrap
16
bootstrap
|
@ -28,10 +28,20 @@ main(Args) ->
|
||||||
%% Extract the system info of the version of OTP we use to compile rebar
|
%% Extract the system info of the version of OTP we use to compile rebar
|
||||||
OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n),
|
OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n),
|
||||||
|
|
||||||
|
%% 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.
|
||||||
|
NamespacedTypes = case is_otp(OtpInfo, "^[0-9]+") of
|
||||||
|
true -> {d, namespaced_types};
|
||||||
|
false -> undefined
|
||||||
|
end,
|
||||||
|
|
||||||
%% Compile all src/*.erl to ebin
|
%% Compile all src/*.erl to ebin
|
||||||
case make:files(filelib:wildcard("src/*.erl"),
|
case make:files(filelib:wildcard("src/*.erl"),
|
||||||
[{outdir, "ebin"}, {i, "include"},
|
[{outdir, "ebin"}, {i, "include"},
|
||||||
DebugFlag,
|
DebugFlag,
|
||||||
|
NamespacedTypes,
|
||||||
{d, 'BUILD_TIME', Built},
|
{d, 'BUILD_TIME', Built},
|
||||||
{d, 'VCS_INFO', VcsInfo},
|
{d, 'VCS_INFO', VcsInfo},
|
||||||
{d, 'OTP_INFO', OtpInfo}]) of
|
{d, 'OTP_INFO', OtpInfo}]) of
|
||||||
|
@ -79,6 +89,12 @@ main(Args) ->
|
||||||
"Place this script anywhere in your path\n"
|
"Place this script anywhere in your path\n"
|
||||||
"and you can use rebar to build OTP-compliant apps.\n").
|
"and you can use rebar to build OTP-compliant apps.\n").
|
||||||
|
|
||||||
|
is_otp(OtpInfo, Regex) ->
|
||||||
|
case re:run(OtpInfo, Regex, [{capture, none}]) of
|
||||||
|
match -> true;
|
||||||
|
nomatch -> false
|
||||||
|
end.
|
||||||
|
|
||||||
rm(Path) ->
|
rm(Path) ->
|
||||||
NativePath = filename:nativename(Path),
|
NativePath = filename:nativename(Path),
|
||||||
Cmd = case os:type() of
|
Cmd = case os:type() of
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
%% escript_incl_extra is for internal rebar-private use only.
|
%% escript_incl_extra is for internal rebar-private use only.
|
||||||
%% Do not use outside rebar. Config interface is not stable.
|
%% Do not use outside rebar. Config interface is not stable.
|
||||||
{escript_incl_extra, [{"priv/templates/*", "."}]}.
|
{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_checks, []}.
|
||||||
{xref_queries,
|
{xref_queries,
|
||||||
[{"(XC - UC) || (XU - X - B
|
[{"(XC - UC) || (XU - X - B
|
||||||
|
|
|
@ -39,13 +39,21 @@
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-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(),
|
-record(config, { dir :: file:filename(),
|
||||||
opts = [] :: list(),
|
opts = [] :: list(),
|
||||||
globals = new_globals() :: dict(),
|
globals = new_globals() :: rebar_dict(),
|
||||||
envs = new_env() :: dict(),
|
envs = new_env() :: rebar_dict(),
|
||||||
%% cross-directory/-command config
|
%% cross-directory/-command config
|
||||||
skip_dirs = new_skip_dirs() :: dict(),
|
skip_dirs = new_skip_dirs() :: rebar_dict(),
|
||||||
xconf = new_xconf() :: dict() }).
|
xconf = new_xconf() :: rebar_dict() }).
|
||||||
|
|
||||||
-export_type([config/0]).
|
-export_type([config/0]).
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,14 @@
|
||||||
info = {[], []} :: erlc_info()
|
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
|
%% Public API
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
@ -522,19 +530,19 @@ expand_file_names(Files, Dirs) ->
|
||||||
end
|
end
|
||||||
end, Files).
|
end, Files).
|
||||||
|
|
||||||
-spec get_parents(digraph(), file:filename()) -> [file:filename()].
|
-spec get_parents(rebar_digraph(), file:filename()) -> [file:filename()].
|
||||||
get_parents(G, Source) ->
|
get_parents(G, Source) ->
|
||||||
%% Return all files which the Source depends upon.
|
%% Return all files which the Source depends upon.
|
||||||
digraph_utils:reachable_neighbours([Source], G).
|
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) ->
|
get_children(G, Source) ->
|
||||||
%% Return all files dependent on the Source.
|
%% Return all files dependent on the Source.
|
||||||
digraph_utils:reaching_neighbours([Source], G).
|
digraph_utils:reaching_neighbours([Source], G).
|
||||||
|
|
||||||
-spec internal_erl_compile(rebar_config:config(), file:filename(),
|
-spec internal_erl_compile(rebar_config:config(), file:filename(),
|
||||||
file:filename(), list(),
|
file:filename(), list(),
|
||||||
digraph()) -> 'ok' | 'skipped'.
|
rebar_digraph()) -> 'ok' | 'skipped'.
|
||||||
internal_erl_compile(Config, Source, OutDir, ErlOpts, G) ->
|
internal_erl_compile(Config, Source, OutDir, ErlOpts, G) ->
|
||||||
%% Determine the target name and includes list by inspecting the source file
|
%% Determine the target name and includes list by inspecting the source file
|
||||||
Module = filename:basename(Source, ".erl"),
|
Module = filename:basename(Source, ".erl"),
|
||||||
|
|
Loading…
Reference in a new issue