diff --git a/cc/common/cc_helper_internal.bzl b/cc/common/cc_helper_internal.bzl index 320954b4e..8fb4810e0 100644 --- a/cc/common/cc_helper_internal.bzl +++ b/cc/common/cc_helper_internal.bzl @@ -282,6 +282,20 @@ def repository_exec_path(repository, sibling_repository_layout): repository = repository[1:] return get_relative_path(prefix, repository) +def is_tool_configuration(ctx): + """Returns whether the current configuration is a tool configuration. + + Args: + ctx: The rule context. + + Returns: + true if the current configuration is a tool configuration, false otherwise. + """ + attr = ctx.configuration.is_tool_configuration + if type(attr) == type(True): + return attr + return attr() + def is_stamping_enabled(ctx): """Returns the tri-state of whether to encode build information into the binary. @@ -296,7 +310,7 @@ def is_stamping_enabled(ctx): 0: Always replace build information by constant values. This gives good build result caching. -1: Embedding of build information is controlled by the [--[no]stamp][stamp] flag. """ - if ctx.configuration.is_tool_configuration(): + if is_tool_configuration(ctx): return 0 stamp = 0 if hasattr(ctx.attr, "stamp"): @@ -315,7 +329,7 @@ def should_stamp(ctx): true if stamping should be performed, false otherwise. """ stamping_tri_state = is_stamping_enabled(ctx) - return False if ctx.configuration.is_tool_configuration() else ( + return False if is_tool_configuration(ctx) else ( stamping_tri_state == 1 or (stamping_tri_state == -1 and ctx.configuration.stamp_binaries()) ) diff --git a/cc/private/rules_impl/cc_toolchain_provider_helper.bzl b/cc/private/rules_impl/cc_toolchain_provider_helper.bzl index 33a088cb9..f6b24fb74 100644 --- a/cc/private/rules_impl/cc_toolchain_provider_helper.bzl +++ b/cc/private/rules_impl/cc_toolchain_provider_helper.bzl @@ -17,7 +17,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("//cc/common:cc_common.bzl", "cc_common") load("//cc/common:cc_helper.bzl", "cc_helper") -load("//cc/common:cc_helper_internal.bzl", "get_relative_path") +load("//cc/common:cc_helper_internal.bzl", "get_relative_path", "is_tool_configuration") load("//cc/common:cc_info.bzl", "CcInfo") load("//cc/private/rules_impl/fdo:fdo_context.bzl", "create_fdo_context") load(":cc_toolchain_info.bzl", "CcToolchainInfo") @@ -256,7 +256,7 @@ def get_cc_toolchain_provider(ctx, attributes): built_in_include_directories = builtin_include_directories, sysroot = sysroot, fdo_context = fdo_context, - is_tool_configuration = ctx.configuration.is_tool_configuration(), + is_tool_configuration = is_tool_configuration(ctx), is_sibling_repository_layout = ctx.configuration.is_sibling_repository_layout(), stamp_binaries = ctx.configuration.stamp_binaries(), tool_paths = tool_paths,