aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reltool/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2012-03-23 11:48:52 +0100
committerSiri Hansen <[email protected]>2012-03-23 11:48:52 +0100
commitb13b88779b3fbc0ef8bb91a17a5d064cd778e0fa (patch)
tree0f4bce1eb128326affdaacaeb0b2de2ac19860f8 /lib/reltool/src
parentfd89175a2b17e92a0b90cb28e5af2375d3aa4535 (diff)
parent38f068341ebf04e5d6bf5eff7fb01e44bce228b6 (diff)
downloadotp-b13b88779b3fbc0ef8bb91a17a5d064cd778e0fa.tar.gz
otp-b13b88779b3fbc0ef8bb91a17a5d064cd778e0fa.tar.bz2
otp-b13b88779b3fbc0ef8bb91a17a5d064cd778e0fa.zip
Merge branch 'siri/reltool/app-level-lib-dir/OTP-9977' into maint
* siri/reltool/app-level-lib-dir/OTP-9977: [reltool] Allow lib_dir on app level to use relative path [reltool] Add configuration parameter lib_dir on application level
Diffstat (limited to 'lib/reltool/src')
-rw-r--r--lib/reltool/src/reltool.hrl3
-rw-r--r--lib/reltool/src/reltool_app_win.erl13
-rw-r--r--lib/reltool/src/reltool_server.erl85
-rw-r--r--lib/reltool/src/reltool_target.erl8
-rw-r--r--lib/reltool/src/reltool_utils.erl18
5 files changed, 92 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..034a42e1e2 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,22 @@ 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 ->
+ Dir = reltool_utils:normalize_dir(Val),
+ App#app{use_selected_vsn = dir,
+ active_dir = Dir,
+ sorted_dirs = [Dir]};
+ 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 +1856,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 +1923,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 +1952,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 +1985,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 44f1977ad6..e3a7b02143 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..6149d6ef06 100644
--- a/lib/reltool/src/reltool_utils.erl
+++ b/lib/reltool/src/reltool_utils.erl
@@ -22,6 +22,7 @@
-export([root_dir/0, erl_libs/0, lib_dirs/1,
split_app_name/1, prim_consult/1,
default_rels/0, choose_default/3,
+ normalize_dir/1,
assign_image_list/1, get_latest_resize/1, wait_for_stop_motion/2,
mod_conds/0, list_to_mod_cond/1, mod_cond_to_index/1,
@@ -87,6 +88,21 @@ split_app_name(Name) ->
{list_to_atom(Name), ""}
end.
+
+normalize_dir(RelDir) ->
+ Tokens = filename:split(filename:absname(RelDir)),
+ filename:join(lists:reverse(normalize_dir(Tokens, []))).
+
+normalize_dir([".."|Dirs], [_Dir|Path]) ->
+ normalize_dir(Dirs, Path);
+normalize_dir(["."|Dirs], Path) ->
+ normalize_dir(Dirs, Path);
+normalize_dir([Dir|Dirs], Path) ->
+ normalize_dir(Dirs, [Dir|Path]);
+normalize_dir([], Path) ->
+ Path.
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
prim_consult(Bin) when is_binary(Bin) ->
@@ -256,7 +272,7 @@ app_dir_test(Dir1, Dir2) ->
Name1 > Name2 -> false;
Vsn1 < Vsn2 -> false;
Vsn1 > Vsn2 -> true;
- Parent1 < Parent2 -> true;
+ Parent1 =< Parent2 -> true;
true -> false
end.