Skip to content

Commit

Permalink
Updated taskmaster to check srcnode for variant dir files without bui…
Browse files Browse the repository at this point in the history
…lders for issue SCons#2908
  • Loading branch information
dmoody256 committed May 20, 2022
1 parent 1f66961 commit 020ce1a
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Updated ninja scons daemon scripts to output errors to stderr as well as the daemon log.
- Fix typo in ninja scons daemon startup which causes ConnectionRefusedError to not retry
to connect to the server during start up.
- Fix for github issue #2908, this updates taskmaster to queue up srcnodes of nodes which
are in a variantdir if the srcnode has a builder. For the executors prepare, it also
checks the srcnode if the node has a srcnode.

From Mats Wichmann:
- Tweak the way default site_scons paths on Windows are expressed to
Expand Down
5 changes: 4 additions & 1 deletion RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ FIXES
- The system environment variable names imported for MSVC 7.0 and 6.0 were updated to be
consistent with the variables names defined by their respective installers. This fixes an
error caused when bypassing MSVC detection by specifying the MSVC 7.0 batch file directly.

- Fix for github issue #2908, this updates taskmaster to queue up srcnodes of nodes which
are in a variantdir if the srcnode has a builder. For the executors prepare, it also
checks the srcnode if the node has a srcnode.

IMPROVEMENTS
------------

Expand Down
2 changes: 2 additions & 0 deletions SCons/Node/FS.py
Original file line number Diff line number Diff line change
Expand Up @@ -3012,6 +3012,8 @@ def retrieve_from_cache(self):
if self.nocache:
return None
if not self.is_derived():
if self.srcnode().is_derived():
return self.get_build_env().get_CacheDir().retrieve(self.srcnode())
return None
return self.get_build_env().get_CacheDir().retrieve(self)

Expand Down
6 changes: 5 additions & 1 deletion SCons/Node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,11 @@ def get_contents(self):
return _get_contents_map[self._func_get_contents](self)

def missing(self):
return not self.is_derived() and \
# nodes in variant dirs may have a srcnode which is also derived
# so check if that is the case.
return not (self.is_derived() or \
(hasattr(self, 'srcnode')
and self.srcnode().is_derived())) and \
not self.linked and \
not self.rexists()

Expand Down
14 changes: 11 additions & 3 deletions SCons/Taskmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def prepare(self):
# or implicit dependencies exists, and also initialize the
# .sconsign info.
executor = self.targets[0].get_executor()
if executor is None and hasattr(self.targets[0], 'srcnode'):
executor = self.targets[0].srcnode().get_executor()
if executor is None:
return
executor.prepare()
Expand Down Expand Up @@ -232,7 +234,12 @@ def execute(self):
t.fs.unlink(t.get_internal_path())
except (IOError, OSError):
pass
self.targets[0].build()
if self.targets[0].has_builder():
self.targets[0].build()
elif hasattr(self.targets[0], 'srcnode'):
self.targets[0].srcnode().build()
else:
self.targets[0].build()
else:
for t in cached_targets:
t.cached = 1
Expand Down Expand Up @@ -387,7 +394,7 @@ def make_ready_current(self):
for t in self.targets:
try:
t.disambiguate().make_ready()
is_up_to_date = not t.has_builder() or \
is_up_to_date = not (t.has_builder() or (hasattr(t, 'srcnode') and t.srcnode().has_builder())) or \
(not t.always_build and t.is_up_to_date())
except EnvironmentError as e:
raise SCons.Errors.BuildError(node=t, errstr=e.strerror, filename=e.filename)
Expand Down Expand Up @@ -946,11 +953,12 @@ def next_task(self):
it in the specific Task subclass with which we were initialized.
"""
node = self._find_next_ready_node()

if node is None:
return None

executor = node.get_executor()
if executor is None and hasattr(node, 'srcnode'):
executor = node.srcnode().get_executor()
if executor is None:
return None

Expand Down
3 changes: 3 additions & 0 deletions test/VariantDir/derived_srcnode-fixture/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VariantDir('bin', 'src', duplicate=False)
Command('src/file.cc', 'src/file.in', Copy('$TARGET', '$SOURCE'))
Program('bin/program', ['bin/main.cc', 'bin/file.cc'])
Empty file.
1 change: 1 addition & 0 deletions test/VariantDir/derived_srcnode-fixture/src/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main(){return 0;}
51 changes: 51 additions & 0 deletions test/VariantDir/derived_srcnode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/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 reproducing issue https://github.com/SCons/scons/issues/2908
The test makes sure that if the srcnode of a variant dir is
a derived file, that it is built correctly.
"""

import TestSCons

test = TestSCons.TestSCons()

obj_suffix = TestSCons._obj

test.dir_fixture('derived_srcnode-fixture')

test.run(arguments='.')

test.must_exist(test.workpath('src/file.cc'))
test.must_exist(test.workpath('bin/file' + obj_suffix))

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:

0 comments on commit 020ce1a

Please sign in to comment.