diff options
author | Tristan Sloughter <[email protected]> | 2014-11-05 19:42:27 -0600 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2014-11-06 12:07:17 -0600 |
commit | 9b066cc53e342f3928dfb01a3511e3869b18e2c0 (patch) | |
tree | be79c248ccd7152913d45a03767a8f8136647765 /src | |
parent | 75b44fa44ef70e078dd450bf68bfaea4d48bf4e3 (diff) | |
download | relx-9b066cc53e342f3928dfb01a3511e3869b18e2c0.tar.gz relx-9b066cc53e342f3928dfb01a3511e3869b18e2c0.tar.bz2 relx-9b066cc53e342f3928dfb01a3511e3869b18e2c0.zip |
add option to strip debug_info from beam files if not dev_mode
Diffstat (limited to 'src')
-rw-r--r-- | src/rlx_config.erl | 2 | ||||
-rw-r--r-- | src/rlx_prv_assembler.erl | 23 | ||||
-rw-r--r-- | src/rlx_state.erl | 11 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/rlx_config.erl b/src/rlx_config.erl index 307d2b6..1a78c6c 100644 --- a/src/rlx_config.erl +++ b/src/rlx_config.erl @@ -162,6 +162,8 @@ load_terms({add_providers, Providers0}, {ok, State0}) -> end; load_terms({skip_apps, SkipApps0}, {ok, State0}) -> {ok, rlx_state:skip_apps(State0, SkipApps0)}; +load_terms({debug_info, DebugInfo}, {ok, State0}) -> + {ok, rlx_state:debug_info(State0, DebugInfo)}; load_terms({overrides, Overrides0}, {ok, State0}) -> {ok, rlx_state:overrides(State0, Overrides0)}; load_terms({dev_mode, DevMode}, {ok, State0}) -> diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index c535485..622c99d 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -60,7 +60,23 @@ do(State) -> ok -> case rlx_release:realized(Release) of true -> - copy_app_directories_to_output(State, Release, OutputDir); + case copy_app_directories_to_output(State, Release, OutputDir) of + {ok, State1} -> + case rlx_state:debug_info(State1) =:= strip + andalso rlx_state:dev_mode(State1) =:= false of + true -> + case beam_lib:strip_release(OutputDir) of + {ok, _} -> + {ok, State1}; + {error, _, Reason} -> + ?RLX_ERROR({strip_release, Reason}) + end; + false -> + {ok, State1} + end; + E -> + E + end; false -> ?RLX_ERROR({unresolved_release, RelName, RelVsn}) end; @@ -95,7 +111,10 @@ format_error({release_script_generation_error, Module, Errors}, State) -> format_error({unable_to_make_symlink, AppDir, TargetDir, Reason}, _) -> io_lib:format("Unable to symlink directory ~s to ~s because \n~s~s", [AppDir, TargetDir, rlx_util:indent(2), - file:format_error(Reason)]). + file:format_error(Reason)]); +format_error({strip_release, Reason}, _) -> + io_lib:format("Stripping debug info from release beam files failed becuase ~s", + [beam_lib:format_error(Reason)]). %%%=================================================================== %%% Internal Functions diff --git a/src/rlx_state.erl b/src/rlx_state.erl index b7cb6ba..a21c9a6 100644 --- a/src/rlx_state.erl +++ b/src/rlx_state.erl @@ -36,6 +36,8 @@ overrides/2, skip_apps/1, skip_apps/2, + debug_info/1, + debug_info/2, goals/1, goals/2, config_file/1, @@ -102,6 +104,7 @@ sys_config :: file:filename() | undefined, overrides=[] :: [{AppName::atom(), Directory::file:filename()}], skip_apps=[] :: [AppName::atom()], + debug_info=keep :: keep | strip, configured_releases :: releases(), realized_releases :: releases(), dev_mode=false :: boolean(), @@ -183,6 +186,14 @@ skip_apps(#state_t{skip_apps=Apps}) -> skip_apps(State, SkipApps) -> State#state_t{skip_apps=SkipApps}. +-spec debug_info(t()) -> keep | strip. +debug_info(#state_t{debug_info=DebugInfo}) -> + DebugInfo. + +-spec debug_info(t(), keep | strip) -> t(). +debug_info(State, DebugInfo) -> + State#state_t{debug_info=DebugInfo}. + %% @doc get the current log state for the system -spec log(t()) -> ec_cmd_log:t(). log(#state_t{log=LogState}) -> |