Port breakpad symbol uploading to AMBuild 2 (bug 5997 part 16, r=ds).
Port breakpad symbol uploading to AMBuild 2 (
bug 5997 part 16, r=ds).
1.1 --- a/AMBuildScript Mon Dec 30 17:51:01 2013 -0500
1.2 +++ b/AMBuildScript Mon Dec 30 17:51:02 2013 -0500
1.3 @@ -468,3 +468,6 @@
1.4 'SM': SM
1.5 }
1.6 )
1.7 +
1.8 +if builder.options.breakpad_dump:
1.9 + builder.RunScript('tools/buildbot/BreakpadSymbols', { 'SM': SM })
2.1 --- a/configure.py Mon Dec 30 17:51:01 2013 -0500
2.2 +++ b/configure.py Mon Dec 30 17:51:02 2013 -0500
2.3 @@ -23,4 +23,6 @@
2.4 run.options.add_option('-s', '--sdks', default='all', dest='sdks',
2.5 help='Build against specified SDKs; valid args are "all", "present", or '
2.6 'comma-delimited list of engine names (default: %default)')
2.7 +run.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump',
2.8 + default=False, help='Dump and upload breakpad symbols')
2.9 run.Configure()
3.1 --- a/tools/buildbot/BreakpadSymbols Mon Dec 30 17:51:01 2013 -0500
3.2 +++ b/tools/buildbot/BreakpadSymbols Mon Dec 30 17:51:02 2013 -0500
3.3 @@ -1,31 +1,35 @@
3.4 # vim: set ts=2 sw=2 tw=99 noet ft=python:
3.5 -import os
3.6 -try:
3.7 - import urllib.request as urllib
3.8 -except ImportError:
3.9 - import urllib2 as urllib
3.10 -from ambuild.command import Command
3.11 -from ambuild.command import ShellCommand
3.12 +import os, sys
3.13 +
3.14 +builder.SetBuildFolder('symbols')
3.15 +
3.16 +UPLOAD_SCRIPT = os.path.join(builder.sourcePath, 'tools', 'buildbot', 'upload_symbols.py')
3.17 +
3.18 +cxx_tasks = SM.binaries + SM.extensions + [SM.spcomp]
3.19 +for cxx_task in cxx_tasks:
3.20 + if builder.target_platform in ['windows']:
3.21 + debug_entry = cxx_task.debug
3.22 + else:
3.23 + debug_entry = cxx_task.binary
3.24
3.25 -class IterateDebugInfoCommand(Command):
3.26 - def run(self, master, job):
3.27 - pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'rt')
3.28 - for debug_info in pdblog:
3.29 - debug_info = os.path.join(AMBuild.outputFolder, debug_info.strip())
3.30 - job.AddCommand(SymbolCommand(debug_info, symbolServer))
3.31 - pdblog.close()
3.32 + debug_file = os.path.join(builder.buildPath, debug_entry.path)
3.33 + if builder.target_platform is 'linux':
3.34 + argv = ['dump_syms', debug_file, os.path.dirname(debug_file)]
3.35 + elif builder.target_platform is 'mac':
3.36 + argv = ['dump_syms', debug_file]
3.37 + elif builder.target_platform is 'windows':
3.38 + argv = ['dump_syms.exe', debug_file]
3.39
3.40 -class SymbolCommand(ShellCommand):
3.41 - def __init__(self, debugFile, symbolServer):
3.42 - self.serverResponse = None
3.43 - self.symbolServer = symbolServer
3.44 - if AMBuild.target['platform'] == 'linux':
3.45 - cmdstring = "dump_syms {0} {1}".format(debugFile, os.path.dirname(debugFile))
3.46 - elif AMBuild.target['platform'] == 'darwin':
3.47 - cmdstring = "dump_syms {0}".format(debugFile)
3.48 - elif AMBuild.target['platform'] == 'windows':
3.49 - cmdstring = "dump_syms.exe {0}".format(debugFile)
3.50 - ShellCommand.__init__(self, cmdstring)
3.51 + base_file = os.path.splitext(os.path.basename(debug_file))[0]
3.52 + symbol_file = base_file + '.breakpad'
3.53 +
3.54 + argv = [sys.executable, UPLOAD_SCRIPT, symbol_file] + argv
3.55 + builder.AddCommand(
3.56 + inputs = [UPLOAD_SCRIPT, debug_file],
3.57 + argv = argv,
3.58 + outputs = [symbol_file]
3.59 + )
3.60 +
3.61 def run(self, master, job):
3.62 ShellCommand.run(self, master, job)
3.63 if self.stdout != None and len(self.stdout) > 0:
3.64 @@ -37,8 +41,3 @@
3.65 runner.PrintOut(self.stderr)
3.66 if self.serverResponse != None and len(self.serverResponse) > 0:
3.67 runner.PrintOut(self.serverResponse)
3.68 -
3.69 -if 'BREAKPAD_SYMBOL_SERVER' in os.environ:
3.70 - symbolServer = os.environ['BREAKPAD_SYMBOL_SERVER']
3.71 - job = AMBuild.AddJob('breakpad-symbols')
3.72 - job.AddCommand(IterateDebugInfoCommand())
4.1 --- a/tools/buildbot/bootstrap.pl Mon Dec 30 17:51:01 2013 -0500
4.2 +++ b/tools/buildbot/bootstrap.pl Mon Dec 30 17:51:02 2013 -0500
4.3 @@ -26,13 +26,14 @@
4.4 my ($result, $argn);
4.5 $argn = $#ARGV + 1;
4.6 print "Attempting to reconfigure...\n";
4.7 + my $conf_args = '--enable-optimize --breakpad-dump';
4.8 if ($argn > 0 && $^O !~ /MSWin/) {
4.9 - $result = `CC=$ARGV[0] CXX=$ARGV[0] python ../build/configure.py --enable-optimize`;
4.10 + $result = `CC=$ARGV[0] CXX=$ARGV[0] python ../build/configure.py $conf_args`;
4.11 } else {
4.12 if ($^O =~ /MSWin/) {
4.13 - $result = `C:\\Python27\\Python.exe ..\\build\\configure.py --enable-optimize`;
4.14 + $result = `C:\\Python27\\Python.exe ..\\build\\configure.py $conf_args`;
4.15 } else {
4.16 - $result = `CC=clang CXX=clang python ../build/configure.py --enable-optimize`;
4.17 + $result = `CC=clang CXX=clang python ../build/configure.py $conf_args`;
4.18 }
4.19 }
4.20 print "$result\n";
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tools/buildbot/upload_symbols.py Mon Dec 30 17:51:02 2013 -0500
5.3 @@ -0,0 +1,38 @@
5.4 +# vim: ts=8 sts=2 sw=2 tw=99 et ft=python:
5.5 +import sys
5.6 +import subprocess
5.7 +import os
5.8 +try:
5.9 + import urllib.request as urllib
5.10 +except ImportError:
5.11 + import urllib2 as urllib
5.12 +
5.13 +if len(sys.argv) < 3:
5.14 + sys.stderr.write('Usage: <symbol-file> <dump-syms-cmd> <args...>\n')
5.15 + sys.exit(1)
5.16 +
5.17 +SYMBOL_SERVER = os.environ['BREAKPAD_SYMBOL_SERVER']
5.18 +symbol_file = sys.argv[1]
5.19 +cmd_argv = sys.argv[2:]
5.20 +
5.21 +sys.stdout.write(' '.join(cmd_argv))
5.22 +sys.stdout.write('\n')
5.23 +
5.24 +p = subprocess.Popen(
5.25 + args = cmd_argv,
5.26 + stdout = subprocess.PIPE,
5.27 + stderr = subprocess.PIPE,
5.28 + shell = False
5.29 +)
5.30 +stdout, stderr = p.communicate()
5.31 +out = stdout.decode('utf8')
5.32 +err = stdout.decode('utf8')
5.33 +
5.34 +with open(symbol_file, 'w') as fp:
5.35 + fp.write(stdout)
5.36 + fp.write(stderr)
5.37 +
5.38 +request = urllib.Request(SYMBOL_SERVER, out)
5.39 +request.add_header('Content-Type', 'text/plain')
5.40 +server_response = urllib.urlopen(request).read().decode('utf8')
5.41 +print(server_response)