Browse Source

Merge pull request #1598 from ferd/unicode-bonanza

Unicode support in all the places
pull/1601/head
Fred Hebert 7 years ago
committed by GitHub
parent
commit
c4b34e1abc
51 changed files with 443 additions and 423 deletions
  1. +3
    -3
      priv/templates/Makefile
  2. +5
    -5
      src/rebar3.erl
  3. +1
    -1
      src/rebar_agent.erl
  4. +3
    -3
      src/rebar_app_discover.erl
  5. +27
    -27
      src/rebar_app_info.erl
  6. +13
    -11
      src/rebar_app_utils.erl
  7. +8
    -8
      src/rebar_base_compiler.erl
  8. +4
    -4
      src/rebar_config.erl
  9. +5
    -5
      src/rebar_core.erl
  10. +89
    -89
      src/rebar_dialyzer_format.erl
  11. +2
    -2
      src/rebar_digraph.erl
  12. +2
    -2
      src/rebar_dir.erl
  13. +5
    -5
      src/rebar_erlc_compiler.erl
  14. +10
    -10
      src/rebar_fetch.erl
  15. +26
    -19
      src/rebar_file_utils.erl
  16. +23
    -24
      src/rebar_git_resource.erl
  17. +12
    -11
      src/rebar_hg_resource.erl
  18. +3
    -3
      src/rebar_hooks.erl
  19. +1
    -1
      src/rebar_log.erl
  20. +4
    -4
      src/rebar_otp_app.erl
  21. +6
    -6
      src/rebar_packages.erl
  22. +9
    -9
      src/rebar_pkg_resource.erl
  23. +6
    -6
      src/rebar_prv_app_discovery.erl
  24. +3
    -3
      src/rebar_prv_as.erl
  25. +1
    -1
      src/rebar_prv_clean.erl
  26. +1
    -1
      src/rebar_prv_common_test.erl
  27. +4
    -4
      src/rebar_prv_compile.erl
  28. +2
    -2
      src/rebar_prv_cover.erl
  29. +10
    -10
      src/rebar_prv_deps.erl
  30. +2
    -2
      src/rebar_prv_deps_tree.erl
  31. +8
    -8
      src/rebar_prv_dialyzer.erl
  32. +3
    -3
      src/rebar_prv_edoc.erl
  33. +7
    -7
      src/rebar_prv_escriptize.erl
  34. +13
    -13
      src/rebar_prv_install_deps.erl
  35. +4
    -4
      src/rebar_prv_local_install.erl
  36. +10
    -10
      src/rebar_prv_new.erl
  37. +3
    -3
      src/rebar_prv_packages.erl
  38. +8
    -8
      src/rebar_prv_path.erl
  39. +5
    -5
      src/rebar_prv_plugins.erl
  40. +1
    -1
      src/rebar_prv_plugins_upgrade.erl
  41. +7
    -7
      src/rebar_prv_report.erl
  42. +2
    -2
      src/rebar_prv_unlock.erl
  43. +5
    -5
      src/rebar_prv_update.erl
  44. +6
    -6
      src/rebar_prv_upgrade.erl
  45. +12
    -12
      src/rebar_prv_xref.erl
  46. +3
    -3
      src/rebar_state.erl
  47. +9
    -9
      src/rebar_templater.erl
  48. +40
    -29
      src/rebar_utils.erl
  49. +1
    -1
      test/rebar_as_SUITE.erl
  50. +2
    -2
      test/rebar_ct_SUITE.erl
  51. +4
    -4
      test/rebar_test_utils.erl

+ 3
- 3
priv/templates/Makefile View File

@ -6,9 +6,9 @@ BASEDIR := $(abspath $(CURDIR)/..)
PROJECT ?= $(notdir $(BASEDIR)) PROJECT ?= $(notdir $(BASEDIR))
PROJECT := $(strip $(PROJECT)) PROJECT := $(strip $(PROJECT))
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).")
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).")
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)]).")
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, include)]).")
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, lib)]).")
C_SRC_DIR = $(CURDIR) C_SRC_DIR = $(CURDIR)
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so

+ 5
- 5
src/rebar3.erl View File

@ -183,11 +183,11 @@ init_config() ->
GlobalConfigFile = rebar_dir:global_config(), GlobalConfigFile = rebar_dir:global_config(),
State = case filelib:is_regular(GlobalConfigFile) of State = case filelib:is_regular(GlobalConfigFile) of
true -> true ->
?DEBUG("Load global config file ~s", [GlobalConfigFile]),
?DEBUG("Load global config file ~ts", [GlobalConfigFile]),
try state_from_global_config(Config1, GlobalConfigFile) try state_from_global_config(Config1, GlobalConfigFile)
catch catch
_:_ -> _:_ ->
?WARN("Global config ~s exists but can not be read. Ignoring global config values.", [GlobalConfigFile]),
?WARN("Global config ~ts exists but can not be read. Ignoring global config values.", [GlobalConfigFile]),
rebar_state:new(Config1) rebar_state:new(Config1)
end; end;
false -> false ->
@ -270,7 +270,7 @@ log_level() ->
-spec version() -> ok. -spec version() -> ok.
version() -> version() ->
{ok, Vsn} = application:get_key(rebar, vsn), {ok, Vsn} = application:get_key(rebar, vsn),
?CONSOLE("rebar ~s on Erlang/OTP ~s Erts ~s",
?CONSOLE("rebar ~ts on Erlang/OTP ~ts Erts ~ts",
[Vsn, erlang:system_info(otp_release), erlang:system_info(version)]). [Vsn, erlang:system_info(otp_release), erlang:system_info(version)]).
%% @private set global flag based on getopt option boolean value %% @private set global flag based on getopt option boolean value
@ -311,11 +311,11 @@ handle_error({error, {Module, Reason}}) ->
?DEBUG("Uncaught error: ~p ~p", [Module, Reason]), ?DEBUG("Uncaught error: ~p ~p", [Module, Reason]),
?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []); ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []);
_ -> _ ->
?ERROR(" ~s", [Module:format_error(Reason)])
?ERROR("~ts", [Module:format_error(Reason)])
end, end,
erlang:halt(1); erlang:halt(1);
handle_error({error, Error}) when is_list(Error) -> handle_error({error, Error}) when is_list(Error) ->
?ERROR(" ~s", [Error]),
?ERROR("~ts", [Error]),
erlang:halt(1); erlang:halt(1);
handle_error(Error) -> handle_error(Error) ->
%% Nothing should percolate up from rebar_core; %% Nothing should percolate up from rebar_core;

+ 1
- 1
src/rebar_agent.erl View File

@ -157,7 +157,7 @@ refresh_paths(RState) ->
{ok, Mods} -> {ok, Mods} ->
case {length(Mods), length(Mods -- Blacklist)} of case {length(Mods), length(Mods -- Blacklist)} of
{X,X} -> {X,X} ->
?DEBUG("reloading ~p from ~s", [Modules, Path]),
?DEBUG("reloading ~p from ~ts", [Modules, Path]),
code:replace_path(App, Path), code:replace_path(App, Path),
reload_modules(Modules); reload_modules(Modules);
{_,_} -> {_,_} ->

+ 3
- 3
src/rebar_app_discover.erl View File

@ -60,7 +60,7 @@ do(State, LibDirs) ->
rebar_state:project_apps(StateAcc1 rebar_state:project_apps(StateAcc1
,rebar_app_info:deps(AppInfo2, ProjectDeps1)); ,rebar_app_info:deps(AppInfo2, ProjectDeps1));
false -> false ->
?INFO("Ignoring ~s", [Name]),
?INFO("Ignoring ~ts", [Name]),
StateAcc StateAcc
end end
end, State1, SortedApps). end, State1, SortedApps).
@ -233,7 +233,7 @@ app_dirs(LibDir, SrcDirs) ->
EbinPath = filename:join([LibDir, "ebin", "*.app"]), EbinPath = filename:join([LibDir, "ebin", "*.app"]),
lists:usort(lists:foldl(fun(Path, Acc) -> lists:usort(lists:foldl(fun(Path, Acc) ->
Files = filelib:wildcard(ec_cnv:to_list(Path)),
Files = filelib:wildcard(rebar_utils:to_list(Path)),
[{app_dir(File), SrcDirs} [{app_dir(File), SrcDirs}
|| File <- Files] ++ Acc || File <- Files] ++ Acc
end, [], [EbinPath | Paths])). end, [], [EbinPath | Paths])).
@ -386,7 +386,7 @@ try_handle_app_file(AppInfo0, [File], AppDir, AppSrcFile, _, Validate) ->
end end
catch catch
throw:{error, {Module, Reason}} -> throw:{error, {Module, Reason}} ->
?DEBUG("Falling back to app.src file because .app failed: ~s", [Module:format_error(Reason)]),
?DEBUG("Falling back to app.src file because .app failed: ~ts", [Module:format_error(Reason)]),
try_handle_app_src_file(AppInfo0, File, AppDir, AppSrcFile, Validate) try_handle_app_src_file(AppInfo0, File, AppDir, AppSrcFile, Validate)
end; end;
try_handle_app_file(_AppInfo, Other, _AppDir, _AppSrcFile, _, _Validate) -> try_handle_app_file(_AppInfo, Other, _AppDir, _AppSrcFile, _, _Validate) ->

+ 27
- 27
src/rebar_app_info.erl View File

