-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Add a way of including private headers (ie, headers included by files in srcs that should not be available to targets that depend on this cc_library) that works the same when the cc_library is in an external repo and when the headers are generated files.
Feature requests: what underlying problem are you trying to solve with this feature?
Currently, the only way I'm aware of including a private header is with copts = ["-Ipath/to/hdr/dir"]. However, this needs a different path when the target is used from an external repository, resulting in code like this (from ceres):
# The path to internal/ depends on whether Ceres is the main workspace or
# an external repository.
if native.repository_name() != '@':
internal = 'external/%s/internal' % native.repository_name().lstrip('@')
else:
internal = 'internal'
copts = ["-I" + internal],
or if the header is generated, like this (from glog):
if native.repository_name() != '@':
gendir = '$(GENDIR)/external/' + native.repository_name().lstrip('@')
else:
gendir = '$(GENDIR)'
copts = ["-I%s/glog_internal" % gendir],
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
- Download and extract private_headers.tar.gz
cd private_headers/ws1bazel build :lib(works)cd ../ws2bazel build :exthdr_lib(fails)bazel build :genhdr_lib(also fails)
What operating system are you running Bazel on?
Ubuntu 14.04
What's the output of bazel info release?
release 0.9.0
Have you found anything relevant by searching the web?
It is related to #2172, but that is specifically about platform independence.
#1950 concerns the difficulty of using private generated headers, but (a) is closed due to inactivity and (b) doesn't mention the complexity of use from external repos.
#2476 might also have been avoided, since it appears to stem from the use of includes = ["$(GENDIR)"] (source).