variablesize check externalized

This commit is contained in:
Radim Kolar 2009-07-25 12:59:47 +02:00
parent 3308bee429
commit 5fcd381fd0
2 changed files with 51 additions and 34 deletions

View File

@ -36,51 +36,19 @@ if ARGUMENTS.get('CCFLAGS',0):
# Convert CCFLAGS into list # Convert CCFLAGS into list
env.Replace(CCFLAGS = str(env['CCFLAGS']).split(' ')) env.Replace(CCFLAGS = str(env['CCFLAGS']).split(' '))
#################### Tests ###################
def getVarSize(conf,var):
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
############ Start configuration ############## ############ Start configuration ##############
from maintainer import checkForMaintainerMode from maintainer import checkForMaintainerMode
from compilertest import checkForCCOption from compilertest import checkForCCOption
from prefix import checkForUserPrefix from prefix import checkForUserPrefix
from lockprefix import checkForLockPrefix from lockprefix import checkForLockPrefix
from clangtest import getVariableSize
conf = Configure(env,{'checkForCCOption':checkForCCOption, conf = Configure(env,{'checkForCCOption':checkForCCOption,
'MAINTAINER_MODE':checkForMaintainerMode, 'MAINTAINER_MODE':checkForMaintainerMode,
'checkForLockPrefix':checkForLockPrefix, 'checkForLockPrefix':checkForLockPrefix,
'checkPrefix':checkForUserPrefix, 'checkPrefix':checkForUserPrefix,
'sizeOf':getVarSize 'sizeOf':getVariableSize
}) })
# check for CC options # check for CC options
for option in Split(""" for option in Split("""

49
site_scons/clangtest.py Normal file
View File

@ -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 <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