Skip to content

Commit

Permalink
Fix for SCons#2757, non conftest nodes involved in configure checks n…
Browse files Browse the repository at this point in the history
…ow get node info cleared after check.
  • Loading branch information
dmoody256 committed May 26, 2022
1 parent 5054f70 commit b2b7a3c
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ 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 issue #2757, configure checks now clear node info for non conftest nodes, so they
will be re-evaluated for the real taskmaster run when the build commences.

From Mats Wichmann:
- Tweak the way default site_scons paths on Windows are expressed to
Expand Down
2 changes: 2 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ 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 issue #2757, configure checks now clear node info for non conftest nodes, so they
will be re-evaluated for the real taskmaster run when the build commences.

IMPROVEMENTS
------------
Expand Down
13 changes: 13 additions & 0 deletions SCons/SConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask):
This is almost the same as SCons.Script.BuildTask. Handles SConfErrors
correctly and knows about the current cache_mode.
"""
sconf_nodes = set()

def display(self, message):
if sconf_global.logstream:
sconf_global.logstream.write("scons: Configure: " + message + "\n")
Expand Down Expand Up @@ -376,6 +378,17 @@ def execute(self):
sconsign.set_entry(t.name, sconsign_entry)
sconsign.merge()

def make_ready_current(self):
self.sconf_nodes.update(self.targets)
super().make_ready_current()
make_ready = make_ready_current

def postprocess(self):
for node in self.sconf_nodes:
if not node.is_conftest():
node.ninfo = node.new_ninfo()
super().postprocess()

class SConfBase:
"""This is simply a class to represent a configure context. After
creating a SConf object, you can call any tests. After finished with your
Expand Down
2 changes: 2 additions & 0 deletions SCons/SConfTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def built(self):
pass
def get_stored_info(self):
pass
def is_conftest(self):
return True
def get_executor(self):
class Executor:
def __init__(self, targets):
Expand Down
52 changes: 52 additions & 0 deletions test/Configure/conftest_source_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/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.

"""
Template for end-to-end test file.
Replace this with a description of the test.
"""

import TestSCons

test = TestSCons.TestSCons()

test.dir_fixture("conftest_source_file")

test.run(arguments='.')

test.write('header2.h', """
#pragma once
int test_header = 2;
""")

test.not_up_to_date(read_str="Checking for C header file header1.h... (cached) yes\n")

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
6 changes: 6 additions & 0 deletions test/Configure/conftest_source_file/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
env = Environment()
env.Append(CPPPATH=['.'])
conf1 = Configure(env)
conf1.CheckHeader("header1.h")
conf1.Finish()
env.Program('out', 'main.c')
2 changes: 2 additions & 0 deletions test/Configure/conftest_source_file/header1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "header2.h"
2 changes: 2 additions & 0 deletions test/Configure/conftest_source_file/header2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
int test_header = 1;
2 changes: 2 additions & 0 deletions test/Configure/conftest_source_file/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "header1.h"
int main(){return 0;}
4 changes: 2 additions & 2 deletions test/sconsign/script/Configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
%(sig_re)s \[.*\]
conftest_%(sig_re)s_0_%(sig_re)s%(_obj)s:
%(_sconf_temp_conftest_0_c)s: %(sig_re)s \d+ \d+
%(CC)s: %(sig_re)s \d+ \d+
%(CC)s: %(sig_re)s None None
%(sig_re)s \[.*\]
=== %(CC_dir)s:
%(CC_file)s: %(sig_re)s \d+ \d+
%(CC_file)s: None None None
""" % locals()

# grab .sconsign or .sconsign_<hashname>
Expand Down
4 changes: 2 additions & 2 deletions testing/framework/TestSCons.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def up_to_date(self, arguments='.', read_str="", **kw):
kw['match'] = self.match_re_dotall
self.run(**kw)

def not_up_to_date(self, arguments='.', **kw):
def not_up_to_date(self, arguments='.', read_str="", **kw):
"""Asserts that none of the targets listed in arguments is
up to date, but does not make any assumptions on other targets.
This function is most useful in conjunction with the -n option.
Expand All @@ -499,7 +499,7 @@ def not_up_to_date(self, arguments='.', **kw):
s = s + "(?!scons: `%s' is up to date.)" % re.escape(arg)
s = '(' + s + '[^\n]*\n)*'
kw['arguments'] = arguments
stdout = re.escape(self.wrap_stdout(build_str='ARGUMENTSGOHERE'))
stdout = re.escape(self.wrap_stdout(read_str=read_str, build_str='ARGUMENTSGOHERE'))
kw['stdout'] = stdout.replace('ARGUMENTSGOHERE', s)
kw['match'] = self.match_re_dotall
self.run(**kw)
Expand Down

0 comments on commit b2b7a3c

Please sign in to comment.