Fix issue causing scanners to receive incorrect paths #3494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request resolves an issue where scanners receive an incorrect path if they use
PathList
as theirpath_function
. It also includes a test to demonstrate the issue.PathList
can be used by scanners to easily get a list of paths corresponding to a specific variable in the environment. For example, theProgramScanner
sets itspath_function
to the result of the callSCons.Scanner.FindPathDirs('LIBPATH')
.The issue happens when the following conditions are all true (demonstrated by the included test):
env['LIBPATH']
) references a subdirectory of that directory node.Here is a summary of why the issue is happening.
The PathList
class converts the directory to a string, thus turning it into a relative path to the source root. When thePathList
class evaluates the string (e.g."$SDKROOT/include"
) it substitutes the directory to a string and ends up with a path that is correct relative to the source root. However, it then applies that path as being relative to the SConscript file, which is not correct.I am not wedded to the current fix but it is the most compelling fix that I have been able to find. In this case it is dangerous to operate on relative paths, so the fix is to operate on absolute paths when doing string substitution in the
PathList
class. Object substitution (e.g. if the string being substituted is"$SDKROOT"
instead of"$SDKROOT/include"
) continues to work as before.Contributor Checklist:
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)