diff options
Diffstat (limited to 'lib/reltool/src')
-rw-r--r-- | lib/reltool/src/reltool.hrl | 3 | ||||
-rw-r--r-- | lib/reltool/src/reltool_app_win.erl | 13 | ||||
-rw-r--r-- | lib/reltool/src/reltool_server.erl | 84 | ||||
-rw-r--r-- | lib/reltool/src/reltool_target.erl | 8 | ||||
-rw-r--r-- | lib/reltool/src/reltool_utils.erl | 2 |
5 files changed, 75 insertions, 35 deletions
diff --git a/lib/reltool/src/reltool.hrl b/lib/reltool/src/reltool.hrl index 4e5c5b2849..71d3b60a2b 100644 --- a/lib/reltool/src/reltool.hrl +++ b/lib/reltool/src/reltool.hrl @@ -63,6 +63,7 @@ -type mod() :: {incl_cond, incl_cond()} | {debug_info, debug_info()}. -type app() :: {vsn, app_vsn()} + | {lib_dir, lib_dir()} | {mod, mod_name(), [mod()]} | {mod_cond, mod_cond()} | {incl_cond, incl_cond()} @@ -169,7 +170,7 @@ { %% Static info name :: app_name(), is_escript :: boolean() | {inlined, escript_app_name()}, - use_selected_vsn :: boolean() | undefined, + use_selected_vsn :: vsn | dir | undefined, active_dir :: dir(), sorted_dirs :: [dir()], vsn :: app_vsn(), diff --git a/lib/reltool/src/reltool_app_win.erl b/lib/reltool/src/reltool_app_win.erl index e0acfab7aa..6cd0d2f90b 100644 --- a/lib/reltool/src/reltool_app_win.erl +++ b/lib/reltool/src/reltool_app_win.erl @@ -611,7 +611,7 @@ handle_event(#state{sys = Sys, app = App} = S, Wx) -> redraw_window(S2); #wx{userData = use_selected_vsn} -> %% Use selected version - App2 = App#app{use_selected_vsn = true}, + App2 = App#app{use_selected_vsn = dir}, {ok, App3} = reltool_sys_win:set_app(S#state.parent_pid, App2), S2 = S#state{app = App3}, redraw_window(S2); @@ -619,7 +619,8 @@ handle_event(#state{sys = Sys, app = App} = S, Wx) -> event = #wxCommand{type = command_radiobox_selected, cmdString = ActiveDir}} -> %% Change app source - S2 = change_version(S, App, ActiveDir), + App2 = App#app{use_selected_vsn = dir}, + S2 = change_version(S, App2, ActiveDir), redraw_window(S2); #wx{userData = {mod_button, Action, ListCtrl}, event = #wxCommand{type = command_button_clicked}} -> @@ -942,11 +943,11 @@ redraw_config(#state{sys = #sys{incl_cond = GlobalIncl, LatestRadio, SelectedRadio, SourceBox, - fun(true) -> + fun(false) -> + 0; + (_) -> reltool_utils:elem_to_index(ActiveDir, - SortedDirs) - 1; - (false) -> - 0 + SortedDirs) - 1 end). redraw_double_box(Global, Local, GlobalRadio, LocalRadio, LocalBox, GetChoice) -> diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl index c99180a613..084174a02a 100644 --- a/lib/reltool/src/reltool_server.erl +++ b/lib/reltool/src/reltool_server.erl @@ -486,15 +486,19 @@ app_set_config_only(Mods,#app{name = Name, vsn = Vsn, mods = Mods}, - %% Some fields shall only be set if it is an escript, e.g. label - %% must never be set for any other applications since that will - %% prevent refreshing. if IsEscript -> + %% Some fields shall only be set if it is an escript, e.g. label + %% must never be set for any other applications since that will + %% prevent refreshing. App#app{is_escript = IsEscript, active_dir = ActiveDir, sorted_dirs = SortedDirs, label = Label, info = Info}; + UseSelectedVsn =:= dir -> + %% Must not loose active_dir if it is configured to be used + App#app{active_dir = ActiveDir, + sorted_dirs = [ActiveDir]}; true -> App end. @@ -1280,11 +1284,11 @@ shrink_app(A) -> {Dir, Dirs, OptVsn} = case A#app.use_selected_vsn of undefined -> - {shrinked, [], undefined}; - false -> - {shrinked, [], undefined}; - true -> - {A#app.active_dir, [A#app.active_dir], A#app.vsn} + {undefined, [], undefined}; + vsn -> + {undefined, [], A#app.vsn}; + dir -> + {A#app.active_dir, [A#app.active_dir], undefined} end, A#app{active_dir = Dir, sorted_dirs = Dirs, @@ -1489,8 +1493,21 @@ decode(#app{} = App, [{Key, Val} | KeyVals]) -> dec_re(Key, Val, App#app.excl_archive_filters)}; archive_opts when is_list(Val) -> App#app{archive_opts = Val}; - vsn when is_list(Val) -> - App#app{use_selected_vsn = true, vsn = Val}; + vsn when is_list(Val), App#app.use_selected_vsn=:=undefined -> + App#app{use_selected_vsn = vsn, vsn = Val}; + lib_dir when is_list(Val), App#app.use_selected_vsn=:=undefined -> + case filelib:is_dir(Val) of + true -> + App#app{use_selected_vsn = dir, + active_dir = Val, + sorted_dirs = [Val]}; + false -> + reltool_utils:throw_error("Illegal lib dir for ~p: ~p", + [App#app.name, Val]) + end; + SelectVsn when SelectVsn=:=vsn; SelectVsn=:=lib_dir -> + reltool_utils:throw_error("Mutual exclusive options " + "'vsn' and 'lib_dir'",[]); _ -> reltool_utils:throw_error("Illegal option: ~p", [{Key, Val}]) end, @@ -1838,7 +1855,10 @@ merge_app_dirs([{Name, Dir} | Rest], Apps) -> merge_app_dirs([], Apps) -> set_active_dirs(Apps). -%% First dir, i.e. the one with highest version, is set to active dir +%% First dir, i.e. the one with highest version, is set to active dir, +%% unless a specific dir is given in config +set_active_dirs([#app{use_selected_vsn = dir} = App | Apps]) -> + [App | set_active_dirs(Apps)]; set_active_dirs([#app{sorted_dirs = [ActiveDir|_]} = App | Apps]) -> [App#app{active_dir = ActiveDir} | set_active_dirs(Apps)]; set_active_dirs([#app{sorted_dirs = []} = App | Apps]) -> @@ -1902,6 +1922,8 @@ ensure_app_info(#app{name = Name, sorted_dirs = []}, _Status) -> reltool_utils:throw_error("~p: : Missing application directory.",[Name]); ensure_app_info(#app{name = Name, vsn = Vsn, + use_selected_vsn = UseSelectedVsn, + active_dir = ActiveDir, sorted_dirs = Dirs, info = undefined}, Status) -> @@ -1929,19 +1951,28 @@ ensure_app_info(#app{name = Name, FirstInfo = hd(AllInfo), FirstDir = hd(Dirs), if - Vsn =:= undefined -> - {FirstInfo, FirstDir, Status3}; - Vsn =:= FirstInfo#app_info.vsn -> - {FirstInfo, FirstDir, Status3}; - true -> - case find_vsn(Vsn, AllInfo, Dirs) of - {Info, VsnDir} -> - {Info, VsnDir, Status3}; - false -> - reltool_utils:throw_error( - "~p: No application directory contains selected version ~p", - [Name,Vsn]) - end + UseSelectedVsn =:= dir -> + if ActiveDir =:= FirstDir -> + {FirstInfo, FirstDir, Status3}; + true -> + Info = find_dir(ActiveDir, AllInfo, Dirs), + {Info, ActiveDir, Status3} + end; + UseSelectedVsn =:= vsn -> + if Vsn =:= FirstInfo#app_info.vsn -> + {FirstInfo, FirstDir, Status3}; + true -> + case find_vsn(Vsn, AllInfo, Dirs) of + {Info, VsnDir} -> + {Info, VsnDir, Status3}; + false -> + reltool_utils:throw_error( + "~p: No application directory contains " + "selected version ~p", [Name,Vsn]) + end + end; + true -> + {FirstInfo, FirstDir, Status3} end; ensure_app_info(#app{active_dir = Dir, info = Info}, Status) -> {Info, Dir, Status}. @@ -1953,6 +1984,11 @@ find_vsn(Vsn, [_ | MoreInfo], [_ | MoreDirs]) -> find_vsn(_, [], []) -> false. +find_dir(Dir, [Info | _], [Dir | _]) -> + Info; +find_dir(Dir, [_ | MoreInfo], [_ | MoreDirs]) -> + find_dir(Dir, MoreInfo, MoreDirs). + get_base(Name, Dir) -> case Name of erts -> diff --git a/lib/reltool/src/reltool_target.erl b/lib/reltool/src/reltool_target.erl index 3d83a77d99..77f862dbc2 100644 --- a/lib/reltool/src/reltool_target.erl +++ b/lib/reltool/src/reltool_target.erl @@ -155,6 +155,7 @@ do_gen_config(#app{name = Name, archive_opts = ArchiveOpts, use_selected_vsn = UseSelected, vsn = Vsn, + active_dir = ActiveDir, mods = Mods, is_included = IsIncl}, InclDefs) -> @@ -170,9 +171,10 @@ do_gen_config(#app{name = Name, emit(excl_archive_filters, ExclArchiveDirs, undefined, InclDefs), emit(archive_opts, ArchiveOpts, undefined, InclDefs), if - IsIncl, InclDefs -> [{vsn, Vsn}]; - UseSelected -> [{vsn, Vsn}]; - true -> [] + IsIncl, InclDefs -> [{vsn, Vsn}, {lib_dir, ActiveDir}]; + UseSelected =:= vsn -> [{vsn, Vsn}]; + UseSelected =:= dir -> [{lib_dir, ActiveDir}]; + true -> [] end, [do_gen_config(M, InclDefs) || M <- Mods] ], diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl index b0def45213..ea0b00bbaf 100644 --- a/lib/reltool/src/reltool_utils.erl +++ b/lib/reltool/src/reltool_utils.erl @@ -256,7 +256,7 @@ app_dir_test(Dir1, Dir2) -> Name1 > Name2 -> false; Vsn1 < Vsn2 -> false; Vsn1 > Vsn2 -> true; - Parent1 < Parent2 -> true; + Parent1 =< Parent2 -> true; true -> false end. |