Factor out function should_create_test_dwp_for_statically_linked_test
PiperOrigin-RevId: 827968328
Change-Id: Ibb35c4aa4ae13a01fed8e7419df1b3f7942d8630
diff --git a/cc/common/cc_helper.bzl b/cc/common/cc_helper.bzl
index cb95dbc..51f2309 100644
--- a/cc/common/cc_helper.bzl
+++ b/cc/common/cc_helper.bzl
@@ -1082,6 +1082,9 @@
return True
return False
+def _should_create_test_dwp_for_statically_linked_test(is_test, linking_mode, cpp_config):
+ return is_test and linking_mode != linker_mode.LINKING_DYNAMIC and cpp_config.build_test_dwp()
+
cc_helper = struct(
rule_error = _rule_error,
attribute_error = _attribute_error,
@@ -1138,5 +1141,6 @@
should_create_per_object_debug_info = should_create_per_object_debug_info,
has_target_constraints = _has_target_constraints,
package_exec_path = _package_exec_path,
+ should_create_test_dwp_for_statically_linked_test = _should_create_test_dwp_for_statically_linked_test,
)
# LINT.ThenChange(https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl:forked_exports)
diff --git a/cc/private/rules_impl/cc_binary.bzl b/cc/private/rules_impl/cc_binary.bzl
index 16de98f..c8f4573 100644
--- a/cc/private/rules_impl/cc_binary.bzl
+++ b/cc/private/rules_impl/cc_binary.bzl
@@ -713,7 +713,7 @@
explicit_dwp_file = dwp_file
if not cc_helper.should_create_per_object_debug_info(feature_configuration, cpp_config):
explicit_dwp_file = None
- elif ctx.attr._is_test and linking_mode != linker_mode.LINKING_DYNAMIC and cpp_config.build_test_dwp():
+ elif cc_helper.should_create_test_dwp_for_statically_linked_test(ctx.attr._is_test, linking_mode, cpp_config):
files_to_build_list.append(dwp_file)
# If the binary is linked dynamically and COPY_DYNAMIC_LIBRARIES_TO_BINARY is enabled, collect