sourcemod/extensions/curl/AMBuilder

87 lines
2.9 KiB
Plaintext
Raw Normal View History

2009-08-30 09:46:56 +02:00
# vim: set ts=2 sw=2 tw=99 noet ft=python :
import os.path
import subprocess
2009-08-30 09:46:56 +02:00
import ambuild.command as command
import ambuild.osutil as osutil
def BuildCURL():
curl = AMBuild.AddJob('curl')
if AMBuild.target['platform'] in ['linux', 'darwin']:
2009-08-30 09:46:56 +02:00
if not osutil.FileExists(os.path.join(AMBuild.outputFolder, 'curl', 'Makefile')):
args = ['/bin/bash',
os.path.join(AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'configure'),
'--enable-static',
'--disable-shared',
'--disable-ldap',
'--without-ssl',
'--without-libidn',
'--without-libssh2',
'--without-zlib']
env = os.environ.copy()
env['CFLAGS'] = '-m32'
if AMBuild.target['platform'] == 'darwin':
2010-05-11 10:46:55 +02:00
env['LDFLAGS'] = '-mmacosx-version-min=10.5'
else:
env['CFLAGS'] += ' -D_GNU_SOURCE'
2010-05-11 10:46:55 +02:00
curl.AddCommand(command.DirectCommand(argv = args, env = env))
curl.AddCommand(command.ShellCommand('cd lib && make'))
2009-08-30 09:46:56 +02:00
else:
args = ''
projpath = os.path.join(AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'lib',
'build_libcurl.vcproj')
try:
subprocess.Popen('vcbuild')
except:
xprojpath = os.path.join(AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'lib',
'build_libcurl.vcxproj')
if not os.path.isfile(xprojpath):
curl.AddCommand(command.DirectCommand(['vcupgrade', projpath]))
args = ['msbuild', xprojpath, '/p:Configuration=LIB Release']
if not args:
args = ['vcbuild', projpath, 'LIB Release']
2009-08-30 09:46:56 +02:00
curl.AddCommand(command.DirectCommand(args))
#die "Unable to find libcurl.lib!\n" unless (-f "LIB-Release\\libcurl.lib");
BuildCURL()
compiler = SM.DefaultExtCompiler('extensions/curl')
extension = AMBuild.AddJob('webternet.ext')
binary = Cpp.LibraryBuilder('webternet.ext', AMBuild, extension, compiler)
curlPath = [AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'include']
compiler['CXXINCLUDES'].append(os.path.join(*curlPath))
compiler['CDEFINES'].append('CURL_STATICLIB')
binary.AddSourceFiles('extensions/curl', [
'extension.cpp',
'curlapi.cpp',
'sdk/smsdk_ext.cpp',
])
2010-05-11 10:46:55 +02:00
if AMBuild.target['platform'] == 'linux' or AMBuild.target['platform'] == 'darwin':
2009-08-30 09:46:56 +02:00
path = os.path.join(AMBuild.outputFolder,
'curl',
'lib',
'.libs',
'libcurl.a')
2010-05-11 10:46:55 +02:00
if AMBuild.target['platform'] == 'linux':
binary['POSTLINKFLAGS'].append('-lrt')
2009-08-30 09:46:56 +02:00
binary.AddObjectFiles([path])
elif AMBuild.target['platform'] == 'windows':
path = os.path.join(AMBuild.sourceFolder,
'extensions',
'curl',
'curl-src',
'lib',
'LIB-Release',
'libcurl.lib')
if os.path.isfile(path):
binary.RelinkIfNewer(path)
binary['POSTLINKFLAGS'].extend([path, 'ws2_32.lib'])
SM.AutoVersion('extensions/curl', binary)
binary.SendToJob()