@ -107,43 +107,43 @@ new() ->
-spec new(atom() | binary() | string()) -> -spec new(atom() | binary() | string()) ->
{ok, t()}. {ok, t()}.
new(AppName) -> new(AppName) ->
{ok, #app_info_t{name=ec_cnv:to_binary(AppName)}}.
{ok, #app_info_t{name=rebar_utils:to_binary(AppName)}}.
%% @doc Build a new app info value with only the name and version set. %% @doc Build a new app info value with only the name and version set.
-spec new(atom() | binary() | string(), binary() | string()) -> -spec new(atom() | binary() | string(), binary() | string()) ->
{ok, t()}. {ok, t()}.
new(AppName, Vsn) -> new(AppName, Vsn) ->
{ok, #app_info_t{name=ec_cnv:to_binary(AppName),
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
original_vsn=Vsn}}. original_vsn=Vsn}}.
%% @doc build a complete version of the app info with all fields set. %% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary() | string(), binary() | string(), file:name()) -> -spec new(atom() | binary() | string(), binary() | string(), file:name()) ->
{ok, t()}. {ok, t()}.
new(AppName, Vsn, Dir) -> new(AppName, Vsn, Dir) ->
{ok, #app_info_t{name=ec_cnv:to_binary(AppName),
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
original_vsn=Vsn, original_vsn=Vsn,
dir=ec_cnv:to_list(Dir),
out_dir=ec_cnv:to_list(Dir)}}.
dir=rebar_utils:to_list(Dir),
out_dir=rebar_utils:to_list(Dir)}}.
%% @doc build a complete version of the app info with all fields set. %% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary() | string(), binary() | string(), file:name(), list()) -> -spec new(atom() | binary() | string(), binary() | string(), file:name(), list()) ->
{ok, t()}. {ok, t()}.
new(AppName, Vsn, Dir, Deps) -> new(AppName, Vsn, Dir, Deps) ->
{ok, #app_info_t{name=ec_cnv:to_binary(AppName),
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
original_vsn=Vsn, original_vsn=Vsn,
dir=ec_cnv:to_list(Dir),
out_dir=ec_cnv:to_list(Dir),
dir=rebar_utils:to_list(Dir),
out_dir=rebar_utils:to_list(Dir),
deps=Deps}}. deps=Deps}}.
%% @doc build a complete version of the app info with all fields set. %% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary(), atom() | binary() | string(), binary() | string(), file:name(), list()) -> -spec new(atom() | binary(), atom() | binary() | string(), binary() | string(), file:name(), list()) ->
{ok, t()}. {ok, t()}.
new(Parent, AppName, Vsn, Dir, Deps) -> new(Parent, AppName, Vsn, Dir, Deps) ->
{ok, #app_info_t{name=ec_cnv:to_binary(AppName),
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
parent=Parent, parent=Parent,
original_vsn=Vsn, original_vsn=Vsn,
dir=ec_cnv:to_list(Dir),
out_dir=ec_cnv:to_list(Dir),
dir=rebar_utils:to_list(Dir),
out_dir=rebar_utils:to_list(Dir),
deps=Deps}}. deps=Deps}}.
%% @doc update the opts based on the contents of a config %% @doc update the opts based on the contents of a config
@ -199,7 +199,7 @@ name(#app_info_t{name=Name}) ->
%% @doc set the name of the app. %% @doc set the name of the app.
-spec name(t(), atom() | binary() | string()) -> t(). -spec name(t(), atom() | binary() | string()) -> t().
name(AppInfo=#app_info_t{}, AppName) -> name(AppInfo=#app_info_t{}, AppName) ->
AppInfo#app_info_t{name=ec_cnv:to_binary(AppName)}.
AppInfo#app_info_t{name=rebar_utils:to_binary(AppName)}.
%% @doc get the dictionary of options for the app. %% @doc get the dictionary of options for the app.
-spec opts(t()) -> rebar_dict(). -spec opts(t()) -> rebar_dict().
@ -249,14 +249,14 @@ set(AppInfo=#app_info_t{opts=Opts}, Key, Value) ->
%% @doc finds the .app.src file for an app, if any. %% @doc finds the .app.src file for an app, if any.
-spec app_file_src(t()) -> file:filename_all() | undefined. -spec app_file_src(t()) -> file:filename_all() | undefined.
app_file_src(#app_info_t{app_file_src=undefined, dir=Dir, name=Name, opts=Opts}) -> app_file_src(#app_info_t{app_file_src=undefined, dir=Dir, name=Name, opts=Opts}) ->
CandidatePaths = [filename:join([ec_cnv:to_list(Dir), Src, ec_cnv:to_list(Name)++".app.src"])
CandidatePaths = [filename:join([rebar_utils:to_list(Dir), Src, rebar_utils:to_list(Name)++".app.src"])
|| Src <- rebar_opts:get(Opts, src_dirs, ["src"])], || Src <- rebar_opts:get(Opts, src_dirs, ["src"])],
case lists:dropwhile(fun(Path) -> not filelib:is_file(Path) end, CandidatePaths) of case lists:dropwhile(fun(Path) -> not filelib:is_file(Path) end, CandidatePaths) of
[] -> undefined; [] -> undefined;
[AppFileSrc|_] -> AppFileSrc [AppFileSrc|_] -> AppFileSrc
end; end;
app_file_src(#app_info_t{app_file_src=AppFileSrc}) -> app_file_src(#app_info_t{app_file_src=AppFileSrc}) ->
ec_cnv:to_list(AppFileSrc).
rebar_utils:to_list(AppFileSrc).
%% @doc sets the .app.src file for an app. An app without such a file %% @doc sets the .app.src file for an app. An app without such a file
%% can explicitly be set with `undefined'. %% can explicitly be set with `undefined'.
@ -264,12 +264,12 @@ app_file_src(#app_info_t{app_file_src=AppFileSrc}) ->
app_file_src(AppInfo=#app_info_t{}, undefined) -> app_file_src(AppInfo=#app_info_t{}, undefined) ->
AppInfo#app_info_t{app_file_src=undefined}; AppInfo#app_info_t{app_file_src=undefined};
app_file_src(AppInfo=#app_info_t{}, AppFileSrc) -> app_file_src(AppInfo=#app_info_t{}, AppFileSrc) ->
AppInfo#app_info_t{app_file_src=ec_cnv:to_list(AppFileSrc)}.
AppInfo#app_info_t{app_file_src=rebar_utils:to_list(AppFileSrc)}.
%% @doc finds the .app.src.script file for an app, if any. %% @doc finds the .app.src.script file for an app, if any.
-spec app_file_src_script(t()) -> file:filename_all() | undefined. -spec app_file_src_script(t()) -> file:filename_all() | undefined.
app_file_src_script(#app_info_t{app_file_src_script=undefined, dir=Dir, name=Name}) -> app_file_src_script(#app_info_t{app_file_src_script=undefined, dir=Dir, name=Name}) ->
AppFileSrcScript = filename:join([ec_cnv:to_list(Dir), "src", ec_cnv:to_list(Name)++".app.src.script"]),
AppFileSrcScript = filename:join([rebar_utils:to_list(Dir), "src", rebar_utils:to_list(Name)++".app.src.script"]),
case filelib:is_file(AppFileSrcScript) of case filelib:is_file(AppFileSrcScript) of
true -> true ->
AppFileSrcScript; AppFileSrcScript;
@ -277,7 +277,7 @@ app_file_src_script(#app_info_t{app_file_src_script=undefined, dir=Dir, name=Nam
undefined undefined
end; end;
app_file_src_script(#app_info_t{app_file_src_script=AppFileSrcScript}) -> app_file_src_script(#app_info_t{app_file_src_script=AppFileSrcScript}) ->
ec_cnv:to_list(AppFileSrcScript).
rebar_utils:to_list(AppFileSrcScript).
%% @doc sets the .app.src.script file for an app. An app without such a file %% @doc sets the .app.src.script file for an app. An app without such a file
%% can explicitly be set with `undefined'. %% can explicitly be set with `undefined'.
@ -285,12 +285,12 @@ app_file_src_script(#app_info_t{app_file_src_script=AppFileSrcScript}) ->
app_file_src_script(AppInfo=#app_info_t{}, undefined) -> app_file_src_script(AppInfo=#app_info_t{}, undefined) ->
AppInfo#app_info_t{app_file_src_script=undefined}; AppInfo#app_info_t{app_file_src_script=undefined};
app_file_src_script(AppInfo=#app_info_t{}, AppFileSrcScript) -> app_file_src_script(AppInfo=#app_info_t{}, AppFileSrcScript) ->
AppInfo#app_info_t{app_file_src_script=ec_cnv:to_list(AppFileSrcScript)}.
AppInfo#app_info_t{app_file_src_script=rebar_utils:to_list(AppFileSrcScript)}.
%% @doc finds the .app file for an app, if any. %% @doc finds the .app file for an app, if any.
-spec app_file(t()) -> file:filename_all() | undefined. -spec app_file(t()) -> file:filename_all() | undefined.
app_file(#app_info_t{app_file=undefined, out_dir=Dir, name=Name}) -> app_file(#app_info_t{app_file=undefined, out_dir=Dir, name=Name}) ->
AppFile = filename:join([ec_cnv:to_list(Dir), "ebin", ec_cnv:to_list(Name)++".app"]),
AppFile = filename:join([rebar_utils:to_list(Dir), "ebin", rebar_utils:to_list(Name)++".app"]),
case filelib:is_file(AppFile) of case filelib:is_file(AppFile) of
true -> true ->
AppFile; AppFile;
@ -317,7 +317,7 @@ app_details(AppInfo=#app_info_t{app_details=[]}) ->
rebar_file_utils:try_consult(AppFile) rebar_file_utils:try_consult(AppFile)
catch catch
throw:{error, {Module, Reason}} -> throw:{error, {Module, Reason}} ->
?DEBUG("Warning, falling back to .app.src because of: ~s",
?DEBUG("Warning, falling back to .app.src because of: ~ts",
[Module:format_error(Reason)]), [Module:format_error(Reason)]),
rebar_file_utils:try_consult(app_file_src(AppInfo)) rebar_file_utils:try_consult(app_file_src(AppInfo))
end end
@ -404,10 +404,10 @@ dir(#app_info_t{dir=Dir}) ->
%% @doc sets the directory that contains the app. %% @doc sets the directory that contains the app.
-spec dir(t(), file:name()) -> t(). -spec dir(t(), file:name()) -> t().
dir(AppInfo=#app_info_t{out_dir=undefined}, Dir) -> dir(AppInfo=#app_info_t{out_dir=undefined}, Dir) ->
AppInfo#app_info_t{dir=ec_cnv:to_list(Dir),
out_dir=ec_cnv:to_list(Dir)};
AppInfo#app_info_t{dir=rebar_utils:to_list(Dir),
out_dir=rebar_utils:to_list(Dir)};
dir(AppInfo=#app_info_t{}, Dir) -> dir(AppInfo=#app_info_t{}, Dir) ->
AppInfo#app_info_t{dir=ec_cnv:to_list(Dir)}.
AppInfo#app_info_t{dir=rebar_utils:to_list(Dir)}.
%% @doc returns the directory where build artifacts for the app %% @doc returns the directory where build artifacts for the app
%% should go %% should go
@ -419,17 +419,17 @@ out_dir(#app_info_t{out_dir=OutDir}) ->
%% should go %% should go
-spec out_dir(t(), file:name()) -> t(). -spec out_dir(t(), file:name()) -> t().
out_dir(AppInfo=#app_info_t{}, OutDir) -> out_dir(AppInfo=#app_info_t{}, OutDir) ->
AppInfo#app_info_t{out_dir=ec_cnv:to_list(OutDir)}.
AppInfo#app_info_t{out_dir=rebar_utils:to_list(OutDir)}.
%% @doc gets the directory where ebin files for the app should go %% @doc gets the directory where ebin files for the app should go
-spec ebin_dir(t()) -> file:name(). -spec ebin_dir(t()) -> file:name().
ebin_dir(#app_info_t{out_dir=OutDir}) -> ebin_dir(#app_info_t{out_dir=OutDir}) ->
ec_cnv:to_list(filename:join(OutDir, "ebin")).
rebar_utils:to_list(filename:join(OutDir, "ebin")).
%% @doc gets the directory where private files for the app should go %% @doc gets the directory where private files for the app should go
-spec priv_dir(t()) -> file:name(). -spec priv_dir(t()) -> file:name().
priv_dir(#app_info_t{out_dir=OutDir}) -> priv_dir(#app_info_t{out_dir=OutDir}) ->
ec_cnv:to_list(filename:join(OutDir, "priv")).
rebar_utils:to_list(filename:join(OutDir, "priv")).
%% @doc returns whether the app is source app or a package app. %% @doc returns whether the app is source app or a package app.
-spec resource_type(t()) -> pkg | src. -spec resource_type(t()) -> pkg | src.
@ -519,7 +519,7 @@ all(Dir, Context, [File|Artifacts]) ->
FilePath = filename:join(Dir, rebar_templater:render(File, Context)), FilePath = filename:join(Dir, rebar_templater:render(File, Context)),
case filelib:is_regular(FilePath) of case filelib:is_regular(FilePath) of
false -> false ->
?DEBUG("Missing artifact ~s", [FilePath]),
?DEBUG("Missing artifact ~ts", [FilePath]),
{false, File}; {false, File};
true -> true ->
all(Dir, Context, Artifacts) all(Dir, Context, Artifacts)

+ 13
- 11
src/rebar_app_utils.erl View File

@ -145,7 +145,7 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) ->
Dep -> Dep ->
Dep Dep
end, end,
case lists:keyfind(ec_cnv:to_binary(Name), 1, Locks) of
case lists:keyfind(rebar_utils:to_binary(Name), 1, Locks) of
false -> false ->
parse_dep(Parent, Dep, DepsDir, false, State); parse_dep(Parent, Dep, DepsDir, false, State);
LockedDep -> LockedDep ->
@ -167,18 +167,20 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) ->
IsLock :: boolean(), IsLock :: boolean(),
State :: rebar_state:t(). State :: rebar_state:t().
parse_dep(Parent, {Name, Vsn, {pkg, PkgName}}, DepsDir, IsLock, State) -> parse_dep(Parent, {Name, Vsn, {pkg, PkgName}}, DepsDir, IsLock, State) ->
{PkgName1, PkgVsn} = {ec_cnv:to_binary(PkgName), ec_cnv:to_binary(Vsn)},
{PkgName1, PkgVsn} = {rebar_utils:to_binary(PkgName),
rebar_utils:to_binary(Vsn)},
dep_to_app(Parent, DepsDir, Name, PkgVsn, {pkg, PkgName1, PkgVsn, undefined}, IsLock, State); dep_to_app(Parent, DepsDir, Name, PkgVsn, {pkg, PkgName1, PkgVsn, undefined}, IsLock, State);
parse_dep(Parent, {Name, {pkg, PkgName}}, DepsDir, IsLock, State) -> parse_dep(Parent, {Name, {pkg, PkgName}}, DepsDir, IsLock, State) ->
%% Package dependency with different package name from app name %% Package dependency with different package name from app name
dep_to_app(Parent, DepsDir, Name, undefined, {pkg, ec_cnv:to_binary(PkgName), undefined, undefined}, IsLock, State);
dep_to_app(Parent, DepsDir, Name, undefined, {pkg, rebar_utils:to_binary(PkgName), undefined, undefined}, IsLock, State);
parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_binary(Vsn) -> parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_binary(Vsn) ->
%% Versioned Package dependency %% Versioned Package dependency
{PkgName, PkgVsn} = {ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)},
{PkgName, PkgVsn} = {rebar_utils:to_binary(Name),
rebar_utils:to_binary(Vsn)},
dep_to_app(Parent, DepsDir, PkgName, PkgVsn, {pkg, PkgName, PkgVsn, undefined}, IsLock, State); dep_to_app(Parent, DepsDir, PkgName, PkgVsn, {pkg, PkgName, PkgVsn, undefined}, IsLock, State);
parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Name) -> parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Name) ->
%% Unversioned package dependency %% Unversioned package dependency
dep_to_app(Parent, DepsDir, ec_cnv:to_binary(Name), undefined, {pkg, ec_cnv:to_binary(Name), undefined, undefined}, IsLock, State);
dep_to_app(Parent, DepsDir, rebar_utils:to_binary(Name), undefined, {pkg, rebar_utils:to_binary(Name), undefined, undefined}, IsLock, State);
parse_dep(Parent, {Name, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> parse_dep(Parent, {Name, Source}, DepsDir, IsLock, State) when is_tuple(Source) ->
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State);
parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(Source) ->
@ -212,12 +214,12 @@ parse_dep(_, Dep, _, _, _) ->
IsLock :: boolean(), IsLock :: boolean(),
State :: rebar_state:t(). State :: rebar_state:t().
dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) ->
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)),
CheckoutsDir = rebar_utils:to_list(rebar_dir:checkouts_dir(State, Name)),
AppInfo = case rebar_app_info:discover(CheckoutsDir) of AppInfo = case rebar_app_info:discover(CheckoutsDir) of
{ok, App} -> {ok, App} ->
rebar_app_info:source(rebar_app_info:is_checkout(App, true), checkout); rebar_app_info:source(rebar_app_info:is_checkout(App, true), checkout);
not_found -> not_found ->
Dir = ec_cnv:to_list(filename:join(DepsDir, Name)),
Dir = rebar_utils:to_list(filename:join(DepsDir, Name)),
{ok, AppInfo0} = {ok, AppInfo0} =
case rebar_app_info:discover(Dir) of case rebar_app_info:discover(Dir) of
{ok, App} -> {ok, App} ->
@ -275,7 +277,7 @@ fetch_checksum(PkgName, PkgVsn, Hash, State) ->
rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State) rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State)
catch catch
_:_ -> _:_ ->
?INFO("Package ~s- ~s not found. Fetching registry updates and trying again...", [PkgName, PkgVsn]),
?INFO("Package ~ts-~ts not found. Fetching registry updates and trying again...", [PkgName, PkgVsn]),
{ok, _} = rebar_prv_update:do(State), {ok, _} = rebar_prv_update:do(State),
rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State) rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State)
end. end.
@ -283,7 +285,7 @@ fetch_checksum(PkgName, PkgVsn, Hash, State) ->
%% @doc convert a given exception's payload into an io description. %% @doc convert a given exception's payload into an io description.
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({missing_package, Package}) -> format_error({missing_package, Package}) ->
io_lib:format("Package not found in registry: ~s", [Package]);
io_lib:format("Package not found in registry: ~ts", [Package]);
format_error({parse_dep, Dep}) -> format_error({parse_dep, Dep}) ->
io_lib:format("Failed parsing dep ~p", [Dep]); io_lib:format("Failed parsing dep ~p", [Dep]);
format_error(Error) -> format_error(Error) ->
@ -302,7 +304,7 @@ get_package(Dep, Vsn, State) ->
{ok, HighestDepVsn} -> {ok, HighestDepVsn} ->
{Dep, HighestDepVsn}; {Dep, HighestDepVsn};
none -> none ->
throw(?PRV_ERROR({missing_package, ec_cnv:to_binary(Dep)}))
throw(?PRV_ERROR({missing_package, rebar_utils:to_binary(Dep)}))
end. end.
%% @private checks that all the beam files have been properly %% @private checks that all the beam files have been properly
@ -310,7 +312,7 @@ get_package(Dep, Vsn, State) ->
-spec has_all_beams(file:filename_all(), [module()]) -> -spec has_all_beams(file:filename_all(), [module()]) ->
true | ?PRV_ERROR({missing_module, module()}). true | ?PRV_ERROR({missing_module, module()}).
has_all_beams(EbinDir, [Module | ModuleList]) -> has_all_beams(EbinDir, [Module | ModuleList]) ->
BeamFile = filename:join([EbinDir, ec_cnv:to_list(Module) ++ ".beam"]),
BeamFile = filename:join([EbinDir, rebar_utils:to_list(Module) ++ ".beam"]),
case filelib:is_file(BeamFile) of case filelib:is_file(BeamFile) of
true -> true ->
has_all_beams(EbinDir, ModuleList); has_all_beams(EbinDir, ModuleList);

+ 8
- 8
src/rebar_base_compiler.erl View File

@ -199,15 +199,15 @@ compile_each([], _Config, _CompileFn) ->
compile_each([Source | Rest], Config, CompileFn) -> compile_each([Source | Rest], Config, CompileFn) ->
case CompileFn(Source, Config) of case CompileFn(Source, Config) of
ok -> ok ->
?DEBUG(" ~sCompiled ~s", [rebar_utils:indent(1), filename:basename(Source)]);
?DEBUG("~tsCompiled ~ts", [rebar_utils:indent(1), filename:basename(Source)]);
{ok, Warnings} -> {ok, Warnings} ->
report(Warnings), report(Warnings),
?DEBUG(" ~sCompiled ~s", [rebar_utils:indent(1), filename:basename(Source)]);
?DEBUG("~tsCompiled ~ts", [rebar_utils:indent(1), filename:basename(Source)]);
skipped -> skipped ->
?DEBUG(" ~sSkipped ~s", [rebar_utils:indent(1), filename:basename(Source)]);
?DEBUG("~tsSkipped ~ts", [rebar_utils:indent(1), filename:basename(Source)]);
Error -> Error ->
NewSource = format_error_source(Source, Config), NewSource = format_error_source(Source, Config),
?ERROR("Compiling ~s failed", [NewSource]),
?ERROR("Compiling ~ts failed", [NewSource]),
maybe_report(Error), maybe_report(Error),
?DEBUG("Compilation failed: ~p", [Error]), ?DEBUG("Compilation failed: ~p", [Error]),
?FAIL ?FAIL
@ -258,7 +258,7 @@ maybe_report(_) ->
%% @private Outputs a bunch of strings, including a newline %% @private Outputs a bunch of strings, including a newline
-spec report([string()]) -> ok. -spec report([string()]) -> ok.
report(Messages) -> report(Messages) ->
lists:foreach(fun(Msg) -> io:format(" ~s~n", [Msg]) end, Messages).
lists:foreach(fun(Msg) -> io:format("~ts~n", [Msg]) end, Messages).
%% private format compiler errors into proper outputtable strings %% private format compiler errors into proper outputtable strings
-spec format_errors(_, Extra, [err_or_warn()]) -> [string()] when -spec format_errors(_, Extra, [err_or_warn()]) -> [string()] when
@ -274,10 +274,10 @@ format_errors(_MainSource, Extra, Errors) ->
Extra :: string(). Extra :: string().
format_error(Source, Extra, {{Line, Column}, Mod, Desc}) -> format_error(Source, Extra, {{Line, Column}, Mod, Desc}) ->
ErrorDesc = Mod:format_error(Desc), ErrorDesc = Mod:format_error(Desc),
?FMT(" ~s:~w:~w: ~s ~s~n", [Source, Line, Column, Extra, ErrorDesc]);
?FMT("~ts:~w:~w: ~ts~ts~n", [Source, Line, Column, Extra, ErrorDesc]);
format_error(Source, Extra, {Line, Mod, Desc}) -> format_error(Source, Extra, {Line, Mod, Desc}) ->
ErrorDesc = Mod:format_error(Desc), ErrorDesc = Mod:format_error(Desc),
?FMT(" ~s:~w: ~s ~s~n", [Source, Line, Extra, ErrorDesc]);
?FMT("~ts:~w: ~ts~ts~n", [Source, Line, Extra, ErrorDesc]);
format_error(Source, Extra, {Mod, Desc}) -> format_error(Source, Extra, {Mod, Desc}) ->
ErrorDesc = Mod:format_error(Desc), ErrorDesc = Mod:format_error(Desc),
?FMT(" ~s: ~s ~s~n", [Source, Extra, ErrorDesc]).
?FMT("~ts: ~ts~ts~n", [Source, Extra, ErrorDesc]).

+ 4
- 4
src/rebar_config.erl View File

@ -120,7 +120,7 @@ write_lock_file(LockFile, Locks) ->
file:write_file(LockFile, io_lib:format("~p.~n", [NewLocks])); file:write_file(LockFile, io_lib:format("~p.~n", [NewLocks]));
_ -> _ ->
file:write_file(LockFile, file:write_file(LockFile,
io_lib:format("{~p,~n~p}.~n[~n ~s~n].~n",
io_lib:format("{~p,~n~p}.~n[~n~ts~n].~n",
[?CONFIG_VERSION, NewLocks, [?CONFIG_VERSION, NewLocks,
format_attrs(Attrs)])) format_attrs(Attrs)]))
end. end.
@ -359,7 +359,7 @@ check_newly_added_({Name, Source}, LockedDeps) ->
false false
end; end;
check_newly_added_(Dep, LockedDeps) when is_atom(Dep) -> check_newly_added_(Dep, LockedDeps) when is_atom(Dep) ->
Name = ec_cnv:to_binary(Dep),
Name = rebar_utils:to_binary(Dep),
case lists:keyfind(Name, 1, LockedDeps) of case lists:keyfind(Name, 1, LockedDeps) of
false -> false ->
{true, Name}; {true, Name};
@ -368,8 +368,8 @@ check_newly_added_(Dep, LockedDeps) when is_atom(Dep) ->
0 -> 0 ->
{true, Name}; {true, Name};
_ -> _ ->
?WARN("Newly added dep ~s is locked at a lower level. "
"If you really want to unlock it, use 'rebar3 upgrade ~s'",
?WARN("Newly added dep ~ts is locked at a lower level. "
"If you really want to unlock it, use 'rebar3 upgrade ~ts'",
[Name, Name]), [Name, Name]),
false false
end end

+ 5
- 5
src/rebar_core.erl View File

@ -119,11 +119,11 @@ process_command(State, Command) ->
State2 = rebar_state:command_parsed_args(State1, Args), State2 = rebar_state:command_parsed_args(State1, Args),
do(TargetProviders, State2); do(TargetProviders, State2);
{error, {invalid_option, Option}} -> {error, {invalid_option, Option}} ->
{error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])};
{error, io_lib:format("Invalid option ~ts on task ~p", [Option, Command])};
{error, {invalid_option_arg, {Option, Arg}}} -> {error, {invalid_option_arg, {Option, Arg}}} ->
{error, io_lib:format("Invalid argument ~s to option ~s", [Arg, Option])};
{error, io_lib:format("Invalid argument ~ts to option ~ts", [Arg, Option])};
{error, {missing_option_arg, Option}} -> {error, {missing_option_arg, Option}} ->
{error, io_lib:format("Missing argument to option ~s", [Option])}
{error, io_lib:format("Missing argument to option ~ts", [Option])}
end end
end end
end. end.
@ -173,6 +173,6 @@ do([ProviderName | Rest], State) ->
%% @doc convert a given exception's payload into an io description. %% @doc convert a given exception's payload into an io description.
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({bad_provider_namespace, {Namespace, Name}}) -> format_error({bad_provider_namespace, {Namespace, Name}}) ->
io_lib:format("Undefined command ~s in namespace ~s", [Name, Namespace]);
io_lib:format("Undefined command ~ts in namespace ~ts", [Name, Namespace]);
format_error({bad_provider_namespace, Name}) -> format_error({bad_provider_namespace, Name}) ->
io_lib:format("Undefined command ~s", [Name]).
io_lib:format("Undefined command ~ts", [Name]).

+ 89
- 89
src/rebar_dialyzer_format.erl View File

@ -31,7 +31,7 @@ format_warnings(Opts, Warnings) ->
format_warning_(_Opts, Warning = {_Tag, {File, Line}, Msg}, {File, Acc}) -> format_warning_(_Opts, Warning = {_Tag, {File, Line}, Msg}, {File, Acc}) ->
try try
String = message_to_string(Msg), String = message_to_string(Msg),
{File, [lists:flatten(fmt("~!c~4w~!!: ~s", [Line, String])) | Acc]}
{File, [lists:flatten(fmt("~!c~4w~!!: ~ts", [Line, String])) | Acc]}
catch catch
Error:Reason -> Error:Reason ->
?DEBUG("Failed to pretty format warning: ~p:~p", ?DEBUG("Failed to pretty format warning: ~p:~p",
@ -47,11 +47,11 @@ format_warning_(Opts, Warning = {_Tag, {SrcFile, Line}, Msg}, {_LastFile, Acc})
Dir = filename:dirname(File), Dir = filename:dirname(File),
Root = filename:rootname(Base), Root = filename:rootname(Base),
Ext = filename:extension(Base), Ext = filename:extension(Base),
Path = re:replace(Dir, "^.*/_build/", "_build/", [{return, list}]),
Base1 = fmt("~!_c ~s~!!~!__ ~s", [Root, Ext]),
F = fmt("~!__ ~s", [filename:join(Path, Base1)]),
Path = re:replace(Dir, "^.*/_build/", "_build/", [{return, list}, unicode]),
Base1 = fmt("~!_c~ts~!!~!__~ts", [Root, Ext]),
F = fmt("~!__~ts", [filename:join(Path, Base1)]),
String = message_to_string(Msg), String = message_to_string(Msg),
{SrcFile, [lists:flatten(fmt("~n ~s~n~!c~4w~!!: ~s", [F, Line, String])) | Acc]}
{SrcFile, [lists:flatten(fmt("~n~ts~n~!c~4w~!!: ~ts", [F, Line, String])) | Acc]}
catch catch
Error:Reason -> Error:Reason ->
?DEBUG("Failed to pretty format warning: ~p:~p~n~p", ?DEBUG("Failed to pretty format warning: ~p:~p~n~p",
@ -72,53 +72,53 @@ fmt(Fmt, Args) ->
%%----- Warnings for general discrepancies ---------------- %%----- Warnings for general discrepancies ----------------
message_to_string({apply, [Args, ArgNs, FailReason, message_to_string({apply, [Args, ArgNs, FailReason,
SigArgs, SigRet, Contract]}) -> SigArgs, SigRet, Contract]}) ->
fmt("~!^Fun application with arguments ~!! ~s ",
fmt("~!^Fun application with arguments ~!!~ts ",
[bad_arg(ArgNs, Args)]) ++ [bad_arg(ArgNs, Args)]) ++
call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet, Contract); call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet, Contract);
message_to_string({app_call, [M, F, Args, Culprit, ExpectedType, FoundType]}) -> message_to_string({app_call, [M, F, Args, Culprit, ExpectedType, FoundType]}) ->
fmt("~!^The call~!! ~s: ~s ~s ~!^requires that"
"~!! ~s ~!^is of type ~!g ~s~!^ not ~!r ~s",
fmt("~!^The call~!! ~ts:~ts~ts ~!^requires that"
"~!! ~ts ~!^is of type ~!g~ts~!^ not ~!r~ts",
[M, F, Args, Culprit, ExpectedType, FoundType]); [M, F, Args, Culprit, ExpectedType, FoundType]);
message_to_string({bin_construction, [Culprit, Size, Seg, Type]}) -> message_to_string({bin_construction, [Culprit, Size, Seg, Type]}) ->
fmt("~!^Binary construction will fail since the ~!b ~s~!^ field~!!"
" ~s~!^ in segment~!! ~s~!^ has type~!! ~s",
fmt("~!^Binary construction will fail since the ~!b~ts~!^ field~!!"
" ~ts~!^ in segment~!! ~ts~!^ has type~!! ~ts",
[Culprit, Size, Seg, Type]); [Culprit, Size, Seg, Type]);
message_to_string({call, [M, F, Args, ArgNs, FailReason, message_to_string({call, [M, F, Args, ArgNs, FailReason,
SigArgs, SigRet, Contract]}) -> SigArgs, SigRet, Contract]}) ->
fmt("~!^The call~!! ~w:~w ~s ", [M, F, bad_arg(ArgNs, Args)]) ++
fmt("~!^The call~!! ~w:~w~ts ", [M, F, bad_arg(ArgNs, Args)]) ++
call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet, Contract); call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet, Contract);
message_to_string({call_to_missing, [M, F, A]}) -> message_to_string({call_to_missing, [M, F, A]}) ->
fmt("~!^Call to missing or unexported function ~!!~w:~w/~w", fmt("~!^Call to missing or unexported function ~!!~w:~w/~w",
[M, F, A]); [M, F, A]);
message_to_string({exact_eq, [Type1, Op, Type2]}) -> message_to_string({exact_eq, [Type1, Op, Type2]}) ->
fmt("~!^The test ~!! ~s ~s ~s~!^ can never evaluate to 'true'",
fmt("~!^The test ~!!~ts ~ts ~ts~!^ can never evaluate to 'true'",
[Type1, Op, Type2]); [Type1, Op, Type2]);
message_to_string({fun_app_args, [Args, Type]}) -> message_to_string({fun_app_args, [Args, Type]}) ->
fmt("~!^Fun application with arguments ~!! ~s~!^ will fail"
" since the function has type ~!! ~s", [Args, Type]);
fmt("~!^Fun application with arguments ~!!~ts~!^ will fail"
" since the function has type ~!!~ts", [Args, Type]);
message_to_string({fun_app_no_fun, [Op, Type, Arity]}) -> message_to_string({fun_app_no_fun, [Op, Type, Arity]}) ->
fmt("~!^Fun application will fail since ~!! ~s ~!^::~!! ~s"
fmt("~!^Fun application will fail since ~!!~ts ~!^::~!! ~ts"
" is not a function of arity ~!!~w", [Op, Type, Arity]); " is not a function of arity ~!!~w", [Op, Type, Arity]);
message_to_string({guard_fail, []}) -> message_to_string({guard_fail, []}) ->
"~!^Clause guard cannot succeed.~!!"; "~!^Clause guard cannot succeed.~!!";
message_to_string({guard_fail, [Arg1, Infix, Arg2]}) -> message_to_string({guard_fail, [Arg1, Infix, Arg2]}) ->
fmt("~!^Guard test ~!! ~s ~s ~s~!^ can never succeed",
fmt("~!^Guard test ~!!~ts ~ts ~ts~!^ can never succeed",
[Arg1, Infix, Arg2]); [Arg1, Infix, Arg2]);
message_to_string({neg_guard_fail, [Arg1, Infix, Arg2]}) -> message_to_string({neg_guard_fail, [Arg1, Infix, Arg2]}) ->
fmt("~!^Guard test not(~!! ~s ~s ~s~!^) can never succeed",
fmt("~!^Guard test not(~!!~ts ~ts ~ts~!^) can never succeed",
[Arg1, Infix, Arg2]); [Arg1, Infix, Arg2]);
message_to_string({guard_fail, [Guard, Args]}) -> message_to_string({guard_fail, [Guard, Args]}) ->
fmt("~!^Guard test ~!!~w ~s~!^ can never succeed",
fmt("~!^Guard test ~!!~w~ts~!^ can never succeed",
[Guard, Args]); [Guard, Args]);
message_to_string({neg_guard_fail, [Guard, Args]}) -> message_to_string({neg_guard_fail, [Guard, Args]}) ->
fmt("~!^Guard test not(~!!~w ~s~!^) can never succeed",
fmt("~!^Guard test not(~!!~w~ts~!^) can never succeed",
[Guard, Args]); [Guard, Args]);
message_to_string({guard_fail_pat, [Pat, Type]}) -> message_to_string({guard_fail_pat, [Pat, Type]}) ->
fmt("~!^Clause guard cannot succeed. The ~!! ~s~!^ was matched"
" against the type ~!! ~s", [Pat, Type]);
fmt("~!^Clause guard cannot succeed. The ~!!~ts~!^ was matched"
" against the type ~!!~ts", [Pat, Type]);
message_to_string({improper_list_constr, [TlType]}) -> message_to_string({improper_list_constr, [TlType]}) ->
fmt("~!^Cons will produce an improper list" fmt("~!^Cons will produce an improper list"
" since its ~!b2~!!nd~!^ argument is~!! ~s", [TlType]);
" since its ~!b2~!!nd~!^ argument is~!! ~ts", [TlType]);
message_to_string({no_return, [Type|Name]}) -> message_to_string({no_return, [Type|Name]}) ->
NameString = NameString =
case Name of case Name of
@ -126,59 +126,59 @@ message_to_string({no_return, [Type|Name]}) ->
[F, A] -> fmt("~!^Function ~!r~w/~w ", [F, A]) [F, A] -> fmt("~!^Function ~!r~w/~w ", [F, A])
end, end,
case Type of case Type of
no_match -> fmt(" ~s~!^has no clauses that will ever match",[NameString]);
only_explicit -> fmt(" ~s~!^only terminates with explicit exception", [NameString]);
only_normal -> fmt(" ~s~!^has no local return", [NameString]);
both -> fmt(" ~s~!^has no local return", [NameString])
no_match -> fmt("~ts~!^has no clauses that will ever match",[NameString]);
only_explicit -> fmt("~ts~!^only terminates with explicit exception", [NameString]);
only_normal -> fmt("~ts~!^has no local return", [NameString]);
both -> fmt("~ts~!^has no local return", [NameString])
end; end;
message_to_string({record_constr, [RecConstr, FieldDiffs]}) -> message_to_string({record_constr, [RecConstr, FieldDiffs]}) ->
fmt("~!^Record construction ~!! ~s~!^ violates the"
" declared type of field ~!! ~s", [RecConstr, FieldDiffs]);
fmt("~!^Record construction ~!!~ts~!^ violates the"
" declared type of field ~!!~ts", [RecConstr, FieldDiffs]);
message_to_string({record_constr, [Name, Field, Type]}) -> message_to_string({record_constr, [Name, Field, Type]}) ->
fmt("~!^Record construction violates the declared type for ~!!#~w{}~!^" fmt("~!^Record construction violates the declared type for ~!!#~w{}~!^"
" since ~!! ~s~!^ cannot be of type ~!! ~s",
" since ~!!~ts~!^ cannot be of type ~!!~ts",
[Name, Field, Type]); [Name, Field, Type]);
message_to_string({record_matching, [String, Name]}) -> message_to_string({record_matching, [String, Name]}) ->
fmt("~!^The ~!! ~s~!^ violates the"
fmt("~!^The ~!!~ts~!^ violates the"
" declared type for ~!!#~w{}", [String, Name]); " declared type for ~!!#~w{}", [String, Name]);
message_to_string({record_match, [Pat, Type]}) -> message_to_string({record_match, [Pat, Type]}) ->
fmt("~!^Matching of ~!! ~s~!^ tagged with a record name violates the"
" declared type of ~!! ~s", [Pat, Type]);
fmt("~!^Matching of ~!!~ts~!^ tagged with a record name violates the"
" declared type of ~!!~ts", [Pat, Type]);
message_to_string({pattern_match, [Pat, Type]}) -> message_to_string({pattern_match, [Pat, Type]}) ->
fmt("~!^The ~s~!^ can never match the type ~!g ~s",
fmt("~!^The ~ts~!^ can never match the type ~!g~ts",
[bad_pat(Pat), Type]); [bad_pat(Pat), Type]);
message_to_string({pattern_match_cov, [Pat, Type]}) -> message_to_string({pattern_match_cov, [Pat, Type]}) ->
fmt("~!^The ~s~!^ can never match since previous"
" clauses completely covered the type ~!g ~s",
fmt("~!^The ~ts~!^ can never match since previous"
" clauses completely covered the type ~!g~ts",
[bad_pat(Pat), Type]); [bad_pat(Pat), Type]);
message_to_string({unmatched_return, [Type]}) -> message_to_string({unmatched_return, [Type]}) ->
fmt("~!^Expression produces a value of type ~!! ~s~!^,"
fmt("~!^Expression produces a value of type ~!!~ts~!^,"
" but this value is unmatched", [Type]); " but this value is unmatched", [Type]);
message_to_string({unused_fun, [F, A]}) -> message_to_string({unused_fun, [F, A]}) ->
fmt("~!^Function ~!r~w/~w~!!~!^ will never be called", [F, A]); fmt("~!^Function ~!r~w/~w~!!~!^ will never be called", [F, A]);
%%----- Warnings for specs and contracts ------------------- %%----- Warnings for specs and contracts -------------------
message_to_string({contract_diff, [M, F, _A, Contract, Sig]}) -> message_to_string({contract_diff, [M, F, _A, Contract, Sig]}) ->
fmt("~!^Type specification ~!!~w:~w ~s~!^"
" is not equal to the success typing: ~!!~w:~w ~s",
fmt("~!^Type specification ~!!~w:~w~ts~!^"
" is not equal to the success typing: ~!!~w:~w~ts",
[M, F, Contract, M, F, Sig]); [M, F, Contract, M, F, Sig]);
message_to_string({contract_subtype, [M, F, _A, Contract, Sig]}) -> message_to_string({contract_subtype, [M, F, _A, Contract, Sig]}) ->
fmt("~!^Type specification ~!!~w:~w ~s~!^"
" is a subtype of the success typing: ~!!~w:~w ~s",
fmt("~!^Type specification ~!!~w:~w~ts~!^"
" is a subtype of the success typing: ~!!~w:~w~ts",
[M, F, Contract, M, F, Sig]); [M, F, Contract, M, F, Sig]);
message_to_string({contract_supertype, [M, F, _A, Contract, Sig]}) -> message_to_string({contract_supertype, [M, F, _A, Contract, Sig]}) ->
fmt("~!^Type specification ~!!~w:~w ~s~!^"
" is a supertype of the success typing: ~!!~w:~w ~s",
fmt("~!^Type specification ~!!~w:~w~ts~!^"
" is a supertype of the success typing: ~!!~w:~w~ts",
[M, F, Contract, M, F, Sig]); [M, F, Contract, M, F, Sig]);
message_to_string({contract_range, [Contract, M, F, ArgStrings, Line, CRet]}) -> message_to_string({contract_range, [Contract, M, F, ArgStrings, Line, CRet]}) ->
fmt("~!^The contract ~!!~w:~w ~s~!^ cannot be right because the"
" inferred return for ~!!~w ~s~!^ on line ~!!~w~!^ is ~!! ~s",
fmt("~!^The contract ~!!~w:~w~ts~!^ cannot be right because the"
" inferred return for ~!!~w~ts~!^ on line ~!!~w~!^ is ~!!~ts",
[M, F, Contract, F, ArgStrings, Line, CRet]); [M, F, Contract, F, ArgStrings, Line, CRet]);
message_to_string({invalid_contract, [M, F, A, Sig]}) -> message_to_string({invalid_contract, [M, F, A, Sig]}) ->
fmt("~!^Invalid type specification for function~!! ~w:~w/~w." fmt("~!^Invalid type specification for function~!! ~w:~w/~w."
"~!^ The success typing is~!! ~s", [M, F, A, Sig]);
"~!^ The success typing is~!! ~ts", [M, F, A, Sig]);
message_to_string({extra_range, [M, F, A, ExtraRanges, SigRange]}) -> message_to_string({extra_range, [M, F, A, ExtraRanges, SigRange]}) ->
fmt("~!^The specification for ~!!~w:~w/~w~!^ states that the function" fmt("~!^The specification for ~!!~w:~w/~w~!^ states that the function"
" might also return ~!! ~s~!^ but the inferred return is ~!! ~s",
" might also return ~!!~ts~!^ but the inferred return is ~!!~ts",
[M, F, A, ExtraRanges, SigRange]); [M, F, A, ExtraRanges, SigRange]);
message_to_string({overlapping_contract, [M, F, A]}) -> message_to_string({overlapping_contract, [M, F, A]}) ->
fmt("~!^Overloaded contract for ~!!~w:~w/~w~!^ has overlapping" fmt("~!^Overloaded contract for ~!!~w:~w/~w~!^ has overlapping"
@ -189,62 +189,62 @@ message_to_string({spec_missing_fun, [M, F, A]}) ->
[M, F, A]); [M, F, A]);
%%----- Warnings for opaque type violations ------------------- %%----- Warnings for opaque type violations -------------------
message_to_string({call_with_opaque, [M, F, Args, ArgNs, ExpArgs]}) -> message_to_string({call_with_opaque, [M, F, Args, ArgNs, ExpArgs]}) ->
fmt("~!^The call ~!!~w:~w ~s~!^ contains ~!! ~s~!^ when ~!! ~s",
fmt("~!^The call ~!!~w:~w~ts~!^ contains ~!!~ts~!^ when ~!!~ts",
[M, F, bad_arg(ArgNs, Args), form_positions(ArgNs), form_expected(ExpArgs)]); [M, F, bad_arg(ArgNs, Args), form_positions(ArgNs), form_expected(ExpArgs)]);
message_to_string({call_without_opaque, [M, F, Args, [{N,_,_}|_] = ExpectedTriples]}) -> message_to_string({call_without_opaque, [M, F, Args, [{N,_,_}|_] = ExpectedTriples]}) ->
fmt("~!^The call ~!!~w:~w ~s ~!^does not have~!! ~s",
fmt("~!^The call ~!!~w:~w~ts ~!^does not have~!! ~ts",
[M, F, bad_arg(N, Args), form_expected_without_opaque(ExpectedTriples)]); [M, F, bad_arg(N, Args), form_expected_without_opaque(ExpectedTriples)]);
message_to_string({opaque_eq, [Type, _Op, OpaqueType]}) -> message_to_string({opaque_eq, [Type, _Op, OpaqueType]}) ->
fmt("~!^Attempt to test for equality between a term of type ~!! ~s~!^"
" and a term of opaque type ~!! ~s", [Type, OpaqueType]);
fmt("~!^Attempt to test for equality between a term of type ~!!~ts~!^"
" and a term of opaque type ~!!~ts", [Type, OpaqueType]);
message_to_string({opaque_guard, [Arg1, Infix, Arg2, ArgNs]}) -> message_to_string({opaque_guard, [Arg1, Infix, Arg2, ArgNs]}) ->
fmt("~!^Guard test ~!! ~s ~s ~s~!^ contains ~!! ~s",
fmt("~!^Guard test ~!!~ts ~ts ~ts~!^ contains ~!!~ts",
[Arg1, Infix, Arg2, form_positions(ArgNs)]); [Arg1, Infix, Arg2, form_positions(ArgNs)]);
message_to_string({opaque_guard, [Guard, Args]}) -> message_to_string({opaque_guard, [Guard, Args]}) ->
fmt("~!^Guard test ~!!~w ~s~!^ breaks the opaqueness of its"
fmt("~!^Guard test ~!!~w~ts~!^ breaks the opaqueness of its"
" argument", [Guard, Args]); " argument", [Guard, Args]);
message_to_string({opaque_match, [Pat, OpaqueType, OpaqueTerm]}) -> message_to_string({opaque_match, [Pat, OpaqueType, OpaqueTerm]}) ->
Term = if OpaqueType =:= OpaqueTerm -> "the term"; Term = if OpaqueType =:= OpaqueTerm -> "the term";
true -> OpaqueTerm true -> OpaqueTerm
end, end,
fmt("~!^The attempt to match a term of type ~!! ~s~!^ against the"
"~!! ~s~!^ breaks the opaqueness of ~!! ~s",
fmt("~!^The attempt to match a term of type ~!!~ts~!^ against the"
"~!! ~ts~!^ breaks the opaqueness of ~!!~ts",
[OpaqueType, Pat, Term]); [OpaqueType, Pat, Term]);
message_to_string({opaque_neq, [Type, _Op, OpaqueType]}) -> message_to_string({opaque_neq, [Type, _Op, OpaqueType]}) ->
fmt("~!^Attempt to test for inequality between a term of type ~!! ~s"
"~!^ and a term of opaque type ~!! ~s", [Type, OpaqueType]);
fmt("~!^Attempt to test for inequality between a term of type ~!!~ts"
"~!^ and a term of opaque type ~!!~ts", [Type, OpaqueType]);
message_to_string({opaque_type_test, [Fun, Args, Arg, ArgType]}) -> message_to_string({opaque_type_test, [Fun, Args, Arg, ArgType]}) ->
fmt("~!^The type test ~!! ~s ~s~!^ breaks the opaqueness of the term "
"~!! ~s ~s", [Fun, Args, Arg, ArgType]);
fmt("~!^The type test ~!!~ts~ts~!^ breaks the opaqueness of the term "
"~!!~ts~ts", [Fun, Args, Arg, ArgType]);
message_to_string({opaque_size, [SizeType, Size]}) -> message_to_string({opaque_size, [SizeType, Size]}) ->
fmt("~!^The size ~!! ~s~!^ breaks the opaqueness of ~!! ~s",
fmt("~!^The size ~!!~ts~!^ breaks the opaqueness of ~!!~ts",
[SizeType, Size]); [SizeType, Size]);
message_to_string({opaque_call, [M, F, Args, Culprit, OpaqueType]}) -> message_to_string({opaque_call, [M, F, Args, Culprit, OpaqueType]}) ->
fmt("~!^The call ~!! ~s: ~s ~s~!^ breaks the opaqueness of the term~!!"
" ~s :: ~s", [M, F, Args, Culprit, OpaqueType]);
fmt("~!^The call ~!!~ts:~ts~ts~!^ breaks the opaqueness of the term~!!"
" ~ts :: ~ts", [M, F, Args, Culprit, OpaqueType]);
%%----- Warnings for concurrency errors -------------------- %%----- Warnings for concurrency errors --------------------
message_to_string({race_condition, [M, F, Args, Reason]}) -> message_to_string({race_condition, [M, F, Args, Reason]}) ->
fmt("~!^The call ~!!~w:~w ~s ~s", [M, F, Args, Reason]);
fmt("~!^The call ~!!~w:~w~ts ~ts", [M, F, Args, Reason]);
%%----- Warnings for behaviour errors -------------------- %%----- Warnings for behaviour errors --------------------
message_to_string({callback_type_mismatch, [B, F, A, ST, CT]}) -> message_to_string({callback_type_mismatch, [B, F, A, ST, CT]}) ->
fmt("~!^The inferred return type of~!! ~w/~w ( ~s) ~!^"
"has nothing in common with~!! ~s, ~!^which is the expected"
fmt("~!^The inferred return type of~!! ~w/~w (~ts) ~!^"
"has nothing in common with~!! ~ts, ~!^which is the expected"
" return type for the callback of~!! ~w ~!^behaviour", " return type for the callback of~!! ~w ~!^behaviour",
[F, A, ST, CT, B]); [F, A, ST, CT, B]);
message_to_string({callback_arg_type_mismatch, [B, F, A, N, ST, CT]}) -> message_to_string({callback_arg_type_mismatch, [B, F, A, N, ST, CT]}) ->
fmt("~!^The inferred type for the~!! ~s ~!^argument of~!!"
" ~w/~w ( ~s) ~!^is not a supertype of~!! ~s~!^, which is"
fmt("~!^The inferred type for the~!! ~ts ~!^argument of~!!"
" ~w/~w (~ts) ~!^is not a supertype of~!! ~ts~!^, which is"
"expected type for this argument in the callback of the~!! ~w " "expected type for this argument in the callback of the~!! ~w "
"~!^behaviour", "~!^behaviour",
[ordinal(N), F, A, ST, CT, B]); [ordinal(N), F, A, ST, CT, B]);
message_to_string({callback_spec_type_mismatch, [B, F, A, ST, CT]}) -> message_to_string({callback_spec_type_mismatch, [B, F, A, ST, CT]}) ->
fmt("~!^The return type ~!! ~s~!^ in the specification of ~!!"
"~w/~w~!^ is not a subtype of ~!! ~s~!^, which is the expected"
fmt("~!^The return type ~!!~ts~!^ in the specification of ~!!"
"~w/~w~!^ is not a subtype of ~!!~ts~!^, which is the expected"
" return type for the callback of ~!!~w~!^ behaviour", " return type for the callback of ~!!~w~!^ behaviour",
[ST, F, A, CT, B]); [ST, F, A, CT, B]);
message_to_string({callback_spec_arg_type_mismatch, [B, F, A, N, ST, CT]}) -> message_to_string({callback_spec_arg_type_mismatch, [B, F, A, N, ST, CT]}) ->
fmt("~!^The specified type for the ~!! ~s~!^ argument of ~!!"
"~w/~w ( ~s)~!^ is not a supertype of ~!! ~s~!^, which is"
fmt("~!^The specified type for the ~!!~ts~!^ argument of ~!!"
"~w/~w (~ts)~!^ is not a supertype of ~!!~ts~!^, which is"
" expected type for this argument in the callback of the ~!!~w" " expected type for this argument in the callback of the ~!!~w"
"~!^ behaviour", [ordinal(N), F, A, ST, CT, B]); "~!^ behaviour", [ordinal(N), F, A, ST, CT, B]);
message_to_string({callback_missing, [B, F, A]}) -> message_to_string({callback_missing, [B, F, A]}) ->
@ -274,26 +274,26 @@ call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet,
true -> true ->
%% We do not know which argument(s) caused the failure %% We do not know which argument(s) caused the failure
fmt("~!^will never return since the success typing arguments" fmt("~!^will never return since the success typing arguments"
" are ~!! ~s", [SigArgs]);
" are ~!!~ts", [SigArgs]);
false -> false ->
fmt("~!^will never return since it differs in the~!!" fmt("~!^will never return since it differs in the~!!"
" ~s ~!^argument from the success typing"
" arguments:~!! ~s",
" ~ts ~!^argument from the success typing"
" arguments:~!! ~ts",
[PositionString, good_arg(ArgNs, SigArgs)]) [PositionString, good_arg(ArgNs, SigArgs)])
end; end;
only_contract -> only_contract ->
case (ArgNs =:= []) orelse IsOverloaded of case (ArgNs =:= []) orelse IsOverloaded of
true -> true ->
%% We do not know which arguments caused the failure %% We do not know which arguments caused the failure
fmt("~!^breaks the contract~!! ~s", [good_arg(ArgNs, Contract)]);
fmt("~!^breaks the contract~!! ~ts", [good_arg(ArgNs, Contract)]);
false -> false ->
fmt("~!^breaks the contract~!! ~s ~!^in the~!!"
" ~s ~!^argument",
fmt("~!^breaks the contract~!! ~ts ~!^in the~!!"
" ~ts ~!^argument",
[good_arg(ArgNs, Contract), PositionString]) [good_arg(ArgNs, Contract), PositionString])
end; end;
both -> both ->
fmt("~!^will never return since the success typing is " fmt("~!^will never return since the success typing is "
"~!! ~s ~!^->~!! ~s ~!^and the contract is ~!! ~s",
"~!!~ts ~!^->~!! ~ts ~!^and the contract is ~!!~ts",
[good_arg(ArgNs, SigArgs), SigRet, [good_arg(ArgNs, SigArgs), SigRet,
good_arg(ArgNs, Contract)]) good_arg(ArgNs, Contract)])
end. end.
@ -301,8 +301,8 @@ call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet,
form_positions(ArgNs) -> form_positions(ArgNs) ->
ArgS = form_position_string(ArgNs), ArgS = form_position_string(ArgNs),
case ArgNs of case ArgNs of
[_] -> fmt("~!^an opaque term as ~!! ~s~!^ argument", [ArgS]);
[_,_|_] -> fmt("~!^opaque terms as ~!! ~s~!^ arguments", [ArgS])
[_] -> fmt("~!^an opaque term as ~!!~ts~!^ argument", [ArgS]);
[_,_|_] -> fmt("~!^opaque terms as ~!!~ts~!^ arguments", [ArgS])
end. end.
%% We know which positions N are to blame; %% We know which positions N are to blame;
@ -310,9 +310,9 @@ form_positions(ArgNs) ->
form_expected_without_opaque([{N, T, TStr}]) -> form_expected_without_opaque([{N, T, TStr}]) ->
FStr = case erl_types:t_is_opaque(T) of FStr = case erl_types:t_is_opaque(T) of
true -> true ->
"~!^an opaque term of type~!g ~s ~!^as ";
"~!^an opaque term of type~!g ~ts ~!^as ";
false -> false ->
"~!^a term of type ~!g ~s ~!^(with opaque subterms) as "
"~!^a term of type ~!g~ts ~!^(with opaque subterms) as "
end ++ form_position_string([N]) ++ "~!^ argument", end ++ form_position_string([N]) ++ "~!^ argument",
fmt(FStr, [TStr]); fmt(FStr, [TStr]);
@ -325,9 +325,9 @@ form_expected(ExpectedArgs) ->
[T] -> [T] ->
TS = erl_types:t_to_string(T), TS = erl_types:t_to_string(T),
case erl_types:t_is_opaque(T) of case erl_types:t_is_opaque(T) of
true -> fmt("~!^an opaque term of type ~!! ~s~!^ is"
true -> fmt("~!^an opaque term of type ~!!~ts~!^ is"
" expected", [TS]); " expected", [TS]);
false -> fmt("~!^a structured term of type ~!! ~s~!^ is"
false -> fmt("~!^a structured term of type ~!!~ts~!^ is"
" expected", [TS]) " expected", [TS])
end; end;
[_,_|_] -> fmt("~!^terms of different types are expected in these" [_,_|_] -> fmt("~!^terms of different types are expected in these"
@ -340,7 +340,7 @@ form_position_string(ArgNs) ->
[N1] -> ordinal(N1); [N1] -> ordinal(N1);
[_,_|_] -> [_,_|_] ->
[Last|Prevs] = lists:reverse(ArgNs), [Last|Prevs] = lists:reverse(ArgNs),
", " ++ Head = lists:flatten([fmt(", ~s",[ordinal(N)]) ||
", " ++ Head = lists:flatten([fmt(", ~ts",[ordinal(N)]) ||
N <- lists:reverse(Prevs)]), N <- lists:reverse(Prevs)]),
Head ++ " and " ++ ordinal(Last) Head ++ " and " ++ ordinal(Last)
end. end.
@ -352,11 +352,11 @@ ordinal(N) when is_integer(N) -> fmt("~!B~w~!!th", [N]).
%% Format a pattern ad highlight errorous part in red. %% Format a pattern ad highlight errorous part in red.
bad_pat("pattern " ++ P) -> bad_pat("pattern " ++ P) ->
fmt("pattern ~!r ~s",[P]);
fmt("pattern ~!r~ts",[P]);
bad_pat("variable " ++ P) -> bad_pat("variable " ++ P) ->
fmt("variable ~!r ~s",[P]);
fmt("variable ~!r~ts",[P]);
bad_pat(P) -> bad_pat(P) ->
fmt("~!r ~s",[P]).
fmt("~!r~ts",[P]).
bad_arg(N, Args) -> bad_arg(N, Args) ->
@ -378,10 +378,10 @@ highlight([], _N, _C, Rest) ->
Rest; Rest;
highlight([N | Nr], N, g, [Arg | Rest]) -> highlight([N | Nr], N, g, [Arg | Rest]) ->
[fmt("~!g ~s", [Arg]) | highlight(Nr, N+1, g, Rest)];
[fmt("~!g~ts", [Arg]) | highlight(Nr, N+1, g, Rest)];
highlight([N | Nr], N, r, [Arg | Rest]) -> highlight([N | Nr], N, r, [Arg | Rest]) ->
[fmt("~!r ~s", [Arg]) | highlight(Nr, N+1, r, Rest)];
[fmt("~!r~ts", [Arg]) | highlight(Nr, N+1, r, Rest)];
highlight(Ns, N, C, [Arg | Rest]) -> highlight(Ns, N, C, [Arg | Rest]) ->
[Arg | highlight(Ns, N + 1, C, Rest)]. [Arg | highlight(Ns, N + 1, C, Rest)].

+ 2
- 2
src/rebar_digraph.erl View File

@ -53,9 +53,9 @@ add(Graph, {PkgName, Deps}) ->
lists:foreach(fun(DepName) -> lists:foreach(fun(DepName) ->
Name1 = case DepName of Name1 = case DepName of
{Name, _Vsn} -> {Name, _Vsn} ->
ec_cnv:to_binary(Name);
rebar_utils:to_binary(Name);
Name -> Name ->
ec_cnv:to_binary(Name)
rebar_utils:to_binary(Name)
end, end,
V3 = case digraph:vertex(Graph, Name1) of V3 = case digraph:vertex(Graph, Name1) of
false -> false ->

+ 2
- 2
src/rebar_dir.erl View File

@ -41,7 +41,7 @@ base_dir(State) ->
%% of profiles. %% of profiles.
-spec profile_dir(rebar_dict(), [atom()]) -> file:filename_all(). -spec profile_dir(rebar_dict(), [atom()]) -> file:filename_all().
profile_dir(Opts, Profiles) -> profile_dir(Opts, Profiles) ->
{BaseDir, ProfilesStrings} = case [ec_cnv:to_list(P) || P <- Profiles] of
{BaseDir, ProfilesStrings} = case [rebar_utils:to_list(P) || P <- Profiles] of
["global" | _] -> {?MODULE:global_cache_dir(Opts), [""]}; ["global" | _] -> {?MODULE:global_cache_dir(Opts), [""]};
["bootstrap", "default"] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), ["default"]}; ["bootstrap", "default"] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), ["default"]};
["default"] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), ["default"]}; ["default"] -> {rebar_opts:get(Opts, base_dir, ?DEFAULT_BASE_DIR), ["default"]};
@ -363,7 +363,7 @@ warn_source_format_once(Format) ->
ok; ok;
true -> true ->
?WARN("Invalid argument ~p for compiler_source_format - " ?WARN("Invalid argument ~p for compiler_source_format - "
"assuming ~s~n", [Format, ?DEFAULT_COMPILER_SOURCE_FORMAT])
"assuming ~ts~n", [Format, ?DEFAULT_COMPILER_SOURCE_FORMAT])
end. end.
%% @private takes a filename and canonicalizes its path if it is a link. %% @private takes a filename and canonicalizes its path if it is a link.

+ 5
- 5
src/rebar_erlc_compiler.erl View File

@ -92,7 +92,7 @@ compile(AppInfo) when element(1, AppInfo) == app_info_t ->
%% @doc compile an individual application. %% @doc compile an individual application.
-spec compile(rebar_app_info:t(), compile_opts()) -> ok. -spec compile(rebar_app_info:t(), compile_opts()) -> ok.
compile(AppInfo, CompileOpts) when element(1, AppInfo) == app_info_t -> compile(AppInfo, CompileOpts) when element(1, AppInfo) == app_info_t ->
Dir = ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)),
Dir = rebar_utils:to_list(rebar_app_info:out_dir(AppInfo)),
RebarOpts = rebar_app_info:opts(AppInfo), RebarOpts = rebar_app_info:opts(AppInfo),
SrcOpts = [check_last_mod, SrcOpts = [check_last_mod,
@ -237,8 +237,8 @@ clean(AppInfo) ->
YrlFiles = rebar_utils:find_files(filename:join([AppDir, "src"]), ?RE_PREFIX".*\\.[x|y]rl\$"), YrlFiles = rebar_utils:find_files(filename:join([AppDir, "src"]), ?RE_PREFIX".*\\.[x|y]rl\$"),
rebar_file_utils:delete_each( rebar_file_utils:delete_each(
[ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
|| F <- YrlFiles ]),
[rebar_utils:to_list(re:replace(F, "\\.[x|y]rl$", ".erl", [unicode]))
|| F <- YrlFiles]),
BinDirs = ["ebin"|rebar_dir:extra_src_dirs(rebar_app_info:opts(AppInfo))], BinDirs = ["ebin"|rebar_dir:extra_src_dirs(rebar_app_info:opts(AppInfo))],
ok = clean_dirs(AppDir, BinDirs), ok = clean_dirs(AppDir, BinDirs),
@ -339,7 +339,7 @@ maybe_rm_beam_and_edge(G, OutDir, Source) ->
false; false;
false -> false ->
Target = target_base(OutDir, Source) ++ ".beam", Target = target_base(OutDir, Source) ++ ".beam",
?DEBUG("Source ~s is gone, deleting previous beam file if it exists ~s", [Source, Target]),
?DEBUG("Source ~ts is gone, deleting previous beam file if it exists ~ts", [Source, Target]),
file:delete(Target), file:delete(Target),
digraph:del_vertex(G, Source), digraph:del_vertex(G, Source),
true true
@ -400,7 +400,7 @@ init_erlcinfo(InclDirs, Erls, Dir, OutDir) ->
try restore_erlcinfo(G, InclDirs, Dir) try restore_erlcinfo(G, InclDirs, Dir)
catch catch
_:_ -> _:_ ->
?WARN("Failed to restore ~s file. Discarding it.~n", [erlcinfo_file(Dir)]),
?WARN("Failed to restore ~ts file. Discarding it.~n", [erlcinfo_file(Dir)]),
file:delete(erlcinfo_file(Dir)) file:delete(erlcinfo_file(Dir))
end, end,
Dirs = source_and_include_dirs(InclDirs, Erls), Dirs = source_and_include_dirs(InclDirs, Erls),

+ 10
- 10
src/rebar_fetch.erl View File

@ -41,7 +41,7 @@ download_source_(AppDir, Source, State) ->
Resources = rebar_state:resources(State), Resources = rebar_state:resources(State),
Module = get_resource_type(Source, Resources), Module = get_resource_type(Source, Resources),
TmpDir = ec_file:insecure_mkdtemp(), TmpDir = ec_file:insecure_mkdtemp(),
AppDir1 = ec_cnv:to_list(AppDir),
AppDir1 = rebar_utils:to_list(AppDir),
case Module:download(TmpDir, Source, State) of case Module:download(TmpDir, Source, State) of
{ok, _} -> {ok, _} ->
ec_file:mkdir_p(AppDir1), ec_file:mkdir_p(AppDir1),
@ -66,25 +66,25 @@ needs_update(AppDir, Source, State) ->
end. end.
format_error({bad_download, CachePath}) -> format_error({bad_download, CachePath}) ->
io_lib:format("Download of package does not match md5sum from server: ~s", [CachePath]);
io_lib:format("Download of package does not match md5sum from server: ~ts", [CachePath]);
format_error({unexpected_hash, CachePath, Expected, Found}) -> format_error({unexpected_hash, CachePath, Expected, Found}) ->
io_lib:format("The checksum for package at ~s ( ~s) does not match the "
"checksum previously locked ( ~s). Either unlock or "
io_lib:format("The checksum for package at ~ts (~ts) does not match the "
"checksum previously locked (~ts). Either unlock or "
"upgrade the package, or make sure you fetched it from " "upgrade the package, or make sure you fetched it from "
"the same index from which it was initially fetched.", "the same index from which it was initially fetched.",
[CachePath, Found, Expected]); [CachePath, Found, Expected]);
format_error({failed_extract, CachePath}) -> format_error({failed_extract, CachePath}) ->
io_lib:format("Failed to extract package: ~s", [CachePath]);
io_lib:format("Failed to extract package: ~ts", [CachePath]);
format_error({bad_etag, Source}) -> format_error({bad_etag, Source}) ->
io_lib:format("MD5 Checksum comparison failed for: ~s", [Source]);
io_lib:format("MD5 Checksum comparison failed for: ~ts", [Source]);
format_error({fetch_fail, Name, Vsn}) -> format_error({fetch_fail, Name, Vsn}) ->
io_lib:format("Failed to fetch and copy dep: ~s- ~s", [Name, Vsn]);
io_lib:format("Failed to fetch and copy dep: ~ts-~ts", [Name, Vsn]);
format_error({fetch_fail, Source}) -> format_error({fetch_fail, Source}) ->
io_lib:format("Failed to fetch and copy dep: ~p", [Source]); io_lib:format("Failed to fetch and copy dep: ~p", [Source]);
format_error({bad_checksum, File}) -> format_error({bad_checksum, File}) ->
io_lib:format("Checksum mismatch against tarball in ~s", [File]);
io_lib:format("Checksum mismatch against tarball in ~ts", [File]);
format_error({bad_registry_checksum, File}) -> format_error({bad_registry_checksum, File}) ->
io_lib:format("Checksum mismatch against registry in ~s", [File]).
io_lib:format("Checksum mismatch against registry in ~ts", [File]).
get_resource_type({Type, Location}, Resources) -> get_resource_type({Type, Location}, Resources) ->
find_resource_module(Type, Location, Resources); find_resource_module(Type, Location, Resources);
@ -100,7 +100,7 @@ find_resource_module(Type, Location, Resources) ->
false -> false ->
case code:which(Type) of case code:which(Type) of
non_existing -> non_existing ->
{error, io_lib:format("Cannot handle dependency ~s.~n"
{error, io_lib:format("Cannot handle dependency ~ts.~n"
" No module for resource type ~p", [Location, Type])}; " No module for resource type ~p", [Location, Type])};
_ -> _ ->
Type Type

+ 26
- 19
src/rebar_file_utils.erl View File

@ -84,7 +84,7 @@ consult_config(State, Filename) ->
[JoinedConfig]. [JoinedConfig].
format_error({bad_term_file, AppFile, Reason}) -> format_error({bad_term_file, AppFile, Reason}) ->
io_lib:format("Error reading file ~s: ~s", [AppFile, file:format_error(Reason)]).
io_lib:format("Error reading file ~ts: ~ts", [AppFile, file:format_error(Reason)]).
symlink_or_copy(Source, Target) -> symlink_or_copy(Source, Target) ->
Link = case os:type() of Link = case os:type() of
@ -121,7 +121,7 @@ symlink_or_copy(Source, Target) ->
win32_symlink(Source, Target) -> win32_symlink(Source, Target) ->
Res = rebar_utils:sh( Res = rebar_utils:sh(
?FMT("cmd /c mklink /j \" ~s\" \" ~s\"",
?FMT("cmd /c mklink /j \"~ts\" \"~ts\"",
[rebar_utils:escape_double_quotes(filename:nativename(Target)), [rebar_utils:escape_double_quotes(filename:nativename(Target)),
rebar_utils:escape_double_quotes(filename:nativename(Source))]), rebar_utils:escape_double_quotes(filename:nativename(Source))]),
[{use_stdout, false}, return_on_error]), [{use_stdout, false}, return_on_error]),
@ -129,7 +129,7 @@ win32_symlink(Source, Target) ->
true -> ok; true -> ok;
false -> false ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to symlink ~s to ~s~n",
io_lib:format("Failed to symlink ~ts to ~ts~n",
[Source, Target]))} [Source, Target]))}
end. end.
@ -141,7 +141,7 @@ rm_rf(Target) ->
case os:type() of case os:type() of
{unix, _} -> {unix, _} ->
EscTarget = rebar_utils:escape_chars(Target), EscTarget = rebar_utils:escape_chars(Target),
{ok, []} = rebar_utils:sh(?FMT("rm -rf ~s", [EscTarget]),
{ok, []} = rebar_utils:sh(?FMT("rm -rf ~ts", [EscTarget]),
[{use_stdout, false}, abort_on_error]), [{use_stdout, false}, abort_on_error]),
ok; ok;
{win32, _} -> {win32, _} ->
@ -161,7 +161,7 @@ cp_r(Sources, Dest) ->
{unix, _} -> {unix, _} ->
EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources], EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources],
SourceStr = string:join(EscSources, " "), SourceStr = string:join(EscSources, " "),
{ok, []} = rebar_utils:sh(?FMT("cp -Rp ~s \" ~s\"",
{ok, []} = rebar_utils:sh(?FMT("cp -Rp ~ts \"~ts\"",
[SourceStr, rebar_utils:escape_double_quotes(Dest)]), [SourceStr, rebar_utils:escape_double_quotes(Dest)]),
[{use_stdout, false}, abort_on_error]), [{use_stdout, false}, abort_on_error]),
ok; ok;
@ -176,7 +176,7 @@ mv(Source, Dest) ->
{unix, _} -> {unix, _} ->
EscSource = rebar_utils:escape_chars(Source), EscSource = rebar_utils:escape_chars(Source),
EscDest = rebar_utils:escape_chars(Dest), EscDest = rebar_utils:escape_chars(Dest),
case rebar_utils:sh(?FMT("mv ~s ~s", [EscSource, EscDest]),
case rebar_utils:sh(?FMT("mv ~ts ~ts", [EscSource, EscDest]),
[{use_stdout, false}, abort_on_error]) of [{use_stdout, false}, abort_on_error]) of
{ok, []} -> {ok, []} ->
ok; ok;
@ -234,7 +234,7 @@ robocopy_mv_and_rename(Source, Dest, SrcDir, SrcName, DestDir, DestName) ->
case ec_file:insecure_mkdtemp() of case ec_file:insecure_mkdtemp() of
{error, _Reason} -> {error, _Reason} ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to move ~s to ~s (tmpdir failed)~n",
io_lib:format("Failed to move ~ts to ~ts (tmpdir failed)~n",
[Source, Dest]))}; [Source, Dest]))};
TmpPath -> TmpPath ->
case robocopy_file(SrcDir, TmpPath, SrcName) of case robocopy_file(SrcDir, TmpPath, SrcName) of
@ -246,7 +246,7 @@ robocopy_mv_and_rename(Source, Dest, SrcDir, SrcName, DestDir, DestName) ->
case file:rename(TmpSrc, TmpDst) of case file:rename(TmpSrc, TmpDst) of
{error, _} -> {error, _} ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to move ~s to ~s (via rename)~n",
io_lib:format("Failed to move ~ts to ~ts (via rename)~n",
[Source, Dest]))}; [Source, Dest]))};
ok -> ok ->
case robocopy_file(TmpPath, DestDir, DestName) of case robocopy_file(TmpPath, DestDir, DestName) of
@ -258,7 +258,7 @@ robocopy_mv_and_rename(Source, Dest, SrcDir, SrcName, DestDir, DestName) ->
end. end.
robocopy_file(SrcPath, DestPath, FileName) -> robocopy_file(SrcPath, DestPath, FileName) ->
Cmd = ?FMT("robocopy /move /e \" ~s\" \" ~s\" \" ~s\"",
Cmd = ?FMT("robocopy /move /e \"~ts\" \"~ts\" \"~ts\"",
[rebar_utils:escape_double_quotes(SrcPath), [rebar_utils:escape_double_quotes(SrcPath),
rebar_utils:escape_double_quotes(DestPath), rebar_utils:escape_double_quotes(DestPath),
rebar_utils:escape_double_quotes(FileName)]), rebar_utils:escape_double_quotes(FileName)]),
@ -266,7 +266,7 @@ robocopy_file(SrcPath, DestPath, FileName) ->
case win32_ok(Res) of case win32_ok(Res) of
false -> false ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to move ~s to ~s~n",
io_lib:format("Failed to move ~ts to ~ts~n",
[filename:join(SrcPath, FileName), [filename:join(SrcPath, FileName),
filename:join(DestPath, FileName)]))}; filename:join(DestPath, FileName)]))};
true -> true ->
@ -274,7 +274,7 @@ robocopy_file(SrcPath, DestPath, FileName) ->
end. end.
robocopy_dir(Source, Dest) -> robocopy_dir(Source, Dest) ->
Cmd = ?FMT("robocopy /move /e \" ~s\" \" ~s\"",
Cmd = ?FMT("robocopy /move /e \"~ts\" \"~ts\"",
[rebar_utils:escape_double_quotes(Source), [rebar_utils:escape_double_quotes(Source),
rebar_utils:escape_double_quotes(Dest)]), rebar_utils:escape_double_quotes(Dest)]),
Res = rebar_utils:sh(Cmd, Res = rebar_utils:sh(Cmd,
@ -283,7 +283,7 @@ robocopy_dir(Source, Dest) ->
true -> ok; true -> ok;
false -> false ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to move ~s to ~s~n",
io_lib:format("Failed to move ~ts to ~ts~n",
[Source, Dest]))} [Source, Dest]))}
end. end.
@ -301,12 +301,19 @@ delete_each([File | Rest]) ->
{error, enoent} -> {error, enoent} ->
delete_each(Rest); delete_each(Rest);
{error, Reason} -> {error, Reason} ->
?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
?ERROR("Failed to delete file ~ts: ~p\n", [File, Reason]),
?FAIL ?FAIL
end. end.
write_file_if_contents_differ(Filename, Bytes) -> write_file_if_contents_differ(Filename, Bytes) ->
ToWrite = iolist_to_binary(Bytes),
%% first try to convert directly to binaries,
%% but if it fails, we likely contain unicode and
%% need special treatment
ToWrite = try
iolist_to_binary(Bytes)
catch
error:badarg -> unicode:characters_to_binary(Bytes)
end,
case file:read_file(Filename) of case file:read_file(Filename) of
{ok, ToWrite} -> {ok, ToWrite} ->
ok; ok;
@ -401,13 +408,13 @@ split_dirname(Path) ->
delete_each_dir_win32([]) -> ok; delete_each_dir_win32([]) -> ok;
delete_each_dir_win32([Dir | Rest]) -> delete_each_dir_win32([Dir | Rest]) ->
{ok, []} = rebar_utils:sh(?FMT("rd /q /s \" ~s\"",
{ok, []} = rebar_utils:sh(?FMT("rd /q /s \"~ts\"",
[rebar_utils:escape_double_quotes(filename:nativename(Dir))]), [rebar_utils:escape_double_quotes(filename:nativename(Dir))]),
[{use_stdout, false}, return_on_error]), [{use_stdout, false}, return_on_error]),
delete_each_dir_win32(Rest). delete_each_dir_win32(Rest).
xcopy_win32(Source,Dest)-> xcopy_win32(Source,Dest)->
%% "xcopy \" ~s\" \" ~s\" /q /y /e 2> nul", Changed to robocopy to
%% "xcopy \"~ts\" \"~ts\" /q /y /e 2> nul", Changed to robocopy to
%% handle long names. May have issues with older windows. %% handle long names. May have issues with older windows.
Cmd = case filelib:is_dir(Source) of Cmd = case filelib:is_dir(Source) of
true -> true ->
@ -417,11 +424,11 @@ xcopy_win32(Source,Dest)->
%% must manually add the last fragment of a directory to the `Dest` %% must manually add the last fragment of a directory to the `Dest`
%% in order to properly replicate POSIX platforms %% in order to properly replicate POSIX platforms
NewDest = filename:join([Dest, filename:basename(Source)]), NewDest = filename:join([Dest, filename:basename(Source)]),
?FMT("robocopy \" ~s\" \" ~s\" /e /is 1> nul",
?FMT("robocopy \"~ts\" \"~ts\" /e /is 1> nul",
[rebar_utils:escape_double_quotes(filename:nativename(Source)), [rebar_utils:escape_double_quotes(filename:nativename(Source)),
rebar_utils:escape_double_quotes(filename:nativename(NewDest))]); rebar_utils:escape_double_quotes(filename:nativename(NewDest))]);
false -> false ->
?FMT("robocopy \" ~s\" \" ~s\" \" ~s\" /e /is 1> nul",
?FMT("robocopy \"~ts\" \"~ts\" \"~ts\" /e /is 1> nul",
[rebar_utils:escape_double_quotes(filename:nativename(filename:dirname(Source))), [rebar_utils:escape_double_quotes(filename:nativename(filename:dirname(Source))),
rebar_utils:escape_double_quotes(filename:nativename(Dest)), rebar_utils:escape_double_quotes(filename:nativename(Dest)),
rebar_utils:escape_double_quotes(filename:basename(Source))]) rebar_utils:escape_double_quotes(filename:basename(Source))])
@ -432,7 +439,7 @@ xcopy_win32(Source,Dest)->
true -> ok; true -> ok;
false -> false ->
{error, lists:flatten( {error, lists:flatten(
io_lib:format("Failed to copy ~s to ~s~n",
io_lib:format("Failed to copy ~ts to ~ts~n",
[Source, Dest]))} [Source, Dest]))}
end. end.

