diff --git a/CHANGES.txt b/CHANGES.txt index 2609355a9..9bf0edfc5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -167,9 +167,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER their values taken from the default in the variable description (if a variable was set to the same value as the default in one of the input sources, it is not included in this list). - - The C scanner now does (limited) macro replacement on the values in - CPPDEFINES, to improve results of conditional source file inclusion - (issue #4523). - The (optional) C Conditional Scanner now does limited macro replacement on the contents of CPPDEFINES, to improve finding deps that are conditionally included. Previously replacement was only diff --git a/SCons/Scanner/C.py b/SCons/Scanner/C.py index e111778c9..1d7e101e4 100644 --- a/SCons/Scanner/C.py +++ b/SCons/Scanner/C.py @@ -114,8 +114,19 @@ def _replace(mapping: Dict) -> Dict: old_ns = mapping loops = 0 while loops < 5: # don't recurse forever in case there's circular data - ns = {k: old_ns[v] if v in old_ns else v for k, v in old_ns.items()} - if old_ns == ns: + # this was originally written as a dict comprehension, but unrolling + # lets us add a finer-grained check for whether another loop is + # needed, rather than comparing two dicts to see if one changed. + again = False + ns = {} + for k, v in old_ns.items(): + if v in old_ns: + ns[k] = old_ns[v] + if not again and ns[k] != v: + again = True + else: + ns[k] = v + if not again: break old_ns = ns loops += 1