From 0b3038f44c9045f9e4f1616e62b56e56219e5817 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 18 Jan 2024 08:32:16 -0800 Subject: [PATCH] Point virtual includes symlinks to the source root instead of the exec root for bazel. See https://github.com/bazelbuild/bazel/pull/20540. Closes #20540. PiperOrigin-RevId: 599516682 Change-Id: I57ac896c9fe127b428367043015feaaaf7b57339 --- .../builtins_bzl/common/cc/cc_compilation_helper.bzl | 3 ++- src/main/starlark/builtins_bzl/common/cc/semantics.bzl | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_compilation_helper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_compilation_helper.bzl index c9f1f2a3e85cd1..1177edbbd71630 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_compilation_helper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_compilation_helper.bzl @@ -16,6 +16,7 @@ load(":common/cc/cc_common.bzl", "cc_common") load(":common/cc/cc_helper.bzl", "cc_helper") +load(":common/cc/semantics.bzl", "USE_EXEC_ROOT_FOR_VIRTUAL_INCLUDES_SYMLINKS") load(":common/paths.bzl", "paths") cc_internal = _builtins.internal.cc_internal @@ -120,7 +121,7 @@ def _compute_public_headers( output = virtual_header, target_file = original_header, progress_message = "Symlinking virtual headers for " + label.name, - use_exec_root_for_source = True, + use_exec_root_for_source = USE_EXEC_ROOT_FOR_VIRTUAL_INCLUDES_SYMLINKS, ) module_map_headers.append(virtual_header) if config.coverage_enabled: diff --git a/src/main/starlark/builtins_bzl/common/cc/semantics.bzl b/src/main/starlark/builtins_bzl/common/cc/semantics.bzl index 914b39107ff1ab..1e7511a8923af5 100644 --- a/src/main/starlark/builtins_bzl/common/cc/semantics.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/semantics.bzl @@ -14,6 +14,11 @@ """Semantics for Bazel cc rules""" +# Point virtual includes symlinks to the source root for better IDE integration. +# See https://github.com/bazelbuild/bazel/pull/20540. +# TODO: b/320980684 - Add a test that fails if this is flipped to True. +USE_EXEC_ROOT_FOR_VIRTUAL_INCLUDES_SYMLINKS = False + def _get_proto_aspects(): return []