+ 23
- 24
src/rebar_git_resource.erl View File

@ -17,7 +17,7 @@
lock(AppDir, {git, Url, _}) -> lock(AppDir, {git, Url, _}) ->
lock(AppDir, {git, Url}); lock(AppDir, {git, Url});
lock(AppDir, {git, Url}) -> lock(AppDir, {git, Url}) ->
AbortMsg = lists:flatten(io_lib:format("Locking of git dependency failed in ~s", [AppDir])),
AbortMsg = lists:flatten(io_lib:format("Locking of git dependency failed in ~ts", [AppDir])),
Dir = rebar_utils:escape_double_quotes(AppDir), Dir = rebar_utils:escape_double_quotes(AppDir),
{ok, VsnString} = {ok, VsnString} =
case os:type() of case os:type() of
@ -38,17 +38,17 @@ needs_update(Dir, {git, Url, {tag, Tag}}) ->
[{cd, Dir}]), [{cd, Dir}]),
Current1 = string:strip(string:strip(Current, both, $\n), both, $\r), Current1 = string:strip(string:strip(Current, both, $\n), both, $\r),
?DEBUG("Comparing git tag ~s with ~s", [Tag, Current1]),
?DEBUG("Comparing git tag ~ts with ~ts", [Tag, Current1]),
not ((Current1 =:= Tag) andalso compare_url(Dir, Url)); not ((Current1 =:= Tag) andalso compare_url(Dir, Url));
needs_update(Dir, {git, Url, {branch, Branch}}) -> needs_update(Dir, {git, Url, {branch, Branch}}) ->
%% Fetch remote so we can check if the branch has changed %% Fetch remote so we can check if the branch has changed
SafeBranch = rebar_utils:escape_chars(Branch), SafeBranch = rebar_utils:escape_chars(Branch),
{ok, _} = rebar_utils:sh(?FMT("git fetch origin ~s", [SafeBranch]),
{ok, _} = rebar_utils:sh(?FMT("git fetch origin ~ts", [SafeBranch]),
[{cd, Dir}]), [{cd, Dir}]),
%% Check for new commits to origin/Branch %% Check for new commits to origin/Branch
{ok, Current} = rebar_utils:sh(?FMT("git log HEAD..origin/ ~s --oneline", [SafeBranch]),
{ok, Current} = rebar_utils:sh(?FMT("git log HEAD..origin/~ts --oneline", [SafeBranch]),
[{cd, Dir}]), [{cd, Dir}]),
?DEBUG("Checking git branch ~s for updates", [Branch]),
?DEBUG("Checking git branch ~ts for updates", [Branch]),
not ((Current =:= []) andalso compare_url(Dir, Url)); not ((Current =:= []) andalso compare_url(Dir, Url));
needs_update(Dir, {git, Url, "master"}) -> needs_update(Dir, {git, Url, "master"}) ->
needs_update(Dir, {git, Url, {branch, "master"}}); needs_update(Dir, {git, Url, {branch, "master"}});
@ -68,7 +68,7 @@ needs_update(Dir, {git, _, Ref}) ->
Ref Ref
end, end,
?DEBUG("Comparing git ref ~s with ~s", [Ref2, Current1]),
?DEBUG("Comparing git ref ~ts with ~ts", [Ref2, Current1]),
(Current1 =/= Ref2). (Current1 =/= Ref2).
compare_url(Dir, Url) -> compare_url(Dir, Url) ->
@ -82,7 +82,7 @@ compare_url(Dir, Url) ->
parse_git_url(Url) -> parse_git_url(Url) ->
%% Checks for standard scp style git remote %% Checks for standard scp style git remote
case re:run(Url, ?SCP_PATTERN, [{capture, [host, path], list}]) of
case re:run(Url, ?SCP_PATTERN, [{capture, [host, path], list}, unicode]) of
{match, [Host, Path]} -> {match, [Host, Path]} ->
{ok, {Host, filename:rootname(Path, ".git")}}; {ok, {Host, filename:rootname(Path, ".git")}};
nomatch -> nomatch ->
@ -119,41 +119,41 @@ download(Dir, {git, Url, Rev}, _State) ->
%% Use different git clone commands depending on git --version %% Use different git clone commands depending on git --version
git_clone(branch,Vsn,Url,Dir,Branch) when Vsn >= {1,7,10}; Vsn =:= undefined -> git_clone(branch,Vsn,Url,Dir,Branch) when Vsn >= {1,7,10}; Vsn =:= undefined ->
rebar_utils:sh(?FMT("git clone ~s ~s -b ~s --single-branch",
rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)), rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]), rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
git_clone(branch,_Vsn,Url,Dir,Branch) -> git_clone(branch,_Vsn,Url,Dir,Branch) ->
rebar_utils:sh(?FMT("git clone ~s ~s -b ~s",
rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)), rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Branch)]), rebar_utils:escape_chars(Branch)]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
git_clone(tag,Vsn,Url,Dir,Tag) when Vsn >= {1,7,10}; Vsn =:= undefined -> git_clone(tag,Vsn,Url,Dir,Tag) when Vsn >= {1,7,10}; Vsn =:= undefined ->
rebar_utils:sh(?FMT("git clone ~s ~s -b ~s --single-branch",
rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts --single-branch",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)), rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]), rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
git_clone(tag,_Vsn,Url,Dir,Tag) -> git_clone(tag,_Vsn,Url,Dir,Tag) ->
rebar_utils:sh(?FMT("git clone ~s ~s -b ~s",
rebar_utils:sh(?FMT("git clone ~ts ~ts -b ~ts",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir)), rebar_utils:escape_chars(filename:basename(Dir)),
rebar_utils:escape_chars(Tag)]), rebar_utils:escape_chars(Tag)]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
git_clone(ref,_Vsn,Url,Dir,Ref) -> git_clone(ref,_Vsn,Url,Dir,Ref) ->
rebar_utils:sh(?FMT("git clone -n ~s ~s",
rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]), [{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~s", [Ref]), [{cd, Dir}]);
rebar_utils:sh(?FMT("git checkout -q ~ts", [Ref]), [{cd, Dir}]);
git_clone(rev,_Vsn,Url,Dir,Rev) -> git_clone(rev,_Vsn,Url,Dir,Rev) ->
rebar_utils:sh(?FMT("git clone -n ~s ~s",
rebar_utils:sh(?FMT("git clone -n ~ts ~ts",
[rebar_utils:escape_chars(Url), [rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]), [{cd, filename:dirname(Dir)}]),
rebar_utils:sh(?FMT("git checkout -q ~s", [rebar_utils:escape_chars(Rev)]),
rebar_utils:sh(?FMT("git checkout -q ~ts", [rebar_utils:escape_chars(Rev)]),
[{cd, Dir}]). [{cd, Dir}]).
git_vsn() -> git_vsn() ->
@ -168,7 +168,7 @@ git_vsn() ->
git_vsn_fetch() -> git_vsn_fetch() ->
case rebar_utils:sh("git --version",[]) of case rebar_utils:sh("git --version",[]) of
{ok, VsnStr} -> {ok, VsnStr} ->
case re:run(VsnStr, "git version\\h+(\\d)\\.(\\d)\\.(\\d).*",[{capture,[1,2,3],list}]) of
case re:run(VsnStr, "git version\\h+(\\d)\\.(\\d)\\.(\\d).*", [{capture,[1,2,3],list}, unicode]) of
{match,[Maj,Min,Patch]} -> {match,[Maj,Min,Patch]} ->
{list_to_integer(Maj), {list_to_integer(Maj),
list_to_integer(Min), list_to_integer(Min),
@ -198,7 +198,7 @@ collect_default_refcount(Dir) ->
return_on_error, return_on_error,
{cd, Dir}]) of {cd, Dir}]) of
{error, _} -> {error, _} ->
?WARN("Getting log of git dependency failed in ~s. Falling back to version 0.0.0", [rebar_dir:get_cwd()]),
?WARN("Getting log of git dependency failed in ~ts. Falling back to version 0.0.0", [rebar_dir:get_cwd()]),
{plain, "0.0.0"}; {plain, "0.0.0"};
{ok, String} -> {ok, String} ->
RawRef = string:strip(String, both, $\n), RawRef = string:strip(String, both, $\n),
@ -222,21 +222,20 @@ collect_default_refcount(Dir) ->
build_vsn_string(Vsn, RawRef, Count) -> build_vsn_string(Vsn, RawRef, Count) ->
%% Cleanup the tag and the Ref information. Basically leading 'v's and %% Cleanup the tag and the Ref information. Basically leading 'v's and
%% whitespace needs to go away. %% whitespace needs to go away.
RefTag = [".ref", re:replace(RawRef, "\\s", "", [global])],
RefTag = [".ref", re:replace(RawRef, "\\s", "", [global, unicode])],
%% Create the valid [semver](http://semver.org) version from the tag %% Create the valid [semver](http://semver.org) version from the tag
case Count of case Count of
0 -> 0 ->
erlang:binary_to_list(erlang:iolist_to_binary(Vsn));
rebar_utils:to_list(Vsn);
_ -> _ ->
erlang:binary_to_list(erlang:iolist_to_binary([Vsn, "+build.",
integer_to_list(Count), RefTag]))
rebar_utils:to_list([Vsn, "+build.", integer_to_list(Count), RefTag])
end. end.
get_patch_count(Dir, RawRef) -> get_patch_count(Dir, RawRef) ->
AbortMsg = "Getting rev-list of git dep failed in " ++ Dir, AbortMsg = "Getting rev-list of git dep failed in " ++ Dir,
Ref = re:replace(RawRef, "\\s", "", [global]),
Cmd = io_lib:format("git rev-list ~s..HEAD",
Ref = re:replace(RawRef, "\\s", "", [global, unicode]),
Cmd = io_lib:format("git rev-list ~ts..HEAD",
[rebar_utils:escape_chars(Ref)]), [rebar_utils:escape_chars(Ref)]),
{ok, PatchLines} = rebar_utils:sh(Cmd, {ok, PatchLines} = rebar_utils:sh(Cmd,
[{use_stdout, false}, [{use_stdout, false},
@ -252,7 +251,7 @@ parse_tags(Dir) ->
{error, _} -> {error, _} ->
{undefined, "0.0.0"}; {undefined, "0.0.0"};
{ok, Line} -> {ok, Line} ->
case re:run(Line, "(\\(|\\s)(HEAD[^,]*,\\s)tag:\\s(v?([^,\\)]+))", [{capture, [3, 4], list}]) of
case re:run(Line, "(\\(|\\s)(HEAD[^,]*,\\s)tag:\\s(v?([^,\\)]+))", [{capture, [3, 4], list}, unicode]) of
{match,[Tag, Vsn]} -> {match,[Tag, Vsn]} ->
{Tag, Vsn}; {Tag, Vsn};
nomatch -> nomatch ->

+ 12
- 11
src/rebar_hg_resource.erl View File

@ -22,7 +22,7 @@ lock(AppDir, {hg, Url}) ->
needs_update(Dir, {hg, Url, {tag, Tag}}) -> needs_update(Dir, {hg, Url, {tag, Tag}}) ->
Ref = get_ref(Dir), Ref = get_ref(Dir),
{ClosestTag, Distance} = get_tag_distance(Dir, Ref), {ClosestTag, Distance} = get_tag_distance(Dir, Ref),
?DEBUG("Comparing hg tag ~s with ref ~s (closest tag is ~s at distance ~s)",
?DEBUG("Comparing hg tag ~ts with ref ~ts (closest tag is ~ts at distance ~ts)",
[Tag, Ref, ClosestTag, Distance]), [Tag, Ref, ClosestTag, Distance]),
not ((Distance =:= "0") andalso (Tag =:= ClosestTag) not ((Distance =:= "0") andalso (Tag =:= ClosestTag)
andalso compare_url(Dir, Url)); andalso compare_url(Dir, Url));
@ -45,7 +45,7 @@ needs_update(Dir, {hg, Url, Ref}) ->
Ref1 -> Ref1 ->
Ref1 Ref1
end, end,
?DEBUG("Comparing hg ref ~s with ~s", [Ref1, LocalRef]),
?DEBUG("Comparing hg ref ~ts with ~ts", [Ref1, LocalRef]),
not ((LocalRef =:= TargetRef) andalso compare_url(Dir, Url)). not ((LocalRef =:= TargetRef) andalso compare_url(Dir, Url)).
download(Dir, {hg, Url}, State) -> download(Dir, {hg, Url}, State) ->
@ -56,28 +56,28 @@ download(Dir, {hg, Url, ""}, State) ->
download(Dir, {hg, Url, {branch, "default"}}, State); download(Dir, {hg, Url, {branch, "default"}}, State);
download(Dir, {hg, Url, {branch, Branch}}, _State) -> download(Dir, {hg, Url, {branch, Branch}}, _State) ->
ok = filelib:ensure_dir(Dir), ok = filelib:ensure_dir(Dir),
rebar_utils:sh(?FMT("hg clone -q -b ~s ~s ~s",
rebar_utils:sh(?FMT("hg clone -q -b ~ts ~ts ~ts",
[rebar_utils:escape_chars(Branch), [rebar_utils:escape_chars(Branch),
rebar_utils:escape_chars(Url), rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, {tag, Tag}}, _State) -> download(Dir, {hg, Url, {tag, Tag}}, _State) ->
ok = filelib:ensure_dir(Dir), ok = filelib:ensure_dir(Dir),
rebar_utils:sh(?FMT("hg clone -q -u ~s ~s ~s",
rebar_utils:sh(?FMT("hg clone -q -u ~ts ~ts ~ts",
[rebar_utils:escape_chars(Tag), [rebar_utils:escape_chars(Tag),
rebar_utils:escape_chars(Url), rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, {ref, Ref}}, _State) -> download(Dir, {hg, Url, {ref, Ref}}, _State) ->
ok = filelib:ensure_dir(Dir), ok = filelib:ensure_dir(Dir),
rebar_utils:sh(?FMT("hg clone -q -r ~s ~s ~s",
rebar_utils:sh(?FMT("hg clone -q -r ~ts ~ts ~ts",
[rebar_utils:escape_chars(Ref), [rebar_utils:escape_chars(Ref),
rebar_utils:escape_chars(Url), rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
[{cd, filename:dirname(Dir)}]); [{cd, filename:dirname(Dir)}]);
download(Dir, {hg, Url, Rev}, _State) -> download(Dir, {hg, Url, Rev}, _State) ->
ok = filelib:ensure_dir(Dir), ok = filelib:ensure_dir(Dir),
rebar_utils:sh(?FMT("hg clone -q -r ~s ~s ~s",
rebar_utils:sh(?FMT("hg clone -q -r ~ts ~ts ~ts",
[rebar_utils:escape_chars(Rev), [rebar_utils:escape_chars(Rev),
rebar_utils:escape_chars(Url), rebar_utils:escape_chars(Url),
rebar_utils:escape_chars(filename:basename(Dir))]), rebar_utils:escape_chars(filename:basename(Dir))]),
@ -88,7 +88,7 @@ make_vsn(Dir) ->
Ref = get_ref(Dir), Ref = get_ref(Dir),
Cmd = BaseHg ++ "log --template \"{latesttag}+build.{latesttagdistance}.rev.{node|short}\"" Cmd = BaseHg ++ "log --template \"{latesttag}+build.{latesttagdistance}.rev.{node|short}\""
" --rev " ++ Ref, " --rev " ++ Ref,
AbortMsg = io_lib:format("Version resolution of hg dependency failed in ~s", [Dir]),
AbortMsg = io_lib:format("Version resolution of hg dependency failed in ~ts", [Dir]),
{ok, VsnString} = {ok, VsnString} =
rebar_utils:sh(Cmd, rebar_utils:sh(Cmd,
[{use_stdout, false}, {debug_abort_on_error, AbortMsg}]), [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]),
@ -108,14 +108,14 @@ compare_url(Dir, Url) ->
parse_hg_url(CurrentUrl1) =:= parse_hg_url(Url). parse_hg_url(CurrentUrl1) =:= parse_hg_url(Url).
get_ref(Dir) -> get_ref(Dir) ->
AbortMsg = io_lib:format("Get ref of hg dependency failed in ~s", [Dir]),
AbortMsg = io_lib:format("Get ref of hg dependency failed in ~ts", [Dir]),
{ok, RefString} = {ok, RefString} =
rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++ "\" --debug id -i", rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++ "\" --debug id -i",
[{use_stdout, false}, {debug_abort_on_error, AbortMsg}]), [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]),
string:strip(RefString, both, $\n). string:strip(RefString, both, $\n).
get_tag_distance(Dir, Ref) -> get_tag_distance(Dir, Ref) ->
AbortMsg = io_lib:format("Get tag distance of hg dependency failed in ~s", [Dir]),
AbortMsg = io_lib:format("Get tag distance of hg dependency failed in ~ts", [Dir]),
{ok, LogString} = {ok, LogString} =
rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++ "\" " rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++ "\" "
"log --template \"{latesttag}-{latesttagdistance}\n\" " "log --template \"{latesttag}-{latesttagdistance}\n\" "
@ -123,11 +123,12 @@ get_tag_distance(Dir, Ref) ->
[{use_stdout, false}, {debug_abort_on_error, AbortMsg}]), [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]),
Log = string:strip(LogString, Log = string:strip(LogString,
both, $\n), both, $\n),
[Tag, Distance] = re:split(Log, "-([0-9]+)$", [{parts,0}, {return, list}]),
[Tag, Distance] = re:split(Log, "-([0-9]+)$",
[{parts,0}, {return,list}, unicode]),
{Tag, Distance}. {Tag, Distance}.
get_branch_ref(Dir, Branch) -> get_branch_ref(Dir, Branch) ->
AbortMsg = io_lib:format("Get branch ref of hg dependency failed in ~s", [Dir]),
AbortMsg = io_lib:format("Get branch ref of hg dependency failed in ~ts", [Dir]),
{ok, BranchRefString} = {ok, BranchRefString} =
rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++ rebar_utils:sh("hg -R \"" ++ rebar_utils:escape_double_quotes(Dir) ++
"\" log --template \"{node}\n\" --rev " ++ rebar_utils:escape_chars(Branch), "\" log --template \"{node}\n\" --rev " ++ rebar_utils:escape_chars(Branch),

+ 3
- 3
src/rebar_hooks.erl View File

@ -57,9 +57,9 @@ run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) ->
end. end.
format_error({bad_provider, Type, Command, {Name, Namespace}}) -> format_error({bad_provider, Type, Command, {Name, Namespace}}) ->
io_lib:format("Unable to run ~s hooks for '~p', command '~p' in namespace '~p' not found.", [Type, Command, Namespace, Name]);
io_lib:format("Unable to run ~ts hooks for '~p', command '~p' in namespace '~p' not found.", [Type, Command, Namespace, Name]);
format_error({bad_provider, Type, Command, Name}) -> format_error({bad_provider, Type, Command, Name}) ->
io_lib:format("Unable to run ~s hooks for '~p', command '~p' not found.", [Type, Command, Name]).
io_lib:format("Unable to run ~ts hooks for '~p', command '~p' not found.", [Type, Command, Name]).
%% @doc The following environment variables are exported when running %% @doc The following environment variables are exported when running
%% a hook (absolute paths): %% a hook (absolute paths):
@ -143,7 +143,7 @@ join_dirs(BaseDir, Dirs) ->
string:join([ filename:join(BaseDir, Dir) || Dir <- Dirs ], ":"). string:join([ filename:join(BaseDir, Dir) || Dir <- Dirs ], ":").
re_version(Path) -> re_version(Path) ->
case re:run(Path, "^.*-(?<VER>[^/-]*)$", [{capture, [1], list}]) of
case re:run(Path, "^.*-(?<VER>[^/-]*)$", [{capture,[1],list}, unicode]) of
nomatch -> ""; nomatch -> "";
{match, [Ver]} -> Ver {match, [Ver]} -> Ver
end. end.

+ 1
- 1
src/rebar_log.erl View File

@ -94,7 +94,7 @@ get_level() ->
log(Level = error, Str, Args) -> log(Level = error, Str, Args) ->
{ok, LogState} = application:get_env(rebar, log), {ok, LogState} = application:get_env(rebar, log),
ec_cmd_log:Level(LogState, lists:flatten(cf:format("~!^ ~s~n", [Str])), Args);
ec_cmd_log:Level(LogState, lists:flatten(cf:format("~!^~ts~n", [Str])), Args);
log(Level, Str, Args) -> log(Level, Str, Args) ->
{ok, LogState} = application:get_env(rebar, log), {ok, LogState} = application:get_env(rebar, log),
ec_cmd_log:Level(LogState, Str++"~n", Args). ec_cmd_log:Level(LogState, Str++"~n", Args).

+ 4
- 4
src/rebar_otp_app.erl View File

@ -58,11 +58,11 @@ compile(State, App) ->
validate_app(State, App1). validate_app(State, App1).
format_error({missing_app_file, Filename}) -> format_error({missing_app_file, Filename}) ->
io_lib:format("App file is missing: ~s", [Filename]);
io_lib:format("App file is missing: ~ts", [Filename]);
format_error({file_read, File, Reason}) -> format_error({file_read, File, Reason}) ->
io_lib:format("Failed to read required file ~s for processing: ~s", [File, file:format_error(Reason)]);
io_lib:format("Failed to read required file ~ts for processing: ~ts", [File, file:format_error(Reason)]);
format_error({invalid_name, File, AppName}) -> format_error({invalid_name, File, AppName}) ->
io_lib:format("Invalid ~s: name of application (~p) must match filename.", [File, AppName]).
io_lib:format("Invalid ~ts: name of application (~p) must match filename.", [File, AppName]).
%% =================================================================== %% ===================================================================
%% Internal functions %% Internal functions
@ -222,7 +222,7 @@ app_vsn(AppData, AppFile, State) ->
get_value(Key, AppInfo, AppFile) -> get_value(Key, AppInfo, AppFile) ->
case proplists:get_value(Key, AppInfo) of case proplists:get_value(Key, AppInfo) of
undefined -> undefined ->
?ABORT("Failed to get app value '~p' from ' ~s'~n", [Key, AppFile]);
?ABORT("Failed to get app value '~p' from '~ts'~n", [Key, AppFile]);
Value -> Value ->
Value Value
end. end.

+ 6
- 6
src/rebar_packages.erl View File

@ -72,12 +72,12 @@ deps(Name, Vsn, State) ->
deps_(Name, Vsn, State) -> deps_(Name, Vsn, State) ->
?MODULE:verify_table(State), ?MODULE:verify_table(State),
ets:lookup_element(?PACKAGE_TABLE, {ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)}, 2).
ets:lookup_element(?PACKAGE_TABLE, {rebar_utils:to_binary(Name), rebar_utils:to_binary(Vsn)}, 2).
handle_missing_package(Dep, State, Fun) -> handle_missing_package(Dep, State, Fun) ->
case Dep of case Dep of
{Name, Vsn} -> {Name, Vsn} ->
?INFO("Package ~s- ~s not found. Fetching registry updates and trying again...", [Name, Vsn]);
?INFO("Package ~ts-~ts not found. Fetching registry updates and trying again...", [Name, Vsn]);
_ -> _ ->
?INFO("Package ~p not found. Fetching registry updates and trying again...", [Dep]) ?INFO("Package ~p not found. Fetching registry updates and trying again...", [Dep])
end, end,
@ -128,7 +128,7 @@ registry_checksum({pkg, Name, Vsn, _Hash}, State) ->
ets:lookup_element(?PACKAGE_TABLE, {Name, Vsn}, 3) ets:lookup_element(?PACKAGE_TABLE, {Name, Vsn}, 3)
catch catch
_:_ -> _:_ ->
throw(?PRV_ERROR({missing_package, ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)}))
throw(?PRV_ERROR({missing_package, rebar_utils:to_binary(Name), rebar_utils:to_binary(Vsn)}))
end. end.
%% Hex supports use of ~> to specify the version required for a dependency. %% Hex supports use of ~> to specify the version required for a dependency.
@ -207,17 +207,17 @@ handle_single_vsn(Pkg, PkgVsn, Dep, Vsn, Constraint) ->
false -> false ->
case {Pkg, PkgVsn} of case {Pkg, PkgVsn} of
{undefined, undefined} -> {undefined, undefined} ->
?DEBUG("Only existing version of ~s is ~s which does not match constraint ~~> ~s. "
?DEBUG("Only existing version of ~ts is ~ts which does not match constraint ~~> ~ts. "
"Using anyway, but it is not guaranteed to work.", [Dep, Vsn, Constraint]); "Using anyway, but it is not guaranteed to work.", [Dep, Vsn, Constraint]);
_ -> _ ->
?DEBUG("[ ~s: ~s] Only existing version of ~s is ~s which does not match constraint ~~> ~s. "
?DEBUG("[~ts:~ts] Only existing version of ~ts is ~ts which does not match constraint ~~> ~ts. "
"Using anyway, but it is not guaranteed to work.", [Pkg, PkgVsn, Dep, Vsn, Constraint]) "Using anyway, but it is not guaranteed to work.", [Pkg, PkgVsn, Dep, Vsn, Constraint])
end, end,
{ok, Vsn} {ok, Vsn}
end. end.
format_error({missing_package, Name, Vsn}) -> format_error({missing_package, Name, Vsn}) ->
io_lib:format("Package not found in registry: ~s- ~s.", [ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)]);
io_lib:format("Package not found in registry: ~ts-~ts.", [rebar_utils:to_binary(Name), rebar_utils:to_binary(Vsn)]);
format_error({missing_package, Dep}) -> format_error({missing_package, Dep}) ->
io_lib:format("Package not found in registry: ~p.", [Dep]). io_lib:format("Package not found in registry: ~p.", [Dep]).

+ 9
- 9
src/rebar_pkg_resource.erl View File

@ -21,7 +21,7 @@ lock(_AppDir, Source) ->
needs_update(Dir, {pkg, _Name, Vsn, _Hash}) -> needs_update(Dir, {pkg, _Name, Vsn, _Hash}) ->
[AppInfo] = rebar_app_discover:find_apps([Dir], all), [AppInfo] = rebar_app_discover:find_apps([Dir], all),
case rebar_app_info:original_vsn(AppInfo) =:= ec_cnv:to_list(Vsn) of
case rebar_app_info:original_vsn(AppInfo) =:= rebar_utils:to_list(Vsn) of
true -> true ->
false; false;
false -> false ->
@ -43,13 +43,13 @@ download(TmpDir, Pkg={pkg, Name, Vsn, _Hash}, State) ->
cached_download(TmpDir, CachePath, Pkg={pkg, Name, Vsn, _Hash}, Url, ETag, State) -> cached_download(TmpDir, CachePath, Pkg={pkg, Name, Vsn, _Hash}, Url, ETag, State) ->
case request(Url, ETag) of case request(Url, ETag) of
{ok, cached} -> {ok, cached} ->
?INFO("Version cached at ~s is up to date, reusing it", [CachePath]),
?INFO("Version cached at ~ts is up to date, reusing it", [CachePath]),
serve_from_cache(TmpDir, CachePath, Pkg, State); serve_from_cache(TmpDir, CachePath, Pkg, State);
{ok, Body, NewETag} -> {ok, Body, NewETag} ->
?INFO("Downloaded package, caching at ~s", [CachePath]),
?INFO("Downloaded package, caching at ~ts", [CachePath]),
serve_from_download(TmpDir, CachePath, Pkg, NewETag, Body, State); serve_from_download(TmpDir, CachePath, Pkg, NewETag, Body, State);
error when ETag =/= false -> error when ETag =/= false ->
?INFO("Download error, using cached file at ~s", [CachePath]),
?INFO("Download error, using cached file at ~ts", [CachePath]),
serve_from_cache(TmpDir, CachePath, Pkg, State); serve_from_cache(TmpDir, CachePath, Pkg, State);
error -> error ->
{fetch_fail, Name, Vsn} {fetch_fail, Name, Vsn}
@ -76,13 +76,13 @@ serve_from_cache(TmpDir, CachePath, Pkg, State) ->
end. end.
serve_from_download(TmpDir, CachePath, Package, ETag, Binary, State) -> serve_from_download(TmpDir, CachePath, Package, ETag, Binary, State) ->
?DEBUG("Writing ~p to cache at ~s", [Package, CachePath]),
?DEBUG("Writing ~p to cache at ~ts", [Package, CachePath]),
file:write_file(CachePath, Binary), file:write_file(CachePath, Binary),
case etag(CachePath) of case etag(CachePath) of
ETag -> ETag ->
serve_from_cache(TmpDir, CachePath, Package, State); serve_from_cache(TmpDir, CachePath, Package, State);
FileETag -> FileETag ->
?DEBUG("Downloaded file ~s ETag ~s doesn't match returned ETag ~s", [CachePath, ETag, FileETag]),
?DEBUG("Downloaded file ~ts ETag ~ts doesn't match returned ETag ~ts", [CachePath, ETag, FileETag]),
{bad_download, CachePath} {bad_download, CachePath}
end. end.
@ -114,11 +114,11 @@ request(Url, ETag) ->
[{body_format, binary}], [{body_format, binary}],
rebar) of rebar) of
{ok, {{_Version, 200, _Reason}, Headers, Body}} -> {ok, {{_Version, 200, _Reason}, Headers, Body}} ->
?DEBUG("Successfully downloaded ~s", [Url]),
?DEBUG("Successfully downloaded ~ts", [Url]),
{"etag", ETag1} = lists:keyfind("etag", 1, Headers), {"etag", ETag1} = lists:keyfind("etag", 1, Headers),
{ok, Body, string:strip(ETag1, both, $")}; {ok, Body, string:strip(ETag1, both, $")};
{ok, {{_Version, 304, _Reason}, _Headers, _Body}} -> {ok, {{_Version, 304, _Reason}, _Headers, _Body}} ->
?DEBUG("Cached copy of ~s still valid", [Url]),
?DEBUG("Cached copy of ~ts still valid", [Url]),
{ok, cached}; {ok, cached};
{ok, {{_Version, Code, _Reason}, _Headers, _Body}} -> {ok, {{_Version, Code, _Reason}, _Headers, _Body}} ->
?DEBUG("Request to ~p failed: status code ~p", [Url, Code]), ?DEBUG("Request to ~p failed: status code ~p", [Url, Code]),
@ -154,7 +154,7 @@ ssl_opts(Url) ->
ssl_opts(ssl_verify_enabled, Url) -> ssl_opts(ssl_verify_enabled, Url) ->
case check_ssl_version() of case check_ssl_version() of
true -> true ->
{ok, {_, _, Hostname, _, _, _}} = http_uri:parse(ec_cnv:to_list(Url)),
{ok, {_, _, Hostname, _, _, _}} = http_uri:parse(rebar_utils:to_list(Url)),
VerifyFun = {fun ssl_verify_hostname:verify_fun/3, [{check_hostname, Hostname}]}, VerifyFun = {fun ssl_verify_hostname:verify_fun/3, [{check_hostname, Hostname}]},
CACerts = certifi:cacerts(), CACerts = certifi:cacerts(),
[{verify, verify_peer}, {depth, 2}, {cacerts, CACerts} [{verify, verify_peer}, {depth, 2}, {cacerts, CACerts}

+ 6
- 6
src/rebar_prv_app_discovery.erl View File

@ -49,19 +49,19 @@ do(State) ->
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({multiple_app_files, Files}) -> format_error({multiple_app_files, Files}) ->
io_lib:format("Multiple app files found in one app dir: ~s", [string:join(Files, " and ")]);
io_lib:format("Multiple app files found in one app dir: ~ts", [string:join(Files, " and ")]);
format_error({invalid_app_file, File, Reason}) -> format_error({invalid_app_file, File, Reason}) ->
case Reason of case Reason of
{Line, erl_parse, Description} -> {Line, erl_parse, Description} ->
io_lib:format("Invalid app file ~s at line ~b: ~p",
io_lib:format("Invalid app file ~ts at line ~b: ~p",
[File, Line, lists:flatten(Description)]); [File, Line, lists:flatten(Description)]);
_ -> _ ->
io_lib:format("Invalid app file ~s: ~p", [File, Reason])
io_lib:format("Invalid app file ~ts: ~p", [File, Reason])
end; end;
%% Provide a slightly more informative error message for consult of app file failure %% Provide a slightly more informative error message for consult of app file failure
format_error({rebar_file_utils, {bad_term_file, AppFile, Reason}}) -> format_error({rebar_file_utils, {bad_term_file, AppFile, Reason}}) ->
io_lib:format("Error in app file ~s: ~s", [rebar_dir:make_relative_path(AppFile,
rebar_dir:get_cwd()),
file:format_error(Reason)]);
io_lib:format("Error in app file ~ts: ~ts", [rebar_dir:make_relative_path(AppFile,
rebar_dir:get_cwd()),
file:format_error(Reason)]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).

+ 3
- 3
src/rebar_prv_as.erl View File

@ -64,7 +64,7 @@ args_to_profiles_and_tasks(Args) ->
first_profile([]) -> {[], []}; first_profile([]) -> {[], []};
first_profile([ProfileList|Rest]) -> first_profile([ProfileList|Rest]) ->
case re:split(ProfileList, ",", [{return, list}, {parts, 2}]) of
case re:split(ProfileList, ",", [{return, list}, {parts, 2}, unicode]) of
%% `foo, bar` %% `foo, bar`
[P, ""] -> profiles(Rest, [P]); [P, ""] -> profiles(Rest, [P]);
%% `foo,bar` %% `foo,bar`
@ -75,7 +75,7 @@ first_profile([ProfileList|Rest]) ->
profiles([], Acc) -> {lists:reverse(Acc), rebar_utils:args_to_tasks([])}; profiles([], Acc) -> {lists:reverse(Acc), rebar_utils:args_to_tasks([])};
profiles([ProfileList|Rest], Acc) -> profiles([ProfileList|Rest], Acc) ->
case re:split(ProfileList, ",", [{return, list}, {parts, 2}]) of
case re:split(ProfileList, ",", [{return, list}, {parts, 2}, unicode]) of
%% `foo, bar` %% `foo, bar`
[P, ""] -> profiles(Rest, [P|Acc]); [P, ""] -> profiles(Rest, [P|Acc]);
%% `foo,bar` %% `foo,bar`
@ -101,5 +101,5 @@ warn_on_empty_profile(Profiles, State) ->
ProjectApps = rebar_state:project_apps(State), ProjectApps = rebar_state:project_apps(State),
DefinedProfiles = rebar_state:get(State, profiles, []) ++ DefinedProfiles = rebar_state:get(State, profiles, []) ++
lists:flatten([rebar_app_info:get(AppInfo, profiles, []) || AppInfo <- ProjectApps]), lists:flatten([rebar_app_info:get(AppInfo, profiles, []) || AppInfo <- ProjectApps]),
[?WARN("No entry for profile ~s in config.", [Profile]) ||
[?WARN("No entry for profile ~ts in config.", [Profile]) ||
Profile <- Profiles, not(lists:keymember(list_to_atom(Profile), 1, DefinedProfiles))]. Profile <- Profiles, not(lists:keymember(list_to_atom(Profile), 1, DefinedProfiles))].

+ 1
- 1
src/rebar_prv_clean.erl View File

@ -68,7 +68,7 @@ format_error(Reason) ->
clean_apps(State, Providers, Apps) -> clean_apps(State, Providers, Apps) ->
[begin [begin
?INFO("Cleaning out ~s...", [rebar_app_info:name(AppInfo)]),
?INFO("Cleaning out ~ts...", [rebar_app_info:name(AppInfo)]),
AppDir = rebar_app_info:dir(AppInfo), AppDir = rebar_app_info:dir(AppInfo),
AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State),
rebar_erlc_compiler:clean(AppInfo1), rebar_erlc_compiler:clean(AppInfo1),

+ 1
- 1
src/rebar_prv_common_test.erl View File

@ -684,7 +684,7 @@ format_result({Passed, 0, {0, 0}}) ->
format_result({Passed, Failed, Skipped}) -> format_result({Passed, Failed, Skipped}) ->
Format = [format_failed(Failed), format_skipped(Skipped), Format = [format_failed(Failed), format_skipped(Skipped),
format_passed(Passed)], format_passed(Passed)],
?CONSOLE(" ~s", [Format]);
?CONSOLE("~ts", [Format]);
format_result(_Unknown) -> format_result(_Unknown) ->
%% Happens when CT itself encounters a bug %% Happens when CT itself encounters a bug
ok. ok.

+ 4
- 4
src/rebar_prv_compile.erl View File

@ -73,7 +73,7 @@ do(State) ->
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({missing_artifact, File}) -> format_error({missing_artifact, File}) ->
io_lib:format("Missing artifact ~s", [File]);
io_lib:format("Missing artifact ~ts", [File]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).
@ -114,7 +114,7 @@ compile(State, AppInfo) ->
compile(State, rebar_state:providers(State), AppInfo). compile(State, rebar_state:providers(State), AppInfo).
compile(State, Providers, AppInfo) -> compile(State, Providers, AppInfo) ->
?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]),
?INFO("Compiling ~ts", [rebar_app_info:name(AppInfo)]),
AppDir = rebar_app_info:dir(AppInfo), AppDir = rebar_app_info:dir(AppInfo),
AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State),
@ -173,8 +173,8 @@ has_all_artifacts(AppInfo1) ->
end. end.
copy_app_dirs(AppInfo, OldAppDir, AppDir) -> copy_app_dirs(AppInfo, OldAppDir, AppDir) ->
case ec_cnv:to_binary(filename:absname(OldAppDir)) =/=
ec_cnv:to_binary(filename:absname(AppDir)) of
case rebar_utils:to_binary(filename:absname(OldAppDir)) =/=
rebar_utils:to_binary(filename:absname(AppDir)) of
true -> true ->
EbinDir = filename:join([OldAppDir, "ebin"]), EbinDir = filename:join([OldAppDir, "ebin"]),
%% copy all files from ebin if it exists %% copy all files from ebin if it exists

+ 2
- 2
src/rebar_prv_cover.erl View File

@ -278,7 +278,7 @@ write_index(State, Coverage) ->
write_index_section(_F, []) -> ok; write_index_section(_F, []) -> ok;
write_index_section(F, [{Section, DataFile, Mods}|Rest]) -> write_index_section(F, [{Section, DataFile, Mods}|Rest]) ->
%% Write the report %% Write the report
ok = file:write(F, ?FMT("<h1> ~s summary</h1>\n", [Section])),
ok = file:write(F, ?FMT("<h1>~ts summary</h1>\n", [Section])),
ok = file:write(F, "coverage calculated from:\n<ul>"), ok = file:write(F, "coverage calculated from:\n<ul>"),
ok = lists:foreach(fun(D) -> ok = file:write(F, io_lib:format("<li>~ts</li>", [D])) end, ok = lists:foreach(fun(D) -> ok = file:write(F, io_lib:format("<li>~ts</li>", [D])) end,
DataFile), DataFile),
@ -303,7 +303,7 @@ strip_coverdir(File) ->
2))). 2))).
cover_compile(State, apps) -> cover_compile(State, apps) ->
ExclApps = [list_to_binary(A) || A <- rebar_state:get(State, cover_excl_apps, [])],
ExclApps = [rebar_utils:to_binary(A) || A <- rebar_state:get(State, cover_excl_apps, [])],
Apps = filter_checkouts_and_excluded(rebar_state:project_apps(State), ExclApps), Apps = filter_checkouts_and_excluded(rebar_state:project_apps(State), ExclApps),
AppDirs = app_dirs(Apps), AppDirs = app_dirs(Apps),
cover_compile(State, lists:filter(fun(D) -> ec_file:is_dir(D) end, AppDirs)); cover_compile(State, lists:filter(fun(D) -> ec_file:is_dir(D) end, AppDirs));

+ 10
- 10
src/rebar_prv_deps.erl View File

@ -55,7 +55,7 @@ merge(Deps, SourceDeps) ->
normalize(Name) when is_binary(Name) -> normalize(Name) when is_binary(Name) ->
Name; Name;
normalize(Name) when is_atom(Name) -> normalize(Name) when is_atom(Name) ->
ec_cnv:to_binary(Name);
atom_to_binary(Name, unicode);
normalize(Dep) when is_tuple(Dep) -> normalize(Dep) when is_tuple(Dep) ->
Name = element(1, Dep), Name = element(1, Dep),
setelement(1, Dep, normalize(Name)). setelement(1, Dep, normalize(Name)).
@ -87,31 +87,31 @@ display_deps(State, Deps) ->
%% packages %% packages
display_dep(_State, {Name, Vsn}) when is_list(Vsn) -> display_dep(_State, {Name, Vsn}) when is_list(Vsn) ->
?CONSOLE(" ~s* (package ~s)", [ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)]);
?CONSOLE("~ts* (package ~ts)", [rebar_utils:to_binary(Name), rebar_utils:to_binary(Vsn)]);
display_dep(_State, Name) when is_binary(Name) -> display_dep(_State, Name) when is_binary(Name) ->
?CONSOLE(" ~s* (package)", [Name]);
?CONSOLE("~ts* (package)", [Name]);
display_dep(_State, {Name, Source}) when is_tuple(Source) -> display_dep(_State, {Name, Source}) when is_tuple(Source) ->
?CONSOLE(" ~s* ( ~s source)", [ec_cnv:to_binary(Name), type(Source)]);
?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
display_dep(_State, {Name, _Vsn, Source}) when is_tuple(Source) -> display_dep(_State, {Name, _Vsn, Source}) when is_tuple(Source) ->
?CONSOLE(" ~s* ( ~s source)", [ec_cnv:to_binary(Name), type(Source)]);
?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
display_dep(_State, {Name, _Vsn, Source, _Opts}) when is_tuple(Source) -> display_dep(_State, {Name, _Vsn, Source, _Opts}) when is_tuple(Source) ->
?CONSOLE(" ~s* ( ~s source)", [ec_cnv:to_binary(Name), type(Source)]);
?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
%% Locked %% Locked
display_dep(State, {Name, Source={pkg, _, Vsn}, Level}) when is_integer(Level) -> display_dep(State, {Name, Source={pkg, _, Vsn}, Level}) when is_integer(Level) ->
DepsDir = rebar_dir:deps_dir(State), DepsDir = rebar_dir:deps_dir(State),
AppDir = filename:join([DepsDir, ec_cnv:to_binary(Name)]),
AppDir = filename:join([DepsDir, rebar_utils:to_binary(Name)]),
NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source, State) of NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source, State) of
true -> "*"; true -> "*";
false -> "" false -> ""
end, end,
?CONSOLE(" ~s ~s (locked package ~s)", [Name, NeedsUpdate, Vsn]);
?CONSOLE("~ts~ts (locked package ~ts)", [Name, NeedsUpdate, Vsn]);
display_dep(State, {Name, Source, Level}) when is_tuple(Source), is_integer(Level) -> display_dep(State, {Name, Source, Level}) when is_tuple(Source), is_integer(Level) ->
DepsDir = rebar_dir:deps_dir(State), DepsDir = rebar_dir:deps_dir(State),
AppDir = filename:join([DepsDir, ec_cnv:to_binary(Name)]),
AppDir = filename:join([DepsDir, rebar_utils:to_binary(Name)]),
NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source, State) of NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source, State) of
true -> "*"; true -> "*";
false -> "" false -> ""
end, end,
?CONSOLE(" ~s ~s (locked ~s source)", [Name, NeedsUpdate, type(Source)]).
?CONSOLE("~ts~ts (locked ~ts source)", [Name, NeedsUpdate, type(Source)]).
type(Source) when is_tuple(Source) -> element(1, Source). type(Source) when is_tuple(Source) -> element(1, Source).

+ 2
- 2
src/rebar_prv_deps_tree.erl View File

@ -90,7 +90,7 @@ type(Source, Verbose) when is_tuple(Source) ->
{pkg, _} -> {pkg, _} ->
"hex package"; "hex package";
{Other, false} -> {Other, false} ->
io_lib:format(" ~s repo", [Other]);
io_lib:format("~ts repo", [Other]);
{_, true} -> {_, true} ->
io_lib:format(" ~s", [element(2, Source)])
io_lib:format("~ts", [element(2, Source)])
end. end.

+ 8
- 8
src/rebar_prv_dialyzer.erl View File

@ -116,18 +116,18 @@ maybe_fix_env() ->
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({error_processing_apps, Error}) -> format_error({error_processing_apps, Error}) ->
io_lib:format("Error in dialyzing apps: ~s", [Error]);
io_lib:format("Error in dialyzing apps: ~ts", [Error]);
format_error({dialyzer_warnings, Warnings}) -> format_error({dialyzer_warnings, Warnings}) ->
io_lib:format("Warnings occurred running dialyzer: ~b", [Warnings]); io_lib:format("Warnings occurred running dialyzer: ~b", [Warnings]);
format_error({unknown_application, App}) -> format_error({unknown_application, App}) ->
io_lib:format("Could not find application: ~s", [App]);
io_lib:format("Could not find application: ~ts", [App]);
format_error({unknown_module, Mod}) -> format_error({unknown_module, Mod}) ->
io_lib:format("Could not find module: ~s", [Mod]);
io_lib:format("Could not find module: ~ts", [Mod]);
format_error({duplicate_module, Mod, File1, File2}) -> format_error({duplicate_module, Mod, File1, File2}) ->
io_lib:format("Duplicates of module ~s: ~s ~s", [Mod, File1, File2]);
io_lib:format("Duplicates of module ~ts: ~ts ~ts", [Mod, File1, File2]);
format_error({output_file_error, File, Error}) -> format_error({output_file_error, File, Error}) ->
Error1 = file:format_error(Error), Error1 = file:format_error(Error),
io_lib:format("Failed to write to ~s: ~s", [File, Error1]);
io_lib:format("Failed to write to ~ts: ~ts", [File, Error1]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).
@ -155,7 +155,7 @@ do(State, Plt) ->
0 -> 0 ->
{ok, State2}; {ok, State2};
TotalWarnings -> TotalWarnings ->
?INFO("Warnings written to ~s", [Output]),
?INFO("Warnings written to ~ts", [Output]),
throw({dialyzer_warnings, TotalWarnings}) throw({dialyzer_warnings, TotalWarnings})
end. end.
@ -229,7 +229,7 @@ apps_files([AppName | DepApps], SkipApps, Files) ->
apps_files(DepApps, SkipApps, Files); apps_files(DepApps, SkipApps, Files);
false -> false ->
AppFiles = app_files(AppName), AppFiles = app_files(AppName),
?DEBUG(" ~s modules: ~p", [AppName, dict:fetch_keys(AppFiles)]),
?DEBUG("~ts modules: ~p", [AppName, dict:fetch_keys(AppFiles)]),
Files2 = merge_files(Files, AppFiles), Files2 = merge_files(Files, AppFiles),
apps_files(DepApps, [AppName | SkipApps], Files2) apps_files(DepApps, [AppName | SkipApps], Files2)
end. end.
@ -505,7 +505,7 @@ format_warnings(Opts, Output, Warnings) ->
length(Warnings). length(Warnings).
console_warnings(Warnings) -> console_warnings(Warnings) ->
_ = [?CONSOLE(" ~s", [Warning]) || Warning <- Warnings],
_ = [?CONSOLE("~ts", [Warning]) || Warning <- Warnings],
ok. ok.
file_warnings(_, []) -> file_warnings(_, []) ->

+ 3
- 3
src/rebar_prv_edoc.erl View File

@ -42,8 +42,8 @@ do(State) ->
Res = try Res = try
lists:foldl(fun(AppInfo, EdocOptsAcc) -> lists:foldl(fun(AppInfo, EdocOptsAcc) ->
rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, AppInfo, State), rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, AppInfo, State),
AppName = ec_cnv:to_list(rebar_app_info:name(AppInfo)),
?INFO("Running edoc for ~s", [AppName]),
AppName = rebar_utils:to_list(rebar_app_info:name(AppInfo)),
?INFO("Running edoc for ~ts", [AppName]),
AppDir = rebar_app_info:dir(AppInfo), AppDir = rebar_app_info:dir(AppInfo),
AppRes = (catch edoc:application(list_to_atom(AppName), AppDir, EdocOptsAcc)), AppRes = (catch edoc:application(list_to_atom(AppName), AppDir, EdocOptsAcc)),
rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State), rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State),
@ -74,7 +74,7 @@ do(State) ->
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({app_failed, AppName}) -> format_error({app_failed, AppName}) ->
io_lib:format("Failed to generate documentation for app ' ~s'", [AppName]);
io_lib:format("Failed to generate documentation for app '~ts'", [AppName]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).

+ 7
- 7
src/rebar_prv_escriptize.erl View File

@ -75,7 +75,7 @@ do(State) ->
end; end;
Name -> Name ->
AllApps = rebar_state:all_deps(State)++rebar_state:project_apps(State), AllApps = rebar_state:all_deps(State)++rebar_state:project_apps(State),
case rebar_app_utils:find(ec_cnv:to_binary(Name), AllApps) of
case rebar_app_utils:find(rebar_utils:to_binary(Name), AllApps) of
{ok, AppInfo} -> {ok, AppInfo} ->
escriptize(State, AppInfo); escriptize(State, AppInfo);
_ -> _ ->
@ -87,12 +87,12 @@ do(State) ->
escriptize(State0, App) -> escriptize(State0, App) ->
AppName = rebar_app_info:name(App), AppName = rebar_app_info:name(App),
AppNameStr = ec_cnv:to_list(AppName),
AppNameStr = rebar_utils:to_list(AppName),
%% Get the output filename for the escript -- this may include dirs %% Get the output filename for the escript -- this may include dirs
Filename = filename:join([rebar_dir:base_dir(State0), "bin", Filename = filename:join([rebar_dir:base_dir(State0), "bin",
rebar_state:get(State0, escript_name, AppName)]), rebar_state:get(State0, escript_name, AppName)]),
?DEBUG("Creating escript file ~s", [Filename]),
?DEBUG("Creating escript file ~ts", [Filename]),
ok = filelib:ensure_dir(Filename), ok = filelib:ensure_dir(Filename),
State = rebar_state:escript_path(State0, Filename), State = rebar_state:escript_path(State0, Filename),
@ -116,7 +116,7 @@ escriptize(State0, App) ->
ExtraFiles = usort(InclBeams ++ InclExtra), ExtraFiles = usort(InclBeams ++ InclExtra),
Files = get_nonempty(EbinFiles ++ ExtraFiles), Files = get_nonempty(EbinFiles ++ ExtraFiles),
DefaultEmuArgs = ?FMT("%%! -escript main ~s -pz ~s/ ~s/ebin\n",
DefaultEmuArgs = ?FMT("%%! -escript main ~ts -pz ~ts/~ts/ebin\n",
[AppNameStr, AppNameStr, AppNameStr]), [AppNameStr, AppNameStr, AppNameStr]),
EscriptSections = EscriptSections =
[ {shebang, [ {shebang,
@ -163,7 +163,7 @@ get_apps_beams(Apps, AllApps) ->
get_apps_beams([], _, Acc) -> get_apps_beams([], _, Acc) ->
Acc; Acc;
get_apps_beams([App | Rest], AllApps, Acc) -> get_apps_beams([App | Rest], AllApps, Acc) ->
case rebar_app_utils:find(ec_cnv:to_binary(App), AllApps) of
case rebar_app_utils:find(rebar_utils:to_binary(App), AllApps) of
{ok, App1} -> {ok, App1} ->
OutDir = filename:absname(rebar_app_info:ebin_dir(App1)), OutDir = filename:absname(rebar_app_info:ebin_dir(App1)),
Beams = get_app_beams(App, OutDir), Beams = get_app_beams(App, OutDir),
@ -235,7 +235,7 @@ get_nonempty(Files) ->
[{FName,FBin} || {FName,FBin} <- Files, FBin =/= <<>>]. [{FName,FBin} || {FName,FBin} <- Files, FBin =/= <<>>].
find_deps(AppNames, AllApps) -> find_deps(AppNames, AllApps) ->
BinAppNames = [ec_cnv:to_binary(Name) || Name <- AppNames],
BinAppNames = [rebar_utils:to_binary(Name) || Name <- AppNames],
[ec_cnv:to_atom(Name) || [ec_cnv:to_atom(Name) ||
Name <- find_deps_of_deps(BinAppNames, AllApps, BinAppNames)]. Name <- find_deps_of_deps(BinAppNames, AllApps, BinAppNames)].
@ -245,7 +245,7 @@ find_deps_of_deps([Name|Names], Apps, Acc) ->
?DEBUG("processing ~p", [Name]), ?DEBUG("processing ~p", [Name]),
{ok, App} = rebar_app_utils:find(Name, Apps), {ok, App} = rebar_app_utils:find(Name, Apps),
DepNames = proplists:get_value(applications, rebar_app_info:app_details(App), []), DepNames = proplists:get_value(applications, rebar_app_info:app_details(App), []),
BinDepNames = [ec_cnv:to_binary(Dep) || Dep <- DepNames,
BinDepNames = [rebar_utils:to_binary(Dep) || Dep <- DepNames,
%% ignore system libs; shouldn't include them. %% ignore system libs; shouldn't include them.
DepDir <- [code:lib_dir(Dep)], DepDir <- [code:lib_dir(Dep)],
DepDir =:= {error, bad_name} orelse % those are all local DepDir =:= {error, bad_name} orelse % those are all local

+ 13
- 13
src/rebar_prv_install_deps.erl View File

@ -104,22 +104,22 @@ do_(State) ->
%% @doc convert a given exception's payload into an io description. %% @doc convert a given exception's payload into an io description.
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({dep_app_not_found, AppDir, AppName}) -> format_error({dep_app_not_found, AppDir, AppName}) ->
io_lib:format("Dependency failure: Application ~s not found at the top level of directory ~s", [AppName, AppDir]);
io_lib:format("Dependency failure: Application ~ts not found at the top level of directory ~ts", [AppName, AppDir]);
format_error({load_registry_fail, Dep}) -> format_error({load_registry_fail, Dep}) ->
io_lib:format("Error loading registry to resolve version of ~s. Try fixing by running 'rebar3 update'", [Dep]);
io_lib:format("Error loading registry to resolve version of ~ts. Try fixing by running 'rebar3 update'", [Dep]);
format_error({bad_constraint, Name, Constraint}) -> format_error({bad_constraint, Name, Constraint}) ->
io_lib:format("Unable to parse version for package ~s: ~s", [Name, Constraint]);
io_lib:format("Unable to parse version for package ~ts: ~ts", [Name, Constraint]);
format_error({parse_dep, Dep}) -> format_error({parse_dep, Dep}) ->
io_lib:format("Failed parsing dep ~p", [Dep]); io_lib:format("Failed parsing dep ~p", [Dep]);
format_error({not_rebar_package, Package, Version}) -> format_error({not_rebar_package, Package, Version}) ->
io_lib:format("Package not buildable with rebar3: ~s- ~s", [Package, Version]);
io_lib:format("Package not buildable with rebar3: ~ts-~ts", [Package, Version]);
format_error({missing_package, Package, Version}) -> format_error({missing_package, Package, Version}) ->
io_lib:format("Package not found in registry: ~s- ~s", [Package, Version]);
io_lib:format("Package not found in registry: ~ts-~ts", [Package, Version]);
format_error({missing_package, Package}) -> format_error({missing_package, Package}) ->
io_lib:format("Package not found in registry: ~s", [Package]);
io_lib:format("Package not found in registry: ~ts", [Package]);
format_error({cycles, Cycles}) -> format_error({cycles, Cycles}) ->
Prints = [["applications: ", Prints = [["applications: ",
[io_lib:format(" ~s ", [Dep]) || Dep <- Cycle],
[io_lib:format("~ts ", [Dep]) || Dep <- Cycle],
"depend on each other\n"] "depend on each other\n"]
|| Cycle <- Cycles], || Cycle <- Cycles],
["Dependency cycle(s) detected:\n", Prints]; ["Dependency cycle(s) detected:\n", Prints];
@ -291,7 +291,7 @@ handle_dep(State, Profile, DepsDir, AppInfo, Locks, Level) ->
-spec maybe_fetch(rebar_app_info:t(), atom(), boolean(), -spec maybe_fetch(rebar_app_info:t(), atom(), boolean(),
sets:set(binary()), rebar_state:t()) -> {boolean(), rebar_app_info:t()}. sets:set(binary()), rebar_state:t()) -> {boolean(), rebar_app_info:t()}.
maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) -> maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) ->
AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)),
AppDir = rebar_utils:to_list(rebar_app_info:dir(AppInfo)),
%% Don't fetch dep if it exists in the _checkouts dir %% Don't fetch dep if it exists in the _checkouts dir
case rebar_app_info:is_checkout(AppInfo) of case rebar_app_info:is_checkout(AppInfo) of
true -> true ->
@ -346,7 +346,7 @@ symlink_dep(State, From, To) ->
ok -> ok ->
RelativeFrom = make_relative_to_root(State, From), RelativeFrom = make_relative_to_root(State, From),
RelativeTo = make_relative_to_root(State, To), RelativeTo = make_relative_to_root(State, To),
?INFO("Linking ~s to ~s", [RelativeFrom, RelativeTo]),
?INFO("Linking ~ts to ~ts", [RelativeFrom, RelativeTo]),
ok; ok;
exists -> exists ->
ok ok
@ -359,7 +359,7 @@ make_relative_to_root(State, Path) when is_list(Path) ->
rebar_dir:make_relative_path(Path, Root). rebar_dir:make_relative_path(Path, Root).
fetch_app(AppInfo, AppDir, State) -> fetch_app(AppInfo, AppDir, State) ->
?INFO("Fetching ~s (~p)", [rebar_app_info:name(AppInfo),
?INFO("Fetching ~ts (~p)", [rebar_app_info:name(AppInfo),
format_source(rebar_app_info:source(AppInfo))]), format_source(rebar_app_info:source(AppInfo))]),
Source = rebar_app_info:source(AppInfo), Source = rebar_app_info:source(AppInfo),
true = rebar_fetch:download_source(AppDir, Source, State). true = rebar_fetch:download_source(AppDir, Source, State).
@ -384,12 +384,12 @@ maybe_upgrade(AppInfo, AppDir, Upgrade, State) ->
true -> true ->
case rebar_fetch:needs_update(AppDir, Source, State) of case rebar_fetch:needs_update(AppDir, Source, State) of
true -> true ->
?INFO("Upgrading ~s (~p)", [rebar_app_info:name(AppInfo), rebar_app_info:source(AppInfo)]),
?INFO("Upgrading ~ts (~p)", [rebar_app_info:name(AppInfo), rebar_app_info:source(AppInfo)]),
true = rebar_fetch:download_source(AppDir, Source, State); true = rebar_fetch:download_source(AppDir, Source, State);
false -> false ->
case Upgrade of case Upgrade of
true -> true ->
?INFO("No upgrade needed for ~s", [rebar_app_info:name(AppInfo)]),
?INFO("No upgrade needed for ~ts", [rebar_app_info:name(AppInfo)]),
false; false;
false -> false ->
false false
@ -400,7 +400,7 @@ maybe_upgrade(AppInfo, AppDir, Upgrade, State) ->
end. end.
warn_skip_deps(AppInfo, State) -> warn_skip_deps(AppInfo, State) ->
Msg = "Skipping ~s (from ~p) as an app of the same name "
Msg = "Skipping ~ts (from ~p) as an app of the same name "
"has already been fetched", "has already been fetched",
Args = [rebar_app_info:name(AppInfo), Args = [rebar_app_info:name(AppInfo),
rebar_app_info:source(AppInfo)], rebar_app_info:source(AppInfo)],

+ 4
- 4
src/rebar_prv_local_install.erl View File

@ -60,7 +60,7 @@ format_error(Reason) ->
bin_contents(OutputDir) -> bin_contents(OutputDir) ->
<<"#!/usr/bin/env sh <<"#!/usr/bin/env sh
erl -pz ", (ec_cnv:to_binary(OutputDir))/binary,"/*/ebin +sbtu +A0 -noshell -boot start_clean -s rebar3 main $REBAR3_ERL_ARGS -extra \"$@\"
erl -pz ", (rebar_utils:to_binary(OutputDir))/binary,"/*/ebin +sbtu +A0 -noshell -boot start_clean -s rebar3 main $REBAR3_ERL_ARGS -extra \"$@\"
">>. ">>.
extract_escript(State, ScriptPath) -> extract_escript(State, ScriptPath) ->
@ -73,7 +73,7 @@ extract_escript(State, ScriptPath) ->
OutputDir = filename:join(rebar_dir:global_cache_dir(Opts), "lib"), OutputDir = filename:join(rebar_dir:global_cache_dir(Opts), "lib"),
filelib:ensure_dir(filename:join(OutputDir, "empty")), filelib:ensure_dir(filename:join(OutputDir, "empty")),
?INFO("Extracting rebar3 libs to ~s...", [OutputDir]),
?INFO("Extracting rebar3 libs to ~ts...", [OutputDir]),
zip:extract(Archive, [{cwd, OutputDir}]), zip:extract(Archive, [{cwd, OutputDir}]),
BinDir = filename:join(rebar_dir:global_cache_dir(Opts), "bin"), BinDir = filename:join(rebar_dir:global_cache_dir(Opts), "bin"),
@ -84,12 +84,12 @@ extract_escript(State, ScriptPath) ->
uid = Uid, uid = Uid,
gid = Gid}} = file:read_file_info(ScriptPath), gid = Gid}} = file:read_file_info(ScriptPath),
?INFO("Writing rebar3 run script ~s...", [BinFile]),
?INFO("Writing rebar3 run script ~ts...", [BinFile]),
file:write_file(BinFile, bin_contents(OutputDir)), file:write_file(BinFile, bin_contents(OutputDir)),
ok = file:write_file_info(BinFile, #file_info{mode=33277, ok = file:write_file_info(BinFile, #file_info{mode=33277,
uid=Uid, uid=Uid,
gid=Gid}), gid=Gid}),
?INFO("Add to $PATH for use: export PATH= ~s:$PATH", [BinDir]),
?INFO("Add to $PATH for use: export PATH=~ts:$PATH", [BinDir]),
{ok, State}. {ok, State}.

