diff --git a/SConstruct b/SConstruct index dbd1f57..89ca3d8 100644 --- a/SConstruct +++ b/SConstruct @@ -36,51 +36,19 @@ if ARGUMENTS.get('CCFLAGS',0): # Convert CCFLAGS into list env.Replace(CCFLAGS = str(env['CCFLAGS']).split(' ')) -#################### Tests ################### - -def getVarSize(conf,var): - conf.Message("checking for size of "+var+" ") - rc = conf.TryCompile(""" -#include -#include - -main () -{ - if ((%s *) 0) - return 0; - if (sizeof (%s)) - return 0; - ; - return 0; -} -""" % (var,var),'.c') - if rc: - rc,result = conf.TryRun(''' -#include -#include - -main () -{ - printf("%%d",sizeof(%s)); - return 0; -}''' % var,'.c') - if rc: - rc=result - conf.Result(rc) - return rc - ############ Start configuration ############## from maintainer import checkForMaintainerMode from compilertest import checkForCCOption from prefix import checkForUserPrefix from lockprefix import checkForLockPrefix +from clangtest import getVariableSize conf = Configure(env,{'checkForCCOption':checkForCCOption, 'MAINTAINER_MODE':checkForMaintainerMode, 'checkForLockPrefix':checkForLockPrefix, 'checkPrefix':checkForUserPrefix, - 'sizeOf':getVarSize + 'sizeOf':getVariableSize }) # check for CC options for option in Split(""" diff --git a/site_scons/clangtest.py b/site_scons/clangtest.py new file mode 100644 index 0000000..40d3938 --- /dev/null +++ b/site_scons/clangtest.py @@ -0,0 +1,49 @@ +# +# 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 +#include + +main () +{ + if ((%s *) 0) + return 0; + if (sizeof (%s)) + return 0; + ; + return 0; +} +""" % (var,var),'.c') + if rc: + rc,result = conf.TryRun(''' +#include +#include + +main () +{ + printf("%%d",sizeof(%s)); + return 0; +}''' % var,'.c') + if rc: + rc=result + conf.Result(rc) + return rc