diff options
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r-- | src/rebar_utils.erl | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 66cd7e2..bb58460 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -45,12 +45,12 @@ 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, - test_dir/0, ebin_dir/0, processing_base_dir/1, processing_base_dir/2]). @@ -75,8 +75,7 @@ is_arch(ArchRegex) -> get_arch() -> Words = wordsize(), erlang:system_info(otp_release) ++ "-" - ++ erlang:system_info(system_architecture) ++ "-" ++ Words - ++ "-" ++ os_family(). + ++ erlang:system_info(system_architecture) ++ "-" ++ Words. wordsize() -> try erlang:system_info({wordsize, external}) of @@ -176,7 +175,7 @@ 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) -> + CodePath = lists:foldl(fun(Path, Acc) -> [filename:absname(Path) | Acc] end, [], code:get_path()), code:set_path(lists:reverse(CodePath)). @@ -217,18 +216,14 @@ get_deprecated_global(Config, OldOpt, NewOpt, When) -> get_deprecated_global(Config, OldOpt, NewOpt, undefined, When). get_deprecated_global(Config, OldOpt, NewOpt, Default, When) -> - case rebar_config:get_global(Config, NewOpt, Default) of - Default -> - case rebar_config:get_global(Config, OldOpt, Default) of - Default -> - Default; - Old -> - deprecated(OldOpt, NewOpt, When), - Old - end; - New -> - New - end. + get_deprecated_3(fun rebar_config:get_global/3, + Config, OldOpt, NewOpt, Default, When). + +get_experimental_global(Config, Opt, Default) -> + get_experimental_3(fun rebar_config:get_global/3, Config, Opt, Default). + +get_experimental_local(Config, Opt, Default) -> + get_experimental_3(fun rebar_config:get_local/3, Config, Opt, Default). get_deprecated_list(Config, OldOpt, NewOpt, When) -> get_deprecated_list(Config, OldOpt, NewOpt, undefined, When). @@ -308,9 +303,6 @@ src_dirs([]) -> src_dirs(SrcDirs) -> SrcDirs. -test_dir() -> - filename:join(get_cwd(), ?TEST_DIR). - ebin_dir() -> filename:join(get_cwd(), "ebin"). @@ -325,10 +317,6 @@ processing_base_dir(Config, Dir) -> %% Internal functions %% ==================================================================== -os_family() -> - {OsFamily, _} = os:type(), - atom_to_list(OsFamily). - get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) -> case Get(Config, NewOpt, Default) of Default -> @@ -343,6 +331,16 @@ get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) -> 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) -> @@ -353,7 +351,8 @@ patch_on_windows(Cmd, Env) -> expand_env_variable(Acc, Key, Value) end, Cmd, Env), %% Remove left-over vars - re:replace(Cmd1, "\\\$\\w+|\\\${\\w+}", "", [global, {return, list}]); + re:replace(Cmd1, "\\\$\\w+|\\\${\\w+}", "", + [global, {return, list}]); _ -> Cmd end. @@ -472,20 +471,11 @@ vcs_vsn_1(Vcs, Dir) -> end end. -vcs_vsn_cmd(git) -> - %% git describe the last commit that touched CWD - %% required for correct versioning of apps in subdirs, such as apps/app1 - case os:type() of - {win32,nt} -> - "FOR /F \"usebackq tokens=* delims=\" %i in " - "(`git log -n 1 \"--pretty=format:%h\" .`) do " - "@git describe --always --tags %i"; - _ -> - "git describe --always --tags `git log -n 1 --pretty=format:%h .`" - end; -vcs_vsn_cmd(hg) -> "hg identify -i"; -vcs_vsn_cmd(bzr) -> "bzr revno"; -vcs_vsn_cmd(svn) -> "svnversion"; +vcs_vsn_cmd(git) -> "git describe --always --tags"; +vcs_vsn_cmd(hg) -> "hg identify -i"; +vcs_vsn_cmd(bzr) -> "bzr revno"; +vcs_vsn_cmd(svn) -> "svnversion"; +vcs_vsn_cmd(fossil) -> "fossil info"; vcs_vsn_cmd({cmd, _Cmd}=Custom) -> Custom; vcs_vsn_cmd(Version) -> {unknown, Version}. |