-- mylib.cc --
#include "external.h"
#ifdef EXTERNAL2_H
#include "external2.h"
#endif
-- BUILD --
# gazelle:cc_group unit
# gazelle:cc_platform linux x86_64 //:on_linux_x86_64
# gazelle:cc_indexfile external.ccindex
-- external.ccindex --
{
"external.h": "@external//:external",
"external2.h": "@external//:external"
}
it will generate duplicate dependencies (@external)
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "mylib",
srcs = ["mylib.cc"],
implementation_deps = [
"@external",
] + select({
"//conditions:default": ["@external"],
}),
visibility = ["//visibility:public"],
)
I think since EXTERNAL2_H is not defined, the #include "external2.h" directive is conditionally disabled and treated by Gazelle as a constrained dependency, while the unconditional #include "external.h" is treated as a generic dependency. Because both headers map to the same Bazel target (@external//:external) in external.ccindex, this results in duplicate entries for that target
it will generate duplicate dependencies (
@external)I think since
EXTERNAL2_His not defined, the#include "external2.h"directive is conditionally disabled and treated by Gazelle as a constrained dependency, while the unconditional#include "external.h"is treated as a generic dependency. Because both headers map to the same Bazel target (@external//:external) inexternal.ccindex, this results in duplicate entries for that target