1

I want to build a rule that is very similar to cc_proto_library. The key features are that it would apply an aspect to all the transitive proto_library dependencies and generate .cc and .h files for all of the dependencies. In addition it would generate actions that would compile these into object files.

While I understand how I can do the file generation, I don't see how to easily do the object generation. The native module is not available for rule (or aspect) implementations, and I cannot use a macro on top of the aspect as I need the object files to be generated in the same package as the proto_library so that it is generated only once.

cc_proto_library can do this I believe because it is not written in Skylark and thus has access to more primitives. Is there anyway to do this with just Skylark?

Eric Dobson
  • 343
  • 2
  • 8
  • I asked our Skylark+C++ person to comment on creating C++ compile actions from Skylark, but just a quick reply - if you ever will use `native.cc_proto_library` in the same project, take care to make your rule generate different file names and different symbols. Otherwise, you'll run into output file conflicts and linker errors. – user1071136 Sep 25 '17 at 08:54

1 Answers1

0

This is unfortunately currently not possible. There is no Skylark API to the C++ rules/actions (what we call C++ sandwich). We have plans to implement this in Q1 2018. There are many tracking issues, this one looks the most relevant: https://github.com/bazelbuild/bazel/issues/2163.

hlopko
  • 3,100
  • 22
  • 27