Skip to content

Specifying the platform will generate duplicate dependencies. #170

@nacljht

Description

@nacljht
-- 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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions