Skip to content

Allow includes = ["."] #453

@dzbarsky

Description

@dzbarsky

For third-party libraries that are brought in via external repositories, includes = ["."] may actually be the desired behavior if they are only exporting a single cc_library target.

For example, see https://bazelbuild.slack.com/archives/CGA9QFQ8H/p1754145239223169 in which I wrote BUILD files for libxslt. The sources in that library import the headers as <libxslt/xslt.h> but also "xslt.h".

I originally had it working with the following target

cc_library(
    name = "libxslt",
    srcs = [
        "config.h",
        "libxslt/xsltconfig.h",
    ] + glob([
        "libxslt/*.c",
        "libxslt/*.h",
    ]),
    includes = ["."],
    deps = [
        "@libxml2",
    ],
    visibility = ["//visibility:public"],
)

Due to the ban of includes = ["."] I had to lower the target definition into the //libxslt package, which resulted in issues setting up the proper prefixes for the headers. I ended up resolving it by using copy_file targets for all the sources and headers to arrange them the way they expected to be arranged, but none of this would be necessary if we could specify this target at the repository root.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions