# number that creates a node.
exec _file_ in stack[-1].globals
else:
- sys.stderr.write("Ignoring missing SConscript '%s'\n" %
- f.path)
+ SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning,
+ "Ignoring missing SConscript '%s'" % f.path)
finally:
sconscript_reading = 0
#
# Private methods of an SConsEnvironment.
#
-
- def _check_version(self, major, minor, version_string):
- """Return 0 if 'major' and 'minor' are greater than the version
- in 'version_string', and 1 otherwise."""
- try:
- v_major, v_minor, v_micro, release, serial = sys.version_info
- except AttributeError:
- version = string.split(string.split(version_string, ' ')[0], '.')
- v_major = int(version[0])
- v_minor = int(re.match('\d+', version[1]).group())
- if major > v_major or (major == v_major and minor > v_minor):
- return 0
- else:
- return 1
+ def _exceeds_version(self, major, minor, v_major, v_minor):
+ """Return 1 if 'major' and 'minor' are greater than the version
+ in 'v_major' and 'v_minor', and 0 otherwise."""
+ return (major > v_major or (major == v_major and minor > v_minor))
+
+ def _get_major_minor(self, version_string):
+ """Split a version string into major and minor parts. This
+ is complicated by the fact that a version string can be something
+ like 3.2b1."""
+ version = string.split(string.split(version_string, ' ')[0], '.')
+ v_major = int(version[0])
+ v_minor = int(re.match('\d+', version[1]).group())
+ return v_major, v_minor
def _get_SConscript_filenames(self, ls, kw):
"""
def EnsureSConsVersion(self, major, minor):
"""Exit abnormally if the SCons version is not late enough."""
- if not self._check_version(major,minor,SCons.__version__):
+ v_major, v_minor = self._get_major_minor(SCons.__version__)
+ if self._exceeds_version(major, minor, v_major, v_minor):
print "SCons %d.%d or greater required, but you have SCons %s" %(major,minor,SCons.__version__)
sys.exit(2)
def EnsurePythonVersion(self, major, minor):
"""Exit abnormally if the Python version is not late enough."""
- if not self._check_version(major,minor,sys.version):
+ try:
+ v_major, v_minor, v_micro, release, serial = sys.version_info
+ except AttributeError:
+ v_major, v_minor = self._get_major_minor(sys.version)
+ if self._exceeds_version(major, minor, v_major, v_minor):
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)
if len(elems) == 1 and elems[0] == 'all':
class_name = "Warning"
else:
- class_name = string.join(map(string.capitalize, elems), '') + \
- "Warning"
+ def _capitalize(s):
+ if s[:5] == "scons":
+ return "SCons" + s[5:]
+ else:
+ return string.capitalize(s)
+ class_name = string.join(map(_capitalize, elems), '') + "Warning"
try:
clazz = getattr(SCons.Warnings, class_name)
except AttributeError:
# Enable deprecated warnings by default.
SCons.Warnings._warningOut = _scons_internal_warning
- SCons.Warnings.enableWarningClass(SCons.Warnings.DeprecatedWarning)
SCons.Warnings.enableWarningClass(SCons.Warnings.CorruptSConsignWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.DeprecatedWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.MissingSConscriptWarning)
SCons.Warnings.enableWarningClass(SCons.Warnings.NoParallelSupportWarning)
global ssoptions
class Warning(SCons.Errors.UserError):
pass
-class DeprecatedWarning(Warning):
- pass
-class DependencyWarning(Warning):
+
+class CacheWriteErrorWarning(Warning):
pass
class CorruptSConsignWarning(Warning):
pass
-class ReservedVariableWarning(Warning):
+class DependencyWarning(Warning):
pass
-class CacheWriteErrorWarning(Warning):
+class DeprecatedWarning(Warning):
+ pass
+
+class MissingSConscriptWarning(Warning):
pass
class NoParallelSupportWarning(Warning):
pass
+class ReservedVariableWarning(Warning):
+ pass
+
_warningAsException = 0
# The below is a list of 2-tuples. The first element is a class object.
File ".+", line \d+, in .+
""")
+test.write("SConstruct", """\
+def build(target, source, env):
+ pass
+
+env=Environment()
+env['BUILDERS']['test'] = Builder(action=build)
+env.test(target='foo', source='foo.c')
+SConscript('no_such_file')
+""")
+
+test.run(arguments = '--warn=missing-sconscript .', stderr = r"""
+scons: warning: Ignoring missing SConscript 'no_such_file'
+File ".+", line \d+, in .+
+""")
+
+test.run(arguments = '--warn=no-missing-sconscript .', stderr = "")
+
test.pass_test()