Add root_dir option to reltool.config

When generating a node using rebar generate, rebar always used
code:root_dir() to find the Erlang installation to clone into the node
tree.  However, for anyone wishing to build a cross-compiled node, there
was no way to override this.  This patch adds a new option to
reltool.config file to allow an alternate root_dir to be specified, for
example:

{root_dir, "/tmp/otp_R14B03_armv7l"}

This assumes that the contents of /tmp/otp_R14B03_armv7l has been
generated using the instructions found in the xcomp directory in your
$ERL_TOP structure.  NOTE: you may have to add additional filters to
exclude files not present in the xcomp version, such as the .smp files
if you have disabled that.
This commit is contained in:
smithwinston 2011-10-11 12:44:34 -04:00 committed by Tuncer Ayaz
parent a54dd53673
commit 1eaf88d1d0
2 changed files with 22 additions and 1 deletions

View file

@ -38,6 +38,7 @@
load_config/1,
get_sys_tuple/1,
get_target_dir/1,
get_root_dir/1,
get_target_parent_dir/1]).
-include("rebar.hrl").
@ -158,6 +159,23 @@ get_target_dir(ReltoolConfig) ->
filename:absname(TargetDir)
end.
%%
%% Look for {root_dir, RootDir} in the reltool config file; if none is
%% found, use the name of the release as the default target directory.
%%
get_root_dir(ReltoolConfig) ->
case rebar_config:get_global(root_dir, undefined) of
undefined ->
case lists:keyfind(root_dir, 1, ReltoolConfig) of
{root_dir, RootDir} ->
filename:absname(RootDir);
false ->
code:root_dir()
end;
RootDir ->
filename:absname(RootDir)
end.
get_target_parent_dir(ReltoolConfig) ->
case lists:reverse(tl(lists:reverse(filename:split(get_target_dir(ReltoolConfig))))) of
[] -> ".";

View file

@ -196,11 +196,14 @@ run_reltool(Server, _Config, ReltoolConfig) ->
TargetDir = rebar_rel_utils:get_target_dir(ReltoolConfig),
mk_target_dir(TargetDir),
%% Determine the otp root dir to use
RootDir = rebar_rel_utils:get_root_dir(ReltoolConfig),
%% Dump the spec, if necessary
dump_spec(Spec),
%% Have reltool actually run
case reltool:eval_target_spec(Spec, code:root_dir(), TargetDir) of
case reltool:eval_target_spec(Spec, RootDir, TargetDir) of
ok ->
ok;
{error, Reason} ->