diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_discover.erl | 8 | ||||
-rw-r--r-- | src/rebar_app_info.erl | 9 | ||||
-rw-r--r-- | src/rebar_app_utils.erl | 51 | ||||
-rw-r--r-- | src/rebar_config.erl | 4 | ||||
-rw-r--r-- | src/rebar_core.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_do.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_escripter.erl | 10 | ||||
-rw-r--r-- | src/rebar_prv_help.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_new.erl | 32 | ||||
-rw-r--r-- | src/rebar_prv_release.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_tar.erl | 6 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 4 | ||||
-rw-r--r-- | src/rebar_state.erl | 7 |
13 files changed, 35 insertions, 104 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 7aaba21..7713ee6 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -105,6 +105,7 @@ find_app(AppDir, Validate) -> app_dir(AppFile) -> filename:join(rebar_utils:droplast(filename:split(filename:dirname(AppFile)))). +-spec create_app_info(file:name(), file:name()) -> rebar_app_info:t() | error. create_app_info(AppDir, AppFile) -> case file:consult(AppFile) of {ok, [{application, AppName, AppDetails}]} -> @@ -122,7 +123,9 @@ create_app_info(AppDir, AppFile) -> AppState1 = rebar_state:set(AppState, base_dir, AbsCwd), AppInfo1 = rebar_app_info:config( rebar_app_info:app_details(AppInfo, AppDetails), AppState1), - rebar_app_info:dir(AppInfo1, AppDir) + rebar_app_info:dir(AppInfo1, AppDir); + _ -> + error end. -spec validate_application_info(rebar_app_info:t()) -> boolean(). @@ -149,8 +152,7 @@ get_modules_list(AppFile, AppDetail) -> {ok, ModulesList} end. --spec has_all_beams(file:name(), list()) -> - ok | {error, Reason::term()}. +-spec has_all_beams(file:name(), list()) -> boolean(). has_all_beams(EbinDir, [Module | ModuleList]) -> BeamFile = filename:join([EbinDir, ec_cnv:to_list(Module) ++ ".beam"]), diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index 44394b3..403a5d1 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -87,13 +87,12 @@ new(AppName, Vsn, Dir, Deps) -> deps=Deps}}. %% @doc discover a complete version of the app info with all fields set. --spec discover(file:name()) -> - {ok, t()}. +-spec discover(file:name()) -> {ok, t()} | not_found. discover(Dir) -> case rebar_app_discover:find_app(Dir, all) of {true, AppInfo} -> {ok, AppInfo}; - _ -> + false -> not_found end. @@ -157,7 +156,7 @@ app_details(AppInfo=#app_info_t{}, AppDetails) -> original_vsn(#app_info_t{original_vsn=Vsn}) -> Vsn. --spec original_vsn(t(), string()) -> string(). +-spec original_vsn(t(), string()) -> t(). original_vsn(AppInfo=#app_info_t{}, Vsn) -> AppInfo#app_info_t{original_vsn=Vsn}. @@ -172,7 +171,7 @@ deps(AppInfo=#app_info_t{}, Deps) -> dep_level(AppInfo=#app_info_t{}, Level) -> AppInfo#app_info_t{dep_level=Level}. -dep_level(AppInfo=#app_info_t{dep_level=Level}) -> +dep_level(#app_info_t{dep_level=Level}) -> Level. -spec dir(t()) -> file:name(). diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index d1487fb..8fc3df8 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -33,8 +33,7 @@ app_src_to_app/1, app_name/2, app_applications/2, - app_vsn/2, - is_skipped_app/2]). + app_vsn/2]). -export([load_app_file/2]). % TEMPORARY @@ -124,30 +123,6 @@ app_vsn(Config, AppFile) -> [AppFile, Reason]) end. -is_skipped_app(Config, AppFile) -> - {Config1, ThisApp} = app_name(Config, AppFile), - %% Check for apps global parameter; this is a comma-delimited list - %% of apps on which we want to run commands - Skipped = - case get_apps(Config) of - undefined -> - %% No apps parameter specified, check the skip_apps list.. - case get_skip_apps(Config) of - undefined -> - %% No skip_apps list, run everything.. - false; - SkipApps -> - TargetApps = [list_to_atom(A) || - A <- string:tokens(SkipApps, ",")], - is_skipped(ThisApp, TargetApps) - end; - Apps -> - %% run only selected apps - TargetApps = [list_to_atom(A) || A <- string:tokens(Apps, ",")], - is_selected(ThisApp, TargetApps) - end, - {Config1, Skipped}. - %% =================================================================== %% Internal functions %% =================================================================== @@ -191,27 +166,3 @@ get_value(Key, AppInfo, AppFile) -> Value -> Value end. - -%% apps= for selecting apps -is_selected(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - {true, ThisApp}; - true -> - false - end. - -%% skip_apps= for filtering apps -is_skipped(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - false; - true -> - {true, ThisApp} - end. - -get_apps(Config) -> - rebar_config:get_global(Config, apps, undefined). - -get_skip_apps(Config) -> - rebar_config:get_global(Config, skip_apps, undefined). diff --git a/src/rebar_config.erl b/src/rebar_config.erl index a45bef9..b3003d6 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -35,11 +35,11 @@ %% Public API %% =================================================================== --spec consult(file:name()) -> {ok, any()}. +-spec consult(file:name()) -> [any()]. consult(Dir) -> consult_file(filename:join(Dir, ?DEFAULT_CONFIG_FILE)). --spec consult_file(file:name()) -> {ok, any()}. +-spec consult_file(file:name()) -> [any()]. consult_file(File) when is_binary(File) -> consult_file(binary_to_list(File)); consult_file(File) -> diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 24b376f..ba77dd8 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -55,8 +55,6 @@ update_code_path(State) -> %% Internal functions %% =================================================================== -update_code_path_([]) -> - no_change; update_code_path_(Paths) -> LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []), ok = code:add_pathsa(LibPaths), diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl index a2ac648..435db6f 100644 --- a/src/rebar_prv_do.erl +++ b/src/rebar_prv_do.erl @@ -29,7 +29,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> Tasks = args_to_tasks(rebar_state:command_args(State)), State1 = lists:foldl(fun(TaskArgs, StateAcc) -> diff --git a/src/rebar_prv_escripter.erl b/src/rebar_prv_escripter.erl index 418ac6c..9b5a812 100644 --- a/src/rebar_prv_escripter.erl +++ b/src/rebar_prv_escripter.erl @@ -61,7 +61,7 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). do(Config) -> - AppName = rebar_state:get_local(Config, escript_top_level_app, undefined), + AppName = rebar_state:get(Config, escript_top_level_app, undefined), App = rebar_state:get_app(Config, AppName), {ok, Config1} = escriptize(Config, rebar_app_info:app_file(App)), {ok, Config1}. @@ -73,14 +73,14 @@ escriptize(Config0, AppFile) -> AppNameStr = atom_to_list(AppName), %% Get the output filename for the escript -- this may include dirs - Filename = rebar_state:get_local(Config, escript_name, AppName), + Filename = rebar_state:get(Config, escript_name, AppName), ok = filelib:ensure_dir(Filename), %% Look for a list of other applications (dependencies) to include %% in the output file. We then use the .app files for each of these %% to pull in all the .beam files. InclBeams = get_app_beams( - rebar_state:get_local(Config, escript_incl_apps, []), []), + rebar_state:get(Config, escript_incl_apps, []), []), %% Look for a list of extra files to include in the output file. %% For internal rebar-private use only. Do not use outside rebar. @@ -130,7 +130,7 @@ clean(Config0, AppFile) -> {Config, AppName} = rebar_app_utils:app_name(Config0, AppFile), %% Get the output filename for the escript -- this may include dirs - Filename = rebar_state:get_local(Config, escript_name, AppName), + Filename = rebar_state:get(Config, escript_name, AppName), rebar_file_utils:delete_each([Filename]), {ok, Config}. @@ -176,7 +176,7 @@ get_app_beams([App | Rest], Acc) -> end. get_extra(Config) -> - Extra = rebar_state:get_local(Config, escript_incl_extra, []), + Extra = rebar_state:get(Config, escript_incl_extra, []), lists:foldl(fun({Wildcard, Dir}, Files) -> load_files(Wildcard, Dir) ++ Files end, [], Extra). diff --git a/src/rebar_prv_help.erl b/src/rebar_prv_help.erl index a9949e7..e9d89ca 100644 --- a/src/rebar_prv_help.erl +++ b/src/rebar_prv_help.erl @@ -29,7 +29,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> help(State), {ok, State}. diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl index ed3c1b4..a3182fd 100644 --- a/src/rebar_prv_new.erl +++ b/src/rebar_prv_new.erl @@ -22,7 +22,7 @@ init(State) -> deps = ?DEPS, example = "rebar new <template>", short_desc = "Create new project from templates.", - desc = info(create), + desc = info(), opts = []}), {ok, State1}. @@ -45,29 +45,9 @@ do(State) -> %% Internal functions %% =================================================================== -info(create) -> +info() -> io_lib:format( - "Create skel based on template and vars.~n" - "~n" - "Valid command line options:~n" - " template= [var=foo,...]~n", []); -info(create_app) -> - io_lib:format( - "Create simple app skel.~n" - "~n" - "Valid command line options:~n" - " [appid=myapp]~n", []); -info(create_lib) -> - io_lib:format( - "Create simple lib skel.~n" - "~n" - "Valid command line options:~n" - " [libid=mylib]~n", []); -info(create_node) -> - io_lib:format( - "Create simple node skel.~n" - "~n" - "Valid command line options:~n" - " [nodeid=mynode]~n", []); -info(list_templates) -> - io_lib:format("List available templates.~n", []). + "Create rebar project based on template and vars.~n" + "~n" + "Valid command line options:~n" + " template= [var=foo,...]~n", []). diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl index 4203c3a..66ad4b2 100644 --- a/src/rebar_prv_release.erl +++ b/src/rebar_prv_release.erl @@ -29,7 +29,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(Config) -> relx:main("release"), {ok, Config}. diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl index 7f5ab4f..6ef773c 100644 --- a/src/rebar_prv_tar.erl +++ b/src/rebar_prv_tar.erl @@ -29,7 +29,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). -do(Config) -> +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. +do(State) -> relx:main("release tar"), - {ok, Config}. + {ok, State}. diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 4a02664..b599266 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -29,13 +29,13 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | rebar:error(). +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> case rebar_state:command_args(State) of [Name] -> ?ERROR("NOT IMPLEMENTED: Updating ~s~n", [Name]), AllDeps = rebar_state:get(State, all_deps, []), - {ok, App} = rebar_app_utils:find(list_to_binary(Name), AllDeps), + {ok, _App} = rebar_app_utils:find(list_to_binary(Name), AllDeps), rebar_prv_install_deps:handle_deps(State, [list_to_atom(Name)], true), {ok, State}; [] -> diff --git a/src/rebar_state.erl b/src/rebar_state.erl index ac6684d..7ec4b97 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -37,7 +37,7 @@ command_args = [] :: list(), src_deps = [] :: [rebar_app_info:t()], - src_apps = [] :: dict:dict(), + src_apps = [] :: [rebar_app_info:t()], binary_deps = [], project_apps = [] :: [rebar_app_info:t()], @@ -68,7 +68,7 @@ new(ParentState=#state_t{}, Config) -> new(ParentState, Config, Dir) -> _Opts = ParentState#state_t.opts, LocalOpts = case rebar_config:consult_file(?LOCK_FILE) of - {ok, [D]} -> + [D] -> [{locks, D} | Config]; _ -> Config @@ -144,7 +144,7 @@ src_deps(State=#state_t{src_deps=SrcDeps}, SrcDep) -> src_apps(#state_t{src_apps=SrcApps}) -> SrcApps. -src_apps(State=#state_t{src_apps=SrcApps}, NewSrcApps) when is_list(NewSrcApps) -> +src_apps(State=#state_t{src_apps=_SrcApps}, NewSrcApps) when is_list(NewSrcApps) -> State#state_t{src_apps=NewSrcApps}; src_apps(State=#state_t{src_apps=SrcApps}, NewSrcApp) -> State#state_t{src_apps=[NewSrcApp | SrcApps]}. @@ -163,6 +163,7 @@ providers(#state_t{providers=Providers}) -> providers(State, NewProviders) -> State#state_t{providers=NewProviders}. +-spec add_provider(t(), rebar_provider:t()) -> t(). add_provider(State=#state_t{providers=Providers}, Provider) -> State#state_t{providers=[Provider | Providers]}. |