setup-hooks/strip.sh: add strip{All,Debug}ListTarget variables
This change mimics existing strip{All,Debug}List variables to allow special stripping directories just for Target. The primary use case in mind is gcc where package has to install both host and target ELFs. They have to be stripped by their own strip tools accordingly. Co-authored-by: Rick van Schijndel <Mindavi@users.noreply.github.com> Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
parent
17f413f293
commit
0f45ce6e77
2 changed files with 20 additions and 15 deletions
|
@ -731,6 +731,10 @@ If set, files in `$out/sbin` are not moved to `$out/bin`. By default, they are.
|
|||
|
||||
List of directories to search for libraries and executables from which *all* symbols should be stripped. By default, it’s empty. Stripping all symbols is risky, since it may remove not just debug symbols but also ELF information necessary for normal execution.
|
||||
|
||||
##### `stripAllListTarget` {#var-stdenv-stripAllListTarget}
|
||||
|
||||
Like `stripAllList`, but only applies to packages’ target platform. By default, it’s empty. Useful when supporting cross compilation.
|
||||
|
||||
##### `stripAllFlags` {#var-stdenv-stripAllFlags}
|
||||
|
||||
Flags passed to the `strip` command applied to the files in the directories listed in `stripAllList`. Defaults to `-s` (i.e. `--strip-all`).
|
||||
|
@ -739,6 +743,10 @@ Flags passed to the `strip` command applied to the files in the directories list
|
|||
|
||||
List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to `lib lib32 lib64 libexec bin sbin`.
|
||||
|
||||
##### `stripDebugListTarget` {#var-stdenv-stripDebugListTarget}
|
||||
|
||||
Like `stripDebugList`, but only applies to packages’ target platform. By default, it’s empty. Useful when supporting cross compilation.
|
||||
|
||||
##### `stripDebugFlags` {#var-stdenv-stripDebugFlags}
|
||||
|
||||
Flags passed to the `strip` command applied to the files in the directories listed in `stripDebugList`. Defaults to `-S` (i.e. `--strip-debug`).
|
||||
|
|
|
@ -7,31 +7,29 @@ _doStrip() {
|
|||
# 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 debugDirs=(stripDebugList stripDebugListTarget)
|
||||
local -ra allDirs=(stripAllList stripAllListTarget)
|
||||
local -ra stripCmds=(STRIP STRIP_FOR_TARGET)
|
||||
|
||||
# Optimization
|
||||
if [[ "${STRIP-}" == "${STRIP_FOR_TARGET-}" ]]; then
|
||||
dontStripTarget+=1
|
||||
fi
|
||||
# Strip only host paths by default. Leave targets as is.
|
||||
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
|
||||
stripDebugListTarget=${stripDebugListTarget:-}
|
||||
stripAllList=${stripAllList:-}
|
||||
stripAllListTarget=${stripAllListTarget:-}
|
||||
|
||||
local i
|
||||
for i in ${!stripCmds[@]}; do
|
||||
local -n flag="${flags[$i]}"
|
||||
local -n debugDirList="${debugDirs[$i]}"
|
||||
local -n allDirList="${allDirs[$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 "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}"
|
||||
fi
|
||||
|
||||
stripAllList=${stripAllList:-}
|
||||
if [ -n "$stripAllList" ]; then
|
||||
stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}"
|
||||
fi
|
||||
stripDirs "$stripCmd" "$debugDirList" "${stripDebugFlags:--S}"
|
||||
stripDirs "$stripCmd" "$allDirList" "${stripAllFlags:--s}"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -50,8 +48,7 @@ stripDirs() {
|
|||
dirs=${dirsNew}
|
||||
|
||||
if [ -n "${dirs}" ]; then
|
||||
header "stripping (with command $cmd and flags $stripFlags) in$dirs"
|
||||
echo "stripping (with command $cmd and flags $stripFlags) in$dirs"
|
||||
find $dirs -type f -exec $cmd $stripFlags '{}' \; 2>/dev/null
|
||||
stopNest
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue