Skip to content

hdrs aren't added to the header search path when compiling reverse dependencies #94

@chrisnovakovic

Description

@chrisnovakovic

The documentation for the hdrs parameter of cc_library and friends says

      hdrs (list): Header files. These will be made available to dependent rules, so the distinction
                   between srcs and hdrs is important.

but "made available to" is rather vague. In particular, a cc:inc: label isn't added to the generated #hdrs target, so even though one cc_library that depends on another will have the latter's headers copied into the former's build environment, the compiler won't actually know to use them unless the directory containing the dependency's headers happens to be in the header search path coincidentally and/or due to some freak accident.

I think the most sensible thing to do here is to interpret "made available" as "copied into the build environment and added to the header search path", otherwise we're expecting users to audit all of their transitive dependencies and define appropriate values of -I in compiler_flags, which feels very un-Please-like. We can set it up so that -Is in compiler_flags take precedence over the -Is we add automatically as a result of depending on a target that provides cc_hdrs, which will allow for overrides in the edge case where a target depends on two targets that provide headers with the same name and cc-rules gives precedence to the wrong one (although TBH I'd expect that to cause problems even without cc-rules so it might be a situation that doesn't arise in reality).

Metadata

Metadata

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions