BaseTools: Clean up os.path.normcase and os.path.normpath usage #6561
+12
−12
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.
Refer to the docs of python,
os.path.normcase(path)
function: "Normalize the case of a pathname. On Windows, convert all characters in the pathname to lowercase, and also convert forward slashes to backward slashes. On other operating systems, return the path unchanged."os.path.normpath(path)
also convert forward slashes to backward slashes.So call
os.path.normcase
afteros.path.normpath
just convert path to lowercase on Windows(only).And Windows is case-insensitive but case-preserving.
So the usage of
os.path.normcase(os.path.normpath(path))
can be simplified toos.path.normpath(path)
. Then we can use case-preserving paths rather than lowercase paths in compile_commands.json file or build log.But this patch continue to use
os.path.normcase
when comparing/searching paths.
Description
Breaking change?
Impacts security?
Includes tests?
How This Was Tested
Compare build log.
Or use
-y report.txt -Y COMPILE_INFO
and compare workspace path string in report.txt or CompileInfo/compile_commands.json file.e.g.
In build log output:
before:
WORKSPACE = d:\opensource\edk2
after:
WORKSPACE = D:\OpenSource\edk2
D:\OpenSource is matched with real charactor case in FileExplorer/CMD...
Integration Instructions
N/A