From e863e1bc71aea05c554e6d06014b51c19f5a6bf5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 27 Feb 2019 14:41:06 -0800 Subject: Add test for GH Issue #3303 --- test/Configure/option--config.py | 10 ++++++++++ test/fixture/test_main.c | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 test/fixture/test_main.c diff --git a/test/Configure/option--config.py b/test/Configure/option--config.py index 80a8bcd..02f10ce 100644 --- a/test/Configure/option--config.py +++ b/test/Configure/option--config.py @@ -122,6 +122,9 @@ test.checkLogAndStdout(["Checking for C header file non_system_header0.h... ", [((".c", CR), (_obj, NCR))]], "config.log", ".sconf_temp", "SConstruct") + +test.file_fixture('test_main.c') + # Check the combination of --config=force and Decider('MD5-timestamp') # On second run there was an issue where the decider would throw DeciderNeedsNode # exception which the configure code didn't handle. @@ -132,12 +135,19 @@ env.Decider('MD5-timestamp') conf = Configure(env) conf.TryLink('int main(){return 0;}','.c') env = conf.Finish() +env.Program('test_main.c') """) test.run(arguments='--config=force') # On second run the sconsign is loaded and decider doesn't just indicate need to rebuild test.run(arguments='--config=force') test.must_not_contain(test.workpath('config.log'), "TypeError: 'NoneType' object is not callable", mode='r') +# Now check to check that test_main.c didn't rebuild on second run above. +# This fixes an issue where --config=force overwrites the Environments decider and is not reset when +# the configure context is done. +# https://github.com/SCons/scons/issues/3303 +test.fail_test(test.stdout().find('test_main.o') != -1) + test.pass_test() # Local Variables: diff --git a/test/fixture/test_main.c b/test/fixture/test_main.c new file mode 100644 index 0000000..adbe919 --- /dev/null +++ b/test/fixture/test_main.c @@ -0,0 +1,4 @@ +int main( int argc, char* argv[] ) +{ + return 0; +} -- cgit v0.12 From 043f3fe3c182730eca17d68030f1de34fa88477e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 27 Feb 2019 14:42:01 -0800 Subject: Fix Issue #3303 --config=force overwritting passed in Environment's Decider and not cleaning it up when configure context is complete --- src/CHANGES.txt | 2 + src/engine/SCons/Environment.py | 1 + src/engine/SCons/SConf.py | 81 +++++++++++++++++++++++++++++------------ 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4acfcba..8fccdeb 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,6 +14,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER The Configure logic directly calls the decider when using --config=force but wasn't handling that exception. This would yield minimally configure tests using TryLink() not running and leaving TypeError Nonetype exception in config.log + - Fix Issue #3303 - Handle --config=force overwriting the Environment passed into Configure()'s + Decider and not clearing it when the configure context is completed. From Daniel Moody: - Change the default for AppendENVPath to delete_existing=0, so path diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 152f0bc..eea8aed 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -2372,6 +2372,7 @@ class OverrideEnvironment(Base): kw = copy_non_reserved_keywords(kw) self.__dict__['overrides'].update(semi_deepcopy(kw)) + # The entry point that will be used by the external world # to refer to a construction environment. This allows the wrapper # interface to extend a construction environment for its own purposes diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index f23c401..b123c11 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -324,24 +324,6 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): s = sys.stdout = sys.stderr = Streamer(sys.stdout) try: env = self.targets[0].get_build_env() - if cache_mode == FORCE: - # Set up the Decider() to force rebuilds by saying - # that every source has changed. Note that we still - # call the environment's underlying source decider so - # that the correct .sconsign info will get calculated - # and keep the build state consistent. - def force_build(dependency, target, prev_ni, - env_decider=env.decide_source, - node=None): - try: - env_decider(dependency, target, prev_ni) - except DeciderNeedsNode as e: - e.decider(target, prev_ni, node=target) - except Exception as e: - raise e - return True - if env.decide_source.__code__ is not force_build.__code__: - env.Decider(force_build) env['PSTDOUT'] = env['PSTDERR'] = s try: sconf.cached = 0 @@ -412,12 +394,42 @@ class SConfBase(object): build tests in the VariantDir, not in the SourceDir) """ global SConfFS + + # Now create isolated override so setting source_decider doesn't affect parent Environment + if cache_mode == FORCE: + self.original_env = env + self.env = env.Clone() + + # Set up the Decider() to force rebuilds by saying + # that every source has changed. Note that we still + # call the environment's underlying source decider so + # that the correct .sconsign info will get calculated + # and keep the build state consistent. + def force_build(dependency, target, prev_ni, + env_decider=env.decide_source, + node=None): + try: + env_decider(dependency, target, prev_ni) + except DeciderNeedsNode as e: + e.decider(target, prev_ni, node=target) + except Exception as e: + raise e + return True + + if self.env.decide_source.__code__ is not force_build.__code__: + self.env.Decider(force_build) + + else: + self.env = env + + # print("Override env:%s"%env) + if not SConfFS: SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: raise SCons.Errors.UserError - self.env = env + if log_file is not None: log_file = SConfFS.File(env.subst(log_file)) self.logfile = log_file @@ -456,6 +468,7 @@ class SConfBase(object): env = sconf.Finish() """ self._shutdown() + return self.env def Define(self, name, value = None, comment = None): @@ -510,6 +523,20 @@ class SConfBase(object): n.attributes = SCons.Node.Node.Attrs() n.attributes.keep_targetinfo = 1 + if True: + # Some checkers have intermediate files (for example anything that compiles a c file into a program to run + # Those files need to be set to not release their target info, otherwise taskmaster will throw a + # Nonetype not callable + for c in n.children(scan=False): + # Keep debug code here. + # print("Checking [%s] for builders and then setting keep_targetinfo"%c) + if c.has_builder(): + n.store_info = 0 + if not hasattr(c, 'attributes'): + c.attributes = SCons.Node.Node.Attrs() + c.attributes.keep_targetinfo = 1 + # pass + ret = 1 try: @@ -746,10 +773,18 @@ class SConfBase(object): self.logstream.write("\n") self.logstream.close() self.logstream = None - # remove the SConfSourceBuilder from the environment - blds = self.env['BUILDERS'] - del blds['SConfSourceBuilder'] - self.env.Replace( BUILDERS=blds ) + + # Now reset the decider if we changed it due to --config=force + # We saved original Environment passed in and cloned it to isolate + # it from being changed. + if cache_mode == FORCE: + self.env.Decider(self.original_env.decide_source) + + # remove the SConfSourceBuilder from the environment + blds = self.env['BUILDERS'] + del blds['SConfSourceBuilder'] + self.env.Replace( BUILDERS=blds ) + self.active = 0 sconf_global = None if not self.config_h is None: -- cgit v0.12 From 910af82db286c12414b2abc252c484bcaaa9beb4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 28 Feb 2019 11:20:58 -0500 Subject: Update SConf tests to add scan arg to mocked out Node children() method since this is now used by SConf's logic --- src/engine/SCons/SConfTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index cf8a7fb..ff544f5 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -194,7 +194,7 @@ class SConfTestCase(unittest.TestCase): pass def add_post_action(self, *actions): pass - def children(self): + def children(self, scan = 1): return [] def get_state(self): return self.state -- cgit v0.12 From 2ea6b7a551620c56f61a5dd9a9c94e342993795e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 28 Feb 2019 13:21:58 -0500 Subject: Add debug logic to try to find why test/TEX/variant_dir.py is failing not finding dvipdf --- .travis/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis/install.sh b/.travis/install.sh index c1a4d02..b4b9ef1 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -47,4 +47,6 @@ else tar xzf rel-3.0.12.tar.gz cd swig-rel-3.0.12 && ./autogen.sh && ./configure --prefix=/usr && make && sudo make install && cd .. fi + + which dvipdf fi -- cgit v0.12