beamPackages: turn on debug_info for beam packages
This allows you to turn on debug infor for all the beam packages in the system with a single change at the top level. This is required for debugging and dialyzer work. It also allows you to switch it on on a package by package basis.
This commit is contained in:
parent
de40133673
commit
b1cd08246f
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, writeText, erlang, perl, which, gitMinimal, wget }:
|
||||
{ stdenv, writeText, erlang, perl, which, gitMinimal, wget, lib }:
|
||||
|
||||
{ name, version
|
||||
, src
|
||||
|
@ -11,11 +11,14 @@
|
|||
, buildPhase ? null
|
||||
, configurePhase ? null
|
||||
, meta ? {}
|
||||
, enableDebugInfo ? false
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
|
||||
|
||||
shell = drv: stdenv.mkDerivation {
|
||||
name = "interactive-shell-${drv.name}";
|
||||
buildInputs = [ drv ];
|
||||
|
@ -55,7 +58,7 @@ let
|
|||
then ''
|
||||
runHook preBuild
|
||||
|
||||
make SKIP_DEPS=1
|
||||
make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}"
|
||||
|
||||
runHook postBuild
|
||||
''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex }:
|
||||
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex, lib }:
|
||||
|
||||
{ name
|
||||
, version
|
||||
|
@ -12,11 +12,15 @@
|
|||
, buildPhase ? null
|
||||
, configurePhase ? null
|
||||
, meta ? {}
|
||||
, enableDebugInfo ? false
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
|
||||
debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info";
|
||||
|
||||
shell = drv: stdenv.mkDerivation {
|
||||
name = "interactive-shell-${drv.name}";
|
||||
buildInputs = [ drv ];
|
||||
|
@ -58,7 +62,7 @@ let
|
|||
export HEX_HOME=`pwd`
|
||||
export MIX_ENV=prod
|
||||
|
||||
MIX_ENV=prod mix compile --debug-info --no-deps-check
|
||||
MIX_ENV=prod mix compile ${debugInfoFlag} --no-deps-check
|
||||
|
||||
runHook postBuild
|
||||
''
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
||||
pc, buildEnv }:
|
||||
pc, buildEnv, lib }:
|
||||
|
||||
{ name, version
|
||||
, src
|
||||
|
@ -11,11 +11,14 @@
|
|||
, buildPhase ? null
|
||||
, configurePhase ? null
|
||||
, meta ? {}
|
||||
, enableDebugInfo ? false
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
|
||||
|
||||
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
||||
|
||||
shell = drv: stdenv.mkDerivation {
|
||||
|
@ -51,7 +54,7 @@ let
|
|||
configurePhase = if configurePhase == null
|
||||
then ''
|
||||
runHook preConfigure
|
||||
${erlang}/bin/escript ${rebar3.bootstrapper}
|
||||
${erlang}/bin/escript ${rebar3.bootstrapper} ${debugInfoFlag}
|
||||
runHook postConfigure
|
||||
''
|
||||
else configurePhase;
|
||||
|
|
|
@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
|
|||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
inherit debugInfo;
|
||||
|
||||
buildFlags = if debugInfo
|
||||
then "ERL_COMPILER_OPTIONS=debug_info"
|
||||
else "";
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
|
||||
, gnused, gawk, makeWrapper
|
||||
, odbcSupport ? false, unixODBC ? null
|
||||
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null }:
|
||||
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null
|
||||
, enableDebugInfo ? false }:
|
||||
|
||||
assert wxSupport -> mesa != null && wxGTK != null && xorg != null;
|
||||
assert odbcSupport -> unixODBC != null;
|
||||
|
@ -17,6 +18,8 @@ stdenv.mkDerivation rec {
|
|||
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
|
||||
};
|
||||
|
||||
debugInfo = enableDebugInfo;
|
||||
|
||||
buildInputs =
|
||||
[ perl gnum4 ncurses openssl makeWrapper
|
||||
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||
, javacSupport ? false, openjdk ? null
|
||||
, enableHipe ? true
|
||||
, enableDebugInfo ? false
|
||||
}:
|
||||
|
||||
assert wxSupport -> (if stdenv.isDarwin
|
||||
|
@ -35,6 +36,8 @@ stdenv.mkDerivation rec {
|
|||
|
||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||
|
||||
debugInfo = enableDebugInfo;
|
||||
|
||||
preConfigure = ''
|
||||
export HOME=$PWD/../
|
||||
sed -e s@/bin/pwd@pwd@g -i otp_build
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||
, javacSupport ? false, openjdk ? null
|
||||
, enableHipe ? true
|
||||
, enableDebugInfo ? false
|
||||
}:
|
||||
|
||||
assert wxSupport -> (if stdenv.isDarwin
|
||||
|
@ -33,6 +34,8 @@ stdenv.mkDerivation rec {
|
|||
++ optional javacSupport openjdk
|
||||
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
||||
|
||||
debugInfo = enableDebugInfo;
|
||||
|
||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||
|
||||
preConfigure = ''
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
-record(data, {version
|
||||
, registry_only = false
|
||||
, debug_info = false
|
||||
, compile_ports
|
||||
, erl_libs
|
||||
, plugins
|
||||
|
@ -54,21 +55,29 @@ do_the_bootstrap(RequiredData) ->
|
|||
%% @doc
|
||||
%% Argument parsing is super simple only because we want to keep the
|
||||
%% dependencies minimal. For now there can be two entries on the
|
||||
%% command line, "registery-only"
|
||||
%% command line, "registery-only" and "debug-info"
|
||||
-spec parse_args([string()]) -> #data{}.
|
||||
parse_args(["registry-only"]) ->
|
||||
{ok, #data{registry_only = true}};
|
||||
parse_args([]) ->
|
||||
{ok, #data{registry_only = false}};
|
||||
parse_args(Args) ->
|
||||
io:format("Unexpected command line arguments passed in: ~p~n", [Args]),
|
||||
erlang:halt(120).
|
||||
parse_args(Args0) ->
|
||||
PossibleArgs = sets:from_list(["registry-only", "debug-info"]),
|
||||
Args1 = sets:from_list(Args0),
|
||||
Result = sets:subtract(Args1, PossibleArgs),
|
||||
case sets:to_list(Result) of
|
||||
[] ->
|
||||
{ok, #data{registry_only = sets:is_element("registry-only", Args1),
|
||||
debug_info = sets:is_element("debug-info", Args1)}};
|
||||
UnknownArgs ->
|
||||
io:format("Unexpected command line arguments passed in: ~p~n",
|
||||
[UnknownArgs]),
|
||||
erlang:halt(120)
|
||||
end.
|
||||
|
||||
|
||||
-spec bootstrap_configs(#data{}) -> ok.
|
||||
bootstrap_configs(RequiredData)->
|
||||
io:format("Boostrapping app and rebar configurations~n"),
|
||||
ok = if_single_app_project_update_app_src_version(RequiredData),
|
||||
ok = if_compile_ports_add_pc_plugin(RequiredData).
|
||||
ok = if_compile_ports_add_pc_plugin(RequiredData),
|
||||
ok = if_debug_info_add(RequiredData).
|
||||
|
||||
-spec bootstrap_plugins(#data{}) -> ok.
|
||||
bootstrap_plugins(#data{plugins = Plugins}) ->
|
||||
|
@ -198,6 +207,33 @@ guard_env(Name) ->
|
|||
Variable
|
||||
end.
|
||||
|
||||
%% @doc
|
||||
%% If debug info is set we need to add debug info to the list of compile options
|
||||
%%
|
||||
-spec if_debug_info_add(#data{}) -> ok.
|
||||
if_debug_info_add(#data{debug_info = true}) ->
|
||||
ConfigTerms = add_debug_info(read_rebar_config()),
|
||||
Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end,
|
||||
ConfigTerms),
|
||||
file:write_file("rebar.config", Text);
|
||||
if_debug_info_add(_) ->
|
||||
ok.
|
||||
|
||||
-spec add_debug_info([term()]) -> [term()].
|
||||
add_debug_info(Config) ->
|
||||
ExistingOpts = case lists:keysearch(erl_opts, 1, Config) of
|
||||
{value, {erl_opts, ExistingOptsList}} -> ExistingOptsList;
|
||||
_ -> []
|
||||
end,
|
||||
case lists:member(debug_info, ExistingOpts) of
|
||||
true ->
|
||||
Config;
|
||||
false ->
|
||||
lists:keystore(erl_opts, 1, Config,
|
||||
{erl_opts, [debug_info | ExistingOpts]})
|
||||
end.
|
||||
|
||||
|
||||
%% @doc
|
||||
%% If the compile ports flag is set, rewrite the rebar config to
|
||||
%% include the 'pc' plugin.
|
||||
|
@ -213,7 +249,7 @@ if_compile_ports_add_pc_plugin(_) ->
|
|||
-spec add_pc_to_plugins([term()]) -> [term()].
|
||||
add_pc_to_plugins(Config) ->
|
||||
PluginList = case lists:keysearch(plugins, 1, Config) of
|
||||
{ok, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
||||
{value, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
||||
_ -> []
|
||||
end,
|
||||
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
||||
|
|
Loading…
Reference in a new issue