summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-10-16 11:15:37 -0500
committerTristan Sloughter <t@crashfast.com>2014-10-16 11:15:37 -0500
commit141d34a5d01216b7e918b07c22ee998766217b6d (patch)
tree3dbfc4696caf1aba78e1f85d3077354c38d3a3d1
parentf1a0249bcf12f08b7aae21aec373fec4cd583dbe (diff)
remove unused utils functions
-rw-r--r--src/rebar_prv_compile.erl5
-rw-r--r--src/rebar_prv_install_deps.erl21
-rw-r--r--src/rebar_utils.erl146
3 files changed, 30 insertions, 142 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index e8a7154..fe0e197 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -42,8 +42,9 @@ do(State) ->
Deps = rebar_state:get(State1, deps_to_build, []),
lists:foreach(fun(AppInfo) ->
- C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
- S = rebar_state:new(State1, C, rebar_app_info:dir(AppInfo)),
+ AppDir = rebar_app_info:dir(AppInfo),
+ C = rebar_config:consult(AppDir),
+ S = rebar_state:new(State1, C, AppDir),
build(S, AppInfo)
end, Deps++ProjectApps),
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 6cd004c..a717e5f 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -118,17 +118,12 @@ handle_deps(State, Deps, Update) ->
%% Find pkg deps needed
{ok, S} = rlx_depsolver:solve(Graph, PkgDeps1),
%% Create app_info record for each pkg dep
- lists:flatmap(fun(Pkg) ->
- AppInfo = package_to_app(DepsDir
- ,Packages
- ,Pkg),
- case maybe_fetch(AppInfo, Update) of
- false ->
- [];
- true ->
- AppInfo
- end
- end, S)
+ [AppInfo || Pkg <- S,
+ AppInfo <- package_to_app(DepsDir
+ ,Packages
+ ,Pkg),
+ maybe_fetch(AppInfo, Update)]
+
end,
AllDeps = lists:ukeymerge(2
@@ -147,7 +142,7 @@ is_valid(App) ->
rebar_app_info:valid(App).
-spec package_to_app(file:filename_all(), rebar_dict(),
- rlx_depsolver:pkg()) -> rebar_app_info:t().
+ rlx_depsolver:pkg()) -> [rebar_app_info:t()].
package_to_app(DepsDir, Packages, Pkg={_, Vsn}) ->
Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)),
FmtVsn = iolist_to_binary(rlx_depsolver:format_version(Vsn)),
@@ -159,7 +154,7 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) ->
AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps),
AppInfo2 =
rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)),
- rebar_app_info:source(AppInfo2, Link).
+ [rebar_app_info:source(AppInfo2, Link)].
-spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t().
update_src_deps(Level, State, Update) ->
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 5397aa8..5661501 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -30,42 +30,25 @@
filtermap/2,
get_cwd/0,
is_arch/1,
- get_arch/0,
- wordsize/0,
sh/2,
sh_send/3,
escript_foldl/3,
find_files/2,
find_files/3,
- now_str/0,
ensure_dir/1,
beam_to_mod/1,
beams/1,
- erl_to_mod/1,
- abort/0,
- abort/2,
find_executable/1,
- prop_check/3,
expand_code_path/0,
- expand_env_variable/3,
vcs_vsn/3,
deprecated/3,
deprecated/4,
- get_deprecated_global/4,
- get_deprecated_global/5,
- get_experimental_global/3,
- get_experimental_local/3,
- get_deprecated_list/4,
- get_deprecated_list/5,
- get_deprecated_local/4,
- get_deprecated_local/5,
delayed_halt/1,
erl_opts/1,
src_dirs/1,
ebin_dir/0,
processing_base_dir/1,
processing_base_dir/2,
- patch_env/2,
indent/1]).
%% for internal use only
@@ -177,11 +160,6 @@ find_files(Dir, Regex, Recursive) ->
filelib:fold_files(Dir, Regex, Recursive,
fun(F, Acc) -> [F | Acc] end, []).
-now_str() ->
- {{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
- lists:flatten(io_lib:format("~4b/~2..0b/~2..0b ~2..0b:~2..0b:~2..0b",
- [Year, Month, Day, Hour, Minute, Second])).
-
%% TODO: filelib:ensure_dir/1 corrected in R13B04. Remove when we drop
%% support for OTP releases older than R13B04.
ensure_dir(Path) ->
@@ -194,15 +172,6 @@ ensure_dir(Path) ->
Error
end.
--spec abort() -> no_return().
-abort() ->
- throw(rebar_abort).
-
--spec abort(string(), [term()]) -> no_return().
-abort(String, Args) ->
- ?ERROR(String, Args),
- abort().
-
find_executable(Name) ->
case os:find_executable(Name) of
false -> false;
@@ -210,10 +179,6 @@ find_executable(Name) ->
"\"" ++ filename:nativename(Path) ++ "\""
end.
-%% Helper function for checking values and aborting when needed
-prop_check(true, _, _) -> true;
-prop_check(false, Msg, Args) -> ?ABORT(Msg, Args).
-
%% Convert all the entries in the code path to absolute paths.
expand_code_path() ->
CodePath = lists:foldl(fun(Path, Acc) ->
@@ -221,25 +186,6 @@ expand_code_path() ->
end, [], code:get_path()),
code:set_path(lists:reverse(CodePath)).
-%%
-%% Given env. variable FOO we want to expand all references to
-%% it in InStr. References can have two forms: $FOO and ${FOO}
-%% The end of form $FOO is delimited with whitespace or eol
-%%
-expand_env_variable(InStr, VarName, RawVarValue) ->
- case string:chr(InStr, $$) of
- 0 ->
- %% No variables to expand
- InStr;
- _ ->
- ReOpts = [global, unicode, {return, list}],
- VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
- %% Use a regex to match/replace:
- %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
- RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
- re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
- end.
-
vcs_vsn(Config, Vsn, Dir) ->
Key = {Vsn, Dir},
Cache = rebar_state:get(Config, vsn_cache, dict:new()),
@@ -253,33 +199,6 @@ vcs_vsn(Config, Vsn, Dir) ->
{Config, VsnString}
end.
-get_deprecated_global(Config, OldOpt, NewOpt, When) ->
- get_deprecated_global(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_global(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_state:get/3,
- Config, OldOpt, NewOpt, Default, When).
-
-get_experimental_global(Config, Opt, Default) ->
- get_experimental_3(fun rebar_state:get/3, Config, Opt, Default).
-
-get_experimental_local(Config, Opt, Default) ->
- get_experimental_3(fun rebar_state:get/3, Config, Opt, Default).
-
-get_deprecated_list(Config, OldOpt, NewOpt, When) ->
- get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_list(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_state:get_list/3,
- Config, OldOpt, NewOpt, Default, When).
-
-get_deprecated_local(Config, OldOpt, NewOpt, When) ->
- get_deprecated_local(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_local(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_state:get/3,
- Config, OldOpt, NewOpt, Default, When).
-
deprecated(Old, New, Opts, When) when is_list(Opts) ->
case lists:member(Old, Opts) of
true ->
@@ -355,25 +274,6 @@ processing_base_dir(State, Dir) ->
AbsDir = filename:absname(Dir),
AbsDir =:= rebar_state:get(State, base_dir).
-%% @doc Returns the list of environment variables including 'REBAR' which
-%% points to the rebar executable used to execute the currently running
-%% command. The environment is not modified if rebar was invoked
-%% programmatically.
--spec patch_env(rebar_state:t(), [{string(), string()}])
- -> [{string(), string()}].
-patch_env(Config, []) ->
- %% If we reached an empty list, the env did not contain the REBAR variable.
- case rebar_state:get(Config, escript, "") of
- "" -> % rebar was invoked programmatically
- [];
- Path ->
- [{"REBAR", Path}]
- end;
-patch_env(_Config, [{"REBAR", _} | _]=All) ->
- All;
-patch_env(Config, [E | Rest]) ->
- [E | patch_env(Config, Rest)].
-
%% ====================================================================
%% Internal functions
%% ====================================================================
@@ -414,30 +314,6 @@ otp_release1(Rel) ->
binary:bin_to_list(Vsn, {0, Size - 1})
end.
-get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
- case Get(Config, NewOpt, Default) of
- Default ->
- case Get(Config, OldOpt, Default) of
- Default ->
- Default;
- Old ->
- deprecated(OldOpt, NewOpt, When),
- Old
- end;
- New ->
- New
- end.
-
-get_experimental_3(Get, Config, Opt, Default) ->
- Val = Get(Config, Opt, Default),
- case Val of
- Default ->
- Default;
- Val ->
- ?CONSOLE("NOTICE: Using experimental option '~p'~n", [Opt]),
- Val
- end.
-
%% We do the shell variable substitution ourselves on Windows and hope that the
%% command doesn't use any other shell magic.
patch_on_windows(Cmd, Env) ->
@@ -454,6 +330,25 @@ patch_on_windows(Cmd, Env) ->
Cmd
end.
+%%
+%% Given env. variable FOO we want to expand all references to
+%% it in InStr. References can have two forms: $FOO and ${FOO}
+%% The end of form $FOO is delimited with whitespace or eol
+%%
+expand_env_variable(InStr, VarName, RawVarValue) ->
+ case string:chr(InStr, $$) of
+ 0 ->
+ %% No variables to expand
+ InStr;
+ _ ->
+ ReOpts = [global, unicode, {return, list}],
+ VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
+ %% Use a regex to match/replace:
+ %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
+ RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
+ re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
+ end.
+
expand_sh_flag(return_on_error) ->
{error_handler,
fun(_Command, Err) ->
@@ -509,9 +404,6 @@ sh_loop(Port, Fun, Acc) ->
beam_to_mod(Filename) ->
list_to_atom(filename:basename(Filename, ".beam")).
-erl_to_mod(Filename) ->
- list_to_atom(filename:rootname(filename:basename(Filename))).
-
beams(Dir) ->
filelib:fold_files(Dir, ".*\.beam\$", true,
fun(F, Acc) -> [F | Acc] end, []).