2014-06-27 15:33:05 +04:00
|
|
|
# This setup hook strips libraries and executables in the fixup phase.
|
|
|
|
|
2014-07-08 15:47:09 +04:00
|
|
|
fixupOutputHooks+=(_doStrip)
|
2014-06-27 15:33:05 +04:00
|
|
|
|
|
|
|
_doStrip() {
|
2017-07-07 22:57:01 +03:00
|
|
|
# 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
|
2019-10-30 02:42:31 +03:00
|
|
|
if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then
|
2017-07-07 22:57:01 +03:00
|
|
|
dontStripTarget+=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local i
|
|
|
|
for i in ${!stripCmds[@]}; do
|
|
|
|
local -n flag="${flags[$i]}"
|
|
|
|
local -n stripCmd="${stripCmds[$i]}"
|
|
|
|
|
|
|
|
# `dontStrip` disables them all
|
2019-10-30 02:42:31 +03:00
|
|
|
if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null
|
2017-07-07 22:57:01 +03:00
|
|
|
then continue; fi
|
|
|
|
|
2016-05-04 14:40:53 +03:00
|
|
|
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
|
2014-06-27 15:33:05 +04:00
|
|
|
if [ -n "$stripDebugList" ]; then
|
2017-07-07 22:57:01 +03:00
|
|
|
stripDirs "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}"
|
2014-06-27 15:33:05 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
stripAllList=${stripAllList:-}
|
|
|
|
if [ -n "$stripAllList" ]; then
|
2017-07-07 22:57:01 +03:00
|
|
|
stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}"
|
2014-06-27 15:33:05 +04:00
|
|
|
fi
|
2017-07-07 22:57:01 +03:00
|
|
|
done
|
2014-06-27 15:33:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
stripDirs() {
|
2017-07-07 22:57:01 +03:00
|
|
|
local cmd="$1"
|
|
|
|
local dirs="$2"
|
|
|
|
local stripFlags="$3"
|
2014-06-27 15:33:05 +04:00
|
|
|
local dirsNew=
|
|
|
|
|
2017-07-07 22:57:01 +03:00
|
|
|
local d
|
2014-06-27 15:33:05 +04:00
|
|
|
for d in ${dirs}; do
|
|
|
|
if [ -d "$prefix/$d" ]; then
|
|
|
|
dirsNew="${dirsNew} $prefix/$d "
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
dirs=${dirsNew}
|
|
|
|
|
|
|
|
if [ -n "${dirs}" ]; then
|
2017-07-07 22:57:01 +03:00
|
|
|
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
|
2014-06-27 15:33:05 +04:00
|
|
|
stopNest
|
|
|
|
fi
|
|
|
|
}
|