From 2909e28730ab72930f923b55f860d554f3b5e216 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Thu, 13 May 2021 13:22:51 -0400 Subject: 3790 - Add a test which fails --- test/CPPDEFINES/basic.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/CPPDEFINES/basic.py b/test/CPPDEFINES/basic.py index d0019a1..176f543 100644 --- a/test/CPPDEFINES/basic.py +++ b/test/CPPDEFINES/basic.py @@ -39,13 +39,24 @@ test_list = [ ['x', ['y', 123], 'z', ('int', '$INTEGER')], { 'c' : 3, 'b': None, 'a' : 1 }, "${TESTDEFS}", + "${GEN}", ] + +def generator(target, source, env, for_signature): + if target and source: + return '_'.join([str(target[0]), 'GENERATED', str(source[0])]) + return 'TARGET_AND_SOURCE_ARE_MISSING' + for i in test_list: - env = Environment(CPPDEFPREFIX='-D', CPPDEFSUFFIX='', INTEGER=0, TESTDEFS=["FOO", "BAR=1"]) - print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) + env = Environment(CPPDEFPREFIX='-D', CPPDEFSUFFIX='', INTEGER=0, TESTDEFS=["FOO", "BAR=1"], GEN=generator) + ttt = env.Entry('#ttt') + sss = env.Entry('#sss') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS', target=[ttt], source=[sss])) for i in test_list: - env = Environment(CPPDEFPREFIX='|', CPPDEFSUFFIX='|', INTEGER=1, TESTDEFS=["FOO", "BAR=1"]) - print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) + env = Environment(CPPDEFPREFIX='|', CPPDEFSUFFIX='|', INTEGER=1, TESTDEFS=["FOO", "BAR=1"], GEN=generator) + ttt = env.Entry('#ttt') + sss = env.Entry('#sss') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS', target=[ttt], source=[sss])) """) expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", @@ -55,11 +66,13 @@ expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", -Dx -Dy=123 -Dz -Dint=0 -Da=1 -Db -Dc=3 -DFOO -DBAR=1 +-Dttt_GENERATED_sss |xyz| |x| |y| |z| |x| |y=123| |z| |int=1| |a=1| |b| |c=3| |FOO| |BAR=1| +|ttt_GENERATED_sss| """) test.run(arguments = '.', stdout=expect) -- cgit v0.12 From 3467ea5877718f0e31d1718c35fddb108a410d64 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Thu, 13 May 2021 13:23:07 -0400 Subject: 3790 - Fix the failing test --- SCons/Defaults.py | 6 +++--- test/CPPDEFINES/basic.py | 0 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 test/CPPDEFINES/basic.py diff --git a/SCons/Defaults.py b/SCons/Defaults.py index ba42a26..95a2e52 100644 --- a/SCons/Defaults.py +++ b/SCons/Defaults.py @@ -498,12 +498,12 @@ def processDefines(defs): return l -def _defines(prefix, defs, suffix, env, c=_concat_ixes): +def _defines(prefix, defs, suffix, env, target, source, c=_concat_ixes): """A wrapper around _concat_ixes that turns a list or string into a list of C preprocessor command-line definitions. """ - return c(prefix, env.subst_list(processDefines(defs)), suffix, env) + return c(prefix, env.subst_list(processDefines(defs), target=target, source=source), suffix, env) class NullCmdGenerator: @@ -608,7 +608,7 @@ ConstructionEnvironment = { '_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}', '_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', '_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', - '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', + '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__, TARGET, SOURCE)}', '__libversionflags': __libversionflags, '__SHLIBVERSIONFLAGS': '${__libversionflags(__env__,"SHLIBVERSION","_SHLIBVERSIONFLAGS")}', diff --git a/test/CPPDEFINES/basic.py b/test/CPPDEFINES/basic.py old mode 100644 new mode 100755 -- cgit v0.12 From d4caa2cf6939fcae4094ccc2201e57aa662f9790 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Thu, 13 May 2021 17:40:28 -0400 Subject: update changes and release --- CHANGES.txt | 4 ++++ RELEASE.txt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index ff4ae28..89a1dac 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -99,6 +99,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER This will provide a path relative to the top of the build tree (where the SConstruct is located) Fixes #396 + From Andrew Morrow: + - Fix issue #3790: Generators in CPPDEFINES now have access to populated source + and target lists + RELEASE 4.1.0 - Tues, 19 Jan 2021 15:04:42 -0700 From James Benton: diff --git a/RELEASE.txt b/RELEASE.txt index db64ee8..f5c1af3 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -62,6 +62,8 @@ FIXES - The Install builder will now set the writable mode on the file(s) it copies. This restores the (previously undocumented) SCons behavior that regressed as of 4.0.0. + - Fix issue #3790: Generators in CPPDEFINES now have access to populated source + and target lists IMPROVEMENTS -- cgit v0.12