From 367b0cd3ea065f280daf0835131ac0483b1dfa6a Mon Sep 17 00:00:00 2001 From: StenGruener <69786685+StenGruener@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:36:34 +0200 Subject: Adding tracing of scons script calls --- SCons/Script/SConscript.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index 539fa75..d87c782 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -274,7 +274,11 @@ def _SConscript(fs, *files, **kw): scriptdata = _file_.read() scriptname = _file_.name _file_.close() + if "SCONS_CALL_TRACING" in os.environ: + print("scons-entering>"+str(scriptname)) exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) + if "SCONS_CALL_TRACING" in os.environ: + print("scons-exiting>"+str(scriptname)) except SConscriptReturn: pass finally: -- cgit v0.12 From d1c2fed3f0085253a40a179a39f9f837769f5dfa Mon Sep 17 00:00:00 2001 From: StenGruener <69786685+StenGruener@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:02:04 +0000 Subject: adding unit test, --debug flag, comments in changes.txt --- CHANGES.txt | 3 ++ SCons/Debug.py | 3 ++ SCons/Script/Main.py | 2 ++ SCons/Script/SConsOptions.py | 2 +- SCons/Script/SConscript.py | 4 +-- test/SConscript/SConscriptTrace.py | 58 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 test/SConscript/SConscriptTrace.py diff --git a/CHANGES.txt b/CHANGES.txt index 9076faa..c362989 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,9 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported RELEASE VERSION/DATE TO BE FILLED IN LATER + From Sten Grüner + - The --debug flag has a 'sconscript-trace' option allowint to trace + files included via SConscript call. From Max Bachmann: - Add missing directories to searched paths for mingw installs diff --git a/SCons/Debug.py b/SCons/Debug.py index 615eb4f..9397fde 100644 --- a/SCons/Debug.py +++ b/SCons/Debug.py @@ -41,6 +41,9 @@ import inspect track_instances = False # List of currently tracked classes tracked_classes = {} +# Global variable that gets set to 'True' by the Main script +# when SConscript call tracing should be enabled. +sconscript_trace = False def logInstanceCreation(instance, name=None) -> None: if name is None: diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py index 9735df2..d218803 100644 --- a/SCons/Script/Main.py +++ b/SCons/Script/Main.py @@ -725,6 +725,8 @@ def _set_debug_values(options) -> None: SCons.Node.print_duplicate = True if "json" in debug_values: ENABLE_JSON = True + if "sconscript-trace" in debug_values: + SCons.Debug.sconscript_trace = True def _create_path(plist): path = '.' diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py index e799716..1d40f5c 100644 --- a/SCons/Script/SConsOptions.py +++ b/SCons/Script/SConsOptions.py @@ -752,7 +752,7 @@ def Parser(version): debug_options = ["count", "duplicate", "explain", "findlibs", "includes", "memoizer", "memory", "objects", "pdb", "prepare", "presub", "stacktrace", - "time", "action-timestamps", "json"] + "time", "action-timestamps", "json", "sconscript-trace"] def opt_debug(option, opt, value__, parser, debug_options=debug_options, diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index d87c782..860b3e7 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -274,10 +274,10 @@ def _SConscript(fs, *files, **kw): scriptdata = _file_.read() scriptname = _file_.name _file_.close() - if "SCONS_CALL_TRACING" in os.environ: + if SCons.Debug.sconscript_trace: print("scons-entering>"+str(scriptname)) exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) - if "SCONS_CALL_TRACING" in os.environ: + if SCons.Debug.sconscript_trace: print("scons-exiting>"+str(scriptname)) except SConscriptReturn: pass diff --git a/test/SConscript/SConscriptTrace.py b/test/SConscript/SConscriptTrace.py new file mode 100644 index 0000000..c432362 --- /dev/null +++ b/test/SConscript/SConscriptTrace.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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 os +import TestSCons + +test = TestSCons.TestSCons() + + +test.write('SConstruct', """\ +print("SConstruct") +""") + +wpath = test.workpath() + +test.run(arguments = ".") +unexpect = [ + 'scons-entering>%s%sSConstruct'%(wpath, os.sep), + 'scons-exiting>%s%sSConstruct'%(wpath, os.sep) +] +test.must_not_contain_any_line(test.stdout(), unexpect) + +test.run(arguments = "--debug=sconscript-trace .") +expect = [ + 'scons-entering>%s%sSConstruct'%(wpath, os.sep), + 'scons-exiting>%s%sSConstruct'%(wpath, os.sep) +] +test.must_contain_all_lines(test.stdout(), expect) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 24c01cf9aed9633ac92f17c9243b4cf65daf9dd6 Mon Sep 17 00:00:00 2001 From: StenGruener <69786685+StenGruener@users.noreply.github.com> Date: Sat, 28 Oct 2023 19:46:50 +0000 Subject: adding info to the man page, changed debug key --- CHANGES.txt | 2 +- SCons/Script/Main.py | 2 +- SCons/Script/SConsOptions.py | 2 +- doc/man/scons.xml | 6 ++++++ test/SConscript/SConscriptTrace.py | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c362989..08d4dd3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,7 @@ 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 Sten Grüner - - The --debug flag has a 'sconscript-trace' option allowint to trace + - The --debug flag has a 'sconscript' option allowint to trace files included via SConscript call. From Max Bachmann: diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py index d218803..c29fb38 100644 --- a/SCons/Script/Main.py +++ b/SCons/Script/Main.py @@ -725,7 +725,7 @@ def _set_debug_values(options) -> None: SCons.Node.print_duplicate = True if "json" in debug_values: ENABLE_JSON = True - if "sconscript-trace" in debug_values: + if "sconscript" in debug_values: SCons.Debug.sconscript_trace = True def _create_path(plist): diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py index 1d40f5c..b74353e 100644 --- a/SCons/Script/SConsOptions.py +++ b/SCons/Script/SConsOptions.py @@ -752,7 +752,7 @@ def Parser(version): debug_options = ["count", "duplicate", "explain", "findlibs", "includes", "memoizer", "memory", "objects", "pdb", "prepare", "presub", "stacktrace", - "time", "action-timestamps", "json", "sconscript-trace"] + "time", "action-timestamps", "json", "sconscript"] def opt_debug(option, opt, value__, parser, debug_options=debug_options, diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 6a888cb..d9406d7 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -1119,6 +1119,12 @@ should take place in parallel.) + + sconscript + +Augments the output of SCons with markers to track included SConscript files. + + diff --git a/test/SConscript/SConscriptTrace.py b/test/SConscript/SConscriptTrace.py index c432362..ab1b660 100644 --- a/test/SConscript/SConscriptTrace.py +++ b/test/SConscript/SConscriptTrace.py @@ -43,7 +43,7 @@ unexpect = [ ] test.must_not_contain_any_line(test.stdout(), unexpect) -test.run(arguments = "--debug=sconscript-trace .") +test.run(arguments = "--debug=sconscript .") expect = [ 'scons-entering>%s%sSConstruct'%(wpath, os.sep), 'scons-exiting>%s%sSConstruct'%(wpath, os.sep) -- cgit v0.12 From a790daf8d878aef83937723e1fb1017fd86875f2 Mon Sep 17 00:00:00 2001 From: StenGruener <69786685+StenGruener@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:38:07 +0200 Subject: Typo in CHANGES.txt --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 08d4dd3..2c69e34 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,7 @@ 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 Sten Grüner - - The --debug flag has a 'sconscript' option allowint to trace + - The --debug flag has a 'sconscript' option allowing to trace files included via SConscript call. From Max Bachmann: -- cgit v0.12 From 71b532b5dadb0fe097d54271b5dbb584a2e06154 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 28 Oct 2023 17:42:30 -0700 Subject: Updates to make ready for merging --- CHANGES.txt | 8 ++--- RELEASE.txt | 2 ++ SCons/Script/SConscript.py | 4 +-- SCons/__init__.py | 10 +++---- doc/man/scons.xml | 2 +- test/SConscript/SConscriptTrace.py | 58 ------------------------------------ test/option/debug-sconscript.py | 60 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 70 deletions(-) delete mode 100644 test/SConscript/SConscriptTrace.py create mode 100644 test/option/debug-sconscript.py diff --git a/CHANGES.txt b/CHANGES.txt index 2c69e34..725539d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,10 +8,6 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported RELEASE VERSION/DATE TO BE FILLED IN LATER - From Sten Grüner - - The --debug flag has a 'sconscript' option allowing to trace - files included via SConscript call. - From Max Bachmann: - Add missing directories to searched paths for mingw installs @@ -62,6 +58,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Obsoleted YACCVCGFILESUFFIX, being replaced by YACC_GRAPH_FILE_SUFFIX. If YACC_GRAPH_FILE_SUFFIX is not set, it will respect YACCVCGFILESUFFIX. + From Sten Grüner + - The newly added --debug=sconscript optiont (new) will output notices when + entering an exiting each SConscript as they are processed. + From Philipp Maierhöfer: - Fix gfortran tool initialization. Defaults to using binary named gfortran as would be expected, and properly set's SHFORTRAN flags to include -fPIC diff --git a/RELEASE.txt b/RELEASE.txt index c0925bb..01ac02d 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -79,6 +79,8 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY Any code that did the direct import will have to change to import from SCons.Util.sctypes. - Add JDK 21 LTS support +- The newly added --debug=sconscript optiont (new) will output notices when + entering an exiting each SConscript as they are processed. FIXES ----- diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index 860b3e7..0d75088 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -275,10 +275,10 @@ def _SConscript(fs, *files, **kw): scriptname = _file_.name _file_.close() if SCons.Debug.sconscript_trace: - print("scons-entering>"+str(scriptname)) + print("scons: Entering "+str(scriptname)) exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) if SCons.Debug.sconscript_trace: - print("scons-exiting>"+str(scriptname)) + print("scons: Exiting "+str(scriptname)) except SConscriptReturn: pass finally: diff --git a/SCons/__init__.py b/SCons/__init__.py index f0f241d..29176c1 100644 --- a/SCons/__init__.py +++ b/SCons/__init__.py @@ -1,9 +1,9 @@ -__version__="4.5.2" +__version__="4.5.3" __copyright__="Copyright (c) 2001 - 2023 The SCons Foundation" __developer__="bdbaddog" -__date__="Sun, 04 Jun 2023 15:36:48 -0700" +__date__="Sat, 28 Oct 2023 17:40:01 -0700" __buildsys__="M1Dog2021" -__revision__="b3744e8862927899e3d0ebcb41297f9b4c142c63" -__build__="b3744e8862927899e3d0ebcb41297f9b4c142c63" +__revision__="a790daf8d878aef83937723e1fb1017fd86875f2" +__build__="a790daf8d878aef83937723e1fb1017fd86875f2" # make sure compatibility is always in place -import SCons.compat # noqa \ No newline at end of file +import SCons.compat # noqa \ No newline at end of file diff --git a/doc/man/scons.xml b/doc/man/scons.xml index d9406d7..aaebc2c 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -1122,7 +1122,7 @@ should take place in parallel.) sconscript -Augments the output of SCons with markers to track included SConscript files. +Enables output indicating entering and exiting each SConscript file. diff --git a/test/SConscript/SConscriptTrace.py b/test/SConscript/SConscriptTrace.py deleted file mode 100644 index ab1b660..0000000 --- a/test/SConscript/SConscriptTrace.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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 os -import TestSCons - -test = TestSCons.TestSCons() - - -test.write('SConstruct', """\ -print("SConstruct") -""") - -wpath = test.workpath() - -test.run(arguments = ".") -unexpect = [ - 'scons-entering>%s%sSConstruct'%(wpath, os.sep), - 'scons-exiting>%s%sSConstruct'%(wpath, os.sep) -] -test.must_not_contain_any_line(test.stdout(), unexpect) - -test.run(arguments = "--debug=sconscript .") -expect = [ - 'scons-entering>%s%sSConstruct'%(wpath, os.sep), - 'scons-exiting>%s%sSConstruct'%(wpath, os.sep) -] -test.must_contain_all_lines(test.stdout(), expect) -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/debug-sconscript.py b/test/option/debug-sconscript.py new file mode 100644 index 0000000..9638f79 --- /dev/null +++ b/test/option/debug-sconscript.py @@ -0,0 +1,60 @@ +#!/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 the --debug=sconscript option +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +print("SConstruct") +""") + +wpath = test.workpath() + +test.run(arguments=".") +unexpect = [ + 'scons: Entering %s%sSConstruct' % (wpath, os.sep), + 'scons: Exiting %s%sSConstruct' % (wpath, os.sep) +] +test.must_not_contain_any_line(test.stdout(), unexpect) + +test.run(arguments="--debug=sconscript .") +expect = [ + 'scons: Entering %s%sSConstruct' % (wpath, os.sep), + 'scons: Exiting %s%sSConstruct' % (wpath, os.sep) +] +test.must_contain_all_lines(test.stdout(), expect) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From b4697e2e38f69071085bdaab764c180462d68504 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 29 Oct 2023 16:12:08 -0700 Subject: [ci skip] Fix typo in CHANGES/RELEASE --- CHANGES.txt | 2 +- RELEASE.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 725539d..69349a2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -59,7 +59,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER If YACC_GRAPH_FILE_SUFFIX is not set, it will respect YACCVCGFILESUFFIX. From Sten Grüner - - The newly added --debug=sconscript optiont (new) will output notices when + - The newly added --debug=sconscript option (new) will output notices when entering an exiting each SConscript as they are processed. From Philipp Maierhöfer: diff --git a/RELEASE.txt b/RELEASE.txt index 01ac02d..f3cbb0e 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -79,7 +79,7 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY Any code that did the direct import will have to change to import from SCons.Util.sctypes. - Add JDK 21 LTS support -- The newly added --debug=sconscript optiont (new) will output notices when +- The newly added --debug=sconscript option (new) will output notices when entering an exiting each SConscript as they are processed. FIXES -- cgit v0.12