summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/build/build.py
diff options
context:
space:
mode:
authorYang Gang <yanggang@byosoft.com.cn>2024-12-19 14:01:12 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-09 07:25:45 +0000
commit3ac092cf721010f6f457e268dcbf5be83bfab243 (patch)
treeed025b52bc1a02b3157a61147f820d34195abdd8 /BaseTools/Source/Python/build/build.py
parent8593eca04817583c4a00e35e7890f9e056ee22f9 (diff)
downloadedk2-3ac092cf721010f6f457e268dcbf5be83bfab243.tar.gz
edk2-3ac092cf721010f6f457e268dcbf5be83bfab243.tar.bz2
edk2-3ac092cf721010f6f457e268dcbf5be83bfab243.zip
BaseTools: Clean up os.path.normcase and os.path.normpath usage
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` after `os.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 to `os.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. Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
Diffstat (limited to 'BaseTools/Source/Python/build/build.py')
-rwxr-xr-xBaseTools/Source/Python/build/build.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 5a4f51c580..74b4242a16 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -105,7 +105,7 @@ def CheckEnvVariable():
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",
ExtraData="WORKSPACE")
- WorkspaceDir = os.path.normcase(os.path.normpath(os.environ["WORKSPACE"]))
+ WorkspaceDir = os.path.normpath(os.environ["WORKSPACE"])
if not os.path.exists(WorkspaceDir):
EdkLogger.error("build", FILE_NOT_FOUND, "WORKSPACE doesn't exist", ExtraData=WorkspaceDir)
elif ' ' in WorkspaceDir:
@@ -124,7 +124,7 @@ def CheckEnvVariable():
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in PACKAGES_PATH", ExtraData=Path)
- os.environ["EDK_TOOLS_PATH"] = os.path.normcase(os.environ["EDK_TOOLS_PATH"])
+ os.environ["EDK_TOOLS_PATH"] = os.path.normpath(os.environ["EDK_TOOLS_PATH"])
# check EDK_TOOLS_PATH
if "EDK_TOOLS_PATH" not in os.environ:
@@ -817,11 +817,11 @@ class Build():
EdkLogger.quiet("%-16s = %s" % ("WORKSPACE", os.environ["WORKSPACE"]))
if "PACKAGES_PATH" in os.environ:
# WORKSPACE env has been converted before. Print the same path style with WORKSPACE env.
- EdkLogger.quiet("%-16s = %s" % ("PACKAGES_PATH", os.path.normcase(os.path.normpath(os.environ["PACKAGES_PATH"]))))
+ EdkLogger.quiet("%-16s = %s" % ("PACKAGES_PATH", os.path.normpath(os.environ["PACKAGES_PATH"])))
EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_PATH", os.environ["EDK_TOOLS_PATH"]))
if "EDK_TOOLS_BIN" in os.environ:
# Print the same path style with WORKSPACE env.
- EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", os.path.normcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"]))))
+ EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", os.path.normpath(os.environ["EDK_TOOLS_BIN"])))
EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", GlobalData.gConfDirectory))
if "PYTHON3_ENABLE" in os.environ:
PYTHON3_ENABLE = os.environ["PYTHON3_ENABLE"]
@@ -2685,7 +2685,7 @@ def Main():
if Option.ModuleFile:
if os.path.isabs (Option.ModuleFile):
- if os.path.normcase (os.path.normpath(Option.ModuleFile)).find (Workspace) == 0:
+ if os.path.normcase (os.path.normpath(Option.ModuleFile)).find (os.path.normcase(Workspace)) == 0:
Option.ModuleFile = NormFile(os.path.normpath(Option.ModuleFile), Workspace)
Option.ModuleFile = PathClass(Option.ModuleFile, Workspace)
ErrorCode, ErrorInfo = Option.ModuleFile.Validate(".inf", False)
@@ -2694,13 +2694,13 @@ def Main():
if Option.PlatformFile is not None:
if os.path.isabs (Option.PlatformFile):
- if os.path.normcase (os.path.normpath(Option.PlatformFile)).find (Workspace) == 0:
+ if os.path.normcase (os.path.normpath(Option.PlatformFile)).find (os.path.normcase(Workspace)) == 0:
Option.PlatformFile = NormFile(os.path.normpath(Option.PlatformFile), Workspace)
Option.PlatformFile = PathClass(Option.PlatformFile, Workspace)
if Option.FdfFile is not None:
if os.path.isabs (Option.FdfFile):
- if os.path.normcase (os.path.normpath(Option.FdfFile)).find (Workspace) == 0:
+ if os.path.normcase (os.path.normpath(Option.FdfFile)).find (os.path.normcase(Workspace)) == 0:
Option.FdfFile = NormFile(os.path.normpath(Option.FdfFile), Workspace)
Option.FdfFile = PathClass(Option.FdfFile, Workspace)
ErrorCode, ErrorInfo = Option.FdfFile.Validate(".fdf", False)