nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

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.

authored by

Eric Merritt and committed by
Eric Merritt
b1cd0824 de401336

+74 -17
+5 -2
pkgs/development/beam-modules/build-erlang-mk.nix
··· 1 - { stdenv, writeText, erlang, perl, which, gitMinimal, wget }: 1 + { stdenv, writeText, erlang, perl, which, gitMinimal, wget, lib }: 2 2 3 3 { name, version 4 4 , src ··· 11 11 , buildPhase ? null 12 12 , configurePhase ? null 13 13 , meta ? {} 14 + , enableDebugInfo ? false 14 15 , ... }@attrs: 15 16 16 17 with stdenv.lib; 17 18 18 19 let 20 + debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info"; 21 + 19 22 shell = drv: stdenv.mkDerivation { 20 23 name = "interactive-shell-${drv.name}"; 21 24 buildInputs = [ drv ]; ··· 58 55 then '' 59 56 runHook preBuild 60 57 61 - make SKIP_DEPS=1 58 + make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}" 62 59 63 60 runHook postBuild 64 61 ''
+6 -2
pkgs/development/beam-modules/build-mix.nix
··· 1 - { stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex }: 1 + { stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex, lib }: 2 2 3 3 { name 4 4 , version ··· 12 12 , buildPhase ? null 13 13 , configurePhase ? null 14 14 , meta ? {} 15 + , enableDebugInfo ? false 15 16 , ... }@attrs: 16 17 17 18 with stdenv.lib; 18 19 19 20 let 21 + 22 + debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info"; 23 + 20 24 shell = drv: stdenv.mkDerivation { 21 25 name = "interactive-shell-${drv.name}"; 22 26 buildInputs = [ drv ]; ··· 62 58 export HEX_HOME=`pwd` 63 59 export MIX_ENV=prod 64 60 65 - MIX_ENV=prod mix compile --debug-info --no-deps-check 61 + MIX_ENV=prod mix compile ${debugInfoFlag} --no-deps-check 66 62 67 63 runHook postBuild 68 64 ''
+5 -2
pkgs/development/beam-modules/build-rebar3.nix
··· 1 1 { stdenv, writeText, erlang, rebar3, openssl, libyaml, 2 - pc, buildEnv }: 2 + pc, buildEnv, lib }: 3 3 4 4 { name, version 5 5 , src ··· 11 11 , buildPhase ? null 12 12 , configurePhase ? null 13 13 , meta ? {} 14 + , enableDebugInfo ? false 14 15 , ... }@attrs: 15 16 16 17 with stdenv.lib; 17 18 18 19 let 20 + debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info"; 21 + 19 22 ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []); 20 23 21 24 shell = drv: stdenv.mkDerivation { ··· 54 51 configurePhase = if configurePhase == null 55 52 then '' 56 53 runHook preConfigure 57 - ${erlang}/bin/escript ${rebar3.bootstrapper} 54 + ${erlang}/bin/escript ${rebar3.bootstrapper} ${debugInfoFlag} 58 55 runHook postConfigure 59 56 '' 60 57 else configurePhase;
+2
pkgs/development/interpreters/elixir/default.nix
··· 21 21 22 22 setupHook = ./setup-hook.sh; 23 23 24 + inherit debugInfo; 25 + 24 26 buildFlags = if debugInfo 25 27 then "ERL_COMPILER_OPTIONS=debug_info" 26 28 else "";
+4 -1
pkgs/development/interpreters/erlang/R16.nix
··· 1 1 { stdenv, fetchurl, perl, gnum4, ncurses, openssl 2 2 , gnused, gawk, makeWrapper 3 3 , odbcSupport ? false, unixODBC ? null 4 - , wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null }: 4 + , wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null 5 + , enableDebugInfo ? false }: 5 6 6 7 assert wxSupport -> mesa != null && wxGTK != null && xorg != null; 7 8 assert odbcSupport -> unixODBC != null; ··· 17 16 url = "http://www.erlang.org/download/otp_src_R${version}.tar.gz"; 18 17 sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp"; 19 18 }; 19 + 20 + debugInfo = enableDebugInfo; 20 21 21 22 buildInputs = 22 23 [ perl gnum4 ncurses openssl makeWrapper
+3
pkgs/development/interpreters/erlang/R17.nix
··· 5 5 , wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null 6 6 , javacSupport ? false, openjdk ? null 7 7 , enableHipe ? true 8 + , enableDebugInfo ? false 8 9 }: 9 10 10 11 assert wxSupport -> (if stdenv.isDarwin ··· 35 34 ++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; 36 35 37 36 patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure ''; 37 + 38 + debugInfo = enableDebugInfo; 38 39 39 40 preConfigure = '' 40 41 export HOME=$PWD/../
+3
pkgs/development/interpreters/erlang/R18.nix
··· 5 5 , wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null 6 6 , javacSupport ? false, openjdk ? null 7 7 , enableHipe ? true 8 + , enableDebugInfo ? false 8 9 }: 9 10 10 11 assert wxSupport -> (if stdenv.isDarwin ··· 33 32 ++ optional odbcSupport unixODBC 34 33 ++ optional javacSupport openjdk 35 34 ++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; 35 + 36 + debugInfo = enableDebugInfo; 36 37 37 38 patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure ''; 38 39
+46 -10
pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
··· 26 26 27 27 -record(data, {version 28 28 , registry_only = false 29 + , debug_info = false 29 30 , compile_ports 30 31 , erl_libs 31 32 , plugins ··· 55 54 %% @doc 56 55 %% Argument parsing is super simple only because we want to keep the 57 56 %% dependencies minimal. For now there can be two entries on the 58 - %% command line, "registery-only" 57 + %% command line, "registery-only" and "debug-info" 59 58 -spec parse_args([string()]) -> #data{}. 60 - parse_args(["registry-only"]) -> 61 - {ok, #data{registry_only = true}}; 62 - parse_args([]) -> 63 - {ok, #data{registry_only = false}}; 64 - parse_args(Args) -> 65 - io:format("Unexpected command line arguments passed in: ~p~n", [Args]), 66 - erlang:halt(120). 59 + parse_args(Args0) -> 60 + PossibleArgs = sets:from_list(["registry-only", "debug-info"]), 61 + Args1 = sets:from_list(Args0), 62 + Result = sets:subtract(Args1, PossibleArgs), 63 + case sets:to_list(Result) of 64 + [] -> 65 + {ok, #data{registry_only = sets:is_element("registry-only", Args1), 66 + debug_info = sets:is_element("debug-info", Args1)}}; 67 + UnknownArgs -> 68 + io:format("Unexpected command line arguments passed in: ~p~n", 69 + [UnknownArgs]), 70 + erlang:halt(120) 71 + end. 72 + 67 73 68 74 -spec bootstrap_configs(#data{}) -> ok. 69 75 bootstrap_configs(RequiredData)-> 70 76 io:format("Boostrapping app and rebar configurations~n"), 71 77 ok = if_single_app_project_update_app_src_version(RequiredData), 72 - ok = if_compile_ports_add_pc_plugin(RequiredData). 78 + ok = if_compile_ports_add_pc_plugin(RequiredData), 79 + ok = if_debug_info_add(RequiredData). 73 80 74 81 -spec bootstrap_plugins(#data{}) -> ok. 75 82 bootstrap_plugins(#data{plugins = Plugins}) -> ··· 208 199 end. 209 200 210 201 %% @doc 202 + %% If debug info is set we need to add debug info to the list of compile options 203 + %% 204 + -spec if_debug_info_add(#data{}) -> ok. 205 + if_debug_info_add(#data{debug_info = true}) -> 206 + ConfigTerms = add_debug_info(read_rebar_config()), 207 + Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end, 208 + ConfigTerms), 209 + file:write_file("rebar.config", Text); 210 + if_debug_info_add(_) -> 211 + ok. 212 + 213 + -spec add_debug_info([term()]) -> [term()]. 214 + add_debug_info(Config) -> 215 + ExistingOpts = case lists:keysearch(erl_opts, 1, Config) of 216 + {value, {erl_opts, ExistingOptsList}} -> ExistingOptsList; 217 + _ -> [] 218 + end, 219 + case lists:member(debug_info, ExistingOpts) of 220 + true -> 221 + Config; 222 + false -> 223 + lists:keystore(erl_opts, 1, Config, 224 + {erl_opts, [debug_info | ExistingOpts]}) 225 + end. 226 + 227 + 228 + %% @doc 211 229 %% If the compile ports flag is set, rewrite the rebar config to 212 230 %% include the 'pc' plugin. 213 231 -spec if_compile_ports_add_pc_plugin(#data{}) -> ok. ··· 249 213 -spec add_pc_to_plugins([term()]) -> [term()]. 250 214 add_pc_to_plugins(Config) -> 251 215 PluginList = case lists:keysearch(plugins, 1, Config) of 252 - {ok, {plugins, ExistingPluginList}} -> ExistingPluginList; 216 + {value, {plugins, ExistingPluginList}} -> ExistingPluginList; 253 217 _ -> [] 254 218 end, 255 219 lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).