From 9595946c73a02af48695d07ca880451b32076d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= <viric@vicerveza.homeunix.net> Date: Tue, 10 Apr 2012 07:13:52 +0000 Subject: [PATCH] Fixing details of debugVersion, and adding a 'symbolsVersion'. I could merge both into one, but I'll do that later. svn path=/nixpkgs/trunk/; revision=33715 --- pkgs/misc/misc.nix | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix index de23d6fa2c8d..df4a0ce81023 100644 --- a/pkgs/misc/misc.nix +++ b/pkgs/misc/misc.nix @@ -109,14 +109,15 @@ in # build a debug version of a package debugVersion = pkg: lib.overrideDerivation pkg (attrs: { - prePhases = ["preHook"] ++ lib.optionals (pkgs ? prePhases) pkgs.prePhases; + prePhases = ["debugPhase"] ++ lib.optionals (attrs ? prePhases) attrs.prePhases; + postPhases = ["objectsPhase"] ++ lib.optionals (attrs ? postPhases) attrs.postPhases; dontStrip = true; CFLAGS="-ggdb -O0"; CXXFLAGS="-ggdb -O0"; - preHook = '' + debugPhase = '' s=$out/src mkdir -p $s; cd $s; export TMP=$s @@ -128,5 +129,38 @@ in echo "file should tell that executable has not been stripped" ''; + objectsPhase = '' + cd $out/src + find . -name "*.o" -exec rm {} \; + ''; + }); + + # build an optimized ersion of a package but with symbols and source + symbolsVersion = pkg: lib.overrideDerivation pkg (attrs: { + + prePhases = ["debugPhase"] ++ lib.optionals (attrs ? prePhases) attrs.prePhases; + postPhases = ["objectsPhase"] ++ lib.optionals (attrs ? postPhases) attrs.postPhases; + + dontStrip = true; + + CFLAGS="-g -O2"; + CXXFLAGS="-g -O2"; + + debugPhase = '' + 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} -g -O2" + done + echo "file should tell that executable has not been stripped" + ''; + + objectsPhase = '' + cd $out/src + find . -name "*.o" -exec rm {} \; + ''; }); }