Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseTools/Plugin: Add tool exclusion to RustEnvironmentCheck #602

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion BaseTools/Plugin/RustEnvironmentCheck/RustEnvironmentCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
# fail much later during firmware code compilation when Rust tools are invoked
# with messages that are ambiguous or difficult to find.
#
# Note:
# - The entire plugin is enabled/disabled by scope.
# - Individual tools can be opted out by setting the environment variable
# `RUST_ENV_CHECK_TOOL_EXCLUSIONS` with a comma separated list of the tools
# to exclude. For example, "rustup, cargo tarpaulin" would not require that
# those tools be installed.
#
# Copyright (c) Microsoft Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
import logging
import re
from collections import namedtuple
from edk2toolext.environment import shell_environment
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
from edk2toolext.environment.uefi_build import UefiBuilder
from edk2toollib.utility_functions import RunCmd
Expand Down Expand Up @@ -142,9 +150,15 @@ def verify_workspace_rust_toolchain_is_installed() -> RustToolChainInfo:
),
}

excluded_tools_in_shell = shell_environment.GetEnvironment().get_shell_var(
"RUST_ENV_CHECK_TOOL_EXCLUSIONS")
excluded_tools = ([t.strip() for t in
excluded_tools_in_shell.split(",")] if
excluded_tools_in_shell else [])

errors = 0
for tool_name, tool_info in tools.items():
if not verify_cmd(*tool_info.presence_cmd):
if tool_name not in excluded_tools and not verify_cmd(*tool_info.presence_cmd):
logging.error(
f"Rust Environment Failure: {tool_name} is not installed "
"or not on the system path.\n\n"
Expand Down