diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2017-07-07 15:57:01 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2017-12-30 22:04:22 -0500 |
commit | a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457 (patch) | |
tree | 7d1cf446523c8c80bbed5eeb63a63a7f49692349 /pkgs/build-support | |
parent | 4ad9a97e9678c70ca974c43fe3ef27f0e65af15a (diff) | |
download | nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar.gz nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar.bz2 nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar.lz nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar.xz nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.tar.zst nixlib-a1cdc2011ed049cf8a7a0f2f7909d401dc8d9457.zip |
strip setup hook: Learn about only stripping host/target binaries alone
`dontStrip` is still a catch-all, but `dontStripHost` and `dontStripTarget` are also now available for finer-grained disabling.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/strip.sh | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index a33968ca18de..fc4c7bfbaf95 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -3,24 +3,45 @@ fixupOutputHooks+=(_doStrip) _doStrip() { - if [ -z "$dontStrip" ]; then + # We don't bother to strip build platform code because it shouldn't make it + # to $out anyways---if it does, that's a bigger problem that a lack of + # stripping will help catch. + local -ra flags=(dontStripHost dontStripTarget) + local -ra stripCmds=(STRIP TARGET_STRIP) + + # Optimization + if [[ "$STRIP" == "$TARGET_STRIP" ]]; then + dontStripTarget+=1 + fi + + local i + for i in ${!stripCmds[@]}; do + local -n flag="${flags[$i]}" + local -n stripCmd="${stripCmds[$i]}" + + # `dontStrip` disables them all + if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null + then continue; fi + stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin} if [ -n "$stripDebugList" ]; then - stripDirs "$stripDebugList" "${stripDebugFlags:--S}" + stripDirs "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}" fi stripAllList=${stripAllList:-} if [ -n "$stripAllList" ]; then - stripDirs "$stripAllList" "${stripAllFlags:--s}" + stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}" fi - fi + done } stripDirs() { - local dirs="$1" - local stripFlags="$2" + local cmd="$1" + local dirs="$2" + local stripFlags="$3" local dirsNew= + local d for d in ${dirs}; do if [ -d "$prefix/$d" ]; then dirsNew="${dirsNew} $prefix/$d " @@ -29,8 +50,8 @@ stripDirs() { dirs=${dirsNew} if [ -n "${dirs}" ]; then - header "stripping (with flags $stripFlags) in$dirs" - find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $STRIP $commonStripFlags $stripFlags 2>/dev/null || true + header "stripping (with command $cmd and flags $stripFlags) in$dirs" + find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $cmd $commonStripFlags $stripFlags 2>/dev/null || true stopNest fi } |