Belle II Software  release-05-01-25
strip_debug.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 from SCons.Action import Action
5 
6 split_debug_action = Action(
7  'objcopy ${STRIP_EXTRA_ARGUMENTS} --only-keep-debug ${TARGET} ${TARGET.dir}/.debug/${TARGET.file}.debug && '
8  'objcopy --strip-debug --strip-unneeded ${STRIP_EXTRA_ARGUMENTS} '
9  ' --add-gnu-debuglink ${TARGET.dir}/.debug/${TARGET.file}.debug ${TARGET}',
10  "${STRIPCOMSTR}", chdir=False)
11 
12 strip_debug_action = Action(
13  'objcopy --strip-debug --strip-unneeded ${STRIP_EXTRA_ARGUMENTS} ${TARGET}',
14  "${STRIPCOMSTR}", chdir=False)
15 
16 
17 def strip_debug_method(env, target):
18  result = []
19  for t in target:
20  if env['SPLIT_DEBUGINFO']:
21  result.append(t.dir.Dir(".debug").File(t.name+".debug"))
22  env.SideEffect(result[-1], t)
23  env.AddPostAction(t, split_debug_action)
24  env.Clean(t, result[-1])
25  else:
26  env.AddPostAction(t, strip_debug_action)
27  return result
28 
29 
30 def generate(env):
31  env.AddMethod(strip_debug_method, 'StripDebug')
32  env['SPLIT_DEBUGINFO'] = True
33  env['STRIP_EXTRA_ARGUMENTS'] = "-R '.gnu.debuglto_*'"
34 
35 
36 def exists(env):
37  return True