90 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# vim: set ts=2 sw=2 tw=99 noet ft=python:
 | 
						|
import os
 | 
						|
import ambuild.osutil as osutil
 | 
						|
from ambuild.command import SymlinkCommand
 | 
						|
from ambuild.command import ShellCommand
 | 
						|
from ambuild.command import DirectCommand
 | 
						|
 | 
						|
def BuildEverything():
 | 
						|
	if AMBuild.target['platform'] not in ['linux', 'windows']:
 | 
						|
		return
 | 
						|
 | 
						|
	compiler = SM.DefaultCompiler()
 | 
						|
 | 
						|
	if AMBuild.target['platform'] in ['linux']:
 | 
						|
		compiler['POSTLINKFLAGS'].append('-lm')
 | 
						|
		compiler['POSTLINKFLAGS'].append('-lstdc++')
 | 
						|
		compiler['POSTLINKFLAGS'].append('-pthread')
 | 
						|
 | 
						|
		compiler['CDEFINES'].append('HAVE_CONFIG_H')
 | 
						|
		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'breakpad', 'build', 'src'))
 | 
						|
	elif compiler.cc.name == 'msvc':
 | 
						|
		compiler['POSTLINKFLAGS'].remove('/SUBSYSTEM:WINDOWS')
 | 
						|
		compiler['POSTLINKFLAGS'].append('/SUBSYSTEM:CONSOLE')
 | 
						|
 | 
						|
	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src'))
 | 
						|
 | 
						|
	name = 'test-crash-dump-generation'
 | 
						|
	extension = AMBuild.AddJob(name)
 | 
						|
	binary = Cpp.ExecutableBuilder(name, AMBuild, extension, compiler)
 | 
						|
 | 
						|
	binary.AddSourceFiles('test', [
 | 
						|
		'test.cpp',
 | 
						|
	]);
 | 
						|
 | 
						|
	if AMBuild.target['platform'] in ['linux']:
 | 
						|
		binary.AddSourceFiles(os.path.join('breakpad', 'src', 'src', 'common'), [
 | 
						|
			'dwarf_cfi_to_module.cc',
 | 
						|
			'dwarf_cu_to_module.cc',
 | 
						|
			'dwarf_line_to_module.cc',
 | 
						|
			'dwarf_range_list_handler.cc',
 | 
						|
			'language.cc',
 | 
						|
			'module.cc',
 | 
						|
			'path_helper.cc',
 | 
						|
			'stabs_reader.cc',
 | 
						|
			'stabs_to_module.cc',
 | 
						|
			'dwarf/bytereader.cc',
 | 
						|
			'dwarf/dwarf2diehandler.cc',
 | 
						|
			'dwarf/dwarf2reader.cc',
 | 
						|
			'dwarf/elf_reader.cc',
 | 
						|
			'linux/crc32.cc',
 | 
						|
			'linux/dump_symbols.cc',
 | 
						|
			'linux/elf_symbols_to_module.cc',
 | 
						|
		])
 | 
						|
 | 
						|
	if AMBuild.target['platform'] in ['linux']:
 | 
						|
		libs = [
 | 
						|
			('libbreakpad_client.a', os.path.join('breakpad', 'build', 'src', 'client', 'linux', 'libbreakpad_client.a')),
 | 
						|
			('libbreakpad.a', os.path.join('breakpad', 'build', 'src', 'libbreakpad.a')),
 | 
						|
			('libdisasm.a', os.path.join('breakpad', 'build', 'src', 'third_party', 'libdisasm', 'libdisasm.a')),
 | 
						|
		]
 | 
						|
 | 
						|
		for lib, target in libs:
 | 
						|
			link = os.path.join(AMBuild.outputFolder, extension.workFolder, lib)
 | 
						|
			target = os.path.join(AMBuild.sourceFolder, target)
 | 
						|
			try:
 | 
						|
				os.lstat(link)
 | 
						|
			except:
 | 
						|
				extension.AddCommand(SymlinkCommand(link, target))
 | 
						|
			binary.AddObjectFiles([lib])
 | 
						|
 | 
						|
	elif AMBuild.target['platform'] in ['windows']:
 | 
						|
		libs = [
 | 
						|
			os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'common.lib'),
 | 
						|
			os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'exception_handler.lib'),
 | 
						|
			os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'crash_generation', 'Release', 'lib', 'crash_generation_client.lib'),
 | 
						|
			os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'third_party', 'libdisasm', 'Release', 'lib', 'libdisasm.lib'),
 | 
						|
			os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'processor', 'Release', 'lib', 'processor.lib'),
 | 
						|
		]
 | 
						|
 | 
						|
		for path in libs:
 | 
						|
			if os.path.isfile(path):
 | 
						|
				binary.RelinkIfNewer(path)
 | 
						|
			binary['POSTLINKFLAGS'].extend([path])
 | 
						|
 | 
						|
	SM.ExtractDebugInfo(extension, binary)
 | 
						|
 | 
						|
	binary.SendToJob()
 | 
						|
 | 
						|
BuildEverything()
 |