From 9d6d50a8172a77a37411d05c580cb9d0430fecc7 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sat, 25 Jul 2020 04:39:48 +0000 Subject: Added method to check if node is used in sconf --- CHANGES.txt | 21 ++++++++++++--------- SCons/Node/NodeTests.py | 17 +++++++++++++++-- SCons/Node/__init__.py | 10 +++++++++- SCons/SConf.py | 8 ++++++++ 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index bbd7ae1..20df0d0 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -30,6 +30,9 @@ RELEASE 4.0.1 - Mon, 16 Jul 2020 16:06:40 -0700 - Added Environment() variable TEMPFILEDIR which allows setting the directory which temp files createdby TEMPFILEMUNGE are created in. + From Daniel Moody: + - Added method on Node to test if its node used in SConf. (Github Issue #3626) + RELEASE 4.0.0 - Sat, 04 Jul 2020 12:00:27 +0000 @@ -53,7 +56,7 @@ RELEASE 4.0.0 - Sat, 04 Jul 2020 12:00:27 +0000 From Joseph Brill: - MSVC updates: When there are multiple product installations (e.g, Community and - Build Tools) of MSVC 2017 or MSVC 2019, an Enterprise, Professional, + Build Tools) of MSVC 2017 or MSVC 2019, an Enterprise, Professional, or Community installation will be selected before a Build Tools installation when "14.1" or "14.2" is requested, respectively. (GH Issue #3699). - MSVC updates: When there are multiple product installations of MSVC 2017 (e.g., @@ -67,7 +70,7 @@ RELEASE 4.0.0 - Sat, 04 Jul 2020 12:00:27 +0000 - Test update: Reduce the number of "false negative" test failures for the interactive configuration test (test/interactive/configure.py). - MSVS update: Fix the development environment path for MSVS 7.0. - + From William Deegan: - Fix broken clang + MSVC 2019 combination by using MSVC configuration logic to propagate'VCINSTALLDIR' and 'VCToolsInstallDir' which clang tools use to locate @@ -84,9 +87,9 @@ RELEASE 4.0.0 - Sat, 04 Jul 2020 12:00:27 +0000 - Add msys2 installed mingw default path to PATH for mingw tool. - C:\msys64\mingw64\bin - Purge obsolete internal build and tooling scripts - - Allow user specified location for vswhere.exe specified by VSWHERE. + - Allow user specified location for vswhere.exe specified by VSWHERE. NOTE: This must be set at the time the 'msvc' 'msvs' and/or 'mslink' tool(s) are initialized to have any effect. - - Resolve Issue #3451 and Issue #3450 - Rewrite SCons setup.py and packaging. Move script logic to entry points so + - Resolve Issue #3451 and Issue #3450 - Rewrite SCons setup.py and packaging. Move script logic to entry points so package can create scripts which use the correct version of Python. - Resolve Issue #3248 - Removing '-Wl,-Bsymbolic' from SHLIBVERSIONFLAGS NOTE: If your build depends on the above you must now add to your SHLIBVERSIONFLAGS @@ -140,16 +143,16 @@ RELEASE 4.0.0 - Sat, 04 Jul 2020 12:00:27 +0000 that instructs scons to use single line drawing characters to draw the dependency tree. From Daniel Moody: - - Add no_progress (-Q) option as a set-able option. However, setting it in the + - Add no_progress (-Q) option as a set-able option. However, setting it in the SConstruct/SConscript will still cause "scons: Reading SConscript files ..." to be printed, since the option is not set when the build scripts first get read. - Added check for SONAME in environment to setup symlinks correctly (Github Issue #3246) - - User callable's called during substition expansion could possibly throw a TypeError - exception, however SCons was using TypeError to detect if the callable had a different - signature than expected, and would silently fail to report user's exceptions. Fixed to + - User callable's called during substition expansion could possibly throw a TypeError + exception, however SCons was using TypeError to detect if the callable had a different + signature than expected, and would silently fail to report user's exceptions. Fixed to use signature module to detect function signature instead of TypeError. (Github Issue #3654) - Added storage of SConstructs and SConscripts nodes into global set for checking - if a given node is a SConstruct/SConscript. + if a given node is a SConstruct/SConscript. Added new node function SCons.Node.is_sconscript(self) (Github Issue #3625) From Andrew Morrow: diff --git a/SCons/Node/NodeTests.py b/SCons/Node/NodeTests.py index f09d367..729be01 100644 --- a/SCons/Node/NodeTests.py +++ b/SCons/Node/NodeTests.py @@ -584,7 +584,7 @@ class NodeTestCase(unittest.TestCase): def test_get_csig(self): """Test generic content signature calculation """ - + class TestNodeInfo(SCons.Node.NodeInfoBase): __slots__ = ('csig',) try: @@ -623,7 +623,7 @@ class NodeTestCase(unittest.TestCase): __slots__ = ('csig',) SCons.Node.Node.NodeInfo = TestNodeInfo node = SCons.Node.Node() - + binfo = node.get_binfo() assert isinstance(binfo, SCons.Node.BuildInfoBase), binfo @@ -1257,6 +1257,19 @@ class NodeTestCase(unittest.TestCase): assert not n.is_sconscript() assert n2.is_sconscript() + def test_conftests(self): + """Test the is_conftest() function.""" + # check nodes are not sconscript unless added to the list + n=SCons.Node.Node() + n2=SCons.Node.Node() + assert not n.is_conftest() + assert not n2.is_conftest() + + # add node to sconscript list and verify + n2.attributes.conftest_node = 1 + assert not n.is_conftest() + assert n2.is_conftest() + def test_Annotate(self): """Test using an interface-specific Annotate function.""" def my_annotate(node, self=self): diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py index 82bb715..8456a26 100644 --- a/SCons/Node/__init__.py +++ b/SCons/Node/__init__.py @@ -781,7 +781,7 @@ class Node(object, metaclass=NoSlotsPyPy): # Handle issue where builder emits more than one target and # the source file for the builder is generated. # in that case only the first target was getting it's .implicit - # cleared when the source file is built (second scan). + # cleared when the source file is built (second scan). # leaving only partial implicits from scan before source file is generated # typically the compiler only. Then scanned files are appended # This is persisted to sconsign and rebuild causes false rebuilds @@ -953,6 +953,14 @@ class Node(object, metaclass=NoSlotsPyPy): """ Returns true if this node is an sconscript """ return self in SConscriptNodes + def is_conftest(self): + """ Returns true if this node is an conftest node""" + try: + test = self.attributes.conftest_node + except AttributeError: + return False + return True + def alter_targets(self): """Return a list of alternate targets for this Node. """ diff --git a/SCons/SConf.py b/SCons/SConf.py index b49667b..6e2a0ba 100644 --- a/SCons/SConf.py +++ b/SCons/SConf.py @@ -520,6 +520,7 @@ class SConfBase: # we override the store_info() method with a null place-holder # so we really control how it gets written. for n in nodes: + self._set_conftest_node(n) n.store_info = 0 if not hasattr(n, 'attributes'): n.attributes = SCons.Node.Node.Attrs() @@ -532,6 +533,7 @@ class SConfBase: for c in n.children(scan=False): # Keep debug code here. # print("Checking [%s] for builders and then setting keep_targetinfo"%c) + self._set_conftest_node(c) if c.has_builder(): n.store_info = 0 if not hasattr(c, 'attributes'): @@ -596,6 +598,7 @@ class SConfBase: nodesToBeBuilt = [] sourcetext = self.env.Value(text) + self._set_conftest_node(sourcetext) f = "conftest" if text is not None: @@ -605,12 +608,14 @@ class SConfBase: f = "_".join([f, textSig, textSigCounter]) textFile = self.confdir.File(f + extension) + self._set_conftest_node(sourcetext) textFileNode = self.env.SConfSourceBuilder(target=textFile, source=sourcetext) nodesToBeBuilt.extend(textFileNode) source = textFile target = textFile.File(f + "SConfActionsContentDummyTarget") + self._set_conftest_node(target) else: source = None target = None @@ -729,6 +734,9 @@ class SConfBase: if not os.path.isdir( dirName ): os.makedirs( dirName ) + def _set_conftest_node(self, node): + node.attributes.conftest_node = 1 + def _startup(self): """Private method. Set up logstream, and set the environment variables necessary for a piped build -- cgit v0.12