diff options
author | smithwinston <smith.winston.101@gmail.com> | 2011-10-11 12:44:34 -0400 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-11-26 10:38:27 +0100 |
commit | 1eaf88d1d0f35047ade13f0b6af4fd8ebb0f725f (patch) | |
tree | 596300b60aa187113d43c48dd62a54eeaec98c79 /src | |
parent | a54dd53673444fc4227341ecfdd78fb2710b600d (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_rel_utils.erl | 18 | ||||
-rw-r--r-- | src/rebar_reltool.erl | 5 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index d9a1fc6..4725f58 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -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 [] -> "."; diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index e08f55f..4847e53 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -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} -> |