Skip to content
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

Expose CcSkylarkApiProvider as a first-class provider in Skylark #4370

Closed
mboes opened this issue Dec 31, 2017 · 2 comments
Closed

Expose CcSkylarkApiProvider as a first-class provider in Skylark #4370

mboes opened this issue Dec 31, 2017 · 2 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules type: feature request

Comments

@mboes
Copy link
Contributor

mboes commented Dec 31, 2017

Description of the feature request

It's possible to write Skylark rules that have cc_* rules as dependencies. Via the CcSkylarkApiProvider, it's possible for these Skylark rules to e.g. collect the list of transitive header files from these dependencies. But,

  1. it's not possible to write a Skylark rule that itself provides CcSkylarkApiProvider,
  2. it's not possible to test whether a dependency provides CcSkylarkApiProvider.

A workaround for (2) is:

[dep for dep in ctx.attr.deps if hasattr(dep, "cc")]

where one would expect to be able to use:

[dep for dep in ctx.attr.deps if CcSkylarkApiProvider in dep]

Underlying both (1) and (2) is the fact that unlike say DefaultInfo and OutputGroupInfo, CcSkylarkApiProvider, along with many other native providers, are not exported to Skylark as a global.

My use case for (1) is writing a replacement for cc_import in Skylark, since that rule does not currently provide CcSkylarkApiProvider.

Environment info

  • Bazel version (output of bazel info release): 0.9.0

Have you found anything relevant by searching the web?

I've seen mention of "Bazel sandwiches" where is some language. e.g. https://blog.bazel.build/2017/03/07/java-sandwich.html. It looks like for Java at least, the equivalent of (2) above is possible. Though the blog post mentions that the equivalent of (1) is still not possible. The Java functionality is provided via the java_common struct. For C/C++, the corresponding struct cc_common does not expose the corresponding methods.

Also related: #2163

Anything else, information or logs or outputs that would be helpful?

(If they are large, please upload as attachment or provide link).

@hlopko
Copy link
Member

hlopko commented Jan 3, 2018

We are currently working on a C++ sandwich. CcSkylarkApiProvider will very likely be replaced by some other thing and we'll also include corresponding cc_common functionality. We will provide a design doc for public review in Q1. Assigning to Pedro since he leads this effort.

@oquenchil
Copy link
Contributor

Sandwich is ready to be used. Closing this bug:
https://docs.bazel.build/versions/master/skylark/lib/CcInfo.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants