Skip to content
Closed
Show file tree
Hide file tree
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
18 changes: 16 additions & 2 deletions cc/common/cc_helper_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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"):
Expand All @@ -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())
)

Expand Down
4 changes: 2 additions & 2 deletions cc/private/rules_impl/cc_toolchain_provider_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down