AMBuildScript
changeset 3835 ac5919d50903
parent 3828 528fb63b2270
child 3856 549960ebe23c
     1.1 --- a/AMBuildScript	Sun Mar 17 11:39:04 2013 -0400
     1.2 +++ b/AMBuildScript	Sun Mar 17 21:00:28 2013 +0000
     1.3 @@ -1,8 +1,28 @@
     1.4  # vim: set ts=2 sw=2 tw=99 noet ft=python:
     1.5  import os
     1.6  import sys
     1.7 +from ambuild.command import Command
     1.8 +from ambuild.command import ShellCommand
     1.9  from ambuild.command import SymlinkCommand
    1.10  
    1.11 +class ExtractDebugInfoCommand(Command):
    1.12 +	def __init__(self, binary, outfile):
    1.13 +		Command.__init__(self)
    1.14 +		self.binary = binary
    1.15 +		self.outfile = outfile
    1.16 +
    1.17 +	def run(self, runner, job):
    1.18 +		if not self.binary.NeedsRelink(self.outfile):
    1.19 +			return
    1.20 +
    1.21 +		if AMBuild.target['platform'] == 'linux':
    1.22 +			job.AddCommand(ShellCommand('objcopy --only-keep-debug ' + self.outfile + ' ' + self.outfile + '.dbg'))
    1.23 +			job.AddCommand(ShellCommand('objcopy --strip-debug ' + self.outfile))
    1.24 +			job.AddCommand(ShellCommand('objcopy --add-gnu-debuglink=' + os.path.basename(self.outfile) + '.dbg ' + self.outfile))
    1.25 +		elif AMBuild.target['platform'] == 'darwin':
    1.26 +			job.AddCommand(ShellCommand('dsymutil ' + self.outfile))
    1.27 +			job.AddCommand(ShellCommand('strip -S ' + self.outfile))
    1.28 +
    1.29  class SM:
    1.30  	def __init__(self):
    1.31  		self.compiler = Cpp.Compiler()
    1.32 @@ -117,6 +137,7 @@
    1.33  				self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
    1.34  				self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
    1.35  				self.compiler.AddToListVar('CFLAGS', '-msse')
    1.36 +				self.compiler.AddToListVar('CFLAGS', '-g3')
    1.37  				self.compiler.AddToListVar('CFLAGS', '-m32')
    1.38  				self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
    1.39  				self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
    1.40 @@ -176,9 +197,7 @@
    1.41  			if AMBuild.options.debug == '1':
    1.42  				self.compiler.AddToListVar('CDEFINES', 'DEBUG')
    1.43  				self.compiler.AddToListVar('CDEFINES', '_DEBUG')
    1.44 -				if self.vendor == 'gcc' or self.vendor == 'clang':
    1.45 -					self.compiler.AddToListVar('CFLAGS', '-g3')
    1.46 -				elif self.vendor == 'msvc':
    1.47 +				if self.vendor == 'msvc':
    1.48  					self.compiler.AddToListVar('CFLAGS', '/Od')
    1.49  					self.compiler.AddToListVar('CFLAGS', '/RTC1')
    1.50  
    1.51 @@ -265,6 +284,10 @@
    1.52  		else:
    1.53  			return
    1.54  
    1.55 +	def ExtractDebugInfo(self, job, binary):
    1.56 +		src = os.path.join('..', AMBuild.outputFolder, job.workFolder, binary.binaryFile)
    1.57 +		job.AddCommand(ExtractDebugInfoCommand(binary, src))
    1.58 +
    1.59  	def PreSetupHL2Job(self, job, builder, sdk):
    1.60  		info = self.sdkInfo[sdk]
    1.61  		sdkPath = AMBuild.cache[info['sdk']]