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
|
|
|
|
for flag in flags
|
|
|
|
if not flag.startswith('-W')
|
|
|
|
)
|
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
|
|
|
|
if (platform.system() == 'darwin'):
|
|
|
|
context.Message( '\nLooking for framework %s... ' % name )
|
|
|
|
lastLINKFLAGS = context.env['LINKFLAGS']
|
|
|
|
context.env.Append(LINKFLAGS = '-Wl,-framework,%s' % name)
|
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
""", '.c')
|
|
|
|
if not ret:
|
|
|
|
context.env.Replace(LIBS = lastLIBS)
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def CheckLib(context, name):
|
|
|
|
context.Message( 'Looking for lib %s... ' % name )
|
|
|
|
lastLIBS = context.env['LIBS']
|
|
|
|
context.env.Append(LIBS = name)
|
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
""",'.c')
|
|
|
|
if not ret:
|
|
|
|
context.env.Replace(LIBS = lastLIBS)
|
|
|
|
|
|
|
|
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 )
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
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 10:04:10 +00:00
|
|
|
return revstr
|