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 )
|
|
|
|
lastLINKFLAGS = context.env['LINKFLAGS']
|
2008-12-09 15:07:11 -07:00
|
|
|
context.env.Append(LINKFLAGS = [ '-framework', name ])
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
""", '.c')
|
|
|
|
if not ret:
|
2008-12-09 15:07:11 -07:00
|
|
|
context.env.Replace(LINKFLAGS = lastLINKFLAGS)
|
2008-12-09 14:46:32 -07:00
|
|
|
|
|
|
|
return 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 )
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
def GenerateRevFile(flavour, template, output):
|
|
|
|
|
|
|
|
try:
|
|
|
|
svnrev = os.popen('svnversion .').read().strip().split(':')[0]
|
|
|
|
except:
|
|
|
|
svnrev = ""
|
|
|
|
|
|
|
|
revstr = svnrev + "-" + flavour
|
|
|
|
tmpstr = open(template, "r").read().replace("$WCREV$",revstr)
|
|
|
|
|
|
|
|
outfile = open(output, 'w')
|
|
|
|
outfile.write(tmpstr +"\n")
|
|
|
|
outfile.close()
|
|
|
|
|
2008-11-13 03:04:10 -07:00
|
|
|
return revstr
|