to \N'34')
Returns 1 on success and 0 on failure.
+.TP
+.RI Configure.CheckFunc( self ", " function_name )
+Checks if the specified
+C or C+++ function is available.
+.I function_name
+is the name of the function to check for.
+
.TP
.RI Configure.CheckLib( self ", [" library ", " symbol ", " autoadd ])
Checks if
specifies whether to add the library to the environment (only if the check
succeeds). This method returns 1 on success and 0 on error.
+.TP
+.RI Configure.CheckType( self ", " type_name ", [" includes ])
+Checks for the existence of a type defined by
+.BR typedef .
+.I type_name
+specifies the typedef name to check for.
+.I includes
+is a string containing one or more
+.B #include
+lines that will be inserted into the program
+that will be run to test for the existence of the type.
+
.EE
Example of a typical Configure usage:
RELEASE 0.15 - XXX
+ From Matt Balvin:
+
+ - Fix handling of library prefixes when the subdirectory matches
+ the prefix.
+
+ From Timothee Bessett:
+
+ - Add an M4 Builder.
+
+ From Charles Crain:
+
+ - Use '.lnk' as the suffix on the temporary file for linking long
+ command lines (necessary for the Phar Lap linkloc linker).
+
From Steven Knight:
- SCons now enforces (with an error) that construction variables
- Eliminate a dependency on the distutils.fancy_getopt module by
copying and pasting its wrap_text() function directly.
+ - Make the Script.Options() subclass match the underlying base class
+ implementation.
+
+ From Steve Leblanc:
+
+ - Don't update the .sconsign files when run with -n.
+
+ From David Snopek
+
+ - Fix use of SConf in paths with white space in them.
+
+ - Add CheckFunc and CheckType functionality to SConf.
+
+ - Fix use of SConf with Builders that return a list of nodes.
+
From David Snopek and Christoph Wiedemann
- Fix use of the SConf subsystem with SConscriptChdir().
+ From Greg Spencer
+
+ - Check for the existence of MS Visual Studio on disk before using it,
+ to avoid getting fooled by leftover junk in the registry.
+
+ - Add support for MSVC++ .NET.
+
+ - Add support for MS Visual Studio project files (DSP, DSW,
+ SLN and VCPROJ files).
+
RELEASE 0.14 - Wed, 21 May 2003 05:16:32 -0500
# add default tests
default_tests = {
+ 'CheckFunc' : CheckFunc,
+ 'CheckType' : CheckType,
'CheckCHeader' : CheckCHeader,
'CheckCXXHeader' : CheckCXXHeader,
'CheckLib' : CheckLib,
else:
source = None
- node = builder(target = target, source = source)
- nodesToBeBuilt.append(node)
+ nodes = builder(target = target, source = source)
+ if not SCons.Util.is_List(nodes):
+ nodes = [nodes]
+ nodesToBeBuilt.extend(nodes)
ret = self.BuildNodes(nodesToBeBuilt)
del self.env['SCONF_TEXT']
_ac_build_counter = _ac_build_counter + 1
if ret:
- self.lastTarget = node
+ self.lastTarget = nodes[0]
else:
self.lastTarget = None
if( ok ):
prog = self.lastTarget
output = SConfFS.File(prog.get_path()+'.out')
- node = self.env.Command(output, prog, "%s > $TARGET" % (prog.get_path()))
+ node = self.env.Command(output, prog, [ [ prog.get_path(), ">", "${TARGET}"] ])
ok = self.BuildNodes([node])
if ok:
outputStr = output.get_contents()
header,
include_quotes[1])
+def CheckFunc(context, function_name):
+ context.Message("Checking for %s... " % function_name)
+
+ ret = context.TryBuild(context.env.Program, """
+ #include <assert.h>
+
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ char %(name)s();
+
+ int main() {
+ #if defined (__stub_%(name)s) || defined (__stub___%(name)s)
+ fail fail fail
+ #else
+ %(name)s();
+ #endif
+
+ return 0;
+ }\n\n""" % { 'name': function_name }, ".cpp")
+ context.Result(ret)
+
+ return ret
+
+def CheckType(context, type_name, includes = ""):
+ context.Message("Checking for %s..." % type_name)
+
+ ret = context.TryBuild(context.env.Program, """
+ %(includes)s
+
+ int main() {
+ if ((%(name)s *) 0)
+ return 0;
+ if (sizeof (%(name)s))
+ return 0;
+ }\n\n""" % { 'name': type_name, 'includes': includes }, ".cpp")
+ context.Result(ret)
+
+ return ret
+
def CheckCHeader(test, header, include_quotes='""'):
"""
A test for a c header file.
finally:
sconf.Finish()
+ def test_TryBuild(self):
+ """Test SConf.TryBuild
+ """
+ # 1 test that we can try a builder that returns a list of nodes
+ self._resetSConfState()
+ sconf = self.SConf.SConf(self.scons_env,
+ conf_dir=self.test.workpath('config.tests'),
+ log_file=self.test.workpath('config.log'))
+ class MyBuilder:
+ def __init__(self):
+ self.prefix = ''
+ self.suffix = ''
+ def __call__(self, env, target, source):
+ class MyNode:
+ def __init__(self, name):
+ self.name = name
+ self.state = None
+ self.side_effects = []
+ def has_builder(self):
+ return 1
+ def add_pre_action(self, *actions):
+ pass
+ def add_post_action(self, *actions):
+ pass
+ def children(self):
+ return []
+ def get_state(self):
+ return self.state
+ def set_state(self, state):
+ self.state = state
+ def alter_targets(self):
+ return [], None
+ def depends_on(self, nodes):
+ return None
+ return [MyNode('n1'), MyNode('n2')]
+ self.scons_env.Append(BUILDERS = {'SConfActionBuilder' : MyBuilder()})
+ sconf.TryBuild(self.scons_env.SConfActionBuilder)
+
def test_TryCompile(self):
"""Test SConf.TryCompile
"""
sconf.env = env.Copy()
return ((res1, libs1), (res2, libs2))
+ def FuncChecks(sconf):
+ res1 = sconf.CheckFunc('strcpy')
+ res2 = sconf.CheckFunc('hopefullynofunction')
+ return (res1, res2)
+
+ def TypeChecks(sconf):
+ res1 = sconf.CheckType('u_int', '#include <sys/types.h>\n')
+ res2 = sconf.CheckType('hopefullynotypedef_not')
+ return (res1, res2)
+
self._resetSConfState()
sconf = self.SConf.SConf(self.scons_env,
conf_dir=self.test.workpath('config.tests'),
assert res1 and res2
assert len(libs1[1]) - 1 == len(libs1[0]) and libs1[1][-1] == existing_lib
assert len(libs2[1]) == len(libs2[0])
+ (res1, res2) = FuncChecks(sconf)
+ assert res1 and not res2
+ (res1, res2) = TypeChecks(sconf)
+ assert res1 and not res2
finally:
sconf.Finish()