Skip to content

Commit aaf476a

Browse files
pzembrodcopybara-github
authored andcommitted
Migrate CppLinkstampCompileHelper.getVariables() to Starlark.
PiperOrigin-RevId: 811303415 Change-Id: Ia28bbee89626b8bb3515b00fbc5cbee87d33d7fc
1 parent 1f84d1e commit aaf476a

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

cc/common/cc_helper.bzl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ load(
2424
"should_create_per_object_debug_info",
2525
_artifact_category = "artifact_category_names",
2626
_extensions = "extensions",
27+
_is_stamping_enabled = "is_stamping_enabled",
2728
_package_source_root = "package_source_root",
2829
_repository_exec_path = "repository_exec_path",
2930
)
@@ -1059,14 +1060,6 @@ def _linker_scripts(ctx):
10591060
result.append(f)
10601061
return result
10611062

1062-
def _is_stamping_enabled(ctx):
1063-
if ctx.configuration.is_tool_configuration():
1064-
return 0
1065-
stamp = 0
1066-
if hasattr(ctx.attr, "stamp"):
1067-
stamp = ctx.attr.stamp
1068-
return stamp
1069-
10701063
def _has_target_constraints(ctx, constraints):
10711064
# Constraints is a label_list.
10721065
for constraint in constraints:

cc/common/cc_helper_internal.bzl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ def repository_exec_path(repository, sibling_repository_layout):
216216
repository = repository[1:]
217217
return get_relative_path(prefix, repository)
218218

219+
def is_stamping_enabled(ctx):
220+
"""Returns whether to encode build information into the binary.
221+
222+
Args:
223+
ctx: The rule context.
224+
225+
Returns:
226+
(int): 1: Always stamp the build information into the binary, even in [--nostamp][stamp] builds.
227+
This setting should be avoided, since it potentially kills remote caching for the binary and
228+
any downstream actions that depend on it.
229+
0: Always replace build information by constant values. This gives good build result caching.
230+
-1: Embedding of build information is controlled by the [--[no]stamp][stamp] flag.
231+
"""
232+
if ctx.configuration.is_tool_configuration():
233+
return 0
234+
stamp = 0
235+
if hasattr(ctx.attr, "stamp"):
236+
stamp = ctx.attr.stamp
237+
return stamp
238+
219239
# LINT.ThenChange(https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl:forked_exports)
220240

221241
def get_relative_path(path_a, path_b):

0 commit comments

Comments
 (0)