fsp/site_scons/clangtest.py
2009-07-25 12:59:47 +02:00

50 lines
922 B
Python

#
# SCons C language related tests
#
# Version 1.1
# 25-Jul-2009
#
def checkForVariable(conf,variable,include):
"""Checks if variable is defined in given include statements."""
conf.Message("checking if variable %s is defined... " % variable)
rc = conf.TryCompile("""
%s
void dummy(void);
void dummy(void) { %s = 0; }
"""% (include,variable),'.c')
conf.Result(rc)
return rc
def getVariableSize(conf,var):
"""Returns variable size in bytes"""
conf.Message("checking for size of "+var+" ")
rc = conf.TryCompile("""
#include <stdio.h>
#include <sys/types.h>
main ()
{
if ((%s *) 0)
return 0;
if (sizeof (%s))
return 0;
;
return 0;
}
""" % (var,var),'.c')
if rc:
rc,result = conf.TryRun('''
#include <stdio.h>
#include <sys/types.h>
main ()
{
printf("%%d",sizeof(%s));
return 0;
}''' % var,'.c')
if rc:
rc=result
conf.Result(rc)
return rc