Skip to content

Commit

Permalink
BaseTools/ClangPdbToolChain: Improve CLANG_BIN guidance (#1278)
Browse files Browse the repository at this point in the history
## Description

Explain whether the default path or a user provided path was used. If
the default path is used and not present, then indicate so and give the
shell variable name to set to a custom installation bin directory.

- [ ] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?
- [x] Backport to release branch?

## How This Was Tested

- Test with clang path set to a valid and invalid path.

## Integration Instructions

- N/A

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored Feb 13, 2025
1 parent 069e167 commit dda9d4e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions BaseTools/Plugin/ClangPdbToolChain/ClangPdbToolChain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ def do_post_build(self, thebuilder):

def do_pre_build(self, thebuilder):
self.Logger = logging.getLogger("ClangPdbToolChain")

##
# CLANGPBD
# - Need to find the clang path.
# - Report path and version for logging
#
#
# if CLANG_BIN already set the plugin will confirm it exists and get the version of clang
# If not set it will look for clang on the path. If found it will configure for that.
# if still not found it will try the default install directory.
# if still not found it will try the default install directory.
# finally an error will be reported if not found
##
if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "CLANGPDB":

HostInfo = GetHostInfo()
ClangBin_Default = "UNDEFINED"
clang_exe = "clang"
Expand Down Expand Up @@ -67,10 +67,15 @@ def do_pre_build(self, thebuilder):

version_aggregator.GetVersionAggregator().ReportVersion(
"CLANG BIN", ClangBin, version_aggregator.VersionTypes.INFO)

# now confirm it exists
if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("CLANG_BIN")):
self.Logger.error(f"Path for CLANGPDB toolchain is invalid. {ClangBin}")
self.Logger.error("Clang was not found!")
if ClangBin == ClangBin_Default:
self.Logger.error(f"The default clang bin path does not exist: {ClangBin.rstrip(os.sep)}.")
self.Logger.error("Set the CLANG_BIN variable in your shell to the installation bin directory.")
else:
self.Logger.error(f"The path provided in CLANG_BIN does not exist: {ClangBin}.")
return -2

version_aggregator.GetVersionAggregator().ReportVersion(
Expand Down

0 comments on commit dda9d4e

Please sign in to comment.