You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add an option to cc_* rules that lets one specify include directories only for the current rule #2670
This would solve a lot of problems we're having migrating a large legacy library to build with bazel. Having an option like private_includes or something of that nature on cc_* rules would be enormously beneficial and make our current setup less fragile.
Any work going on with this?
I've looked, and it doesn't look like there's a good workaround for this other than an actual native code change.
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 BUILD file. I know you can get that from a skylark rule, but we use some pretty simple macro wrappers and that feels a bit overkill.
Correct -- You can get it from a rule context either natively or in skylark.
But skylark macros don't have a rule context object -- they are not actual rules but simple expansions.
So unfortunately I don't think there's a workaround within a macro.
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.
We're better off fixing this natively, IMO
I think I was able to figure out a (perhaps less-than-ideal) workaround for this.
In our wrapper macro for objc_library, I added a new field called private_includes. If our macro sees this field, it creates a header-only objc_library and adds it to non_propagated_deps so the includes aren't passed to anyone who depends upon the library:
Activity
dflems commentedon Mar 13, 2017
This would solve a lot of problems we're having migrating a large legacy library to build with bazel. Having an option like
private_includesor something of that nature oncc_*rules would be enormously beneficial and make our current setup less fragile.c-parsons commentedon Jun 21, 2017
Any work going on with this?
I've looked, and it doesn't look like there's a good workaround for this other than an actual native code change.
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.
dflems commentedon Jun 21, 2017
@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
BUILDfile. I know you can get that from a skylark rule, but we use some pretty simple macro wrappers and that feels a bit overkill.c-parsons commentedon Jun 21, 2017
Correct -- You can get it from a rule context either natively or in skylark.
But skylark macros don't have a rule context object -- they are not actual rules but simple expansions.
So unfortunately I don't think there's a workaround within a macro.
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.
We're better off fixing this natively, IMO
dflems commentedon Jun 26, 2017
I think I was able to figure out a (perhaps less-than-ideal) workaround for this.
In our wrapper macro for
objc_library, I added a new field calledprivate_includes. If our macro sees this field, it creates a header-onlyobjc_libraryand adds it tonon_propagated_depsso the includes aren't passed to anyone who depends upon the library:@c-parsons Do you think this could serve as an interim solution until we get support for this natively?
c-parsons commentedon Jun 26, 2017
This is a really nice idea, indeed. This workaround LGTM. Does it work for you?
dflems commentedon Jun 26, 2017
@c-parsons: Yup, already migrated everything to use this approach 😄
silvester747 commentedon Oct 12, 2017
The workaround using objc_library looks pretty good, but there does not seem to be an equivalent for cc_library, or is there?
8 remaining items
alanfalloon commentedon Mar 29, 2019
Does this work-around still work? I don't see a
non_propagated_depsattribute onobjc_library. Any chance we will see a real option soon?Having a makefile variable with the current package path so that I could write
copts=["-I$(PACKAGEDIR)/include"]would also work for me.meisterT commentedon May 12, 2020
cc @oquenchil
oquenchil commentedon May 12, 2020
Duplicate of #6790
Remove copts from bazel build files
Remove copts from bazel build files