diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-08-29 21:41:58 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-08-31 21:40:51 -0500 |
commit | 32d07ec0767524c8bdf0321c70a741ab64dedd78 (patch) | |
tree | 753df6f323b76fec5d9d7561ac4caed5090255ad /src | |
parent | 3aec31f0bcc6b8b0e240e25f9ec4baed27e51b5a (diff) |
build on already created AppInfo instead of having to do copy
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_discover.erl | 58 | ||||
-rw-r--r-- | src/rebar_app_info.erl | 7 | ||||
-rw-r--r-- | src/rebar_app_utils.erl | 5 | ||||
-rw-r--r-- | src/rebar_dir.erl | 34 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 104 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 43 | ||||
-rw-r--r-- | src/rebar_utils.erl | 16 |
7 files changed, 125 insertions, 142 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index e32a9f5..08502a9 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -5,7 +5,8 @@ find_unbuilt_apps/1, find_apps/1, find_apps/2, - find_app/2]). + find_app/2, + find_app/3]). -include("rebar.hrl"). -include_lib("providers/include/providers.hrl"). @@ -183,41 +184,46 @@ find_apps(LibDirs, Validate) -> -spec find_app(file:filename_all(), valid | invalid | all) -> {true, rebar_app_info:t()} | false. find_app(AppDir, Validate) -> + find_app(rebar_app_info:new(), AppDir, Validate). + +find_app(AppInfo, AppDir, Validate) -> AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])), AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])), AppSrcScriptFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src.script"])), - AppInfo = try_handle_app_file(AppFile, AppDir, AppSrcFile, AppSrcScriptFile, Validate), - AppInfo. + try_handle_app_file(AppInfo, AppFile, AppDir, AppSrcFile, AppSrcScriptFile, 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(). -create_app_info(AppDir, AppFile) -> +-spec create_app_info(rebar_app_info:t(), file:name(), file:name()) -> rebar_app_info:t(). +create_app_info(AppInfo, AppDir, AppFile) -> [{application, AppName, AppDetails}] = rebar_config:consult_app_file(AppFile), AppVsn = proplists:get_value(vsn, AppDetails), Applications = proplists:get_value(applications, AppDetails, []), IncludedApplications = proplists:get_value(included_applications, AppDetails, []), - {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir), - AppInfo1 = rebar_app_info:applications( - rebar_app_info:app_details(AppInfo, AppDetails), + AppInfo1 = rebar_app_info:name( + rebar_app_info:original_vsn( + rebar_app_info:dir(AppInfo, AppDir), AppVsn), AppName), + AppInfo2 = rebar_app_info:applications( + rebar_app_info:app_details(AppInfo1, AppDetails), IncludedApplications++Applications), - Valid = case rebar_app_utils:validate_application_info(AppInfo1) of + Valid = case rebar_app_utils:validate_application_info(AppInfo2) =:= true + andalso rebar_app_info:has_all_artifacts(AppInfo2) =:= true of true -> true; _ -> false end, - rebar_app_info:dir(rebar_app_info:valid(AppInfo1, Valid), AppDir). + rebar_app_info:dir(rebar_app_info:valid(AppInfo2, Valid), AppDir). %% Read in and parse the .app file if it is availabe. Do the same for %% the .app.src file if it exists. -try_handle_app_file([], AppDir, [], AppSrcScriptFile, Validate) -> - try_handle_app_src_file([], AppDir, AppSrcScriptFile, Validate); -try_handle_app_file([], AppDir, AppSrcFile, _, Validate) -> - try_handle_app_src_file([], AppDir, AppSrcFile, Validate); -try_handle_app_file([File], AppDir, AppSrcFile, _, Validate) -> - try create_app_info(AppDir, File) of +try_handle_app_file(AppInfo, [], AppDir, [], AppSrcScriptFile, Validate) -> + try_handle_app_src_file(AppInfo, [], AppDir, AppSrcScriptFile, Validate); +try_handle_app_file(AppInfo, [], AppDir, AppSrcFile, _, Validate) -> + try_handle_app_src_file(AppInfo, [], AppDir, AppSrcFile, Validate); +try_handle_app_file(AppInfo0, [File], AppDir, AppSrcFile, _, Validate) -> + try create_app_info(AppInfo0, AppDir, File) of AppInfo -> AppInfo1 = rebar_app_info:app_file(AppInfo, File), AppInfo2 = case AppSrcFile of @@ -249,26 +255,26 @@ try_handle_app_file([File], AppDir, AppSrcFile, _, Validate) -> catch throw:{error, {Module, Reason}} -> ?DEBUG("Falling back to app.src file because .app failed: ~s", [Module:format_error(Reason)]), - try_handle_app_src_file(File, AppDir, AppSrcFile, Validate) + try_handle_app_src_file(AppInfo0, File, AppDir, AppSrcFile, Validate) end; -try_handle_app_file(Other, _AppDir, _AppSrcFile, _, _Validate) -> +try_handle_app_file(_AppInfo, Other, _AppDir, _AppSrcFile, _, _Validate) -> throw({error, {multiple_app_files, Other}}). %% Read in the .app.src file if we aren't looking for a valid (already built) app -try_handle_app_src_file(_, _AppDir, [], _Validate) -> +try_handle_app_src_file(_AppInfo, _, _AppDir, [], _Validate) -> false; -try_handle_app_src_file(_, _AppDir, _AppSrcFile, valid) -> +try_handle_app_src_file(_AppInfo, _, _AppDir, _AppSrcFile, valid) -> false; -try_handle_app_src_file(_, AppDir, [File], Validate) when Validate =:= invalid - ; Validate =:= all -> - AppInfo = create_app_info(AppDir, File), +try_handle_app_src_file(AppInfo, _, AppDir, [File], Validate) when Validate =:= invalid + ; Validate =:= all -> + AppInfo1 = create_app_info(AppInfo, AppDir, File), case filename:extension(File) of ".script" -> - {true, rebar_app_info:app_file_src_script(AppInfo, File)}; + {true, rebar_app_info:app_file_src_script(AppInfo1, File)}; _ -> - {true, rebar_app_info:app_file_src(AppInfo, File)} + {true, rebar_app_info:app_file_src(AppInfo1, File)} end; -try_handle_app_src_file(_, _AppDir, Other, _Validate) -> +try_handle_app_src_file(_AppInfo, _, _AppDir, Other, _Validate) -> throw({error, {multiple_app_files, Other}}). enable(State, AppInfo) -> diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index 21fbbea..3ace5e4 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -1,6 +1,7 @@ -module(rebar_app_info). --export([new/1, +-export([new/0, + new/1, new/2, new/3, new/4, @@ -98,6 +99,10 @@ %% ============================================================================ %% @doc Build a new, empty, app info value. This is not of a lot of use and you %% probably wont be doing this much. +-spec new() -> t(). +new() -> + #app_info_t{}. + -spec new(atom() | binary() | string()) -> {ok, t()}. new(AppName) -> diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 87d5d00..2509c7d 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -157,7 +157,6 @@ pkg_to_app(Parent, DepsDir, AppName, PkgName, PkgVsn, IsLock, State) -> dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), - %BaseDir = rebar_state:get(State, base_dir, []), {ok, AppInfo} = case rebar_app_info:discover(CheckoutsDir) of {ok, App} -> {ok, rebar_app_info:is_checkout(App, true)}; @@ -173,10 +172,6 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> C = rebar_config:consult(rebar_app_info:dir(AppInfo)), AppInfo0 = rebar_app_info:update_opts(AppInfo, rebar_app_info:opts(AppInfo), C), AppInfo1 = rebar_app_info:apply_overrides(AppInfo0, Name), - %Overrides = rebar_state:get(State, overrides, []), - %ParentOverrides = rebar_state:overrides(State), - %% S1 = rebar_state:set(rebar_state:overrides(State, ParentOverrides++Overrides), base_dir, BaseDir), - %% AppInfo3 = rebar_app_info:opts(AppInfo1, rebar_state:opts(S1)), rebar_app_info:is_lock(rebar_app_info:source(AppInfo1, Source), IsLock). format_error({missing_package, Package}) -> diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index af6696e..39fa723 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -129,34 +129,34 @@ do_make_relative_path(Source, Target) -> Base = lists:duplicate(max(length(Target) - 1, 0), ".."), filename:join(Base ++ Source). --spec src_dirs(rebar_app_info:t()) -> list(file:filename_all()). -src_dirs(State) -> src_dirs(State, []). +-spec src_dirs(rebar_dict()) -> list(file:filename_all()). +src_dirs(Opts) -> src_dirs(Opts, []). --spec src_dirs(rebar_app_info:t(), list(file:filename_all())) -> list(file:filename_all()). -src_dirs(AppInfo, Default) -> - ErlOpts = rebar_utils:erl_opts(AppInfo), +-spec src_dirs(rebar_dict(), list(file:filename_all())) -> list(file:filename_all()). +src_dirs(Opts, Default) -> + ErlOpts = rebar_utils:erl_opts(Opts), Vs = proplists:get_all_values(src_dirs, ErlOpts), - case lists:append([rebar_utils:get(AppInfo, src_dirs, []) | Vs]) of + case lists:append([rebar_utils:get(Opts, src_dirs, []) | Vs]) of [] -> Default; Dirs -> Dirs end. --spec extra_src_dirs(rebar_app_info:t()) -> list(file:filename_all()). -extra_src_dirs(AppInfo) -> extra_src_dirs(AppInfo, []). +-spec extra_src_dirs(rebar_dict()) -> list(file:filename_all()). +extra_src_dirs(Opts) -> extra_src_dirs(Opts, []). --spec extra_src_dirs(rebar_app_info:t(), list(file:filename_all())) -> list(file:filename_all()). -extra_src_dirs(AppInfo, Default) -> - ErlOpts = rebar_utils:erl_opts(AppInfo), +-spec extra_src_dirs(rebar_dict(), list(file:filename_all())) -> list(file:filename_all()). +extra_src_dirs(Opts, Default) -> + ErlOpts = rebar_utils:erl_opts(Opts), Vs = proplists:get_all_values(extra_src_dirs, ErlOpts), - case lists:append([rebar_utils:get(AppInfo, extra_src_dirs, []) | Vs]) of + case lists:append([rebar_utils:get(Opts, extra_src_dirs, []) | Vs]) of [] -> Default; Dirs -> Dirs end. --spec all_src_dirs(rebar_app_info:t()) -> list(file:filename_all()). -all_src_dirs(AppInfo) -> all_src_dirs(AppInfo, [], []). +-spec all_src_dirs(rebar_dict()) -> list(file:filename_all()). +all_src_dirs(Opts) -> all_src_dirs(Opts, [], []). --spec all_src_dirs(rebar_app_info:t(), list(file:filename_all()), list(file:filename_all())) -> +-spec all_src_dirs(rebar_dict(), list(file:filename_all()), list(file:filename_all())) -> list(file:filename_all()). -all_src_dirs(AppInfo, SrcDefault, ExtraDefault) -> - src_dirs(AppInfo, SrcDefault) ++ extra_src_dirs(AppInfo, ExtraDefault). +all_src_dirs(Opts, SrcDefault, ExtraDefault) -> + src_dirs(Opts, SrcDefault) ++ extra_src_dirs(Opts, ExtraDefault). diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 69b5f29..2b3942c 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -85,27 +85,27 @@ compile(AppInfo) -> Dir = ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)), compile(rebar_app_info:opts(AppInfo), Dir, filename:join([Dir, "ebin"])). --spec compile(rebar_app_info:t(), file:name(), file:name()) -> 'ok'. -compile(AppInfo, Dir, OutDir) -> - rebar_base_compiler:run(AppInfo, +-spec compile(rebar_dict(), file:name(), file:name()) -> 'ok'. +compile(Opts, Dir, OutDir) -> + rebar_base_compiler:run(Opts, check_files(rebar_utils:get( - AppInfo, xrl_first_files, [])), + Opts, xrl_first_files, [])), filename:join(Dir, "src"), ".xrl", filename:join(Dir, "src"), ".erl", fun compile_xrl/3), - rebar_base_compiler:run(AppInfo, + rebar_base_compiler:run(Opts, check_files(rebar_utils:get( - AppInfo, yrl_first_files, [])), + Opts, yrl_first_files, [])), filename:join(Dir, "src"), ".yrl", filename:join(Dir, "src"), ".erl", fun compile_yrl/3), - rebar_base_compiler:run(AppInfo, + rebar_base_compiler:run(Opts, check_files(rebar_utils:get( - AppInfo, mib_first_files, [])), + Opts, mib_first_files, [])), filename:join(Dir, "mibs"), ".mib", filename:join([Dir, "priv", "mibs"]), ".bin", fun compile_mib/3), - doterl_compile(AppInfo, Dir, OutDir). + doterl_compile(Opts, Dir, OutDir). --spec clean(rebar_app_info:t(), file:filename()) -> 'ok'. -clean(_AppInfo, AppDir) -> +-spec clean(rebar_dict(), file:filename()) -> 'ok'. +clean(_Opts, AppDir) -> MibFiles = rebar_utils:find_files(filename:join(AppDir, "mibs"), ?RE_PREFIX".*\\.mib\$"), MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles], rebar_file_utils:delete_each( @@ -134,17 +134,17 @@ clean(_AppInfo, AppDir) -> %% Internal functions %% =================================================================== --spec doterl_compile(rebar_app_info:t(), file:filename(), file:filename()) -> ok. -doterl_compile(State, Dir, ODir) -> - ErlOpts = rebar_utils:erl_opts(State), - doterl_compile(State, Dir, ODir, [], ErlOpts). +-spec doterl_compile(rebar_dict(), file:filename(), file:filename()) -> ok. +doterl_compile(Opts, Dir, ODir) -> + ErlOpts = rebar_utils:erl_opts(Opts), + doterl_compile(Opts, Dir, ODir, [], ErlOpts). -doterl_compile(AppInfo, Dir, OutDir, MoreSources, ErlOpts) -> +doterl_compile(Opts, Dir, OutDir, MoreSources, ErlOpts) -> ?DEBUG("erl_opts ~p", [ErlOpts]), %% Support the src_dirs option allowing multiple directories to %% contain erlang source. This might be used, for example, should %% eunit tests be separated from the core application source. - SrcDirs = [filename:join(Dir, X) || X <- rebar_dir:all_src_dirs(AppInfo, ["src"], [])], + SrcDirs = [filename:join(Dir, X) || X <- rebar_dir:all_src_dirs(Opts, ["src"], [])], AllErlFiles = gather_src(SrcDirs, []) ++ MoreSources, %% Make sure that ebin/ exists and is on the path @@ -156,7 +156,7 @@ doterl_compile(AppInfo, Dir, OutDir, MoreSources, ErlOpts) -> G = init_erlcinfo(proplists:get_all_values(i, ErlOpts), AllErlFiles, Dir, OutDir), NeededErlFiles = needed_files(G, ErlOpts, Dir, OutDir1, AllErlFiles), - {ErlFirstFiles, ErlOptsFirst} = erl_first_files(AppInfo, ErlOpts, Dir, NeededErlFiles), + {ErlFirstFiles, ErlOptsFirst} = erl_first_files(Opts, ErlOpts, Dir, NeededErlFiles), {DepErls, OtherErls} = lists:partition( fun(Source) -> digraph:in_degree(G, Source) > 0 end, [File || File <- NeededErlFiles, not lists:member(File, ErlFirstFiles)]), @@ -166,7 +166,7 @@ doterl_compile(AppInfo, Dir, OutDir, MoreSources, ErlOpts) -> ?DEBUG("Files to compile first: ~p", [FirstErls]), try rebar_base_compiler:run( - AppInfo, FirstErls, OtherErls, + Opts, FirstErls, OtherErls, fun(S, C) -> ErlOpts1 = case lists:member(S, ErlFirstFiles) of true -> ErlOptsFirst; @@ -183,8 +183,8 @@ doterl_compile(AppInfo, Dir, OutDir, MoreSources, ErlOpts) -> %% Get files which need to be compiled first, i.e. those specified in erl_first_files %% and parse_transform options. Also produce specific erl_opts for these first %% files, so that yet to be compiled parse transformations are excluded from it. -erl_first_files(AppInfo, ErlOpts, Dir, NeededErlFiles) -> - ErlFirstFilesConf = rebar_utils:get(AppInfo, erl_first_files, []), +erl_first_files(Opts, ErlOpts, Dir, NeededErlFiles) -> + ErlFirstFilesConf = rebar_utils:get(Opts, erl_first_files, []), NeededSrcDirs = lists:usort(lists:map(fun filename:dirname/1, NeededErlFiles)), %% NOTE: order of files here is important! ErlFirstFiles = @@ -209,10 +209,10 @@ needed_files(G, ErlOpts, Dir, OutDir, SourceFiles) -> lists:filter(fun(Source) -> TargetBase = target_base(OutDir, Source), Target = TargetBase ++ ".beam", - Opts = [{outdir, filename:dirname(Target)} + AllOpts = [{outdir, filename:dirname(Target)} ,{i, filename:join(Dir, "include")}] ++ ErlOpts, digraph:vertex(G, Source) > {Source, filelib:last_modified(Target)} - orelse opts_changed(Opts, TargetBase) + orelse opts_changed(AllOpts, TargetBase) end, SourceFiles). maybe_rm_beam_and_edge(G, OutDir, Source) -> @@ -403,40 +403,40 @@ expand_file_names(Files, Dirs) -> end, Files). --spec internal_erl_compile(rebar_app_info:t(), file:filename(), file:filename(), +-spec internal_erl_compile(rebar_dict(), file:filename(), file:filename(), file:filename(), list()) -> ok | {ok, any()} | {error, any(), any()}. -internal_erl_compile(AppInfo, Dir, Module, OutDir, ErlOpts) -> +internal_erl_compile(Opts, Dir, Module, OutDir, ErlOpts) -> Target = target_base(OutDir, Module) ++ ".beam", ok = filelib:ensure_dir(Target), - Opts = [{outdir, filename:dirname(Target)}] ++ ErlOpts ++ + AllOpts = [{outdir, filename:dirname(Target)}] ++ ErlOpts ++ [{i, filename:join(Dir, "include")}, return], - case compile:file(Module, Opts) of + case compile:file(Module, AllOpts) of {ok, _Mod} -> ok; {ok, _Mod, Ws} -> - rebar_base_compiler:ok_tuple(AppInfo, Module, Ws); + rebar_base_compiler:ok_tuple(Opts, Module, Ws); {error, Es, Ws} -> - rebar_base_compiler:error_tuple(AppInfo, Module, Es, Ws, Opts) + rebar_base_compiler:error_tuple(Opts, Module, Es, Ws, Opts) end. target_base(OutDir, Source) -> filename:join(OutDir, filename:basename(Source, ".erl")). -spec compile_mib(file:filename(), file:filename(), - rebar_app_info:t()) -> 'ok'. -compile_mib(Source, Target, AppInfo) -> + rebar_dict()) -> 'ok'. +compile_mib(Source, Target, Opts) -> Dir = filename:dirname(Target), ok = filelib:ensure_dir(Target), ok = filelib:ensure_dir(filename:join([Dir, "include", "dummy.hrl"])), - Opts = [{outdir, Dir} - ,{i, [Dir]}] ++ - rebar_utils:get(AppInfo, mib_opts, []), + AllOpts = [{outdir, Dir} + ,{i, [Dir]}] ++ + rebar_utils:get(Opts, mib_opts, []), - case snmpc:compile(Source, Opts) of + case snmpc:compile(Source, AllOpts) of {ok, _} -> Mib = filename:rootname(Target), MibToHrlOpts = - case proplists:get_value(verbosity, Opts, undefined) of + case proplists:get_value(verbosity, AllOpts, undefined) of undefined -> #options{specific = []}; Verbosity -> @@ -451,33 +451,33 @@ compile_mib(Source, Target, AppInfo) -> end. -spec compile_xrl(file:filename(), file:filename(), - rebar_app_info:t()) -> 'ok'. -compile_xrl(Source, Target, AppInfo) -> - Opts = [{scannerfile, Target} | rebar_utils:get(AppInfo, xrl_opts, [])], - compile_xrl_yrl(AppInfo, Source, Target, Opts, leex). + rebar_dict()) -> 'ok'. +compile_xrl(Source, Target, Opts) -> + AllOpts = [{scannerfile, Target} | rebar_utils:get(Opts, xrl_opts, [])], + compile_xrl_yrl(Opts, Source, Target, AllOpts, leex). -spec compile_yrl(file:filename(), file:filename(), - rebar_app_info:t()) -> 'ok'. -compile_yrl(Source, Target, AppInfo) -> - Opts = [{parserfile, Target} | rebar_utils:get(AppInfo, yrl_opts, [])], - compile_xrl_yrl(AppInfo, Source, Target, Opts, yecc). + rebar_dict()) -> 'ok'. +compile_yrl(Source, Target, Opts) -> + AllOpts = [{parserfile, Target} | rebar_utils:get(Opts, yrl_opts, [])], + compile_xrl_yrl(Opts, Source, Target, AllOpts, yecc). --spec compile_xrl_yrl(rebar_app_info:t(), file:filename(), +-spec compile_xrl_yrl(rebar_dict(), file:filename(), file:filename(), list(), module()) -> 'ok'. -compile_xrl_yrl(AppInfo, Source, Target, Opts, Mod) -> +compile_xrl_yrl(Opts, Source, Target, AllOpts, Mod) -> Dir = filename:dirname(Target), - Opts1 = [{includefile, filename:join(Dir, I)} || {includefile, I} <- Opts, - filename:pathtype(I) =:= relative], + AllOpts1 = [{includefile, filename:join(Dir, I)} || {includefile, I} <- AllOpts, + filename:pathtype(I) =:= relative], case needs_compile(Source, Target) of true -> - case Mod:file(Source, Opts1 ++ [{return, true}]) of + case Mod:file(Source, AllOpts1 ++ [{return, true}]) of {ok, _} -> ok; {ok, _Mod, Ws} -> - rebar_base_compiler:ok_tuple(AppInfo, Source, Ws); + rebar_base_compiler:ok_tuple(Opts, Source, Ws); {error, Es, Ws} -> - rebar_base_compiler:error_tuple(AppInfo, Source, - Es, Ws, Opts1) + rebar_base_compiler:error_tuple(Opts, Source, + Es, Ws, AllOpts1) end; false -> skipped diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 58557bf..6ae22d6 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -287,24 +287,20 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) -> true -> {false, AppInfo}; false -> - case rebar_app_discover:find_app(AppDir, all) of + case rebar_app_discover:find_app(AppInfo, AppDir, all) of false -> true = fetch_app(AppInfo, AppDir, State), maybe_symlink_default(State, Profile, AppDir, AppInfo), {true, rebar_app_info:valid(update_app_info(AppDir, AppInfo), false)}; {true, AppInfo1} -> - %% Preserve the state we created with overrides - AppInfo3 = copy_app_info(AppInfo, AppInfo1), - %% AppState = rebar_app_info:state(AppInfo), - %% AppInfo3 = rebar_app_info:state(AppInfo2, AppState), - case sets:is_element(rebar_app_info:name(AppInfo3), Seen) of + case sets:is_element(rebar_app_info:name(AppInfo1), Seen) of true -> - {false, AppInfo3}; + {false, AppInfo1}; false -> - maybe_symlink_default(State, Profile, AppDir, AppInfo3), + maybe_symlink_default(State, Profile, AppDir, AppInfo1), MaybeUpgrade = maybe_upgrade(AppInfo, AppDir, Upgrade, State), - AppInfo4 = update_app_info(AppDir, AppInfo3), - {MaybeUpgrade, AppInfo4} + AppInfo2 = update_app_info(AppDir, AppInfo1), + {MaybeUpgrade, AppInfo2} end end end. @@ -361,32 +357,13 @@ fetch_app(AppInfo, AppDir, State) -> %% So this is the first time for newly downloaded apps that its .app/.app.src data can %% be read in an parsed. update_app_info(AppDir, AppInfo) -> - case rebar_app_info:discover(AppDir) of - {ok, Found} -> - AppDetails = rebar_app_info:app_details(Found), - Vsn = rebar_app_info:original_vsn(Found), - Applications = proplists:get_value(applications, AppDetails, []), - IncludedApplications = proplists:get_value(included_applications, AppDetails, []), - AppInfo1 = rebar_app_info:original_vsn(rebar_app_info:applications( - rebar_app_info:app_details(AppInfo, AppDetails), - IncludedApplications++Applications), Vsn), - AppInfo2 = copy_app_info(AppInfo, AppInfo1), - rebar_app_info:valid(AppInfo2, undefined); - not_found -> + case rebar_app_discover:find_app(AppInfo, AppDir, all) of + {true, AppInfo1} -> + AppInfo1; + false -> throw(?PRV_ERROR({dep_app_not_found, AppDir, rebar_app_info:name(AppInfo)})) end. -copy_app_info(OldAppInfo, NewAppInfo) -> - Deps = rebar_app_info:deps(OldAppInfo), - ResourceType = rebar_app_info:resource_type(OldAppInfo), - Parent = rebar_app_info:parent(OldAppInfo), - Source = rebar_app_info:source(OldAppInfo), - - rebar_app_info:deps( - rebar_app_info:resource_type( - rebar_app_info:source( - rebar_app_info:parent(NewAppInfo, Parent), Source), ResourceType), Deps). - maybe_upgrade(AppInfo, AppDir, Upgrade, State) -> Source = rebar_app_info:source(AppInfo), case Upgrade orelse rebar_app_info:is_lock(AppInfo) of diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index cf6e8e8..7363d0a 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -237,17 +237,17 @@ deprecated(Old, New, When) -> [Old, Old, New, Old, When]). %% @doc Return list of erl_opts --spec erl_opts(rebar_app_info:t()) -> list(). -erl_opts(AppInfo) -> - RawErlOpts = filter_defines(rebar_utils:get(AppInfo, erl_opts, []), []), +-spec erl_opts(rebar_dict()) -> list(). +erl_opts(Opts) -> + RawErlOpts = filter_defines(rebar_utils:get(Opts, erl_opts, []), []), Defines = [{d, list_to_atom(D)} || - D <- rebar_utils:get(AppInfo, defines, [])], - Opts = Defines ++ RawErlOpts, - case proplists:is_defined(no_debug_info, Opts) of + D <- rebar_utils:get(Opts, defines, [])], + AllOpts = Defines ++ RawErlOpts, + case proplists:is_defined(no_debug_info, AllOpts) of true -> - [O || O <- Opts, O =/= no_debug_info]; + [O || O <- AllOpts, O =/= no_debug_info]; false -> - [debug_info|Opts] + [debug_info|AllOpts] end. %% for use by `do` task |