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