+ 10
- 10
src/rebar_prv_new.erl View File

@ -60,7 +60,7 @@ do(State) ->
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error({consult, File, Reason}) -> format_error({consult, File, Reason}) ->
io_lib:format("Error consulting file at ~s for reason ~p", [File, Reason]);
io_lib:format("Error consulting file at ~ts for reason ~p", [File, Reason]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).
@ -70,7 +70,7 @@ format_error(Reason) ->
list_templates(State) -> list_templates(State) ->
lists:foldl(fun({error, {consult, File, Reason}}, Acc) -> lists:foldl(fun({error, {consult, File, Reason}}, Acc) ->
?WARN("Error consulting template file ~s for reason ~p",
?WARN("Error consulting template file ~ts for reason ~p",
[File, Reason]), [File, Reason]),
Acc Acc
; (Tpl, Acc) -> ; (Tpl, Acc) ->
@ -116,16 +116,16 @@ show_short_templates(List) ->
lists:map(fun show_short_template/1, lists:sort(List)). lists:map(fun show_short_template/1, lists:sort(List)).
show_short_template({Name, Type, _Location, Description, _Vars}) -> show_short_template({Name, Type, _Location, Description, _Vars}) ->
io:format(" ~s ( ~s): ~s~n",
io:format("~ts (~ts): ~ts~n",
[Name, [Name,
format_type(Type), format_type(Type),
format_description(Description)]). format_description(Description)]).
show_template({Name, Type, Location, Description, Vars}) -> show_template({Name, Type, Location, Description, Vars}) ->
io:format(" ~s:~n"
"\t ~s~n"
"\tDescription: ~s~n"
"\tVariables:~n ~s~n",
io:format("~ts:~n"
"\t~ts~n"
"\tDescription: ~ts~n"
"\tVariables:~n~ts~n",
[Name, [Name,
format_type(Type, Location), format_type(Type, Location),
format_description(Description), format_description(Description),
@ -141,9 +141,9 @@ format_type(escript, _) ->
format_type(builtin, _) -> format_type(builtin, _) ->
"built-in template"; "built-in template";
format_type(plugin, Loc) -> format_type(plugin, Loc) ->
io_lib:format("plugin template ( ~s)", [Loc]);
io_lib:format("plugin template (~ts)", [Loc]);
format_type(file, Loc) -> format_type(file, Loc) ->
io_lib:format("custom template ( ~s)", [Loc]).
io_lib:format("custom template (~ts)", [Loc]).
format_description(Description) -> format_description(Description) ->
case Description of case Description of
@ -156,4 +156,4 @@ format_vars(Vars) -> [format_var(Var) || Var <- Vars].
format_var({Var, Default}) -> format_var({Var, Default}) ->
io_lib:format("\t\t~p=~p~n",[Var, Default]); io_lib:format("\t\t~p=~p~n",[Var, Default]);
format_var({Var, Default, Doc}) -> format_var({Var, Default, Doc}) ->
io_lib:format("\t\t~p=~p ( ~s)~n", [Var, Default, Doc]).
io_lib:format("\t\t~p=~p (~ts)~n", [Var, Default, Doc]).

+ 3
- 3
src/rebar_prv_packages.erl View File

@ -30,7 +30,7 @@ do(State) ->
rebar_packages:packages(State), rebar_packages:packages(State),
case rebar_state:command_args(State) of case rebar_state:command_args(State) of
[Name] -> [Name] ->
print_packages(get_packages(iolist_to_binary(Name)));
print_packages(get_packages(rebar_utils:to_binary(Name)));
_ -> _ ->
print_packages(sort_packages()) print_packages(sort_packages())
end, end,
@ -47,7 +47,7 @@ print_packages(Pkgs) ->
,ec_semver:parse(B)) ,ec_semver:parse(B))
end, Vsns), end, Vsns),
VsnStr = join(SortedVsns, <<", ">>), VsnStr = join(SortedVsns, <<", ">>),
?CONSOLE(" ~s:~n Versions: ~s~n", [Name, VsnStr])
?CONSOLE("~ts:~n Versions: ~ts~n", [Name, VsnStr])
end, Pkgs). end, Pkgs).
sort_packages() -> sort_packages() ->
@ -71,4 +71,4 @@ join([Bin | T], Sep) ->
info(Description) -> info(Description) ->
io_lib:format(" ~s.~n", [Description]).
io_lib:format("~ts.~n", [Description]).

