sm-ext-accelerator-2023/extension/AMBuilder

85 lines
3.3 KiB
Plaintext
Raw Normal View History

2013-05-16 08:18:31 +02:00
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
2013-05-16 08:46:55 +02:00
import ambuild.osutil as osutil
2013-05-16 08:18:31 +02:00
from ambuild.command import SymlinkCommand
2013-05-16 08:46:55 +02:00
from ambuild.command import ShellCommand
2013-05-18 01:46:46 +02:00
from ambuild.command import DirectCommand
2013-05-16 08:46:55 +02:00
2013-05-17 06:24:31 +02:00
def BuildEverything():
2013-05-18 01:46:46 +02:00
if AMBuild.target['platform'] not in ['linux', 'windows']:
2013-05-16 08:46:55 +02:00
return
2013-05-17 06:24:31 +02:00
BuildBreakpad()
BuildExtension();
def BuildBreakpad():
breakpad = AMBuild.AddJob('google-breakpad')
2013-05-18 01:46:46 +02:00
if AMBuild.target['platform'] in ['linux']:
if osutil.FileExists(os.path.join(AMBuild.outputFolder, 'google-breakpad', 'src', 'client', 'linux', 'libbreakpad_client.a')):
return
2013-05-17 06:24:31 +02:00
2013-05-18 01:46:46 +02:00
breakpad.AddCommand(ShellCommand('CXXFLAGS=-m32 CFLAGS=-m32 CPPFLAGS=-m32 ' + os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'configure')))
breakpad.AddCommand(ShellCommand('make src/client/linux/libbreakpad_client.a'))
elif AMBuild.target['platform'] in ['windows']:
if osutil.FileExists(os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'exception_handler.lib')):
return
gyp = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'tools', 'gyp', 'gyp.bat')
gyppath = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'exception_handler.gyp')
breakpad.AddCommand(DirectCommand([gyp, gyppath]))
slnpath = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'exception_handler.sln')
breakpad.AddCommand(DirectCommand(['msbuild', slnpath, '/p:Configuration=Release']))
2013-05-16 08:46:55 +02:00
2013-05-17 06:24:31 +02:00
def BuildExtension():
compiler = SM.DefaultCompiler()
2013-05-16 08:18:31 +02:00
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'extension'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'extension', 'sdk'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD15'], 'public'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD15'], 'public', 'extensions'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD15'], 'public', 'sourcepawn'))
2013-05-16 08:46:55 +02:00
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src'))
2013-05-16 08:18:31 +02:00
2013-05-18 01:46:46 +02:00
if AMBuild.target['platform'] in ['linux']:
compiler['POSTLINKFLAGS'].append('-lstdc++')
compiler['POSTLINKFLAGS'].append('-pthread')
2013-05-17 06:24:31 +02:00
name = 'accelerator.ext'
2013-05-16 08:18:31 +02:00
extension = AMBuild.AddJob(name)
binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
2013-05-17 06:24:31 +02:00
2013-05-16 08:18:31 +02:00
binary.AddSourceFiles('extension', [
'extension.cpp',
'MemoryDownloader.cpp',
'sdk/smsdk_ext.cpp'
2013-05-17 06:24:31 +02:00
])
2013-05-16 08:18:31 +02:00
2013-05-18 01:46:46 +02:00
if AMBuild.target['platform'] in ['linux']:
link = os.path.join(AMBuild.outputFolder, extension.workFolder, 'libbreakpad_client.a')
target = os.path.join(AMBuild.outputFolder, 'google-breakpad', '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', 'crash_generation_client']
for lib in libs:
path = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', lib + '.lib')
if os.path.isfile(path):
binary.RelinkIfNewer(path)
binary['POSTLINKFLAGS'].extend([path])
2013-05-16 08:18:31 +02:00
SM.AutoVersion('extension', binary)
SM.ExtractDebugInfo(extension, binary)
2013-05-17 06:24:31 +02:00
2013-05-16 08:18:31 +02:00
binary.SendToJob()
2013-05-17 06:24:31 +02:00
BuildEverything()