From 8e5c916cb6e93b484278e7463af3e7b07fe6db07 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 1 Dec 2014 17:54:47 -0600 Subject: move dir functions from utils to new module rebar_dir --- src/rebar3.erl | 4 +- src/rebar_app_discover.erl | 2 +- src/rebar_app_utils.erl | 2 +- src/rebar_core.erl | 8 +-- src/rebar_cover_utils.erl | 4 +- src/rebar_erlc_compiler.erl | 10 ++-- src/rebar_hooks.erl | 2 +- src/rebar_packages.erl | 2 +- src/rebar_plugins.erl | 2 +- src/rebar_prv_clean.erl | 2 +- src/rebar_prv_common_test.erl | 2 +- src/rebar_prv_compile.erl | 2 +- src/rebar_prv_dialyzer.erl | 2 +- src/rebar_prv_eunit.erl | 8 +-- src/rebar_prv_install_deps.erl | 12 ++--- src/rebar_prv_release.erl | 4 +- src/rebar_prv_tar.erl | 4 +- src/rebar_prv_update.erl | 2 +- src/rebar_state.erl | 8 +-- src/rebar_templater.erl | 4 +- src/rebar_utils.erl | 107 ++--------------------------------------- 21 files changed, 46 insertions(+), 147 deletions(-) (limited to 'src') diff --git a/src/rebar3.erl b/src/rebar3.erl index 94ba2a4..65b125e 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -115,7 +115,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> end, %% Process each command, resetting any state between each one - BaseDir = rebar_utils:base_dir(State2), + BaseDir = rebar_dir:base_dir(State2), State3 = rebar_state:set(State2, base_dir, filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), @@ -149,7 +149,7 @@ init_config() -> end, %% If $HOME/.rebar3/config exists load and use as global config - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), GlobalConfigFile = filename:join([Home, ?CONFIG_DIR, "config"]), State = case filelib:is_regular(GlobalConfigFile) of true -> diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index ea49075..e2bf05e 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -124,7 +124,7 @@ create_app_info(AppDir, AppFile) -> C = rebar_config:consult(AppDir), S = rebar_state:new(rebar_state:new(), C, AppDir), AppDeps = rebar_state:deps_names(S), - AbsCwd = filename:absname(rebar_utils:get_cwd()), + AbsCwd = filename:absname(rebar_dir:get_cwd()), {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir, AppDeps), RebarConfig = filename:join(AppDir, "rebar.config"), AppState = case filelib:is_file(RebarConfig) of diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 8fc3df8..dac3f0f 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -56,7 +56,7 @@ find(Name, Vsn, Apps) -> -spec is_app_dir() -> {true, file:name()} | false. is_app_dir() -> - is_app_dir(rebar_utils:get_cwd()). + is_app_dir(rebar_dir:get_cwd()). -spec is_app_dir(file:name()) -> {true, file:name()} | false. is_app_dir(Dir) -> diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 2396294..21d008a 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -73,9 +73,9 @@ do([{ProviderName, Profile} | Rest], State) -> update_code_path(State) -> true = rebar_utils:expand_code_path(), - LibDirs = rebar_utils:lib_dirs(State), - DepsDir = rebar_utils:deps_dir(State), - PluginsDir = rebar_utils:plugins_dir(State), + LibDirs = rebar_dir:lib_dirs(State), + DepsDir = rebar_dir:deps_dir(State), + PluginsDir = rebar_dir:plugins_dir(State), _UpdatedCodePaths = update_code_path_([DepsDir, PluginsDir | LibDirs]). @@ -84,7 +84,7 @@ update_code_path(State) -> %% =================================================================== update_code_path_(Paths) -> - LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []), + LibPaths = expand_lib_dirs(Paths, rebar_dir:get_cwd(), []), ok = code:add_pathsa(LibPaths), %% track just the paths we added, so we can remove them without %% removing other paths added by this dep diff --git a/src/rebar_cover_utils.erl b/src/rebar_cover_utils.erl index 7de9d48..0439b8a 100644 --- a/src/rebar_cover_utils.erl +++ b/src/rebar_cover_utils.erl @@ -78,7 +78,7 @@ init(true, BeamFiles, TargetDir) -> group_leader(F, CoverPid), - ?INFO("Cover compiling ~s\n", [rebar_utils:get_cwd()]), + ?INFO("Cover compiling ~s\n", [rebar_dir:get_cwd()]), Compiled = [{Beam, cover:compile_beam(Beam)} || Beam <- BeamFiles], case [Module || {_, {ok, Module}} <- Compiled] of @@ -121,7 +121,7 @@ analyze(Config, FilteredModules, SrcModules, TargetDir) -> [html]) end, Coverage), - Index = filename:join([rebar_utils:get_cwd(), TargetDir, "index.html"]), + Index = filename:join([rebar_dir:get_cwd(), TargetDir, "index.html"]), ?CONSOLE("Cover analysis: ~s\n", [Index]), %% Export coverage data, if configured diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 71ee780..99082f8 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -142,7 +142,7 @@ test_compile(Config, Cmd, OutDir) -> %% Copy source files to eunit dir for cover in case they are not directly %% in src but in a subdirectory of src. Cover only looks in cwd and ../src %% for source files. Also copy files from src_dirs. - SrcDirs = rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts1)), + SrcDirs = rebar_dir:src_dirs(proplists:append_values(src_dirs, ErlOpts1)), SrcErls = lists:foldl( fun(Dir, Acc) -> Files = rebar_utils:find_files( @@ -295,7 +295,7 @@ doterl_compile(Config, Dir, MoreSources, ErlOpts) -> %% eunit tests be separated from the core application source. SrcDirs = lists:map(fun(X) -> filename:join(Dir, X) - end, rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts))), + end, rebar_dir:src_dirs(proplists:append_values(src_dirs, ErlOpts))), AllErlFiles = gather_src(SrcDirs, []) ++ MoreSources, %% NOTE: If and when erl_first_files is not inherited anymore %% (rebar_state:get instead of rebar_state:get_list), consider @@ -410,7 +410,7 @@ check_erlcinfo(Config, _) -> [erlcinfo_file(Config)]). erlcinfo_file(_Config) -> - filename:join([rebar_utils:get_cwd(), ?CONFIG_DIR, ?ERLCINFO_FILE]). + filename:join([rebar_dir:get_cwd(), ?CONFIG_DIR, ?ERLCINFO_FILE]). init_erlcinfo(Config, Erls) -> G = restore_erlcinfo(Config), @@ -589,8 +589,8 @@ internal_erl_compile(Config, Dir, Source, OutDir, ErlOpts, G) -> -spec compile_mib(file:filename(), file:filename(), rebar_state:t()) -> 'ok'. compile_mib(Source, Target, Config) -> - ok = rebar_utils:ensure_dir(Target), - ok = rebar_utils:ensure_dir(filename:join("include", "dummy.hrl")), + ok = rebar_dir:ensure_dir(Target), + ok = rebar_dir:ensure_dir(filename:join("include", "dummy.hrl")), Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++ rebar_state:get(Config, mib_opts, []), case snmpc:compile(Source, Opts) of diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index e64b7eb..fbc207e 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -4,7 +4,7 @@ run_compile_hooks(Dir, Type, Command, State) -> Hooks = rebar_state:get(State, Type, []), - Env = [{"REBAR_DEPS_DIR", rebar_utils:deps_dir(State)}], + Env = [{"REBAR_DEPS_DIR", rebar_dir:deps_dir(State)}], lists:foreach(fun({_, C, _}=Hook) when C =:= Command -> apply_hook(Dir, Env, Hook); ({C, _}=Hook) when C =:= Command -> diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index a2a7203..2164b79 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -12,7 +12,7 @@ -spec get_packages(rebar_state:t()) -> {rebar_dict(), rebar_digraph()}. get_packages(State) -> - RebarDir = rebar_utils:global_config_dir(State), + RebarDir = rebar_dir:global_config_dir(State), PackagesFile = filename:join(RebarDir, "packages"), case ec_file:exists(PackagesFile) of true -> diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index 990170d..000ccdc 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -15,7 +15,7 @@ install(State) -> %% Set deps_dir to a different dir for plugin so they don't collide OldDepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR), State1 = rebar_state:set(State, deps_dir, ?DEFAULT_PLUGINS_DIR), - DepsDir = rebar_utils:deps_dir(State1), + DepsDir = rebar_dir:deps_dir(State1), expand_plugins(DepsDir), Plugins = rebar_state:get(State1, plugins, []), PluginProviders = rebar_utils:filtermap(fun(Plugin) -> diff --git a/src/rebar_prv_clean.erl b/src/rebar_prv_clean.erl index 2a5abf7..6d14cdb 100644 --- a/src/rebar_prv_clean.erl +++ b/src/rebar_prv_clean.erl @@ -48,7 +48,7 @@ do(State) -> EmptyState = rebar_state:new(), clean_apps(EmptyState, DepApps), - Cwd = rebar_utils:get_cwd(), + Cwd = rebar_dir:get_cwd(), rebar_hooks:run_compile_hooks(Cwd, pre_hooks, clean, State), clean_apps(State, ProjectApps), rebar_hooks:run_compile_hooks(Cwd, post_hooks, clean, State), diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl index d14144f..3d64517 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -37,7 +37,7 @@ do(State) -> {Opts, _} = rebar_state:command_parsed_args(State), Opts1 = transform_opts(Opts), ok = create_dirs(Opts1), - expand_test_deps(filename:join(rebar_utils:profile_dir(State), ?DEFAULT_DEPS_DIR)), + expand_test_deps(filename:join(rebar_dir:profile_dir(State), ?DEFAULT_DEPS_DIR)), case ct:run_test(Opts1) of {_, 0, _} -> {ok, State}; {_, FailedCount, _} -> {error, {?MODULE, {failures_running_tests, diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 60737d1..221876b 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -43,7 +43,7 @@ do(State) -> ProjectApps = rebar_state:project_apps(State1), Deps = rebar_state:deps_to_build(State1), - Cwd = rebar_utils:get_cwd(), + Cwd = rebar_dir:get_cwd(), rebar_hooks:run_compile_hooks(Cwd, pre_hooks, compile, State1), %% Need to allow global config vars used on deps diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 6bff26b..8ef5b50 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -286,7 +286,7 @@ build_proj_plt(State, Plt, Files) -> end. get_base_plt_location(State) -> - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), GlobalConfigDir = filename:join(Home, ?CONFIG_DIR), BaseDir = rebar_state:get(State, dialyzer_base_plt_dir, GlobalConfigDir), BasePlt = rebar_state:get(State, dialyzer_base_plt, default_plt()), diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index 8f05f02..c14a15d 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -101,9 +101,9 @@ run_eunit(Config, CodePath, SrcErls) -> ensure_dirs() -> %% Make sure ?EUNIT_DIR/ and ebin/ directory exists (append dummy module) ok = filelib:ensure_dir(filename:join(eunit_dir(), "dummy")), - ok = filelib:ensure_dir(filename:join(rebar_utils:ebin_dir(), "dummy")). + ok = filelib:ensure_dir(filename:join(rebar_dir:ebin_dir(), "dummy")). eunit_dir() -> - filename:join(rebar_utils:get_cwd(), ?EUNIT_DIR). + filename:join(rebar_dir:get_cwd(), ?EUNIT_DIR). setup_code_path() -> %% Setup code path prior to compilation so that parse_transforms %% and the like work properly. Also, be sure to add ebin_dir() @@ -111,7 +111,7 @@ setup_code_path() -> %% through hoops to access the .app file CodePath = code:get_path(), true = code:add_patha(eunit_dir()), - true = code:add_pathz(rebar_utils:ebin_dir()), + true = code:add_pathz(rebar_dir:ebin_dir()), CodePath. %% %% == get matching tests == @@ -354,7 +354,7 @@ perform_eunit(Config, Tests) -> EunitOpts = get_eunit_opts(Config), %% Move down into ?EUNIT_DIR while we run tests so any generated files %% are created there (versus in the source dir) - Cwd = rebar_utils:get_cwd(), + Cwd = rebar_dir:get_cwd(), ok = file:set_cwd(?EUNIT_DIR), EunitResult = (catch eunit:test(Tests, EunitOpts)), %% Return to original working dir diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 68a0e21..5fcc4d6 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -108,7 +108,7 @@ handle_deps(State, Deps, Update) -> {Packages, Graph} = rebar_packages:get_packages(State), %% Split source deps from pkg deps, needed to keep backwards compatibility - DepsDir = rebar_utils:deps_dir(State), + DepsDir = rebar_dir:deps_dir(State), {SrcDeps, PkgDeps} = parse_deps(State, DepsDir, Deps), %% Fetch transitive src deps @@ -144,7 +144,7 @@ handle_deps(State, Deps, Update) -> update_pkg_deps(Pkgs, Packages, Update, Seen, State) -> %% Create app_info record for each pkg dep - DepsDir = rebar_utils:deps_dir(State), + DepsDir = rebar_dir:deps_dir(State), {Solved, _, State1} = lists:foldl(fun(Pkg, {Acc, SeenAcc, StateAcc}) -> AppInfo = package_to_app(DepsDir @@ -179,7 +179,7 @@ package_to_app(DepsDir, Packages, {Name, Vsn}) -> Link = proplists:get_value(<<"link">>, P, ""), {ok, AppInfo} = rebar_app_info:new(Name, Vsn), AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), - AppInfo2 = rebar_app_info:dir(AppInfo1, rebar_utils:deps_dir(DepsDir, Name)), + AppInfo2 = rebar_app_info:dir(AppInfo1, rebar_dir:deps_dir(DepsDir, Name)), rebar_app_info:source(AppInfo2, {pkg, Name, Vsn, Link}) end. @@ -241,7 +241,7 @@ handle_update(AppInfo, UpdateName, UpdateLevel, SrcDeps, PkgDeps, SrcApps, Level end. handle_dep(AppInfo, SrcDeps, PkgDeps, SrcApps, Level, State) -> - DepsDir = rebar_utils:deps_dir(State), + DepsDir = rebar_dir:deps_dir(State), {AppInfo1, NewSrcDeps, NewPkgDeps} = handle_dep(State, DepsDir, AppInfo), AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), @@ -272,7 +272,7 @@ handle_dep(State, DepsDir, AppInfo) -> sets:set(binary())) -> boolean(). maybe_fetch(State, AppInfo, Update, Seen) -> AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), - DefaultProfileDeps = rebar_utils:default_profile_deps(State), + DefaultProfileDeps = rebar_dir:default_profile_deps(State), Apps = rebar_app_discover:find_apps(["_checkouts", DefaultProfileDeps], all), case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of {ok, _} -> @@ -339,7 +339,7 @@ parse_deps(State, DepsDir, Deps) -> end, {[], []}, Deps). new_dep(State, DepsDir, Name, Vsn, Source) -> - Dirs = [ec_cnv:to_list(filename:join(rebar_utils:default_profile_deps(State), Name)), + Dirs = [ec_cnv:to_list(filename:join(rebar_dir:default_profile_deps(State), Name)), ec_cnv:to_list(filename:join(DepsDir, Name))], {ok, Dep} = case ec_lists:search(fun(Dir) -> rebar_app_info:discover(Dir) diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl index 7ec8ead..d9cc40f 100644 --- a/src/rebar_prv_release.erl +++ b/src/rebar_prv_release.erl @@ -33,8 +33,8 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> Options = rebar_state:command_args(State), - DepsDir = [rebar_utils:default_deps_dir(State)], % rebar_utils:deps_dir(State)], - OutputDir = filename:join(rebar_utils:profile_dir(State), ?DEFAULT_RELEASE_DIR), + DepsDir = [rebar_dir:default_deps_dir(State)], % rebar_dir:deps_dir(State)], + OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR), AllOptions = string:join(["release" | Options], " "), try case rebar_state:get(State, relx, []) of diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl index 34a9153..ae1942b 100644 --- a/src/rebar_prv_tar.erl +++ b/src/rebar_prv_tar.erl @@ -32,9 +32,9 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - OutputDir = filename:join(rebar_utils:profile_dir(State), ?DEFAULT_RELEASE_DIR), + OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR), Options = rebar_state:command_args(State), - DepsDir = rebar_utils:deps_dir(State), + DepsDir = rebar_dir:deps_dir(State), AllOptions = string:join(["release", "tar" | Options], " "), case rebar_state:get(State, relx, []) of [] -> diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 16987be..524a684 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -37,7 +37,7 @@ do(State) -> Url = url(State), TmpDir = ec_file:insecure_mkdtemp(), TmpFile = filename:join(TmpDir, "packages"), - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), PackagesFile = filename:join([Home, ?CONFIG_DIR, "packages"]), filelib:ensure_dir(PackagesFile), {ok, _RequestId} = httpc:request(get, {Url, [{"Accept", "application/erlang"}]}, diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 3350ffe..77004a7 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -52,12 +52,12 @@ -spec new() -> t(). new() -> - #state_t{dir = rebar_utils:get_cwd()}. + #state_t{dir = rebar_dir:get_cwd()}. -spec new(list()) -> t(). new(Config) when is_list(Config) -> Opts = dict:from_list(Config), - #state_t { dir = rebar_utils:get_cwd(), + #state_t { dir = rebar_dir:get_cwd(), default = Opts, opts = Opts }. @@ -65,13 +65,13 @@ new(Config) when is_list(Config) -> new(Profile, Config) when is_atom(Profile) , is_list(Config) -> Opts = dict:from_list(Config), - #state_t { dir = rebar_utils:get_cwd(), + #state_t { dir = rebar_dir:get_cwd(), current_profile = Profile, default = Opts, opts = Opts }; new(ParentState=#state_t{}, Config) -> %% Load terms from rebar.config, if it exists - Dir = rebar_utils:get_cwd(), + Dir = rebar_dir:get_cwd(), new(ParentState, Config, Dir). -spec new(t(), list(), file:name()) -> t(). diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index f4cf3d2..7fe9241 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -143,7 +143,7 @@ default_variables() -> %% Load variable definitions from the 'Globals' file in the home template %% directory global_variables() -> - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), GlobalFile = filename:join([Home, ?CONFIG_DIR, "templates", "globals"]), case file:consult(GlobalFile) of {error, enoent} -> []; @@ -270,7 +270,7 @@ find_escript_templates(Files) -> %% Fetch template indexes that sit on disk in the user's HOME find_disk_templates(State) -> OtherTemplates = find_other_templates(State), - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), HomeFiles = rebar_utils:find_files(filename:join([Home, ?CONFIG_DIR, "templates"]), ?TEMPLATE_RE), [{file, F} || F <- OtherTemplates ++ HomeFiles]. diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index a6c9162..21629a4 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -26,21 +26,8 @@ %% ------------------------------------------------------------------- -module(rebar_utils). --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, - global_config_dir/1, - - droplast/1, +-export([droplast/1, filtermap/2, - get_cwd/0, is_arch/1, sh/2, sh_send/3, @@ -49,7 +36,6 @@ escript_foldl/3, find_files/2, find_files/3, - ensure_dir/1, beam_to_mod/1, beam_to_mod/2, erl_to_mod/1, @@ -61,10 +47,6 @@ deprecated/4, delayed_halt/1, erl_opts/1, - src_dirs/1, - ebin_dir/0, - processing_base_dir/1, - processing_base_dir/2, indent/1, cleanup_code_path/1]). @@ -79,63 +61,9 @@ %% 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"). - -profile_dir(State) -> - case rebar_state:current_profile(State) of - global -> - global_config_dir(State); - Profile -> - filename:join(base_dir(State), atom_to_list(Profile)) - end. - --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. - -global_config_dir(State) -> - Home = home_dir(), - rebar_state:get(State, global_rebar_dir, filename:join(Home, ?CONFIG_DIR)). - droplast(L) -> lists:reverse(tl(lists:reverse(L))). -get_cwd() -> - {ok, Dir} = file:get_cwd(), - Dir. - filtermap(F, [Hd|Tail]) -> case F(Hd) of true -> @@ -171,7 +99,7 @@ wordsize() -> sh_send(Command0, String, Options0) -> ?INFO("sh_send info:\n\tcwd: ~p\n\tcmd: ~s < ~s\n", - [get_cwd(), Command0, String]), + [rebar_dir:get_cwd(), Command0, String]), ?DEBUG("\topts: ~p\n", [Options0]), DefaultOptions = [use_stdout, abort_on_error], @@ -197,7 +125,7 @@ sh_send(Command0, String, Options0) -> %% Val = string() | false %% sh(Command0, Options0) -> - ?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [get_cwd(), Command0]), + ?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [rebar_dir:get_cwd(), Command0]), ?DEBUG("\topts: ~p\n", [Options0]), DefaultOptions = [{use_stdout, false}, debug_and_abort_on_error], @@ -227,18 +155,6 @@ find_files(Dir, Regex, Recursive) -> filelib:fold_files(Dir, Regex, Recursive, fun(F, Acc) -> [F | Acc] end, []). -%% TODO: filelib:ensure_dir/1 corrected in R13B04. Remove when we drop -%% support for OTP releases older than R13B04. -ensure_dir(Path) -> - case filelib:ensure_dir(Path) of - ok -> - ok; - {error,eexist} -> - ok; - Error -> - Error - end. - find_executable(Name) -> case os:find_executable(Name) of false -> false; @@ -324,23 +240,6 @@ erl_opts(Config) -> [debug_info|Opts] end. --spec src_dirs([string()]) -> [file:filename(), ...]. -src_dirs([]) -> - ["src"]; -src_dirs(SrcDirs) -> - SrcDirs. - -ebin_dir() -> - filename:join(get_cwd(), "ebin"). - -processing_base_dir(State) -> - Cwd = rebar_utils:get_cwd(), - processing_base_dir(State, Cwd). - -processing_base_dir(State, Dir) -> - AbsDir = filename:absname(Dir), - AbsDir =:= rebar_state:get(State, base_dir). - %% ==================================================================== %% Internal functions %% ==================================================================== -- cgit v1.1