Add a wrapper script to objcopy + strip executables and shared libraries (bug 5997 part 12, r=ds).
Add a wrapper script to objcopy + strip executables and shared libraries (
bug 5997 part 12, r=ds).
1.1 --- a/ambuild2/frontend/cpp.py Sat Dec 28 10:22:08 2013 -0500
1.2 +++ b/ambuild2/frontend/cpp.py Mon Dec 30 17:33:25 2013 -0500
1.3 @@ -451,25 +451,33 @@
1.4 self.linker_outputs = [self.outputFile]
1.5 self.debug_entry = None
1.6
1.7 - if self.compiler.debuginfo and not isinstance(self, StaticLibrary):
1.8 - if isinstance(self.linker_, MSVC):
1.9 - self.linker_outputs += [self.name_ + '.pdb']
1.10 - elif cx.target_platform is 'mac':
1.11 - bundle_folder = os.path.join(self.localFolder, self.outputFile + '.dSYM')
1.12 - bundle_entry = cx.AddFolder(bundle_folder)
1.13 - bundle_layout = [
1.14 - 'Contents',
1.15 - 'Contents/Resources',
1.16 - 'Contents/Resources/DWARF',
1.17 - ]
1.18 - for folder in bundle_layout:
1.19 - cx.AddFolder(os.path.join(bundle_folder, folder))
1.20 - self.linker_outputs += [
1.21 - self.outputFile + '.dSYM/Contents/Info.plist',
1.22 - self.outputFile + '.dSYM/Contents/Resources/DWARF/' + self.outputFile
1.23 - ]
1.24 - self.debug_entry = bundle_entry
1.25 - self.argv = ['ambuild_dsymutil_wrapper.sh', self.outputFile] + self.argv
1.26 + if self.compiler.debuginfo:
1.27 + self.perform_symbol_steps(cx)
1.28 +
1.29 + def perform_symbol_steps(self, cx):
1.30 + if isinstance(self.linker_, MSVC):
1.31 + self.linker_outputs += [self.name_ + '.pdb']
1.32 + elif cx.target_platform is 'mac':
1.33 + bundle_folder = os.path.join(self.localFolder, self.outputFile + '.dSYM')
1.34 + bundle_entry = cx.AddFolder(bundle_folder)
1.35 + bundle_layout = [
1.36 + 'Contents',
1.37 + 'Contents/Resources',
1.38 + 'Contents/Resources/DWARF',
1.39 + ]
1.40 + for folder in bundle_layout:
1.41 + cx.AddFolder(os.path.join(bundle_folder, folder))
1.42 + self.linker_outputs += [
1.43 + self.outputFile + '.dSYM/Contents/Info.plist',
1.44 + self.outputFile + '.dSYM/Contents/Resources/DWARF/' + self.outputFile
1.45 + ]
1.46 + self.debug_entry = bundle_entry
1.47 + self.argv = ['ambuild_dsymutil_wrapper.sh', self.outputFile] + self.argv
1.48 + elif cx.target_platform is 'linux':
1.49 + self.linker_outputs += [
1.50 + self.outputFile + '.dbg'
1.51 + ]
1.52 + self.argv = ['ambuild_objcopy_wrapper.sh', self.outputFile] + self.argv
1.53
1.54 def link(self, context, folder, inputs):
1.55 ignore, outputs = context.AddCommand(
1.56 @@ -549,3 +557,6 @@
1.57 argv = ['ar', 'rcs', self.outputFile]
1.58 argv += files
1.59 return argv
1.60 +
1.61 + def perform_symbol_steps(self, cx):
1.62 + pass
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scripts/ambuild_objcopy_wrapper.sh Mon Dec 30 17:33:25 2013 -0500
2.3 @@ -0,0 +1,29 @@
2.4 +#!/bin/bash
2.5 +
2.6 +if [ $# -lt 3 ]; then
2.7 + echo "Usage: <file> <linker> <...linker args>";
2.8 + exit 1;
2.9 +fi
2.10 +
2.11 +LD_FILE=$1
2.12 +LD_EXEC=$2
2.13 +
2.14 +shift;
2.15 +shift;
2.16 +
2.17 +$LD_EXEC $@
2.18 +if [ $? -ne 0 ]; then
2.19 + exit $?
2.20 +fi
2.21 +objcopy --only-keep-debug $LD_FILE $LD_FILE.dbg
2.22 +if [ $? -ne 0 ]; then
2.23 + exit $?
2.24 +fi
2.25 +objcopy --strip-debug $LD_FILE
2.26 +if [ $? -ne 0 ]; then
2.27 + exit $?
2.28 +fi
2.29 +objcopy --add-gnu-debuglink=$LD_FILE.dbg $LD_FILE
2.30 +if [ $? -ne 0 ]; then
2.31 + exit $?
2.32 +fi
3.1 --- a/setup.py Sat Dec 28 10:22:08 2013 -0500
3.2 +++ b/setup.py Mon Dec 30 17:33:25 2013 -0500
3.3 @@ -11,6 +11,8 @@
3.4 scripts.append('scripts/ambuild.bat')
3.5 elif sys.platform == 'darwin':
3.6 scripts.append('scripts/ambuild_dsymutil_wrapper.sh')
3.7 +else:
3.8 + scripts.append('scripts/ambuild_objcopy_wrapper.sh')
3.9
3.10 setup(
3.11 name = 'AMBuild',
3.12 @@ -29,4 +31,3 @@
3.13 scripts = scripts
3.14 )
3.15
3.16 -