Skip to content

Commit 7822e53

Browse files
authored
Merge pull request #3670 from dmoody256/sconscript_node_flags
Added flags for SConscript nodes to be easily identified
2 parents f32dd91 + 2bf0b8a commit 7822e53

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
9292
exception, however SCons was using TypeError to detect if the callable had a different
9393
signature than expected, and would silently fail to report user's exceptions. Fixed to
9494
use signature module to detect function signature instead of TypeError. (Github Issue #3654)
95+
- Added storage of SConstructs and SConscripts nodes into global set for checking
96+
if a given node is a SConstruct/SConscript.
97+
Added new node function SCons.Node.is_sconscript(self) (Github Issue #3625)
9598

9699
From Andrew Morrow:
97100
- Fix Issue #3469 - Fixed improper reuse of temporary and compiled files by Configure when changing

SCons/Node/NodeTests.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,19 @@ def test_literal(self):
12441244
n=SCons.Node.Node()
12451245
assert n.is_literal()
12461246

1247+
def test_sconscripts(self):
1248+
"""Test the is_sconscript() function."""
1249+
# check nodes are not sconscript unless added to the list
1250+
n=SCons.Node.Node()
1251+
n2=SCons.Node.Node()
1252+
assert not n.is_sconscript()
1253+
assert not n2.is_sconscript()
1254+
1255+
# add node to sconscript list and verify
1256+
SCons.Node.SConscriptNodes.add(n2)
1257+
assert not n.is_sconscript()
1258+
assert n2.is_sconscript()
1259+
12471260
def test_Annotate(self):
12481261
"""Test using an interface-specific Annotate function."""
12491262
def my_annotate(node, self=self):

SCons/Node/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def do_nothing_node(node): pass
111111

112112
Annotate = do_nothing_node
113113

114+
# global set for recording all processed SContruct/SConscript nodes
115+
SConscriptNodes = set()
116+
114117
# Gets set to 'True' if we're running in interactive mode. Is
115118
# currently used to release parts of a target's info during
116119
# clean builds and update runs (see release_target_info).
@@ -946,6 +949,10 @@ def is_derived(self):
946949
"""
947950
return _is_derived_map[self._func_is_derived](self)
948951

952+
def is_sconscript(self):
953+
""" Returns true if this node is an sconscript """
954+
return self in SConscriptNodes
955+
949956
def alter_targets(self):
950957
"""Return a list of alternate targets for this Node.
951958
"""

SCons/Script/SConscript.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import SCons.Script.Main
4444
import SCons.Tool
4545
from SCons.Util import is_List, is_String, is_Dict, flatten
46-
46+
from SCons.Node import SConscriptNodes
4747
from . import Main
4848

4949
import collections
@@ -202,6 +202,7 @@ def _SConscript(fs, *files, **kw):
202202
else:
203203
f = fs.File(str(fn))
204204
_file_ = None
205+
SConscriptNodes.add(f)
205206

206207
# Change directory to the top of the source
207208
# tree to make sure the os's cwd and the cwd of

0 commit comments

Comments
 (0)