+ 8
- 8
src/rebar_prv_path.erl View File

@ -75,23 +75,23 @@ paths([{src, true}|Rest], Apps, State, Acc) ->
paths([{rel, true}|Rest], Apps, State, Acc) -> paths([{rel, true}|Rest], Apps, State, Acc) ->
paths(Rest, Apps, State, [rel_dir(State)|Acc]). paths(Rest, Apps, State, [rel_dir(State)|Acc]).
base_dir(State) -> io_lib:format(" ~s", [rebar_dir:base_dir(State)]).
bin_dir(State) -> io_lib:format(" ~s/bin", [rebar_dir:base_dir(State)]).
lib_dir(State) -> io_lib:format(" ~s", [rebar_dir:deps_dir(State)]).
rel_dir(State) -> io_lib:format(" ~s/rel", [rebar_dir:base_dir(State)]).
base_dir(State) -> io_lib:format("~ts", [rebar_dir:base_dir(State)]).
bin_dir(State) -> io_lib:format("~ts/bin", [rebar_dir:base_dir(State)]).
lib_dir(State) -> io_lib:format("~ts", [rebar_dir:deps_dir(State)]).
rel_dir(State) -> io_lib:format("~ts/rel", [rebar_dir:base_dir(State)]).
ebin_dirs(Apps, State) -> ebin_dirs(Apps, State) ->
lists:map(fun(App) -> io_lib:format(" ~s/ ~s/ebin", [rebar_dir:deps_dir(State), App]) end, Apps).
lists:map(fun(App) -> io_lib:format("~ts/~ts/ebin", [rebar_dir:deps_dir(State), App]) end, Apps).
priv_dirs(Apps, State) -> priv_dirs(Apps, State) ->
lists:map(fun(App) -> io_lib:format(" ~s/ ~s/priv", [rebar_dir:deps_dir(State), App]) end, Apps).
lists:map(fun(App) -> io_lib:format("~ts/~ts/priv", [rebar_dir:deps_dir(State), App]) end, Apps).
src_dirs(Apps, State) -> src_dirs(Apps, State) ->
lists:map(fun(App) -> io_lib:format(" ~s/ ~s/src", [rebar_dir:deps_dir(State), App]) end, Apps).
lists:map(fun(App) -> io_lib:format("~ts/~ts/src", [rebar_dir:deps_dir(State), App]) end, Apps).
print_paths_if_exist(Paths, State) -> print_paths_if_exist(Paths, State) ->
{RawOpts, _} = rebar_state:command_parsed_args(State), {RawOpts, _} = rebar_state:command_parsed_args(State),
Sep = proplists:get_value(separator, RawOpts, " "), Sep = proplists:get_value(separator, RawOpts, " "),
RealPaths = lists:filter(fun(P) -> ec_file:is_dir(P) end, Paths), RealPaths = lists:filter(fun(P) -> ec_file:is_dir(P) end, Paths),
io:format(" ~s", [string:join(RealPaths, Sep)]).
io:format("~ts", [string:join(RealPaths, Sep)]).
project_deps(State) -> project_deps(State) ->
Profiles = rebar_state:current_profiles(State), Profiles = rebar_state:current_profiles(State),

