Belle II Software light-2406-ragdoll
strip_debug.py
1#!/usr/bin/env python
2
3
10
11from SCons.Action import Action
12
13# Perform debug info splitting according to the GDB manual's guidelines
14# https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
15#
16# Cannot use scons' chdir feature because it doesn't work in parallel builds
17# (working directory is a global variable that is shared by all threads)
18#
19split_debug_action = Action(
20 'cd ${TARGET.dir} && '
21 'objcopy ${STRIP_EXTRA_ARGUMENTS} --only-keep-debug ${TARGET.file} ${TARGET.file}.debug && '
22 'objcopy --add-gnu-debuglink ${TARGET.file}.debug ${TARGET.file} && '
23 'mv ${TARGET.file}.debug .debug/${TARGET.file}.debug && '
24 'objcopy --strip-debug --strip-unneeded ${STRIP_EXTRA_ARGUMENTS} ${TARGET.file}',
25 "${STRIPCOMSTR}", chdir=False)
26
27strip_debug_action = Action(
28 'objcopy --strip-debug --strip-unneeded ${STRIP_EXTRA_ARGUMENTS} ${TARGET}',
29 "${STRIPCOMSTR}", chdir=False)
30
31
32def strip_debug_method(env, target):
33 result = []
34 for t in target:
35 if env['SPLIT_DEBUGINFO']:
36 result.append(t.dir.Dir(".debug").File(t.name+".debug"))
37 env.SideEffect(result[-1], t)
38 env.AddPostAction(t, split_debug_action)
39 env.Clean(t, result[-1])
40 else:
41 env.AddPostAction(t, strip_debug_action)
42 return result
43
44
45def generate(env):
46 env.AddMethod(strip_debug_method, 'StripDebug')
47 env['SPLIT_DEBUGINFO'] = True
48 env['STRIP_EXTRA_ARGUMENTS'] = "-R '.gnu.debuglto_*'"
49
50
51def exists(env):
52 return True