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
|
{ name, version
|
||||||
, src
|
, src
|
||||||
@ -11,11 +11,14 @@
|
|||||||
, buildPhase ? null
|
, buildPhase ? null
|
||||||
, configurePhase ? null
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
name = "interactive-shell-${drv.name}";
|
name = "interactive-shell-${drv.name}";
|
||||||
buildInputs = [ drv ];
|
buildInputs = [ drv ];
|
||||||
@ -55,7 +58,7 @@ let
|
|||||||
then ''
|
then ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
make SKIP_DEPS=1
|
make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}"
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
''
|
''
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex }:
|
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex, lib }:
|
||||||
|
|
||||||
{ name
|
{ name
|
||||||
, version
|
, version
|
||||||
@ -12,11 +12,15 @@
|
|||||||
, buildPhase ? null
|
, buildPhase ? null
|
||||||
, configurePhase ? null
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info";
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
name = "interactive-shell-${drv.name}";
|
name = "interactive-shell-${drv.name}";
|
||||||
buildInputs = [ drv ];
|
buildInputs = [ drv ];
|
||||||
@ -58,7 +62,7 @@ let
|
|||||||
export HEX_HOME=`pwd`
|
export HEX_HOME=`pwd`
|
||||||
export MIX_ENV=prod
|
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
|
runHook postBuild
|
||||||
''
|
''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
||||||
pc, buildEnv }:
|
pc, buildEnv, lib }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
, src
|
, src
|
||||||
@ -11,11 +11,14 @@
|
|||||||
, buildPhase ? null
|
, buildPhase ? null
|
||||||
, configurePhase ? null
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
|
||||||
|
|
||||||
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
@ -51,7 +54,7 @@ let
|
|||||||
configurePhase = if configurePhase == null
|
configurePhase = if configurePhase == null
|
||||||
then ''
|
then ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${erlang}/bin/escript ${rebar3.bootstrapper}
|
${erlang}/bin/escript ${rebar3.bootstrapper} ${debugInfoFlag}
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
''
|
''
|
||||||
else configurePhase;
|
else configurePhase;
|
||||||
|
@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
|
|
||||||
|
inherit debugInfo;
|
||||||
|
|
||||||
buildFlags = if debugInfo
|
buildFlags = if debugInfo
|
||||||
then "ERL_COMPILER_OPTIONS=debug_info"
|
then "ERL_COMPILER_OPTIONS=debug_info"
|
||||||
else "";
|
else "";
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
|
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
|
||||||
, gnused, gawk, makeWrapper
|
, gnused, gawk, makeWrapper
|
||||||
, odbcSupport ? false, unixODBC ? null
|
, 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 wxSupport -> mesa != null && wxGTK != null && xorg != null;
|
||||||
assert odbcSupport -> unixODBC != null;
|
assert odbcSupport -> unixODBC != null;
|
||||||
@ -17,6 +18,8 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
|
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[ perl gnum4 ncurses openssl makeWrapper
|
[ perl gnum4 ncurses openssl makeWrapper
|
||||||
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
|
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||||
, javacSupport ? false, openjdk ? null
|
, javacSupport ? false, openjdk ? null
|
||||||
, enableHipe ? true
|
, enableHipe ? true
|
||||||
|
, enableDebugInfo ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert wxSupport -> (if stdenv.isDarwin
|
assert wxSupport -> (if stdenv.isDarwin
|
||||||
@ -35,6 +36,8 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
export HOME=$PWD/../
|
export HOME=$PWD/../
|
||||||
sed -e s@/bin/pwd@pwd@g -i otp_build
|
sed -e s@/bin/pwd@pwd@g -i otp_build
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||||
, javacSupport ? false, openjdk ? null
|
, javacSupport ? false, openjdk ? null
|
||||||
, enableHipe ? true
|
, enableHipe ? true
|
||||||
|
, enableDebugInfo ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert wxSupport -> (if stdenv.isDarwin
|
assert wxSupport -> (if stdenv.isDarwin
|
||||||
@ -33,6 +34,8 @@ stdenv.mkDerivation rec {
|
|||||||
++ optional javacSupport openjdk
|
++ optional javacSupport openjdk
|
||||||
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
-record(data, {version
|
-record(data, {version
|
||||||
, registry_only = false
|
, registry_only = false
|
||||||
|
, debug_info = false
|
||||||
, compile_ports
|
, compile_ports
|
||||||
, erl_libs
|
, erl_libs
|
||||||
, plugins
|
, plugins
|
||||||
@ -54,21 +55,29 @@ do_the_bootstrap(RequiredData) ->
|
|||||||
%% @doc
|
%% @doc
|
||||||
%% Argument parsing is super simple only because we want to keep the
|
%% Argument parsing is super simple only because we want to keep the
|
||||||
%% dependencies minimal. For now there can be two entries on 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{}.
|
-spec parse_args([string()]) -> #data{}.
|
||||||
parse_args(["registry-only"]) ->
|
parse_args(Args0) ->
|
||||||
{ok, #data{registry_only = true}};
|
PossibleArgs = sets:from_list(["registry-only", "debug-info"]),
|
||||||
parse_args([]) ->
|
Args1 = sets:from_list(Args0),
|
||||||
{ok, #data{registry_only = false}};
|
Result = sets:subtract(Args1, PossibleArgs),
|
||||||
parse_args(Args) ->
|
case sets:to_list(Result) of
|
||||||
io:format("Unexpected command line arguments passed in: ~p~n", [Args]),
|
[] ->
|
||||||
erlang:halt(120).
|
{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.
|
-spec bootstrap_configs(#data{}) -> ok.
|
||||||
bootstrap_configs(RequiredData)->
|
bootstrap_configs(RequiredData)->
|
||||||
io:format("Boostrapping app and rebar configurations~n"),
|
io:format("Boostrapping app and rebar configurations~n"),
|
||||||
ok = if_single_app_project_update_app_src_version(RequiredData),
|
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.
|
-spec bootstrap_plugins(#data{}) -> ok.
|
||||||
bootstrap_plugins(#data{plugins = Plugins}) ->
|
bootstrap_plugins(#data{plugins = Plugins}) ->
|
||||||
@ -198,6 +207,33 @@ guard_env(Name) ->
|
|||||||
Variable
|
Variable
|
||||||
end.
|
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
|
%% @doc
|
||||||
%% If the compile ports flag is set, rewrite the rebar config to
|
%% If the compile ports flag is set, rewrite the rebar config to
|
||||||
%% include the 'pc' plugin.
|
%% include the 'pc' plugin.
|
||||||
@ -213,7 +249,7 @@ if_compile_ports_add_pc_plugin(_) ->
|
|||||||
-spec add_pc_to_plugins([term()]) -> [term()].
|
-spec add_pc_to_plugins([term()]) -> [term()].
|
||||||
add_pc_to_plugins(Config) ->
|
add_pc_to_plugins(Config) ->
|
||||||
PluginList = case lists:keysearch(plugins, 1, Config) of
|
PluginList = case lists:keysearch(plugins, 1, Config) of
|
||||||
{ok, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
{value, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
||||||
|
Loading…
Reference in New Issue
Block a user