+ 5
- 5
src/rebar_prv_plugins.erl View File

@ -55,19 +55,19 @@ format_error(Reason) ->
display_plugins(_Header, _Apps, []) -> display_plugins(_Header, _Apps, []) ->
ok; ok;
display_plugins(Header, Apps, Plugins) -> display_plugins(Header, Apps, Plugins) ->
?CONSOLE("--- ~s ---", [Header]),
?CONSOLE("--- ~ts ---", [Header]),
display_plugins(Apps, Plugins), display_plugins(Apps, Plugins),
?CONSOLE("", []). ?CONSOLE("", []).
display_plugins(Apps, Plugins) -> display_plugins(Apps, Plugins) ->
lists:foreach(fun(Plugin) -> lists:foreach(fun(Plugin) ->
Name = if is_atom(Plugin) -> ec_cnv:to_binary(Plugin);
is_tuple(Plugin) -> ec_cnv:to_binary(element(1, Plugin))
Name = if is_atom(Plugin) -> atom_to_binary(Plugin, unicode);
is_tuple(Plugin) -> rebar_utils:to_binary(element(1, Plugin))
end, end,
case rebar_app_utils:find(Name, Apps) of case rebar_app_utils:find(Name, Apps) of
{ok, _App} -> {ok, _App} ->
?CONSOLE(" ~s", [Name]);
?CONSOLE("~ts", [Name]);
error -> error ->
?DEBUG("Unable to find plugin ~s", [Name])
?DEBUG("Unable to find plugin ~ts", [Name])
end end
end, Plugins). end, Plugins).

