91 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.5 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
 | |
| 
 | |
| 	if AMBuild.target['platform'] in ['windows']:
 | |
| 		BuildBreakpad()
 | |
| 
 | |
| 	BuildExtension();
 | |
| 
 | |
| def BuildBreakpad():
 | |
| 	breakpad = AMBuild.AddJob('breakpad')
 | |
| 
 | |
| 	if osutil.FileExists(os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'exception_handler.lib')):
 | |
| 		return
 | |
| 
 | |
| 	gyp = os.path.join(AMBuild.sourceFolder, 'breakpad', 'gyp', 'gyp.bat')
 | |
| 
 | |
| 	gyppath = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'handler', 'exception_handler.gyp')
 | |
| 	breakpad.AddCommand(DirectCommand([gyp, '--no-circular-check', gyppath]))
 | |
| 
 | |
| 	slnpath = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'handler', 'exception_handler.sln')
 | |
| 	breakpad.AddCommand(DirectCommand(['msbuild', slnpath, '/p:Configuration=Release']))
 | |
| 
 | |
| 	gyppath = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'crash_generation', 'crash_generation.gyp')
 | |
| 	breakpad.AddCommand(DirectCommand([gyp, '--no-circular-check', gyppath]))
 | |
| 
 | |
| 	slnpath = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'crash_generation', 'crash_generation.sln')
 | |
| 	breakpad.AddCommand(DirectCommand(['msbuild', slnpath, '/p:Configuration=Release']))
 | |
| 
 | |
| def BuildExtension():
 | |
| 	compiler = SM.DefaultCompiler()
 | |
| 
 | |
| 	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'extension'))
 | |
| 
 | |
| 	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD'], 'public'))
 | |
| 	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD'], 'public', 'extensions'))
 | |
| 	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD'], 'public', 'sourcepawn'))
 | |
| 
 | |
| 	compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src'))
 | |
| 
 | |
| 	if AMBuild.target['platform'] in ['linux']:
 | |
| 		compiler['POSTLINKFLAGS'].append('-lstdc++')
 | |
| 		compiler['POSTLINKFLAGS'].append('-pthread')
 | |
| 
 | |
| 	name = 'accelerator.ext'
 | |
| 	extension = AMBuild.AddJob(name)
 | |
| 	binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
 | |
| 
 | |
| 	binary.AddSourceFiles('extension', [
 | |
| 		'extension.cpp',
 | |
| 		'MemoryDownloader.cpp',
 | |
| 	])
 | |
| 
 | |
| 	binary.AddSourceFiles(AMBuild.cache['SOURCEMOD'], ['public/smsdk_ext.cpp'])
 | |
| 
 | |
| 	if AMBuild.target['platform'] in ['linux']:
 | |
| 		link = os.path.join(AMBuild.outputFolder, extension.workFolder, 'libbreakpad_client.a')
 | |
| 		target = os.path.join(AMBuild.sourceFolder, 'breakpad', 'build', 'src', 'client', 'linux', 'libbreakpad_client.a')
 | |
| 		try:
 | |
| 			os.lstat(link)
 | |
| 		except:
 | |
| 			extension.AddCommand(SymlinkCommand(link, target))
 | |
| 		binary.AddObjectFiles(['libbreakpad_client.a'])
 | |
| 
 | |
| 	elif AMBuild.target['platform'] in ['windows']:
 | |
| 		libs = ['exception_handler', 'common']
 | |
| 		for lib in libs:
 | |
| 			path = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'handler', 'Release', 'lib', lib + '.lib')
 | |
| 			if os.path.isfile(path):
 | |
| 				binary.RelinkIfNewer(path)
 | |
| 			binary['POSTLINKFLAGS'].extend([path])
 | |
| 
 | |
| 		path = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'src', 'client', 'windows', 'crash_generation', 'Release', 'lib', 'crash_generation_client.lib')
 | |
| 		if os.path.isfile(path):
 | |
| 			binary.RelinkIfNewer(path)
 | |
| 		binary['POSTLINKFLAGS'].extend([path])
 | |
| 
 | |
| 	SM.AutoVersion('extension', binary)
 | |
| 	SM.ExtractDebugInfo(extension, binary)
 | |
| 
 | |
| 	binary.SendToJob()
 | |
| 
 | |
| BuildEverything()
 |