tools/buildbot/BreakpadSymbols
author Asher Baker <asherkin@gmail.com>
Sun Mar 17 21:07:28 2013 +0000 (2013-03-17)
changeset 3836 fedfe0c3165e
parent 3821 3443f13cd47f
child 4193 dc6688771f63
permissions -rw-r--r--
Whoops. Snakes.
asherkin@3458
     1
# vim: set ts=2 sw=2 tw=99 noet ft=python: 
asherkin@3458
     2
import os
ds@3821
     3
try:
ds@3821
     4
	import urllib.request as urllib
ds@3821
     5
except ImportError:
ds@3821
     6
	import urllib2 as urllib
asherkin@3458
     7
from ambuild.command import Command
asherkin@3458
     8
from ambuild.command import ShellCommand
asherkin@3458
     9
asherkin@3458
    10
class IterateDebugInfoCommand(Command):
asherkin@3458
    11
	def run(self, master, job):
asherkin@3458
    12
		pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'rt')
asherkin@3458
    13
		for debug_info in pdblog:
asherkin@3458
    14
			debug_info = os.path.join(AMBuild.outputFolder, debug_info.strip())
asherkin@3458
    15
			job.AddCommand(SymbolCommand(debug_info, symbolServer))
asherkin@3458
    16
		pdblog.close()
asherkin@3458
    17
asherkin@3458
    18
class SymbolCommand(ShellCommand):
asherkin@3458
    19
	def __init__(self, debugFile, symbolServer):
asherkin@3458
    20
		self.serverResponse = None
asherkin@3458
    21
		self.symbolServer = symbolServer
asherkin@3458
    22
		if AMBuild.target['platform'] == 'linux':
asherkin@3458
    23
			cmdstring = "dump_syms {0} {1}".format(debugFile, os.path.dirname(debugFile))
asherkin@3458
    24
		elif AMBuild.target['platform'] == 'darwin':
asherkin@3458
    25
			cmdstring = "dump_syms {0}".format(debugFile)
asherkin@3458
    26
		elif AMBuild.target['platform'] == 'windows':
asherkin@3458
    27
			cmdstring = "dump_syms.exe {0}".format(debugFile)
asherkin@3458
    28
		ShellCommand.__init__(self, cmdstring)
asherkin@3458
    29
	def run(self, master, job):
asherkin@3458
    30
		ShellCommand.run(self, master, job)
asherkin@3458
    31
		if self.stdout != None and len(self.stdout) > 0:
ds@3821
    32
			request = urllib.Request(symbolServer, self.stdout.encode('utf-8'))
asherkin@3458
    33
			request.add_header("Content-Type", "text/plain")
ds@3821
    34
			self.serverResponse = urllib.urlopen(request).read().decode('utf-8')
asherkin@3458
    35
	def spew(self, runner):
asherkin@3458
    36
		if self.stderr != None and len(self.stderr) > 0:
asherkin@3458
    37
			runner.PrintOut(self.stderr)
asherkin@3458
    38
		if self.serverResponse != None and len(self.serverResponse) > 0:
asherkin@3458
    39
			runner.PrintOut(self.serverResponse)
asherkin@3458
    40
asherkin@3458
    41
if 'BREAKPAD_SYMBOL_SERVER' in os.environ:
asherkin@3458
    42
	symbolServer = os.environ['BREAKPAD_SYMBOL_SERVER']
asherkin@3458
    43
	job = AMBuild.AddJob('breakpad-symbols')
asherkin@3458
    44
	job.AddCommand(IterateDebugInfoCommand())