forked from mirrors/nixpkgs
Build a package with debugging information so that you can run it within gdb or run valgrind on it.
Example: xmessageDebug = misc.debugVersion xorg.xmessage svn path=/nixpkgs/trunk/; revision=21945
This commit is contained in:
parent
0212a63e07
commit
32edcce80b
|
@ -1,4 +1,7 @@
|
|||
let lib = import ./default.nix; in
|
||||
let lib = import ./default.nix;
|
||||
inherit (builtins) getAttr attrNames isFunction;
|
||||
|
||||
in
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -31,7 +34,10 @@ rec {
|
|||
overrideDerivation = drv: f:
|
||||
let
|
||||
# Filter out special attributes.
|
||||
attrs = removeAttrs drv ["meta" "passthru" "outPath" "drvPath" "hostDrv" "buildDrv" "type" "override" "deepOverride" "origArgs"];
|
||||
drop = ["meta" "passthru" "outPath" "drvPath" "hostDrv" "buildDrv" "type" "override" "deepOverride" "origArgs"]
|
||||
# also drop functions such as .merge .override etc
|
||||
++ lib.filter (n: isFunction (getAttr n drv)) (attrNames drv);
|
||||
attrs = removeAttrs drv drop;
|
||||
newDrv = derivation (attrs // (f drv));
|
||||
in newDrv //
|
||||
{ meta = if drv ? meta then drv.meta else {};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, stdenv } :
|
||||
|
||||
let inherit (pkgs) stdenv runCommand perl;
|
||||
let inherit (pkgs) stdenv runCommand perl lib;
|
||||
|
||||
in
|
||||
|
||||
|
@ -106,4 +106,30 @@ in
|
|||
echo "''${PATH}" > $target/PATH
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
# build a debug version of a package
|
||||
debugVersion = pkg: lib.overrideDerivation pkg (attrs: {
|
||||
|
||||
prePhases = ["preHook"] ++ lib.optionals (pkgs ? prePhases) pkgs.prePhases;
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
NIX_STRIP_DEBUG=0;
|
||||
CFLAGS="-ggdb -O0";
|
||||
CXXFLAGS="-ggdb -O0";
|
||||
|
||||
preHook = ''
|
||||
s=$out/src
|
||||
mkdir -p $s; cd $s;
|
||||
export TMP=$s
|
||||
export TEMP=$s
|
||||
|
||||
for var in CFLAGS CXXFLAGS NIX_CFLAGS_COMPILE; do
|
||||
declare -x "$var=''${!var} -ggdb -O0"
|
||||
done
|
||||
echo "file should tell that executable has not been strippee"
|
||||
'';
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue