diff options
author | Mats Wichmann <mats@linux.com> | 2021-06-18 17:22:16 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-06-18 17:22:16 (GMT) |
commit | a87c9c461ab1b0e05321ba2649d1e853821be5c2 (patch) | |
tree | 76246ef2a9b3a6c0ef3da57a541e2e52baa1163a /SCons/Script/SConscript.py | |
parent | 62e45b7012767a6d3d7ff033c8b4910e275a7501 (diff) | |
download | SCons-a87c9c461ab1b0e05321ba2649d1e853821be5c2.zip SCons-a87c9c461ab1b0e05321ba2649d1e853821be5c2.tar.gz SCons-a87c9c461ab1b0e05321ba2649d1e853821be5c2.tar.bz2 |
Change warnings behavior of missing SConscript
If SConscript() is called with must_exist=False, accept the user's
will without issuing a warning about the file being missing.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'SCons/Script/SConscript.py')
-rw-r--r-- | SCons/Script/SConscript.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index 596fca0..6188151 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -148,31 +148,37 @@ stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) def handle_missing_SConscript(f, must_exist=None): """Take appropriate action on missing file in SConscript() call. - Print a warning or raise an exception on missing file. + Print a warning or raise an exception on missing file, unless + missing is explicitly allowed by the *must_exist* value. On first warning, print a deprecation message. Args: f (str): path of missing configuration file - must_exist (bool): raise exception if file does not exist + must_exist (bool): if true, fail. If false, but not ``None``, + allow the file to be missing. The default is ``None``, + which means issue the warning. The default is deprecated. Raises: - UserError if 'must_exist' is True or if global - SCons.Script._no_missing_sconscript is True. + UserError: if *must_exist* is true or if global + :data:`SCons.Script._no_missing_sconscript` is true. """ if must_exist or (SCons.Script._no_missing_sconscript and must_exist is not False): msg = "Fatal: missing SConscript '%s'" % f.get_internal_path() raise SCons.Errors.UserError(msg) - if SCons.Script._warn_missing_sconscript_deprecated and must_exist is None: - msg = "Calling missing SConscript without error is deprecated.\n" + \ - "Transition by adding must_exist=0 to SConscript calls.\n" + \ - "Missing SConscript '%s'" % f.get_internal_path() - SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) - SCons.Script._warn_missing_sconscript_deprecated = False - else: - msg = "Ignoring missing SConscript '%s'" % f.get_internal_path() - SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) + if must_exist is None: + if SCons.Script._warn_missing_sconscript_deprecated: + msg = ( + "Calling missing SConscript without error is deprecated.\n" + "Transition by adding must_exist=False to SConscript calls.\n" + "Missing SConscript '%s'" % f.get_internal_path() + ) + SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) + SCons.Script._warn_missing_sconscript_deprecated = False + else: + msg = "Ignoring missing SConscript '%s'" % f.get_internal_path() + SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) def _SConscript(fs, *files, **kw): top = fs.Top |