diff options
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r-- | src/rebar_utils.erl | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 9a0e1d9..d28d761 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -26,7 +26,17 @@ %% ------------------------------------------------------------------- -module(rebar_utils). --export([home_dir/0, +-export([base_dir/1, + deps_dir/1, + deps_dir/2, + plugins_dir/1, + lib_dirs/1, + profile_dir/1, + default_deps_dir/1, + default_profile_dir/1, + default_profile_deps/1, + home_dir/0, + droplast/1, filtermap/2, get_cwd/0, @@ -68,6 +78,45 @@ %% Public API %% ==================================================================== +-spec base_dir(rebar_state:t()) -> file:filename_all(). +base_dir(State) -> + rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR). + +-spec deps_dir(rebar_state:t()) -> file:filename_all(). +deps_dir(State) -> + DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR), + filename:join(profile_dir(State), DepsDir). + +-spec deps_dir(file:filename_all(), file:filename_all()) -> file:filename_all(). +deps_dir(DepsDir, App) -> + filename:join(DepsDir, App). + +-spec default_deps_dir(rebar_state:t()) -> file:filename_all(). +default_deps_dir(State) -> + DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR), + filename:join([base_dir(State), "default", DepsDir]). + +-spec plugins_dir(rebar_state:t()) -> file:filename_all(). +plugins_dir(State) -> + filename:join(base_dir(State), rebar_state:get(State, plugins_dir, ?DEFAULT_PLUGINS_DIR)). + +-spec lib_dirs(rebar_state:t()) -> file:filename_all(). +lib_dirs(State) -> + rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS). + +-spec default_profile_dir(rebar_state:t()) -> file:filename_all(). +default_profile_dir(State) -> + filename:join(base_dir(State), "default"). + +-spec profile_dir(rebar_state:t()) -> file:filename_all(). +profile_dir(State) -> + Profile = rebar_state:current_profile(State), + filename:join(base_dir(State), atom_to_list(Profile)). + +-spec default_profile_deps(rebar_state:t()) -> file:filename_all(). +default_profile_deps(State) -> + filename:join(default_profile_dir(State), ?DEFAULT_DEPS_DIR). + home_dir() -> {ok, [[Home]]} = init:get_argument(home), Home. |