+ 1
- 1
src/rebar_prv_plugins_upgrade.erl View File

@ -44,7 +44,7 @@ do(State) ->
format_error(no_plugin_arg) -> format_error(no_plugin_arg) ->
io_lib:format("Must give an installed plugin to upgrade as an argument", []); io_lib:format("Must give an installed plugin to upgrade as an argument", []);
format_error({not_found, Plugin}) -> format_error({not_found, Plugin}) ->
io_lib:format("Plugin to upgrade not found: ~s", [Plugin]);
io_lib:format("Plugin to upgrade not found: ~ts", [Plugin]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).

+ 7
- 7
src/rebar_prv_report.erl View File

@ -44,7 +44,7 @@ do(State) ->
{ok, Vsn} = application:get_key(rebar, vsn), {ok, Vsn} = application:get_key(rebar, vsn),
{ok, Apps} = application:get_key(rebar, applications), {ok, Apps} = application:get_key(rebar, applications),
[application:load(App) || App <- Apps], [application:load(App) || App <- Apps],
Vsns = [io_lib:format("~p: ~s~n", [App, AVsn])
Vsns = [io_lib:format("~p: ~ts~n", [App, AVsn])
|| App <- lists:sort(Apps), || App <- lists:sort(Apps),
{ok, AVsn} <- [application:get_key(App, vsn)]], {ok, AVsn} <- [application:get_key(App, vsn)]],
%% Show OS and versions %% Show OS and versions
@ -59,10 +59,10 @@ do(State) ->
%% %%
?CONSOLE( ?CONSOLE(
"Rebar3 report~n" "Rebar3 report~n"
" version ~s~n"
" generated at ~s~n"
" version ~ts~n"
" generated at ~ts~n"
"=================~n" "=================~n"
"Please submit this along with your issue at ~s "
"Please submit this along with your issue at ~ts "
"(and feel free to edit out private information, if any)~n" "(and feel free to edit out private information, if any)~n"
"-----------------~n" "-----------------~n"
"Task: ~ts~n" "Task: ~ts~n"
@ -75,11 +75,11 @@ do(State) ->
"Library directory: ~ts~n" "Library directory: ~ts~n"
"-----------------~n" "-----------------~n"
"Loaded Applications:~n" "Loaded Applications:~n"
" ~s~n"
"~ts~n"
"-----------------~n" "-----------------~n"
"Escript path: ~ts~n" "Escript path: ~ts~n"
"Providers:~n" "Providers:~n"
" ~s",
" ~ts",
[Vsn, time_to_string(UTC), [Vsn, time_to_string(UTC),
?ISSUES_URL, Command, Task, ?ISSUES_URL, Command, Task,
OS, ERTS, Root, Lib, OS, ERTS, Root, Lib,
@ -100,4 +100,4 @@ time_to_string({{Y,M,D},{H,Min,S}}) ->
[Y,M,D,H,Min,S])). [Y,M,D,H,Min,S])).
parse_task(Str) -> parse_task(Str) ->
hd(re:split(Str, " ")).
hd(re:split(Str, " ", [unicode])).

+ 2
- 2
src/rebar_prv_unlock.erl View File

@ -66,7 +66,7 @@ format_error(Reason) ->
handle_unlocks(State, Locks, LockFile) -> handle_unlocks(State, Locks, LockFile) ->
{Args, _} = rebar_state:command_parsed_args(State), {Args, _} = rebar_state:command_parsed_args(State),
Names = parse_names(ec_cnv:to_binary(proplists:get_value(package, Args, <<"">>))),
Names = parse_names(rebar_utils:to_binary(proplists:get_value(package, Args, <<"">>))),
case [Lock || Lock = {Name, _, _} <- Locks, not lists:member(Name, Names)] of case [Lock || Lock = {Name, _, _} <- Locks, not lists:member(Name, Names)] of
[] -> [] ->
file:delete(LockFile); file:delete(LockFile);
@ -77,7 +77,7 @@ handle_unlocks(State, Locks, LockFile) ->
end. end.
parse_names(Bin) -> parse_names(Bin) ->
case lists:usort(re:split(Bin, <<" *, *">>, [trim])) of
case lists:usort(re:split(Bin, <<" *, *">>, [trim, unicode])) of
[<<"">>] -> []; % nothing submitted [<<"">>] -> []; % nothing submitted
Other -> Other Other -> Other
end. end.

+ 5
- 5
src/rebar_prv_update.erl View File

