From fd6676a3d652b3a5eef51879ee03515992a65732 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 23 Feb 2022 07:50:00 -0700 Subject: Change the default to error on missing SConscript This completes a change begun in 3.0.2, when the behavior changed from "skip silently" to "skip but issue a warning"; that behavior was marked deprecated in 3.1. Use must_exist=False to get the old "skip silently" behavior. Fixes #3958 Signed-off-by: Mats Wichmann --- CHANGES.txt | 3 + README.rst | 2 +- RELEASE.txt | 6 + SCons/Script/SConscript.py | 42 +++---- SCons/Script/SConscript.xml | 17 +-- SCons/Script/__init__.py | 6 +- SCons/Warnings.py | 1 + doc/man/scons.xml | 4 +- .../Old/SConscript-must_exist_deprecation.py | 57 +++++++++ test/Removed/Old/warn-missing-sconscript.py | 75 ++++++++++++ test/SConscript/must_exist.py | 135 ++++++++++++--------- test/SConscript/must_exist_deprecation.py | 57 --------- test/option/option-f.py | 62 +++++----- test/option/warn-missing-sconscript.py | 79 ------------ 14 files changed, 282 insertions(+), 264 deletions(-) create mode 100644 test/Removed/Old/SConscript-must_exist_deprecation.py create mode 100644 test/Removed/Old/warn-missing-sconscript.py delete mode 100644 test/SConscript/must_exist_deprecation.py delete mode 100644 test/option/warn-missing-sconscript.py diff --git a/CHANGES.txt b/CHANGES.txt index db96df0..30953a8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -131,6 +131,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - More tweaking of test framework overview (which is duplicated onto the website, but not in the regular documentation section). - Extend range of recognized Java versions to 20. + - Finish the change to make calling SConscript() with a nonexistent + file an error. It has issued a warning since 3.0, with "warn instead + of fail" deprecated since 3.1. Fixes #3958. From Jonathon Reinhart: - Fix another instance of `int main()` in CheckLib() causing failures diff --git a/README.rst b/README.rst index 6cc89bd..f779b0b 100755 --- a/README.rst +++ b/README.rst @@ -167,7 +167,7 @@ messages during installation like this:: Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. -If you are running on a system which uses a package manager +If you are running on a system which uses a package manager (for example most Linux distributions), you may, at your option, use the package manager (e.g. ``apt``, ``dnf``, ``yum``, ``zypper``, ``brew``, ``pacman`` etc.) to install a version diff --git a/RELEASE.txt b/RELEASE.txt index f72a2a6..59215dd 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -60,6 +60,12 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY architecture combination. For example, when using VS2022 on arm64, the arm64 native tools are only installed for the 14.3x toolsets. - Extend range of recognized Java versions to 20. +- Calling SConscript() with a nonexistent file is now an error. + Previously this succeeded - prior to SCons 3.0, silently; since 3.0, with + a warning. Developers can still instruct such an SConscript() call not + to fail by being explicit: pass keyword argument "must_exist=False". + The "--warn=missing-sconscript" commandline option is no longer available + as the warning was part of the transitional phase. FIXES ----- diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index c0b556c..28a3773 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -145,40 +145,32 @@ def Return(*vars, **kw): stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) -def handle_missing_SConscript(f, must_exist=None): +def handle_missing_SConscript(f: str, must_exist: bool = True) -> None: """Take appropriate action on missing file in SConscript() call. 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. + missing is explicitly allowed by the *must_exist* parameter or by + a global flag. Args: - f (str): path of missing configuration file - 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. + f: path to missing configuration file + must_exist: if true (the default), fail. If false + do nothing, allowing a build to declare it's okay to be missing. Raises: - UserError: if *must_exist* is true or if global + UserError: if *must_exist* is true or if global :data:`SCons.Script._no_missing_sconscript` is true. + + .. versionchanged: 4.6.0 + Changed default from False. """ + if not must_exist: # explicitly set False: ok + return + if not SCons.Script._no_missing_sconscript: # system default changed: ok + return + msg = f"Fatal: missing SConscript '{f.get_internal_path()}'" + raise SCons.Errors.UserError(msg) - 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 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 @@ -294,7 +286,7 @@ def _SConscript(fs, *files, **kw): call_stack[-1].globals.update({__file__:old_file}) else: - handle_missing_SConscript(f, kw.get('must_exist', None)) + handle_missing_SConscript(f, kw.get('must_exist', True)) finally: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading - 1 diff --git a/SCons/Script/SConscript.xml b/SCons/Script/SConscript.xml index 7a4bc29..e5d9a72 100644 --- a/SCons/Script/SConscript.xml +++ b/SCons/Script/SConscript.xml @@ -538,18 +538,21 @@ TODO??? SConscript('build/SConscript', src_dir='src') If the optional must_exist -is True, +is True (the default), causes an exception to be raised if a requested -SConscript file is not found. The current default is -False, -causing only a warning to be emitted, but this default is deprecated -(since 3.1). -For scripts which truly intend to be optional, transition to -explicitly supplying +SConscript file is not found. +To allow missing scripts to be silently ignored +(the default behavior prior to &SCons; version 3.1), +pass must_exist=False to the &f-SConscript; call. +Changed in 4.6.0: must_exist +now defaults to True. + + + Here are some composite examples: diff --git a/SCons/Script/__init__.py b/SCons/Script/__init__.py index e398ecf..3249817 100644 --- a/SCons/Script/__init__.py +++ b/SCons/Script/__init__.py @@ -269,10 +269,10 @@ def HelpFunction(text, append: bool=False) -> None: # Will be non-zero if we are reading an SConscript file. sconscript_reading = 0 -_no_missing_sconscript = False -_warn_missing_sconscript_deprecated = True +_no_missing_sconscript = True +_warn_missing_sconscript_deprecated = False # TODO: now unused -def set_missing_sconscript_error(flag: int=1): +def set_missing_sconscript_error(flag: bool = True) -> bool: """Set behavior on missing file in SConscript() call. Returns: diff --git a/SCons/Warnings.py b/SCons/Warnings.py index 5c2a0db..f6809fb 100644 --- a/SCons/Warnings.py +++ b/SCons/Warnings.py @@ -70,6 +70,7 @@ class LinkWarning(WarningOnByDefault): class MisleadingKeywordsWarning(WarningOnByDefault): pass +# TODO: no longer needed, now an error instead of warning. Leave for a bit. class MissingSConscriptWarning(WarningOnByDefault): pass diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 4a422be..b3bf372 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -2272,13 +2272,13 @@ of this tool module. - + no-object-count diff --git a/test/Removed/Old/SConscript-must_exist_deprecation.py b/test/Removed/Old/SConscript-must_exist_deprecation.py new file mode 100644 index 0000000..4c1db12 --- /dev/null +++ b/test/Removed/Old/SConscript-must_exist_deprecation.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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. + +""" +Test deprecation warning if must_exist flag is used in an SConscript() call +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +# catch the exception if is raised, send it on as a warning +# this gives us traceability of the line responsible +SConstruct_path = test.workpath('SConstruct') +test.file_fixture("fixture/SConstruct") + +# we should see two warnings, the second being the deprecation message. +# need to build the path in the expected msg in an OS-agnostic way +missing = os.path.normpath('missing/SConscript') +warnmsg = """ +scons: warning: Calling missing SConscript without error is deprecated. +Transition by adding must_exist=False to SConscript calls. +Missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 18) + +expect_stderr = warnmsg +test.run(arguments=".", stderr=expect_stderr) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Removed/Old/warn-missing-sconscript.py b/test/Removed/Old/warn-missing-sconscript.py new file mode 100644 index 0000000..7859b64 --- /dev/null +++ b/test/Removed/Old/warn-missing-sconscript.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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. + +""" +Verify use of the --warn=missing-sconscript option. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + +test.write("SConstruct", """\ +DefaultEnvironment(tools=[]) +def build(target, source, env): + pass + +env=Environment(tools=[]) +env['BUILDERS']['test'] = Builder(action=build) +env.test(target='foo', source='foo.c') +WARN = ARGUMENTS.get('WARN') +if WARN: + SetOption('warn', WARN) +SConscript('no_such_file') +""") + +test.write("foo.c",""" +#include "not_there.h" +""") + +expect = r""" +scons: warning: Calling missing SConscript without error is deprecated. +Transition by adding must_exist=False to SConscript calls. +Missing SConscript 'no_such_file' +""" + TestSCons.file_expr + +# this is the old message: +#expect = r""" +#scons: warning: Ignoring missing SConscript 'no_such_file' +"" + TestSCons.file_expr + +test.run(arguments='--warn=missing-sconscript .', stderr=expect) +test.run(arguments='--warn=no-missing-sconscript .', stderr="") +test.run(arguments='WARN=missing-sconscript .', stderr=expect) +test.run(arguments='WARN=no-missing-sconscript .', stderr="") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py index 81e018a..52b3e45 100644 --- a/test/SConscript/must_exist.py +++ b/test/SConscript/must_exist.py @@ -37,76 +37,93 @@ test = TestSCons.TestSCons() # this gives us traceability of the line responsible SConstruct_path = test.workpath('SConstruct') test.write(SConstruct_path, """\ -import SCons -from SCons.Warnings import _warningOut import sys +import traceback + +import SCons.Script +from SCons.Errors import UserError +from SCons.Script.Main import find_deepest_user_frame DefaultEnvironment(tools=[]) -# 1. 1st default call should succeed with deprecation warning -try: - SConscript('missing/SConscript') -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -# 2. 2nd default call should succeed with warning (no depr) + +def user_error(e): + "Synthesize msg from UserError." + # Borrowed from SCons.Script._scons_user_error which we don't use + # because it exits - we only want the message. + etype, value, tb = sys.exc_info() + filename, lineno, routine, _ = find_deepest_user_frame(traceback.extract_tb(tb)) + sys.stderr.write(f"\\nscons: *** {value}\\n") + sys.stderr.write(f'File "{filename}", line {lineno}, in {routine}\\n') + +# 1. Call with defaults raises exception try: - SConscript('missing/SConscript') -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -# 3. must_exist True call should raise exception + SConscript("missing/SConscript") +except UserError as e: + user_error(e) + +# 2. Call with must_exist=True raises exception try: - SConscript('missing/SConscript', must_exist=True) -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -# 4. must_exist False call should succeed silently + SConscript("missing/SConscript", must_exist=True) +except UserError as e: + user_error(e) + +# 3. Call with must_exist=False call should succeed silently try: - SConscript('missing/SConscript', must_exist=False) -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -# 5. with system setting changed, should raise exception -SCons.Script.set_missing_sconscript_error() + SConscript("missing/SConscript", must_exist=False) +except UserError as e: + user_error(e) + +# 4. with system setting changed, should succeed silently +SCons.Script.set_missing_sconscript_error(flag=False) try: - SConscript('missing/SConscript') -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -# 6. must_exist=False overrides system setting, should emit warning + SConscript("missing/SConscript") +except UserError as e: + user_error(e) + +# 5. must_exist=True "wins" over system setting try: - SConscript('missing/SConscript', must_exist=False) -except SCons.Errors.UserError as e: - if _warningOut: - _warningOut(e) -""") - -# we should see two exceptions as "Fatal" and -# and see four warnings, the first having the depr message -# need to build the path in the expected msg in an OS-agnostic way -missing = os.path.normpath('missing/SConscript') -warn1 = """ -scons: warning: Calling missing SConscript without error is deprecated. -Transition by adding must_exist=False to SConscript calls. -Missing SConscript '{}' -""".format(missing) + test.python_file_line(SConstruct_path, 8) - -warn2 = """ -scons: warning: Ignoring missing SConscript '{}' -""".format(missing) + test.python_file_line(SConstruct_path, 14) - -err1 = """ -scons: warning: Fatal: missing SConscript '{}' -""".format(missing) + test.python_file_line(SConstruct_path, 23) - -err2 = """ -scons: warning: Fatal: missing SConscript '{}' -""".format(missing) + test.python_file_line(SConstruct_path, 36) + SConscript("missing/SConscript", must_exist=True) +except UserError as e: + user_error(e) +""", +) + +missing = "missing/SConscript" +err1 = f""" +scons: *** Fatal: missing SConscript {missing!r} +""" + test.python_file_line( + SConstruct_path, 21 +) + +err2 = f""" +scons: *** Fatal: missing SConscript {missing!r} +""" + test.python_file_line( + SConstruct_path, 27 +) + +err3 = f""" +scons: *** Fatal: missing SConscript {missing!r} +""" + test.python_file_line( + SConstruct_path, 33 +) + +err4 = f""" +scons: *** Fatal: missing SConscript {missing!r} +""" + test.python_file_line( + SConstruct_path, 40 +) + +err5 = f""" +scons: *** Fatal: missing SConscript {missing!r} +""" + test.python_file_line( + SConstruct_path, 46 +) nowarn = "" -expect_stderr = warn1 + warn2 + err1 + nowarn + err2 + nowarn -test.run(arguments = ".", stderr = expect_stderr) +# of the five tests, we actually expect fails from 1 and 2 +expect_stderr = err1 + err2 + nowarn + nowarn + nowarn +test.run(arguments=".", stderr=expect_stderr) test.pass_test() # Local Variables: diff --git a/test/SConscript/must_exist_deprecation.py b/test/SConscript/must_exist_deprecation.py deleted file mode 100644 index 4c1db12..0000000 --- a/test/SConscript/must_exist_deprecation.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# 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. - -""" -Test deprecation warning if must_exist flag is used in an SConscript() call -""" - -import os -import TestSCons - -test = TestSCons.TestSCons() - -# catch the exception if is raised, send it on as a warning -# this gives us traceability of the line responsible -SConstruct_path = test.workpath('SConstruct') -test.file_fixture("fixture/SConstruct") - -# we should see two warnings, the second being the deprecation message. -# need to build the path in the expected msg in an OS-agnostic way -missing = os.path.normpath('missing/SConscript') -warnmsg = """ -scons: warning: Calling missing SConscript without error is deprecated. -Transition by adding must_exist=False to SConscript calls. -Missing SConscript '{}' -""".format(missing) + test.python_file_line(SConstruct_path, 18) - -expect_stderr = warnmsg -test.run(arguments=".", stderr=expect_stderr) -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/option-f.py b/test/option/option-f.py index e1343a6..14a7ecc 100644 --- a/test/option/option-f.py +++ b/test/option/option-f.py @@ -34,21 +34,24 @@ test.subdir('subdir') subdir_BuildThis = os.path.join('subdir', 'Buildthis') test.write('SConscript', """ -DefaultEnvironment(tools=[]) import os + +DefaultEnvironment(tools=[]) print("SConscript " + os.getcwd()) """) test.write(subdir_BuildThis, """ -DefaultEnvironment(tools=[]) import os -print("subdir/BuildThis "+ os.getcwd()) + +DefaultEnvironment(tools=[]) +print("subdir/BuildThis " + os.getcwd()) """) test.write('Build2', """ -DefaultEnvironment(tools=[]) import os -print("Build2 "+ os.getcwd()) + +DefaultEnvironment(tools=[]) +print("Build2 " + os.getcwd()) """) wpath = test.workpath() @@ -56,14 +59,15 @@ wpath = test.workpath() test.run( arguments='-f SConscript .', stdout=test.wrap_stdout( - read_str='SConscript %s\n' % wpath, build_str="scons: `.' is up to date.\n" + read_str=f'SConscript {wpath}\n', + build_str="scons: `.' is up to date.\n" ), ) test.run( - arguments='-f %s .' % subdir_BuildThis, + arguments=f'-f {subdir_BuildThis} .', stdout=test.wrap_stdout( - read_str='subdir/BuildThis %s\n' % wpath, + read_str=f'subdir/BuildThis {wpath}\n', build_str="scons: `.' is up to date.\n", ), ) @@ -71,14 +75,15 @@ test.run( test.run( arguments='--file=SConscript .', stdout=test.wrap_stdout( - read_str='SConscript %s\n' % wpath, build_str="scons: `.' is up to date.\n" + read_str=f'SConscript {wpath}\n', + build_str="scons: `.' is up to date.\n" ), ) test.run( - arguments='--file=%s .' % subdir_BuildThis, + arguments=f'--file={subdir_BuildThis} .', stdout=test.wrap_stdout( - read_str='subdir/BuildThis %s\n' % wpath, + read_str=f'subdir/BuildThis {wpath}\n', build_str="scons: `.' is up to date.\n", ), ) @@ -86,14 +91,15 @@ test.run( test.run( arguments='--makefile=SConscript .', stdout=test.wrap_stdout( - read_str='SConscript %s\n' % wpath, build_str="scons: `.' is up to date.\n" + read_str=f'SConscript {wpath}\n', + build_str="scons: `.' is up to date.\n" ), ) test.run( - arguments='--makefile=%s .' % subdir_BuildThis, + arguments=f'--makefile={subdir_BuildThis} .', stdout=test.wrap_stdout( - read_str='subdir/BuildThis %s\n' % wpath, + read_str=f'subdir/BuildThis {wpath}\n', build_str="scons: `.' is up to date.\n", ), ) @@ -101,14 +107,15 @@ test.run( test.run( arguments='--sconstruct=SConscript .', stdout=test.wrap_stdout( - read_str='SConscript %s\n' % wpath, build_str="scons: `.' is up to date.\n" + read_str=f'SConscript {wpath}\n', + build_str="scons: `.' is up to date.\n" ), ) test.run( - arguments='--sconstruct=%s .' % subdir_BuildThis, + arguments=f'--sconstruct={subdir_BuildThis} .', stdout=test.wrap_stdout( - read_str='subdir/BuildThis %s\n' % wpath, + read_str=f'subdir/BuildThis {wpath}\n', build_str="scons: `.' is up to date.\n", ), ) @@ -121,28 +128,21 @@ import os print("STDIN " + os.getcwd()) """, stdout=test.wrap_stdout( - read_str='STDIN %s\n' % wpath, build_str="scons: `.' is up to date.\n" + read_str=f'STDIN {wpath}\n', + build_str="scons: `.' is up to date.\n" ), ) expect = test.wrap_stdout( - read_str='Build2 %s\nSConscript %s\n' % (wpath, wpath), + read_str=f'Build2 {wpath}\nSConscript {wpath}\n', build_str="scons: `.' is up to date.\n", ) test.run(arguments='-f Build2 -f SConscript .', stdout=expect) -test.run( - arguments='-f no_such_file .', - stdout=test.wrap_stdout("scons: `.' is up to date.\n"), - stderr=None, -) - -expect = """ -scons: warning: Calling missing SConscript without error is deprecated. -Transition by adding must_exist=False to SConscript calls. -Missing SConscript 'no_such_file'""" -stderr = test.stderr() -test.must_contain_all(test.stderr(), expect) +missing = "no_such_file" +test.run(arguments=f"-f {missing} .", status=2, stderr=None) +expect = [f"scons: *** Fatal: missing SConscript {missing!r}"] +test.must_contain_all_lines(test.stderr(), expect) test.pass_test() diff --git a/test/option/warn-missing-sconscript.py b/test/option/warn-missing-sconscript.py deleted file mode 100644 index 5413229..0000000 --- a/test/option/warn-missing-sconscript.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# 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. - -""" -Verify use of the --warn=missing-sconscript option. -""" - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - - -test.write("SConstruct", """\ -DefaultEnvironment(tools=[]) -def build(target, source, env): - pass - -env=Environment(tools=[]) -env['BUILDERS']['test'] = Builder(action=build) -env.test(target='foo', source='foo.c') -WARN = ARGUMENTS.get('WARN') -if WARN: - SetOption('warn', WARN) -SConscript('no_such_file') -""") - -test.write("foo.c",""" -#include "not_there.h" -""") - -expect = r""" -scons: warning: Calling missing SConscript without error is deprecated. -Transition by adding must_exist=False to SConscript calls. -Missing SConscript 'no_such_file' -""" + TestSCons.file_expr - -# this is the old message: -#expect = r""" -#scons: warning: Ignoring missing SConscript 'no_such_file' -"" + TestSCons.file_expr - -test.run(arguments = '--warn=missing-sconscript .', stderr = expect) - -test.run(arguments = '--warn=no-missing-sconscript .', stderr = "") - -test.run(arguments = 'WARN=missing-sconscript .', stderr = expect) - -test.run(arguments = 'WARN=no-missing-sconscript .', stderr = "") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From da270a8b9fa2a8f19c2f56de8ccbba4d576d9326 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 6 Aug 2023 13:14:16 -0600 Subject: SConscript must_exist test: fix Windows Make the path to the missing script in expected errors be OS-independent to avoid Windows failing on wrong path separator Signed-off-by: Mats Wichmann --- test/SConscript/must_exist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py index 52b3e45..85b2438 100644 --- a/test/SConscript/must_exist.py +++ b/test/SConscript/must_exist.py @@ -88,7 +88,7 @@ except UserError as e: """, ) -missing = "missing/SConscript" +missing = os.path.join("missing", "SConscript") err1 = f""" scons: *** Fatal: missing SConscript {missing!r} """ + test.python_file_line( -- cgit v0.12 From 0654a72eb779d329421fde4fad7ee411c70f9e0d Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 7 Aug 2023 09:01:52 -0600 Subject: missing-sconscript: fix Windows test again Also dropped the word Fatal from the error, it's not consistent with any other scons-generated exception. Signed-off-by: Mats Wichmann --- SCons/Script/SConscript.py | 2 +- test/SConscript/must_exist.py | 10 +++++----- test/option/option-f.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index 28a3773..2a36a6f 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -168,7 +168,7 @@ def handle_missing_SConscript(f: str, must_exist: bool = True) -> None: return if not SCons.Script._no_missing_sconscript: # system default changed: ok return - msg = f"Fatal: missing SConscript '{f.get_internal_path()}'" + msg = f"missing SConscript file {f.get_internal_path()!r}" raise SCons.Errors.UserError(msg) diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py index 85b2438..90f447e 100644 --- a/test/SConscript/must_exist.py +++ b/test/SConscript/must_exist.py @@ -90,31 +90,31 @@ except UserError as e: missing = os.path.join("missing", "SConscript") err1 = f""" -scons: *** Fatal: missing SConscript {missing!r} +scons: *** missing SConscript file {missing!r} """ + test.python_file_line( SConstruct_path, 21 ) err2 = f""" -scons: *** Fatal: missing SConscript {missing!r} +scons: *** missing SConscript file {missing!r} """ + test.python_file_line( SConstruct_path, 27 ) err3 = f""" -scons: *** Fatal: missing SConscript {missing!r} +scons: *** missing SConscript file {missing!r} """ + test.python_file_line( SConstruct_path, 33 ) err4 = f""" -scons: *** Fatal: missing SConscript {missing!r} +scons: *** missing SConscript file {missing!r} """ + test.python_file_line( SConstruct_path, 40 ) err5 = f""" -scons: *** Fatal: missing SConscript {missing!r} +scons: *** missing SConscript file {missing!r} """ + test.python_file_line( SConstruct_path, 46 ) diff --git a/test/option/option-f.py b/test/option/option-f.py index 14a7ecc..a2c8561 100644 --- a/test/option/option-f.py +++ b/test/option/option-f.py @@ -141,7 +141,7 @@ test.run(arguments='-f Build2 -f SConscript .', stdout=expect) missing = "no_such_file" test.run(arguments=f"-f {missing} .", status=2, stderr=None) -expect = [f"scons: *** Fatal: missing SConscript {missing!r}"] +expect = [f"scons: *** missing SConscript file {missing!r}"] test.must_contain_all_lines(test.stderr(), expect) test.pass_test() -- cgit v0.12 From 52fbd8c9accfc6244a8c2443b46dd5cb73d0e3eb Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 12 Aug 2023 02:53:53 +0200 Subject: add missing include directories --- SCons/Platform/mingw.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SCons/Platform/mingw.py b/SCons/Platform/mingw.py index 1d38a9b..55dd3b8 100644 --- a/SCons/Platform/mingw.py +++ b/SCons/Platform/mingw.py @@ -29,5 +29,7 @@ MINGW_DEFAULT_PATHS = [] if sys.platform == 'win32': MINGW_DEFAULT_PATHS = [ r'C:\msys64', - r'C:\msys' + r'C:\msys64\usr\bin', + r'C:\msys', + r'C:\msys\usr\bin' ] -- cgit v0.12 From 78d27feb199a04713373660bd62167dad6f4a6e7 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 12 Aug 2023 11:52:12 +0200 Subject: add changelog entry --- CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index db96df0..dabeee7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -136,6 +136,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix another instance of `int main()` in CheckLib() causing failures when using -Wstrict-prototypes. + From Max Bachmann: + - Add missing directories to searched paths for mingw installs RELEASE 4.5.2 - Sun, 21 Mar 2023 14:08:29 -0700 -- cgit v0.12 From 1e98a22f24f7eb6c3ab83fdd8649c78e71b129c6 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Thu, 17 Aug 2023 19:01:34 +0900 Subject: Correct warning type name 'target_not_build' -> 'target-not-built' --- doc/man/scons.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 4a422be..2d68b48 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -2341,7 +2341,7 @@ These warnings are enabled by default. - target_not_build + target-not-built Warnings about a build rule not building the expected targets. These warnings are disabled by default. -- cgit v0.12 From e98715057f2f95fd5713b023de2090a5960e81c6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 24 Aug 2023 11:00:17 -0700 Subject: [ci skip] added blurb to RELEASE.txt. Reordered items in CHANGES.txt be alphbetical by last name --- CHANGES.txt | 18 +++++++++--------- RELEASE.txt | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index dabeee7..126651a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,12 +9,8 @@ NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer suppo RELEASE VERSION/DATE TO BE FILLED IN LATER - From William Deegan: - - The --debug flag now has a 'json' option which will write information - generated by --debug={count, memory, time, action-timestamps} and about - the build. - - Obsoleted YACCVCGFILESUFFIX, being replaced by YACC_GRAPH_FILE_SUFFIX. - If YACC_GRAPH_FILE_SUFFIX is not set, it will respect YACCVCGFILESUFFIX. + From Max Bachmann: + - Add missing directories to searched paths for mingw installs From Joseph Brill: - Fix issue #4312: the cached installed msvc list had an indirect dependency @@ -43,6 +39,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Add arm64 to the MSVS supported architectures list for VS2017 and later to be consistent with the current documentation of MSVS_ARCH. + From William Deegan: + - The --debug flag now has a 'json' option which will write information + generated by --debug={count, memory, time, action-timestamps} and about + the build. + - Obsoleted YACCVCGFILESUFFIX, being replaced by YACC_GRAPH_FILE_SUFFIX. + If YACC_GRAPH_FILE_SUFFIX is not set, it will respect YACCVCGFILESUFFIX. + From Mats Wichmann - C scanner's dictifyCPPDEFINES routine did not understand the possible combinations of CPPDEFINES - not aware of a "name=value" string either @@ -136,9 +139,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix another instance of `int main()` in CheckLib() causing failures when using -Wstrict-prototypes. - From Max Bachmann: - - Add missing directories to searched paths for mingw installs - RELEASE 4.5.2 - Sun, 21 Mar 2023 14:08:29 -0700 From Michał Górny: diff --git a/RELEASE.txt b/RELEASE.txt index f72a2a6..42199c1 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -60,6 +60,7 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY architecture combination. For example, when using VS2022 on arm64, the arm64 native tools are only installed for the 14.3x toolsets. - Extend range of recognized Java versions to 20. +- Add missing directories to searched paths for mingw installs FIXES ----- -- cgit v0.12