diff --git a/AMBuildScript b/AMBuildScript index 7be563ae..d509e090 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -468,3 +468,6 @@ builder.RunBuildScripts( 'SM': SM } ) + +if builder.options.breakpad_dump: + builder.RunScript('tools/buildbot/BreakpadSymbols', { 'SM': SM }) diff --git a/configure.py b/configure.py index 8b6a2868..484cd2c1 100644 --- a/configure.py +++ b/configure.py @@ -23,4 +23,6 @@ run.options.add_option('--no-mysql', action='store_false', default=True, dest='h run.options.add_option('-s', '--sdks', default='all', dest='sdks', help='Build against specified SDKs; valid args are "all", "present", or ' 'comma-delimited list of engine names (default: %default)') +run.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump', + default=False, help='Dump and upload breakpad symbols') run.Configure() diff --git a/tools/buildbot/BreakpadSymbols b/tools/buildbot/BreakpadSymbols index b824bd21..dd958790 100644 --- a/tools/buildbot/BreakpadSymbols +++ b/tools/buildbot/BreakpadSymbols @@ -1,31 +1,35 @@ # vim: set ts=2 sw=2 tw=99 noet ft=python: -import os -try: - import urllib.request as urllib -except ImportError: - import urllib2 as urllib -from ambuild.command import Command -from ambuild.command import ShellCommand +import os, sys -class IterateDebugInfoCommand(Command): - def run(self, master, job): - pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'rt') - for debug_info in pdblog: - debug_info = os.path.join(AMBuild.outputFolder, debug_info.strip()) - job.AddCommand(SymbolCommand(debug_info, symbolServer)) - pdblog.close() +builder.SetBuildFolder('symbols') + +UPLOAD_SCRIPT = os.path.join(builder.sourcePath, 'tools', 'buildbot', 'upload_symbols.py') + +cxx_tasks = SM.binaries + SM.extensions + [SM.spcomp] +for cxx_task in cxx_tasks: + if builder.target_platform in ['windows']: + debug_entry = cxx_task.debug + else: + debug_entry = cxx_task.binary + + debug_file = os.path.join(builder.buildPath, debug_entry.path) + if builder.target_platform is 'linux': + argv = ['dump_syms', debug_file, os.path.dirname(debug_file)] + elif builder.target_platform is 'mac': + argv = ['dump_syms', debug_file] + elif builder.target_platform is 'windows': + argv = ['dump_syms.exe', debug_file] + + base_file = os.path.splitext(os.path.basename(debug_file))[0] + symbol_file = base_file + '.breakpad' + + argv = [sys.executable, UPLOAD_SCRIPT, symbol_file] + argv + builder.AddCommand( + inputs = [UPLOAD_SCRIPT, debug_file], + argv = argv, + outputs = [symbol_file] + ) -class SymbolCommand(ShellCommand): - def __init__(self, debugFile, symbolServer): - self.serverResponse = None - self.symbolServer = symbolServer - if AMBuild.target['platform'] == 'linux': - cmdstring = "dump_syms {0} {1}".format(debugFile, os.path.dirname(debugFile)) - elif AMBuild.target['platform'] == 'darwin': - cmdstring = "dump_syms {0}".format(debugFile) - elif AMBuild.target['platform'] == 'windows': - cmdstring = "dump_syms.exe {0}".format(debugFile) - ShellCommand.__init__(self, cmdstring) def run(self, master, job): ShellCommand.run(self, master, job) if self.stdout != None and len(self.stdout) > 0: @@ -37,8 +41,3 @@ class SymbolCommand(ShellCommand): runner.PrintOut(self.stderr) if self.serverResponse != None and len(self.serverResponse) > 0: runner.PrintOut(self.serverResponse) - -if 'BREAKPAD_SYMBOL_SERVER' in os.environ: - symbolServer = os.environ['BREAKPAD_SYMBOL_SERVER'] - job = AMBuild.AddJob('breakpad-symbols') - job.AddCommand(IterateDebugInfoCommand()) diff --git a/tools/buildbot/bootstrap.pl b/tools/buildbot/bootstrap.pl index 82a25efa..1c93bc74 100755 --- a/tools/buildbot/bootstrap.pl +++ b/tools/buildbot/bootstrap.pl @@ -26,13 +26,14 @@ if (!(-f 'OUTPUT/.ambuild2/graph') || !(-f 'OUTPUT/.ambuild2/vars')) { my ($result, $argn); $argn = $#ARGV + 1; print "Attempting to reconfigure...\n"; + my $conf_args = '--enable-optimize --breakpad-dump'; if ($argn > 0 && $^O !~ /MSWin/) { - $result = `CC=$ARGV[0] CXX=$ARGV[0] python ../build/configure.py --enable-optimize`; + $result = `CC=$ARGV[0] CXX=$ARGV[0] python ../build/configure.py $conf_args`; } else { if ($^O =~ /MSWin/) { - $result = `C:\\Python27\\Python.exe ..\\build\\configure.py --enable-optimize`; + $result = `C:\\Python27\\Python.exe ..\\build\\configure.py $conf_args`; } else { - $result = `CC=clang CXX=clang python ../build/configure.py --enable-optimize`; + $result = `CC=clang CXX=clang python ../build/configure.py $conf_args`; } } print "$result\n"; diff --git a/tools/buildbot/upload_symbols.py b/tools/buildbot/upload_symbols.py new file mode 100644 index 00000000..ad732157 --- /dev/null +++ b/tools/buildbot/upload_symbols.py @@ -0,0 +1,38 @@ +# vim: ts=8 sts=2 sw=2 tw=99 et ft=python: +import sys +import subprocess +import os +try: + import urllib.request as urllib +except ImportError: + import urllib2 as urllib + +if len(sys.argv) < 3: + sys.stderr.write('Usage: \n') + sys.exit(1) + +SYMBOL_SERVER = os.environ['BREAKPAD_SYMBOL_SERVER'] +symbol_file = sys.argv[1] +cmd_argv = sys.argv[2:] + +sys.stdout.write(' '.join(cmd_argv)) +sys.stdout.write('\n') + +p = subprocess.Popen( + args = cmd_argv, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + shell = False +) +stdout, stderr = p.communicate() +out = stdout.decode('utf8') +err = stdout.decode('utf8') + +with open(symbol_file, 'w') as fp: + fp.write(stdout) + fp.write(stderr) + +request = urllib.Request(SYMBOL_SERVER, out) +request.add_header('Content-Type', 'text/plain') +server_response = urllib.urlopen(request).read().decode('utf8') +print(server_response)