aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlav Frengstad <[email protected]>2013-06-20 09:53:23 +0200
committerOlav Frengstad <[email protected]>2013-06-20 10:04:53 +0200
commit5ed7ea3172170fa05ac806250f695834d5d6ae58 (patch)
tree0247674887803bb006fb2384c0bc4e98e4371e04 /src
parentc5f0a8c9175b2d152c69f72da15e7ceff411f86b (diff)
downloadrelx-5ed7ea3172170fa05ac806250f695834d5d6ae58.tar.gz
relx-5ed7ea3172170fa05ac806250f695834d5d6ae58.tar.bz2
relx-5ed7ea3172170fa05ac806250f695834d5d6ae58.zip
Add support for {vm_args,_} argument in config
Diffstat (limited to 'src')
-rw-r--r--src/rlx_prv_assembler.erl21
-rw-r--r--src/rlx_prv_config.erl2
-rw-r--r--src/rlx_prv_overlay.erl1
-rw-r--r--src/rlx_state.erl11
4 files changed, 34 insertions, 1 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 18a372c..20f9c5c 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -250,9 +250,28 @@ write_bin_file(State, Release, OutputDir, RelDir) ->
ok = file:write_file(BareRel, StartFile),
ok = file:change_mode(BareRel, 8#777)
end,
- ok = file:write_file(filename:join(RelDir, "vm.args"), vm_args_file(RelName)),
+ copy_or_generate_vmargs_file(State, RelName, RelDir),
copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir).
+%% @doc copy vm.args or generate one to releases/VSN/vm.args
+-spec copy_or_generate_vmargs_file(rlx_state:t(), string(), file:name()) ->
+ {ok, rlx_state:t()} | relx:error().
+
+copy_or_generate_vmargs_file(State, RelName, RelDir) ->
+ RelVmargsPath = filename:join([RelDir, "vm.args"]),
+
+ case rlx_state:vm_args(State) of
+ undefined ->
+ ok = file:write_file(RelVmargsPath, vm_args_file(RelName));
+ ArgsPath ->
+ case filelib:is_regular(ArgsPath) of
+ false ->
+ ?RLX_ERROR({vmargs_does_not_exist, ArgsPath});
+ true ->
+ ec_file:copy(ArgsPath, RelVmargsPath)
+ end
+ end.
+
%% @doc copy config/sys.config or generate one to releases/VSN/sys.config
-spec copy_or_generate_sys_config_file(rlx_state:t(), rlx_release:t(),
file:name(), file:name()) ->
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index 36a0527..bbdf6e6 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -165,6 +165,8 @@ load_terms({release, {RelName, Vsn}, {erts, ErtsVsn},
{ok, Release1} ->
{ok, rlx_state:add_configured_release(State, Release1)}
end;
+load_terms({vm_args, VmArgs}, {ok, State}) ->
+ {ok, rcl_state:vm_args(State, filename:absname(VmArgs))};
load_terms({sys_config, SysConfig}, {ok, State}) ->
{ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
load_terms({Name, Value}, {ok, State})
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 5fffd78..2a81730 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -200,6 +200,7 @@ generate_state_vars(State) ->
{lib_dirs, rlx_state:lib_dirs(State)},
{config_file, rlx_state:config_file(State)},
{providers, rlx_state:providers(State)},
+ {vm_args, rlx_state:vm_args(State)},
{sys_config, rlx_state:sys_config(State)},
{root_dir, rlx_state:root_dir(State)},
{default_release_name, case rlx_state:default_configured_release(State) of
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 9b0811f..f5f363e 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -37,6 +37,8 @@
config_file/2,
providers/1,
providers/2,
+ vm_args/1,
+ vm_args/2,
sys_config/1,
sys_config/2,
root_dir/1,
@@ -78,6 +80,7 @@
providers = [] :: [rlx_provider:t()],
available_apps = [] :: [rlx_app_info:t()],
default_configured_release :: {rlx_release:name(), rlx_release:vsn()},
+ vm_args :: file:filename() | undefined,
sys_config :: file:filename() | undefined,
overrides :: [{AppName::atom(), Directory::file:filename()}],
skip_apps = [] :: [AppName::atom()],
@@ -183,6 +186,14 @@ config_file(State, ConfigFiles) ->
providers(#state_t{providers=Providers}) ->
Providers.
+-spec vm_args(t()) -> file:filename() | undefined.
+vm_args(#state_t{vm_args=VmArgs}) ->
+ VmArgs.
+
+-spec vm_args(t(), file:filename()) -> t().
+vm_args(State, VmArgs) ->
+ State#state_t{vm_args=VmArgs}.
+
-spec sys_config(t()) -> file:filename() | undefined.
sys_config(#state_t{sys_config=SysConfig}) ->
SysConfig.