-
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
Make transitive dependencies available to Skylark - Make native provider available in Skylark #146
Comments
The way to propagate data about the transitive closure is by using TransitiveInfoProviders. In Skylark these are just called providers. I'm certain there's some way to get the classpath from the whole transitive closure because I think we do that in the java rules. Unfortunately I don't know how :( Summoning Damien to answer. |
Ok there is no way to do it nicely: Re-assigning to laurentlb for skylark feature. |
Each rule has to expose its providers to Skylark. So this should be implemented by rule owners. |
Can we rename this issue since its topic has changed? My issue was specifically about adding Skylark providers to the {java,cxx}_* native rules. This is needed to have proper support for Go's cgo, other FFIs, and the language analysis rules in Kythe. |
Done. Please list the providers you would like to have access to so we can use this bug to track the list of provider to add. |
From cc_library rules, we would need at least the CcLinkParams and CppCompilationContext. |
For java_library we definitely need at least the following: Though I suspect several of the other providers in that package would be useful in general also. Is there an example somewhere of a rule exposing providers to Skylark? If I can find an example I'd be happy to make equivalent changes for the Java rules. |
Some information is here: More specifically, for each of the files, add the annotation on the class: Add an annotation on each method: Access the providers: Of course, this is experimental. We'll probably provide a nicer syntax in the future. |
What would it take to get these annotations committed the master branch? These changes seem pretty simple to make, but I'd like to stay away from using a custom Bazel binary. I'm fine with using experimental features that may change, however. |
I personally don't know how the Java rules work, and I don't know which methods make or don't make sense to be exported. Also, it's maybe better to clean the API before making it public (it will be much more complicated later). And they need to be documented. What you can do is to make this local change. Expose everything and try to see what is valuable. I can make public the functions that have an actual use-case. |
The information exposed in https://github.com/schroederc/bazel/commit/9619db3b72df502836c42905b923a62a54f7fa2c is valuable to Kythe. |
I tried a similar change in https://github.com/ekuefler/bazel/commit/f1a737314aabed706d4f561d394c51fdc01e6317 to expose classpaths for the Groovy compiler. Accessing the provider works, but I run into an interesting problem:
I'm guessing this is an ijar issue. |
Also tried this for Java source jars and confirmed that it does what I want for GWT. Sent a PR with the changes - not sure if you want to do this or wait for syntactic changes in Skylark first. |
Just a quick reviews of the Java providers that were asked. IMO they all makes sense and we should definitely accept change that exposes the one asked in that thread. We definitely also want the runtime classpath provider to be exposed (it is currently exposed but not documented). For the ijars issue, you might want to use the runtime classpath which contains non-ijar jar. Though it might miss some "neverlink" dependencies. |
Can I vote for CcNativeLibraryProvider.java? |
@abergmeier : Are you looking for something different than |
@bsilver8192 Ah thanks, I kinda missed that.
Filed #2163 for that. |
PythonImportsProvider would be great. More generally, is there any reason for exposing native providers only upon request rather than just exposing them all now? |
Yes. Providers should be reviewed / cleaned up before we expose them. Once a provider is exposed, it's hard to modify it and make it evolve, so we should be comfortable supporting it. |
This is fixed now by @oquenchil's work on #4570. |
Skylark currently makes its direct dependencies available via
ctx.files.deps
, but doesn't provide any way to get the classpath or full set of transitive dependencies required by the target. This information is critical for integrating with any javac-like tool that requires specifying a classpath, such as GWT or Groovy compilers.The only workaround is to force these rules to specify all of their transitive dependencies in the BUILD file. This is very cumbersome and sometimes impossible, since transitive dependencies might not actually be visible to the target that needs them.
The text was updated successfully, but these errors were encountered: