Should `cc_import` support `srcs` for private header files?
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
It is not uncommon for C/C++ libraries to contain both public API headers and also private headers that are included by the public API headers, but which should not be directly included by any clients of the library.
When using `cc_import` with such libraries, there seems to be no way to keep the private headers private;
both public and private headers need to be listed in "hdrs". This contrasts with `cc_library`, which does support private headers by listing them in "srcs" rather than "hdrs". But `cc_import` doesn't support the "srcs" attribute.
A potential work-around that I tried was using another `cc_library` target for the private headers, and listing that one in the `deps` of the `cc_import` rule. However, that doesn't seem to work either, getting a "file not found" error for the private header files in the CppCompileHeader action generated from the `cc_import` rule.
Contributor guide
Research direction
Start with the cc_import and cc_library rule behavior described in the issue, then reproduce the reported file-not-found error in the CppCompileHeader action using private headers supplied through deps. Trace how cc_import exposes hdrs and handles dependencies. Done means cc_import accepts private headers through srcs, keeps them unavailable to library clients, and compiles public headers that include them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100