summaryrefslogtreecommitdiffstats
path: root/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py
diff options
context:
space:
mode:
authormergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-27 16:26:54 +0000
committerGitHub <noreply@github.com>2024-08-27 16:26:54 +0000
commit1bf1b9cc9b55fde85d44a22f829cf09f41a974ab (patch)
treefeb30fce2c8f5cdba62210d726a7f3ad2ab7035b /BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py
parent911a62f1327a7a689e3d061efc4e62508521d48d (diff)
parentb2a431868c4ae0ad99def0a504d2fe097e16cd4f (diff)
downloadedk2-dependabot/github_actions/github/issue-labeler-3.4.tar.gz
Merge branch 'master' into dependabot/github_actions/github/issue-labeler-3.4dependabot/github_actions/github/issue-labeler-3.4
Diffstat (limited to 'BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py')
-rw-r--r--BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py b/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py
index ec2f2d1298..348e847fa7 100644
--- a/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py
+++ b/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py
@@ -6,24 +6,40 @@
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
-import os
+import logging
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
import edk2toollib.windows.locate_tools as locate_tools
from edk2toolext.environment import shell_environment
from edk2toolext.environment import version_aggregator
+from pathlib import Path
-class WinRcPath(IUefiBuildPlugin):
- def do_post_build(self, thebuilder):
- return 0
+class WinRcPath(IUefiBuildPlugin):
def do_pre_build(self, thebuilder):
- #get the locate tools module
+ # Check if the rc.exe path is already cached and still exists
+ cache_path = Path(thebuilder.ws, "Conf", ".rc_path")
+ if cache_path.exists():
+ with open(cache_path, "r") as f:
+ rc_path = Path(f.readline().strip()).absolute()
+ if (rc_path / "rc.exe").exists():
+ logging.debug(f"Found rc.exe folder in cache: {rc_path}")
+ self._set_path(rc_path)
+ return 0
+
+ # If it does not exist, try to find it with FindToolInWinSdk
path = locate_tools.FindToolInWinSdk("rc.exe")
if path is None:
- thebuilder.logging.warning("Failed to find rc.exe")
- else:
- p = os.path.abspath(os.path.dirname(path))
- shell_environment.GetEnvironment().set_shell_var("WINSDK_PATH_FOR_RC_EXE", p)
- version_aggregator.GetVersionAggregator().ReportVersion("WINSDK_PATH_FOR_RC_EXE", p, version_aggregator.VersionTypes.INFO)
+ logging.critical("Failed to find rc.exe")
+ return 1
+
+ path = Path(path).absolute().parent
+ self._set_path(path)
+ cache_path.unlink(missing_ok=True)
+ with cache_path.open("w") as f:
+ f.write(str(path))
return 0
+
+ def _set_path(self, path: Path):
+ shell_environment.GetEnvironment().set_shell_var("WINSDK_PATH_FOR_RC_EXE", str(path))
+ version_aggregator.GetVersionAggregator().ReportVersion("WINSDK_PATH_FOR_RC_EXE", str(path), version_aggregator.VersionTypes.INFO)