@ -150,7 +150,7 @@ update_deps_list(Pkg, PkgVsn, Deps, HexRegistry, State) ->
%% and doubled since spaces seem not to be %% and doubled since spaces seem not to be
%% enforced %% enforced
{false, Vsn} -> {false, Vsn} ->
?WARN("[ ~s: ~s], Bad dependency version for ~s: ~s.",
?WARN("[~ts:~ts], Bad dependency version for ~ts: ~ts.",
[Pkg, PkgVsn, Dep, Vsn]), [Pkg, PkgVsn, Dep, Vsn]),
DepsListAcc; DepsListAcc;
{_, <<"~>", Vsn/binary>>} -> {_, <<"~>", Vsn/binary>>} ->
@ -202,14 +202,14 @@ valid_vsn(Vsn) ->
SemVerRegExp = "v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?" SemVerRegExp = "v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?"
"(-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9a-z-]+(\\.[0-9a-z-]+)*)?", "(-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9a-z-]+(\\.[0-9a-z-]+)*)?",
SupportedVersions = "^(>=?|<=?|~>|==)?\\s*" ++ SemVerRegExp ++ "$", SupportedVersions = "^(>=?|<=?|~>|==)?\\s*" ++ SemVerRegExp ++ "$",
re:run(Vsn, SupportedVersions) =/= nomatch.
re:run(Vsn, SupportedVersions, [unicode]) =/= nomatch.
highest_matching({Pkg, PkgVsn, Dep, App}, Vsn, HexRegistry, State, DepsListAcc) -> highest_matching({Pkg, PkgVsn, Dep, App}, Vsn, HexRegistry, State, DepsListAcc) ->
case rebar_packages:find_highest_matching(Pkg, PkgVsn, Dep, Vsn, HexRegistry, State) of case rebar_packages:find_highest_matching(Pkg, PkgVsn, Dep, Vsn, HexRegistry, State) of
{ok, HighestDepVsn} -> {ok, HighestDepVsn} ->
[{App, {pkg, Dep, HighestDepVsn, undefined}} | DepsListAcc]; [{App, {pkg, Dep, HighestDepVsn, undefined}} | DepsListAcc];
none -> none ->
?WARN("[ ~s: ~s] Missing registry entry for package ~s. Try to fix with `rebar3 update`",
?WARN("[~ts:~ts] Missing registry entry for package ~ts. Try to fix with `rebar3 update`",
[Pkg, PkgVsn, Dep]), [Pkg, PkgVsn, Dep]),
DepsListAcc DepsListAcc
end. end.
@ -220,7 +220,7 @@ cmp({_Pkg, _PkgVsn, Dep, _App} = Dep1, Vsn, HexRegistry, State, DepsListAcc, Cmp
cmp_(undefined, _MinVsn, [], DepsListAcc, {Pkg, PkgVsn, Dep, _App}, _CmpFun) -> cmp_(undefined, _MinVsn, [], DepsListAcc, {Pkg, PkgVsn, Dep, _App}, _CmpFun) ->
?WARN("[ ~s: ~s] Missing registry entry for package ~s. Try to fix with `rebar3 update`",
?WARN("[~ts:~ts] Missing registry entry for package ~ts. Try to fix with `rebar3 update`",
[Pkg, PkgVsn, Dep]), [Pkg, PkgVsn, Dep]),
DepsListAcc; DepsListAcc;
cmp_(HighestDepVsn, _MinVsn, [], DepsListAcc, {_Pkg, _PkgVsn, Dep, App}, _CmpFun) -> cmp_(HighestDepVsn, _MinVsn, [], DepsListAcc, {_Pkg, _PkgVsn, Dep, App}, _CmpFun) ->
@ -241,7 +241,7 @@ cmpl({_Pkg, _PkgVsn, Dep, _App} = Dep1, Vsn, HexRegistry, State, DepsListAcc, Cm
cmpl_(undefined, Vsn, Vsns, DepsListAcc, Dep1, CmpFun). cmpl_(undefined, Vsn, Vsns, DepsListAcc, Dep1, CmpFun).
cmpl_(undefined, _MaxVsn, [], DepsListAcc, {Pkg, PkgVsn, Dep, _App}, _CmpFun) -> cmpl_(undefined, _MaxVsn, [], DepsListAcc, {Pkg, PkgVsn, Dep, _App}, _CmpFun) ->
?WARN("[ ~s: ~s] Missing registry entry for package ~s. Try to fix with `rebar3 update`",
?WARN("[~ts:~ts] Missing registry entry for package ~ts. Try to fix with `rebar3 update`",
[Pkg, PkgVsn, Dep]), [Pkg, PkgVsn, Dep]),
DepsListAcc; DepsListAcc;

+ 6
- 6
src/rebar_prv_upgrade.erl View File

@ -68,7 +68,7 @@ do(State) ->
ProfileDeps = rebar_state:get(State, {deps, default}, []), ProfileDeps = rebar_state:get(State, {deps, default}, []),
Deps = [Dep || Dep <- TopDeps ++ ProfileDeps, % TopDeps > ProfileDeps Deps = [Dep || Dep <- TopDeps ++ ProfileDeps, % TopDeps > ProfileDeps
is_atom(Dep) orelse is_atom(element(1, Dep))], is_atom(Dep) orelse is_atom(element(1, Dep))],
Names = parse_names(ec_cnv:to_binary(proplists:get_value(package, Args, <<"">>)), Locks),
Names = parse_names(rebar_utils:to_binary(proplists:get_value(package, Args, <<"">>)), Locks),
DepsDict = deps_dict(rebar_state:all_deps(State)), DepsDict = deps_dict(rebar_state:all_deps(State)),
AltDeps = find_non_default_deps(Deps, State), AltDeps = find_non_default_deps(Deps, State),
FilteredNames = cull_default_names_if_profiles(Names, Deps, State), FilteredNames = cull_default_names_if_profiles(Names, Deps, State),
@ -109,7 +109,7 @@ format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).
parse_names(Bin, Locks) -> parse_names(Bin, Locks) ->
case lists:usort(re:split(Bin, <<" *, *">>, [trim])) of
case lists:usort(re:split(Bin, <<" *, *">>, [trim, unicode])) of
%% Nothing submitted, use *all* apps %% Nothing submitted, use *all* apps
[<<"">>] -> [Name || {Name, _, 0} <- Locks]; [<<"">>] -> [Name || {Name, _, 0} <- Locks];
[] -> [Name || {Name, _, 0} <- Locks]; [] -> [Name || {Name, _, 0} <- Locks];
@ -150,7 +150,7 @@ prepare_locks([Name|Names], Deps, Locks, Unlocks, Dict, AltDeps) ->
{_, _, 0} = Lock -> {_, _, 0} = Lock ->
case rebar_utils:tup_find(AtomName, Deps) of case rebar_utils:tup_find(AtomName, Deps) of
false -> false ->
?WARN("Dependency ~s has been removed and will not be upgraded", [Name]),
?WARN("Dependency ~ts has been removed and will not be upgraded", [Name]),
prepare_locks(Names, Deps, Locks, Unlocks, Dict, AltDeps); prepare_locks(Names, Deps, Locks, Unlocks, Dict, AltDeps);
Dep -> Dep ->
{Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks, Dict), {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks, Dict),
@ -181,7 +181,7 @@ prepare_lock(Dep, Lock, Locks, Dict) ->
{Name, _, Src} -> {Name, Src}; {Name, _, Src} -> {Name, Src};
_ when is_atom(Dep) -> _ when is_atom(Dep) ->
%% version-free package. Must unlock whatever matches in locks %% version-free package. Must unlock whatever matches in locks
{_, Vsn, _} = lists:keyfind(ec_cnv:to_binary(Dep), 1, Locks),
{_, Vsn, _} = lists:keyfind(rebar_utils:to_binary(Dep), 1, Locks),
{Dep, Vsn} {Dep, Vsn}
end, end,
Children = all_children(Name1, Dict), Children = all_children(Name1, Dict),
@ -197,7 +197,7 @@ unlock_children(Children, Locks) ->
unlock_children(_, [], Locks, Unlocks) -> unlock_children(_, [], Locks, Unlocks) ->
{Locks, Unlocks}; {Locks, Unlocks};
unlock_children(Children, [App = {Name,_,_} | Apps], Locks, Unlocks) -> unlock_children(Children, [App = {Name,_,_} | Apps], Locks, Unlocks) ->
case lists:member(ec_cnv:to_binary(Name), Children) of
case lists:member(rebar_utils:to_binary(Name), Children) of
true -> true ->
unlock_children(Children, Apps, Locks, [App | Unlocks]); unlock_children(Children, Apps, Locks, [App | Unlocks]);
false -> false ->
@ -215,7 +215,7 @@ all_children(Name, Dict) ->
lists:flatten(all_children_(Name, Dict)). lists:flatten(all_children_(Name, Dict)).
all_children_(Name, Dict) -> all_children_(Name, Dict) ->
case dict:find(ec_cnv:to_binary(Name), Dict) of
case dict:find(rebar_utils:to_binary(Name), Dict) of
{ok, Children} -> {ok, Children} ->
[Children | [all_children_(Child, Dict) || Child <- Children]]; [Children | [all_children_(Child, Dict) || Child <- Children]];
error -> error ->

+ 12
- 12
src/rebar_prv_xref.erl View File

@ -71,7 +71,7 @@ short_desc() ->
desc() -> desc() ->
io_lib:format( io_lib:format(
" ~s~n"
"~ts~n"
"~n" "~n"
"Valid rebar.config options:~n" "Valid rebar.config options:~n"
" ~p~n" " ~p~n"
@ -204,7 +204,7 @@ display_results(XrefResults, QueryResults) ->
lists:map(fun display_query_result/1, QueryResults)]. lists:map(fun display_query_result/1, QueryResults)].
display_query_result({Query, Answer, Value}) -> display_query_result({Query, Answer, Value}) ->
io_lib:format("Query ~s~n answer ~p~n did not match ~p~n",
io_lib:format("Query ~ts~n answer ~p~n did not match ~p~n",
[Query, Answer, Value]). [Query, Answer, Value]).
display_xref_results_for_type({Type, XrefResults}) -> display_xref_results_for_type({Type, XrefResults}) ->
@ -225,37 +225,37 @@ display_xref_result_fun(Type) ->
end, end,
case Type of case Type of
undefined_function_calls -> undefined_function_calls ->
io_lib:format(" ~sWarning: ~s calls undefined function ~s (Xref)\n",
io_lib:format("~tsWarning: ~ts calls undefined function ~ts (Xref)\n",
[Source, SMFA, TMFA]); [Source, SMFA, TMFA]);
undefined_functions -> undefined_functions ->
io_lib:format(" ~sWarning: ~s is undefined function (Xref)\n",
io_lib:format("~tsWarning: ~ts is undefined function (Xref)\n",
[Source, SMFA]); [Source, SMFA]);
locals_not_used -> locals_not_used ->
io_lib:format(" ~sWarning: ~s is unused local function (Xref)\n",
io_lib:format("~tsWarning: ~ts is unused local function (Xref)\n",
[Source, SMFA]); [Source, SMFA]);
exports_not_used -> exports_not_used ->
io_lib:format(" ~sWarning: ~s is unused export (Xref)\n",
io_lib:format("~tsWarning: ~ts is unused export (Xref)\n",
[Source, SMFA]); [Source, SMFA]);
deprecated_function_calls -> deprecated_function_calls ->
io_lib:format(" ~sWarning: ~s calls deprecated function ~s (Xref)\n",
io_lib:format("~tsWarning: ~ts calls deprecated function ~ts (Xref)\n",
[Source, SMFA, TMFA]); [Source, SMFA, TMFA]);
deprecated_functions -> deprecated_functions ->
io_lib:format(" ~sWarning: ~s is deprecated function (Xref)\n",
io_lib:format("~tsWarning: ~ts is deprecated function (Xref)\n",
[Source, SMFA]); [Source, SMFA]);
Other -> Other ->
io_lib:format(" ~sWarning: ~s - ~s xref check: ~s (Xref)\n",
io_lib:format("~tsWarning: ~ts - ~ts xref check: ~ts (Xref)\n",
[Source, SMFA, TMFA, Other]) [Source, SMFA, TMFA, Other])
end end
end. end.
format_mfa({M, F, A}) -> format_mfa({M, F, A}) ->
?FMT(" ~s: ~s/~w", [M, F, A]).
?FMT("~ts:~ts/~w", [M, F, A]).
format_mfa_source(MFA) -> format_mfa_source(MFA) ->
case find_mfa_source(MFA) of case find_mfa_source(MFA) of
{module_not_found, function_not_found} -> ""; {module_not_found, function_not_found} -> "";
{Source, function_not_found} -> ?FMT(" ~s: ", [Source]);
{Source, Line} -> ?FMT(" ~s:~w: ", [Source, Line])
{Source, function_not_found} -> ?FMT("~ts: ", [Source]);
{Source, Line} -> ?FMT("~ts:~w: ", [Source, Line])
end. end.
%% %%

+ 3
- 3
src/rebar_state.erl View File

@ -182,7 +182,7 @@ all(_, []) ->
all(Dir, [File|Artifacts]) -> all(Dir, [File|Artifacts]) ->
case filelib:is_regular(filename:join(Dir, File)) of case filelib:is_regular(filename:join(Dir, File)) of
false -> false ->
?DEBUG("Missing artifact ~s", [filename:join(Dir, File)]),
?DEBUG("Missing artifact ~ts", [filename:join(Dir, File)]),
{false, File}; {false, File};
true -> true ->
all(Dir, Artifacts) all(Dir, Artifacts)
@ -302,9 +302,9 @@ dir(State=#state_t{}, Dir) ->
deps_names(Deps) when is_list(Deps) -> deps_names(Deps) when is_list(Deps) ->
lists:map(fun(Dep) when is_tuple(Dep) -> lists:map(fun(Dep) when is_tuple(Dep) ->
ec_cnv:to_binary(element(1, Dep));
rebar_utils:to_binary(element(1, Dep));
(Dep) when is_atom(Dep) -> (Dep) when is_atom(Dep) ->
ec_cnv:to_binary(Dep)
rebar_utils:to_binary(Dep)
end, Deps); end, Deps);
deps_names(State) -> deps_names(State) ->
Deps = rebar_state:get(State, deps, []), Deps = rebar_state:get(State, deps, []),

+ 9
- 9
src/rebar_templater.erl View File

@ -129,7 +129,7 @@ default_author_and_email() ->
%% Ok, try mecurial %% Ok, try mecurial
case rebar_utils:sh("hg showconfig ui.username", [return_on_error]) of case rebar_utils:sh("hg showconfig ui.username", [return_on_error]) of
{ok, NameEmail} -> {ok, NameEmail} ->
case re:run(NameEmail, "^(.*) <(.*)>$", [{capture, [1,2], list}]) of
case re:run(NameEmail, "^(.*) <(.*)>$", [{capture, [1,2], list}, unicode]) of
{match, [Name, Email]} -> {match, [Name, Email]} ->
{Name, Email}; {Name, Email};
_ -> _ ->
@ -169,7 +169,7 @@ maybe_warn_about_name(Vars) ->
invalid -> invalid ->
?WARN("The 'name' variable is often associated with Erlang " ?WARN("The 'name' variable is often associated with Erlang "
"module names and/or file names. The value submitted " "module names and/or file names. The value submitted "
"( ~s) isn't an unquoted Erlang atom. Templates "
"(~ts) isn't an unquoted Erlang atom. Templates "
"generated may contain errors.", "generated may contain errors.",
[Name]); [Name]);
valid -> valid ->
@ -189,7 +189,7 @@ validate_atom(Str) ->
%% Run template instructions one at a time. %% Run template instructions one at a time.
execute_template([], _, {Template,_,_}, _, _) -> execute_template([], _, {Template,_,_}, _, _) ->
?DEBUG("Template ~s applied", [Template]),
?DEBUG("Template ~ts applied", [Template]),
ok; ok;
%% We can't execute the description %% We can't execute the description
execute_template([{description, _} | Terms], Files, Template, Vars, Force) -> execute_template([{description, _} | Terms], Files, Template, Vars, Force) ->
@ -242,7 +242,7 @@ execute_template([{template, From, To} | Terms], Files, {Template, Type, Cwd}, V
execute_template(Terms, Files, {Template, Type, Cwd}, Vars, Force); execute_template(Terms, Files, {Template, Type, Cwd}, Vars, Force);
%% Unknown %% Unknown
execute_template([Instruction|Terms], Files, Tpl={Template,_,_}, Vars, Force) -> execute_template([Instruction|Terms], Files, Tpl={Template,_,_}, Vars, Force) ->
?WARN("Unknown template instruction ~p in template ~s",
?WARN("Unknown template instruction ~p in template ~ts",
[Instruction, Template]), [Instruction, Template]),
execute_template(Terms, Files, Tpl, Vars, Force). execute_template(Terms, Files, Tpl, Vars, Force).
@ -305,7 +305,7 @@ cache_escript_files(State) ->
find_escript_templates(Files) -> find_escript_templates(Files) ->
[{escript, Name} [{escript, Name}
|| {Name, _Bin} <- Files, || {Name, _Bin} <- Files,
re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
re:run(Name, ?TEMPLATE_RE, [{capture, none}, unicode]) == match].
find_localinstall_templates(_State) -> find_localinstall_templates(_State) ->
Templates = rebar_utils:find_files(code:priv_dir(rebar), ?TEMPLATE_RE), Templates = rebar_utils:find_files(code:priv_dir(rebar), ?TEMPLATE_RE),
@ -374,7 +374,7 @@ prioritize_templates([{Name, Type, File} | Rest], Valid) ->
prioritize_templates(Rest, Valid); prioritize_templates(Rest, Valid);
{_, file, _} -> {_, file, _} ->
?DEBUG("Skipping template ~p, due to presence of a custom " ?DEBUG("Skipping template ~p, due to presence of a custom "
"template at ~s", [Name, File]),
"template at ~ts", [Name, File]),
prioritize_templates(Rest, Valid) prioritize_templates(Rest, Valid)
end. end.
@ -429,10 +429,10 @@ write_file(Output, Data, Force) ->
ok = filelib:ensure_dir(Output), ok = filelib:ensure_dir(Output),
case {Force, FileExists} of case {Force, FileExists} of
{true, true} -> {true, true} ->
?INFO("Writing ~s (forcibly overwriting)",
?INFO("Writing ~ts (forcibly overwriting)",
[Output]); [Output]);
_ -> _ ->
?INFO("Writing ~s", [Output])
?INFO("Writing ~ts", [Output])
end, end,
case file:write_file(Output, Data) of case file:write_file(Output, Data) of
ok -> ok ->
@ -449,4 +449,4 @@ write_file(Output, Data, Force) ->
%% Render a binary to a string, using mustache and the specified context %% Render a binary to a string, using mustache and the specified context
%% %%
render(Bin, Context) -> render(Bin, Context) ->
bbmustache:render(ec_cnv:to_binary(Bin), Context, [{key_type, atom}]).
bbmustache:render(rebar_utils:to_binary(Bin), Context, [{key_type, atom}]).

+ 40
- 29
src/rebar_utils.erl View File

@ -55,6 +55,8 @@
get_arch/0, get_arch/0,
wordsize/0, wordsize/0,
deps_to_binary/1, deps_to_binary/1,
to_binary/1,
to_list/1,
tup_dedup/1, tup_dedup/1,
tup_umerge/2, tup_umerge/2,
tup_sort/1, tup_sort/1,
@ -115,7 +117,7 @@ filtermap(F, [Hd|Tail]) ->
filtermap(F, []) when is_function(F, 1) -> []. filtermap(F, []) when is_function(F, 1) -> [].
is_arch(ArchRegex) -> is_arch(ArchRegex) ->
case re:run(get_arch(), ArchRegex, [{capture, none}]) of
case re:run(get_arch(), ArchRegex, [{capture, none}, unicode]) of
match -> match ->
true; true;
nomatch -> nomatch ->
@ -142,7 +144,7 @@ wordsize() ->
end. end.
sh_send(Command0, String, Options0) -> sh_send(Command0, String, Options0) ->
?INFO("sh_send info:\n\tcwd: ~p\n\tcmd: ~s < ~s\n",
?INFO("sh_send info:\n\tcwd: ~p\n\tcmd: ~ts < ~ts\n",
[rebar_dir:get_cwd(), Command0, String]), [rebar_dir:get_cwd(), Command0, String]),
?DEBUG("\topts: ~p\n", [Options0]), ?DEBUG("\topts: ~p\n", [Options0]),
@ -171,7 +173,7 @@ sh_send(Command0, String, Options0) ->
%% Val = string() | false %% Val = string() | false
%% %%
sh(Command0, Options0) -> sh(Command0, Options0) ->
?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [rebar_dir:get_cwd(), Command0]),
?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~ts\n", [rebar_dir:get_cwd(), Command0]),
?DEBUG("\topts: ~p\n", [Options0]), ?DEBUG("\topts: ~p\n", [Options0]),
DefaultOptions = [{use_stdout, false}, debug_and_abort_on_error], DefaultOptions = [{use_stdout, false}, debug_and_abort_on_error],
@ -184,7 +186,7 @@ sh(Command0, Options0) ->
Command = lists:flatten(patch_on_windows(Command0, proplists:get_value(env, Options, []))), Command = lists:flatten(patch_on_windows(Command0, proplists:get_value(env, Options, []))),
PortSettings = proplists:get_all_values(port_settings, Options) ++ PortSettings = proplists:get_all_values(port_settings, Options) ++
[exit_status, {line, 16384}, use_stdio, stderr_to_stdout, hide, eof], [exit_status, {line, 16384}, use_stdio, stderr_to_stdout, hide, eof],
?DEBUG("Port Cmd: ~s\nPort Opts: ~p\n", [Command, PortSettings]),
?DEBUG("Port Cmd: ~ts\nPort Opts: ~p\n", [Command, PortSettings]),
Port = open_port({spawn, Command}, PortSettings), Port = open_port({spawn, Command}, PortSettings),
try try
@ -232,7 +234,7 @@ deprecated(Old, New, When) ->
<<"WARNING: deprecated ~p option used~n" <<"WARNING: deprecated ~p option used~n"
"Option '~p' has been deprecated~n" "Option '~p' has been deprecated~n"
"in favor of '~p'.~n" "in favor of '~p'.~n"
"'~p' will be removed ~s.~n">>,
"'~p' will be removed ~ts.~n">>,
[Old, Old, New, Old, When]). [Old, Old, New, Old, When]).
%% for use by `do` task %% for use by `do` task
@ -244,11 +246,17 @@ args_to_tasks(Args) -> new_task(Args, []).
deps_to_binary([]) -> deps_to_binary([]) ->
[]; [];
deps_to_binary([{Name, _, Source} | T]) -> deps_to_binary([{Name, _, Source} | T]) ->
[{ec_cnv:to_binary(Name), Source} | deps_to_binary(T)];
[{to_binary(Name), Source} | deps_to_binary(T)];
deps_to_binary([{Name, Source} | T]) -> deps_to_binary([{Name, Source} | T]) ->
[{ec_cnv:to_binary(Name), Source} | deps_to_binary(T)];
[{to_binary(Name), Source} | deps_to_binary(T)];
deps_to_binary([Name | T]) -> deps_to_binary([Name | T]) ->
[ec_cnv:to_binary(Name) | deps_to_binary(T)].
[to_binary(Name) | deps_to_binary(T)].
to_binary(A) when is_atom(A) -> atom_to_binary(A, unicode);
to_binary(Str) -> unicode:characters_to_binary(Str).
to_list(A) when is_atom(A) -> atom_to_list(A);
to_list(Str) -> unicode:characters_to_list(Str).
tup_dedup(List) -> tup_dedup(List) ->
tup_dedup_(tup_sort(List)). tup_dedup_(tup_sort(List)).
@ -396,10 +404,10 @@ check_min_otp_version(MinOtpVersion) ->
case ParsedVsn >= ParsedMin of case ParsedVsn >= ParsedMin of
true -> true ->
?DEBUG(" ~s satisfies the requirement for minimum OTP version ~s",
?DEBUG("~ts satisfies the requirement for minimum OTP version ~ts",
[OtpRelease, MinOtpVersion]); [OtpRelease, MinOtpVersion]);
false -> false ->
?ABORT("OTP release ~s or later is required. Version in use: ~s",
?ABORT("OTP release ~ts or later is required. Version in use: ~ts",
[MinOtpVersion, OtpRelease]) [MinOtpVersion, OtpRelease])
end. end.
@ -415,16 +423,16 @@ check_blacklisted_otp_versions(BlacklistedRegexes) ->
abort_if_blacklisted(BlacklistedRegex, OtpRelease) -> abort_if_blacklisted(BlacklistedRegex, OtpRelease) ->
case re:run(OtpRelease, BlacklistedRegex, [{capture, none}]) of case re:run(OtpRelease, BlacklistedRegex, [{capture, none}]) of
match -> match ->
?ABORT("OTP release ~s matches blacklisted version ~s",
?ABORT("OTP release ~ts matches blacklisted version ~ts",
[OtpRelease, BlacklistedRegex]); [OtpRelease, BlacklistedRegex]);
nomatch -> nomatch ->
?DEBUG(" ~s does not match blacklisted OTP version ~s",
?DEBUG("~ts does not match blacklisted OTP version ~ts",
[OtpRelease, BlacklistedRegex]) [OtpRelease, BlacklistedRegex])
end. end.
user_agent() -> user_agent() ->
{ok, Vsn} = application:get_key(rebar, vsn), {ok, Vsn} = application:get_key(rebar, vsn),
?FMT("Rebar/ ~s (OTP/ ~s)", [Vsn, otp_release()]).
?FMT("Rebar/~ts (OTP/~ts)", [Vsn, otp_release()]).
reread_config(ConfigList) -> reread_config(ConfigList) ->
%% NB: we attempt to mimic -config here, which survives app reload, %% NB: we attempt to mimic -config here, which survives app reload,
@ -457,7 +465,7 @@ version_tuple(OtpRelease) ->
{match, [_Full, Maj]} -> {match, [_Full, Maj]} ->
{list_to_integer(Maj), 0, 0}; {list_to_integer(Maj), 0, 0};
nomatch -> nomatch ->
?ABORT("Minimum OTP release unable to be parsed: ~s", [OtpRelease])
?ABORT("Minimum OTP release unable to be parsed: ~ts", [OtpRelease])
end. end.
otp_release() -> otp_release() ->
@ -510,7 +518,7 @@ patch_on_windows(Cmd, Env) ->
end, Cmd, Env), end, Cmd, Env),
%% Remove left-over vars %% Remove left-over vars
re:replace(Cmd1, "\\\$\\w+|\\\${\\w+}", "", re:replace(Cmd1, "\\\$\\w+|\\\${\\w+}", "",
[global, {return, list}]);
[global, {return, list}, unicode]);
_ -> _ ->
Cmd Cmd
end. end.
@ -529,7 +537,7 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts), VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
%% Use a regex to match/replace: %% Use a regex to match/replace:
%% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
RegEx = io_lib:format("\\\$( ~s(\\W|$)|{ ~s})", [VarName, VarName]),
RegEx = io_lib:format("\\\$(~ts(\\W|$)|{~ts})", [VarName, VarName]),
re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts) re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
end. end.
@ -554,7 +562,7 @@ expand_sh_flag(use_stdout) ->
{output_handler, {output_handler,
fun(Line, Acc) -> fun(Line, Acc) ->
%% Line already has a newline so don't use ?CONSOLE which adds one %% Line already has a newline so don't use ?CONSOLE which adds one
io:format(" ~s", [Line]),
io:format("~ts", [Line]),
[Line | Acc] [Line | Acc]
end}; end};
expand_sh_flag({use_stdout, false}) -> expand_sh_flag({use_stdout, false}) ->
@ -577,23 +585,23 @@ log_msg_and_abort(Message) ->
-spec debug_log_msg_and_abort(string()) -> err_handler(). -spec debug_log_msg_and_abort(string()) -> err_handler().
debug_log_msg_and_abort(Message) -> debug_log_msg_and_abort(Message) ->
fun(Command, {Rc, Output}) -> fun(Command, {Rc, Output}) ->
?DEBUG("sh( ~s)~n"
?DEBUG("sh(~ts)~n"
"failed with return code ~w and the following output:~n" "failed with return code ~w and the following output:~n"
" ~s", [Command, Rc, Output]),
"~ts", [Command, Rc, Output]),
?ABORT(Message, []) ?ABORT(Message, [])
end. end.
-spec log_and_abort(string(), {integer(), string()}) -> no_return(). -spec log_and_abort(string(), {integer(), string()}) -> no_return().
log_and_abort(Command, {Rc, Output}) -> log_and_abort(Command, {Rc, Output}) ->
?ABORT("sh( ~s)~n"
?ABORT("sh(~ts)~n"
"failed with return code ~w and the following output:~n" "failed with return code ~w and the following output:~n"
" ~s", [Command, Rc, Output]).
"~ts", [Command, Rc, Output]).
-spec debug_and_abort(string(), {integer(), string()}) -> no_return(). -spec debug_and_abort(string(), {integer(), string()}) -> no_return().
debug_and_abort(Command, {Rc, Output}) -> debug_and_abort(Command, {Rc, Output}) ->
?DEBUG("sh( ~s)~n"
?DEBUG("sh(~ts)~n"
"failed with return code ~w and the following output:~n" "failed with return code ~w and the following output:~n"
" ~s", [Command, Rc, Output]),
"~ts", [Command, Rc, Output]),
throw(rebar_abort). throw(rebar_abort).
sh_loop(Port, Fun, Acc) -> sh_loop(Port, Fun, Acc) ->
@ -662,7 +670,7 @@ vcs_vsn(Vcs, Dir, Resources) ->
unknown -> unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p", [Vcs]); ?ABORT("vcs_vsn: Unknown vsn format: ~p", [Vcs]);
{error, Reason} -> {error, Reason} ->
?ABORT("vcs_vsn: ~s", [Reason])
?ABORT("vcs_vsn: ~ts", [Reason])
end. end.
%% Temp work around for repos like relx that use "semver" %% Temp work around for repos like relx that use "semver"
@ -779,7 +787,7 @@ cleanup_code_path(OrigPath) ->
new_task([], Acc) -> lists:reverse(Acc); new_task([], Acc) -> lists:reverse(Acc);
new_task([TaskList|Rest], Acc) -> new_task([TaskList|Rest], Acc) ->
case re:split(TaskList, ",", [{return, list}, {parts, 2}]) of
case re:split(TaskList, ",", [{return, list}, {parts, 2}, unicode]) of
%% `do` consumes all remaining args %% `do` consumes all remaining args
["do" = Task] -> ["do" = Task] ->
lists:reverse([{Task, Rest}|Acc]); lists:reverse([{Task, Rest}|Acc]);
@ -806,7 +814,7 @@ arg_or_flag(["-" ++ _ = Flag|Rest], [{Task, Args}|Acc]) ->
end; end;
%% an argument or a sequence of arguments %% an argument or a sequence of arguments
arg_or_flag([ArgList|Rest], [{Task, Args}|Acc]) -> arg_or_flag([ArgList|Rest], [{Task, Args}|Acc]) ->
case re:split(ArgList, ",", [{return, list}, {parts, 2}]) of
case re:split(ArgList, ",", [{return, list}, {parts, 2}, unicode]) of
%% single arg terminated by a comma %% single arg terminated by a comma
[Arg, ""] -> new_task(Rest, [{Task, [Arg, ""] -> new_task(Rest, [{Task,
lists:reverse([Arg|Args])}|Acc]); lists:reverse([Arg|Args])}|Acc]);
@ -857,15 +865,18 @@ url_append_path(Url, ExtraPath) ->
escape_chars(Str) when is_atom(Str) -> escape_chars(Str) when is_atom(Str) ->
escape_chars(atom_to_list(Str)); escape_chars(atom_to_list(Str));
escape_chars(Str) -> escape_chars(Str) ->
re:replace(Str, "([ ()?`!$&;\"\'])", "\\\\&", [global, {return, list}]).
re:replace(Str, "([ ()?`!$&;\"\'])", "\\\\&",
[global, {return, list}, unicode]).
%% "escape inside these" %% "escape inside these"
escape_double_quotes(Str) -> escape_double_quotes(Str) ->
re:replace(Str, "([\"\\\\`!$&*;])", "\\\\&", [global, {return, list}]).
re:replace(Str, "([\"\\\\`!$&*;])", "\\\\&",
[global, {return, list}, unicode]).
%% "escape inside these" but allow * %% "escape inside these" but allow *
escape_double_quotes_weak(Str) -> escape_double_quotes_weak(Str) ->
re:replace(Str, "([\"\\\\`!$&;])", "\\\\&", [global, {return, list}]).
re:replace(Str, "([\"\\\\`!$&;])", "\\\\&",
[global, {return, list}, unicode]).
info_useless(Old, New) -> info_useless(Old, New) ->
[?INFO("App ~ts is no longer needed and can be deleted.", [Name]) [?INFO("App ~ts is no longer needed and can be deleted.", [Name])

+ 1
- 1
test/rebar_as_SUITE.erl View File

@ -176,7 +176,7 @@ error_on_empty_tasks(Config) ->
warn_match(App, History) -> warn_match(App, History) ->
lists:any( lists:any(
fun({_, {rebar_log,log, [warn, "No entry for profile ~s in config.",
fun({_, {rebar_log,log, [warn, "No entry for profile ~ts in config.",
[ArgApp]]}, _}) -> ArgApp =:= App [ArgApp]]}, _}) -> ArgApp =:= App
; (_) -> ; (_) ->
false false

+ 2
- 2
test/rebar_ct_SUITE.erl View File

@ -1611,7 +1611,7 @@ test_suite(Name) ->
"some_test(_) -> ok.\n", [Name]). "some_test(_) -> ok.\n", [Name]).
cmd_sys_config_file(AppName) -> cmd_sys_config_file(AppName) ->
io_lib:format("[{ ~s, [{key, cmd_value}]}].", [AppName]).
io_lib:format("[{~ts, [{key, cmd_value}]}].", [AppName]).
cfg_sys_config_file(AppName) -> cfg_sys_config_file(AppName) ->
io_lib:format("[{ ~s, [{key, cfg_value}]}].", [AppName]).
io_lib:format("[{~ts, [{key, cfg_value}]}].", [AppName]).

+ 4
- 4
test/rebar_test_utils.erl View File

@ -349,7 +349,7 @@ check_results(AppDir, Expected, ProfileRun) ->
iolist_to_binary(LockVsn)) iolist_to_binary(LockVsn))
end end
; ({release, Name, Vsn, ExpectedDevMode}) -> ; ({release, Name, Vsn, ExpectedDevMode}) ->
ct:pal("Release: ~p- ~s", [Name, Vsn]),
ct:pal("Release: ~p-~ts", [Name, Vsn]),
{ok, Cwd} = file:get_cwd(), {ok, Cwd} = file:get_cwd(),
try try
file:set_cwd(AppDir), file:set_cwd(AppDir),
@ -377,14 +377,14 @@ check_results(AppDir, Expected, ProfileRun) ->
file:set_cwd(Cwd) file:set_cwd(Cwd)
end end
; ({tar, Name, Vsn}) -> ; ({tar, Name, Vsn}) ->
ct:pal("Tarball: ~s- ~s", [Name, Vsn]),
ct:pal("Tarball: ~ts-~ts", [Name, Vsn]),
Tarball = filename:join([AppDir, "_build", "rel", Name, Name++"-"++Vsn++".tar.gz"]), Tarball = filename:join([AppDir, "_build", "rel", Name, Name++"-"++Vsn++".tar.gz"]),
?assertNotEqual([], filelib:is_file(Tarball)) ?assertNotEqual([], filelib:is_file(Tarball))
; ({file, Filename}) -> ; ({file, Filename}) ->
ct:pal("Filename: ~s", [Filename]),
ct:pal("Filename: ~ts", [Filename]),
?assert(filelib:is_file(Filename)) ?assert(filelib:is_file(Filename))
; ({dir, Dirname}) -> ; ({dir, Dirname}) ->
ct:pal("Directory: ~s", [Dirname]),
ct:pal("Directory: ~ts", [Dirname]),
?assert(filelib:is_dir(Dirname)) ?assert(filelib:is_dir(Dirname))
end, Expected). end, Expected).

Loading…
Cancel
Save