summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-11 01:28:19 (GMT)
committerSteven Knight <knight@baldmt.com>2003-06-11 01:28:19 (GMT)
commitc6f1c79f88056176cc2d1567521177744f79b569 (patch)
tree968eb55acc387589ca85b589a2b7e95ff2fa5004 /src
parent19a3c78db2cdd47cc38df41c014c30072c1ac461 (diff)
downloadSCons-c6f1c79f88056176cc2d1567521177744f79b569.zip
SCons-c6f1c79f88056176cc2d1567521177744f79b569.tar.gz
SCons-c6f1c79f88056176cc2d1567521177744f79b569.tar.bz2
SConf CheckFunc and CheckType functionality, plus fixes. (David Snopek)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt39
-rw-r--r--src/engine/SCons/SConf.py52
-rw-r--r--src/engine/SCons/SConfTests.py52
3 files changed, 139 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index b86c2de..0971f96 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -10,6 +10,20 @@
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
@@ -21,10 +35,35 @@ RELEASE 0.15 - XXX
- 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
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index d01ce7e..7336cde 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -104,6 +104,8 @@ class SConf:
# add default tests
default_tests = {
+ 'CheckFunc' : CheckFunc,
+ 'CheckType' : CheckType,
'CheckCHeader' : CheckCHeader,
'CheckCXXHeader' : CheckCXXHeader,
'CheckLib' : CheckLib,
@@ -224,15 +226,17 @@ class SConf:
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
@@ -279,7 +283,7 @@ class SConf:
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()
@@ -531,6 +535,46 @@ def _header_prog( header, include_quotes ):
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.
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index cd4a31f..bf003b4 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -146,6 +146,44 @@ class SConfTestCase(unittest.TestCase):
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
"""
@@ -277,6 +315,16 @@ int main() {
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'),
@@ -298,6 +346,10 @@ int main() {
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()