Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StenGruener's --debug=sconscript #4439

Merged
merged 6 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +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 Max Bachmann:
- Add missing directories to searched paths for mingw installs

Expand Down Expand Up @@ -59,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 option (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
Expand Down
2 changes: 2 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 option (new) will output notices when
entering an exiting each SConscript as they are processed.

FIXES
-----
Expand Down
3 changes: 3 additions & 0 deletions SCons/Debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
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:
Expand Down
2 changes: 2 additions & 0 deletions SCons/Script/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" in debug_values:
SCons.Debug.sconscript_trace = True

def _create_path(plist):
path = '.'
Expand Down
2 changes: 1 addition & 1 deletion SCons/Script/SConsOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def opt_invalid_rm(group, value, msg):
debug_options = ["count", "duplicate", "explain", "findlibs",
"includes", "memoizer", "memory", "objects",
"pdb", "prepare", "presub", "stacktrace",
"time", "action-timestamps", "json"]
"time", "action-timestamps", "json", "sconscript"]

def opt_debug(option, opt, value__, parser,
debug_options=debug_options,
Expand Down
4 changes: 4 additions & 0 deletions SCons/Script/SConscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ def _SConscript(fs, *files, **kw):
scriptdata = _file_.read()
scriptname = _file_.name
_file_.close()
if SCons.Debug.sconscript_trace:
print("scons: Entering "+str(scriptname))
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
if SCons.Debug.sconscript_trace:
print("scons: Exiting "+str(scriptname))
except SConscriptReturn:
pass
finally:
Expand Down
10 changes: 5 additions & 5 deletions SCons/__init__.py
Original file line number Diff line number Diff line change
@@ -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
import SCons.compat # noqa
6 changes: 6 additions & 0 deletions doc/man/scons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,12 @@ since multiple build commands and
intervening SCons processing
should take place in parallel.)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">sconscript</emphasis></term>
<listitem>
<para>Enables output indicating entering and exiting each SConscript file.</para>
</listitem>
</varlistentry>
</variablelist> <!-- end nested list -->
Expand Down
60 changes: 60 additions & 0 deletions test/option/debug-sconscript.py
Original file line number Diff line number Diff line change
@@ -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: