Open fergushenderson opened 4 months ago
Why would you even need to provide private headers to cc_import
?
Why would you even need to provide private headers to cc_import?
To avoid compilation errors when building code that depends on the public headers that in turn depend on the private headers, e.g.
In file included from main.cc:1:
foo_public.h:4:10: fatal error: foo_private.h: No such file or directory
4 | #include "foo_private.h"
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 withcc_library
, which does support private headers by listing them in "srcs" rather than "hdrs". Butcc_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 thedeps
of thecc_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 thecc_import
rule.