is an optional directory that will be used as the parent directory.
.TP
-.RI FindFile( file ", "
+.RI FindFile( file ", " dirs )
+Search for
+.I file
+in the path specified by
+.IR dirs .
+.I file
+may be a list of file names or a single file name. In addition to searching
+for files that exist in the filesytem, this function also searches for
+derived files that have not yet been built.
+
+.ES
+foo = FindFile('foo', ['dir1', 'dir2'])
+.EE
+
+.TP
+.RI EnsurePythonVersion( major ", " minor )
+Ensure that the Python version is at least
+.IR major . minor .
+This function will
+print out an error message and exit SCons with a non-zero exit code if the
+actual Python version is not late enough.
+
+.ES
+EnsurePythonVersion(2,2)
+.EE
+
+.TP
+.RI EnsureSConsVersion( major ", " minor )
+Ensure that the SCons version is at least
+.IR major . minor .
+This function will
+print out an error message and exit SCons with a non-zero exit code if the
+actual SCons version is not late enough.
+
+.ES
+EnsureSConsVersion(0,9)
+.EE
.TP
.RI Export( vars )
- Fix dependency scans when $LIBS is overridden.
+ - Add EnsurePythonVersion() and EnsureSConsVersion() functions.
+
From sam th:
- Dynamically check for the existence of utilities with which to
import SCons.Util
import SCons.Sig
import SCons.Options
+import SCons
import os
import os.path
def Update(self, env):
return SCons.Options.Options.Update(self, env, arguments)
+def CheckVersion(major,minor,version_string):
+ """Return 0 if 'major' and 'minor' are greater than the version
+ in 'version_string', and 1 otherwise."""
+ version = string.split(string.split(version_string, ' ')[0], '.')
+ if major > int(version[0]) or (major == int(version[0]) and minor > int(version[1])):
+ return 0
+ else:
+ return 1
+
+def EnsureSConsVersion(major, minor):
+ """Exit abnormally if the SCons version is not late enough."""
+ if not CheckVersion(major,minor,SCons.__version__):
+ print "SCons %d.%d or greater required, but you have SCons %s" %(major,minor,SCons.__version__)
+ sys.exit(2)
+
+def EnsurePythonVersion(major, minor):
+ """Exit abnormally if the Python version is not late enough."""
+ if not CheckVersion(major,minor,sys.version):
+ v = string.split(sys.version, " ", 1)[0]
+ print "Python %d.%d or greater required, but you have Python %s" %(major,minor,v)
+ sys.exit(2)
+
def BuildDefaultGlobals():
"""
Create a dictionary containing all the default globals for
globals['CScan'] = SCons.Defaults.CScan
globals['Default'] = Default
globals['Dir'] = SCons.Node.FS.default_fs.Dir
+ globals['EnsurePythonVersion'] = EnsurePythonVersion
+ globals['EnsureSConsVersion'] = EnsureSConsVersion
globals['Environment'] = SCons.Environment.Environment
globals['Export'] = Export
globals['File'] = SCons.Node.FS.default_fs.File
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+import SCons
+
+if SCons.__version__ == "__VERSION__":
+
+ test.write('SConstruct', """
+import sys
+EnsurePythonVersion(0,0)
+sys.exit(0)
+""")
+
+ test.run()
+
+ test.write('SConstruct', """
+import sys
+EnsurePythonVersion(2000,0)
+sys.exit(0)
+""")
+
+ test.run(status=2)
+
+else:
+ test.write('SConstruct', """
+import sys
+EnsurePythonVersion(0,0)
+EnsureSConsVersion(0,0)
+sys.exit(0)
+""")
+
+ test.run()
+
+ test.write('SConstruct', """
+import sys
+EnsurePythonVersion(0,0)
+EnsureSConsVersion(2000,0)
+sys.exit(0)
+""")
+
+ test.run(status=2)
+
+ test.write('SConstruct', """
+import sys
+EnsurePythonVersion(2000,0)
+EnsureSConsVersion(2000,0)
+sys.exit(0)
+""")
+
+ test.run(status=2)
+
+test.pass_test()