2008-09-24 11:39:15 -06:00
|
|
|
import os
|
2008-12-09 14:46:32 -07:00
|
|
|
import platform
|
2008-09-24 11:39:15 -06:00
|
|
|
|
2008-09-21 13:56:24 -06:00
|
|
|
# methods that should be added to env
|
|
|
|
def filterWarnings(self, flags):
|
2008-10-05 12:49:55 -06:00
|
|
|
return ' '.join(
|
|
|
|
flag
|
|
|
|
for flag in flags
|
|
|
|
if not flag.startswith('-W')
|
|
|
|
)
|
2008-09-24 11:39:15 -06:00
|
|
|
|
|
|
|
# taken from scons wiki
|
|
|
|
def CheckPKGConfig(context, version):
|
2008-10-05 12:49:55 -06:00
|
|
|
context.Message( 'Checking for pkg-config version > %s... ' % version)
|
|
|
|
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
|
|
|
|
context.Result( ret )
|
|
|
|
return ret
|
|
|
|
|
2008-12-09 14:46:32 -07:00
|
|
|
def CheckFramework(context, name):
|
|
|
|
ret = 0
|
2008-12-09 16:47:18 -07:00
|
|
|
if (platform.system().lower() == 'darwin'):
|
2008-12-09 14:46:32 -07:00
|
|
|
context.Message( '\nLooking for framework %s... ' % name )
|
2009-03-03 15:34:32 -07:00
|
|
|
lastFRAMEWORKS = context.env['FRAMEWORKS']
|
|
|
|
context.env.Append(FRAMEWORKS = [name])
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
""", '.c')
|
|
|
|
if not ret:
|
2009-03-03 15:34:32 -07:00
|
|
|
context.env.Replace(FRAMEWORKS = lastFRAMEWORKS
|
|
|
|
)
|
2008-12-09 14:46:32 -07:00
|
|
|
|
|
|
|
return ret
|
|
|
|
|
2009-03-03 15:34:32 -07:00
|
|
|
|
|
|
|
def CheckFink(context):
|
|
|
|
context.Message( 'Looking for fink... ')
|
|
|
|
prog = context.env.WhereIs('fink')
|
|
|
|
if prog:
|
|
|
|
ret = 1
|
|
|
|
prefix = prog.rsplit(os.sep, 2)[0]
|
|
|
|
context.env.Append(LIBPATH = [prefix + os.sep +'lib'],
|
|
|
|
CPPPATH = [prefix + os.sep +'include'])
|
|
|
|
context.Message( 'Adding fink lib and include path')
|
|
|
|
else:
|
|
|
|
ret = 0
|
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
|
|
|
def CheckMacports(context):
|
|
|
|
context.Message( 'Looking for macports... ')
|
|
|
|
prog = context.env.WhereIs('port')
|
|
|
|
if prog:
|
|
|
|
ret = 1
|
|
|
|
prefix = prog.rsplit(os.sep, 2)[0]
|
|
|
|
context.env.Append(LIBPATH = [prefix + os.sep + 'lib'],
|
|
|
|
CPPPATH = [prefix + os.sep + 'include'])
|
|
|
|
context.Message( 'Adding port lib and include path')
|
|
|
|
else:
|
|
|
|
ret = 0
|
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
2008-12-09 16:47:18 -07:00
|
|
|
# TODO: We should use the scons one instead
|
2008-12-09 14:46:32 -07:00
|
|
|
def CheckLib(context, name):
|
|
|
|
context.Message( 'Looking for lib %s... ' % name )
|
|
|
|
lastLIBS = context.env['LIBS']
|
2008-12-09 16:47:18 -07:00
|
|
|
context.env.Append(LIBS = [name])
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
2008-12-09 16:47:18 -07:00
|
|
|
return 0;
|
2008-12-09 14:46:32 -07:00
|
|
|
}
|
|
|
|
""",'.c')
|
|
|
|
if not ret:
|
|
|
|
context.env.Replace(LIBS = lastLIBS)
|
2008-12-09 16:47:18 -07:00
|
|
|
|
2008-12-09 14:46:32 -07:00
|
|
|
return ret
|
|
|
|
|
|
|
|
def ConfigPKG(context, name):
|
|
|
|
context.Message( '\nUsing pkg-config for %s... ' % name )
|
2008-10-05 12:49:55 -06:00
|
|
|
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
|
2008-12-06 16:32:10 -07:00
|
|
|
context.Result( ret )
|
2008-12-09 11:10:16 -07:00
|
|
|
if ret:
|
|
|
|
context.env.ParseConfig('pkg-config --cflags --libs \'%s\'' % name)
|
2008-12-05 06:46:19 -07:00
|
|
|
return int(ret)
|
2008-12-09 14:46:32 -07:00
|
|
|
|
|
|
|
def CheckPKG(context, name):
|
|
|
|
context.Message( 'Checking for %s... ' % name )
|
2009-03-07 15:12:01 -07:00
|
|
|
if platform.system().lower() == 'windows':
|
|
|
|
return 0
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = 1
|
|
|
|
if not CheckFramework(context, name):
|
|
|
|
if not ConfigPKG(context, name.lower()):
|
|
|
|
ret = CheckLib(context, name)
|
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
2008-09-24 11:39:15 -06:00
|
|
|
|
|
|
|
|
|
|
|
def CheckSDL(context, version):
|
2008-10-05 12:49:55 -06:00
|
|
|
context.Message( 'Checking for sdl lib version > %s... ' % version)
|
2009-03-07 15:12:01 -07:00
|
|
|
if platform.system().lower() == 'windows':
|
|
|
|
return 1
|
2008-10-05 12:49:55 -06:00
|
|
|
sdl_config = context.env.WhereIs('sdl-config')
|
|
|
|
if sdl_config == None:
|
|
|
|
ret = 0
|
|
|
|
else:
|
|
|
|
found_ver = os.popen('sdl-config --version').read().strip()
|
|
|
|
required = [int(n) for n in version.split(".")]
|
|
|
|
found = [int(n) for n in found_ver.split(".")]
|
|
|
|
ret = (found >= required)
|
|
|
|
|
2008-12-09 11:10:16 -07:00
|
|
|
context.Result(ret)
|
|
|
|
if ret:
|
|
|
|
context.env.ParseConfig('sdl-config --cflags --libs')
|
2008-12-05 06:46:19 -07:00
|
|
|
return int(ret)
|
2008-10-05 12:49:55 -06:00
|
|
|
|
2009-03-03 13:14:39 -07:00
|
|
|
def CheckPortaudio(context, version):
|
2009-03-06 07:48:39 -07:00
|
|
|
found = 0
|
|
|
|
if CheckPKG(context, 'portaudio'):
|
|
|
|
context.Message( 'Checking for lib portaudio version > %s... ' % version)
|
|
|
|
found = context.TryRun("""
|
2009-03-03 13:14:39 -07:00
|
|
|
#include <portaudio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
printf("%d", Pa_GetVersion());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
""", '.c')[1]
|
|
|
|
|
2009-03-03 13:28:51 -07:00
|
|
|
if found:
|
|
|
|
ret = (version <= found)
|
|
|
|
else:
|
|
|
|
ret = 0
|
2009-03-03 13:14:39 -07:00
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-05 12:49:55 -06:00
|
|
|
def GenerateRevFile(flavour, template, output):
|
|
|
|
|
|
|
|
try:
|
|
|
|
svnrev = os.popen('svnversion .').read().strip().split(':')[0]
|
|
|
|
except:
|
|
|
|
svnrev = ""
|
|
|
|
|
2009-08-14 00:48:15 -06:00
|
|
|
revstr = '"' + svnrev + "-" + flavour + '"'
|
|
|
|
tmpstr = open(template, "r").read().replace("$WCMODS?\"$WCREV$M\":\"$WCREV$\"$",revstr)
|
2008-10-05 12:49:55 -06:00
|
|
|
outfile = open(output, 'w')
|
|
|
|
outfile.write(tmpstr +"\n")
|
|
|
|
outfile.close()
|
|
|
|
|
2008-11-13 03:04:10 -07:00
|
|
|
return revstr
|