-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to cc_*
rules that lets one specify include directories only for the current rule
#2670
Comments
This would solve a lot of problems we're having migrating a large legacy library to build with bazel. Having an option like |
Any work going on with this? IIUC, it just looks like we need an alternate attribute which acts identically to "includes" except that it does not propagate these values up to dependents. |
@c-parsons: We could work around it pretty readily if we had a way to get the path to the directory represented by the current |
Correct -- You can get it from a rule context either natively or in skylark. I agree that writing a skylark rule for this is overkill, especially when it would be infeasible to emulate cc_library except with the added attribute. |
I think I was able to figure out a (perhaps less-than-ideal) workaround for this. In our wrapper macro for def my_objc_library(**args):
include_dirs = args.pop('private_includes', None)
if include_dirs:
priv_name = args['name'] + '_incl_private'
native.objc_library(
name = priv_name,
includes = include_dirs,
hdrs = native.glob([dir + '/**/*.h' for dir in include_dirs]),
visibility = ['//visibility:private'],
)
args['non_propagated_deps'] = args.pop('non_propagated_deps', []) + [':' + priv_name]
native.objc_library(**args) @c-parsons Do you think this could serve as an interim solution until we get support for this natively? |
This is a really nice idea, indeed. This workaround LGTM. Does it work for you? |
@c-parsons: Yup, already migrated everything to use this approach 😄 |
The workaround using objc_library looks pretty good, but there does not seem to be an equivalent for cc_library, or is there? |
Nope, with cc_library you still have to use |
@mhlopko Any updates on this? We have a clunky workaround that works for edit: 2018-07-18 added genfiles support def private_include_copts(includes):
copts = []
prefix = ''
# convert "@" to "external/" unless in the main workspace
repo_name = native.repository_name()
package_name = native.package_name()
if repo_name != '@':
prefix = 'external/{}/'.format(repo_name[1:])
for inc in includes:
copts.append("-I{}{}/{}".format(prefix, package_name, inc))
copts.append("-I$(GENDIR)/{}{}/{}".format(prefix, package_name, inc))
return copts |
cc @c-parsons |
No progress on this so far. We're doing quite big refactorings for Skylark API for C++ rules, and Skylark API for C++ toolchain, and I don't plan to work on "includes" (there's a bunch of problems) before we're done with apis. Current estimate is ~Q4/2018 for includes. |
@mhlopko @c-parsons: I updated my workaround above. Do you see any issues with how I'm using Also, any update on this? Are these new skylark rules being developed openly? I'd love to follow along. |
CC @oquenchil |
Does this work-around still work? I don't see a Having a makefile variable with the current package path so that I could write |
cc @oquenchil |
Duplicate of #6790 |
* copts does not work well if the repo is included as an external repo. * See bazelbuild/bazel#2670
* copts does not work well if the repo is included as an external repo. * See bazelbuild/bazel#2670
Currently, this is done by
copts=["-I<dir>"]
.This has two problems:Thus, it'd be better to express this in a compiler-independent way just like we have the
includes
anddefines
attributes.The text was updated successfully, but these errors were encountered: