Can't spawn builtin actions from a rule implementation
I'd like to be able to use the builtin version of the C++ compilation action in a custom rule. Right now it seems like this is impossible and the only thing I'm able to do is cons up a string to pass to the shell, maybe referring to $(CC) and friends, and explicitly walking through ctx.targets.deps to figure out my includes and copts.
Supposing you're writing this in Skylark, does creating native.cc_binary help?
Are you writing a "macro" (a function that expands at BUILD loading time and emits existing rules), or a native rule? If the latter, can you post a snippet or a more detailed explanation of what you are trying to do?
The macro and rule we're using is https://github.com/google/kythe/blob/master/tools/build_rules/genproto.bzl ; for Java, this is based on genproto from Bazel's build_rules. Since we started the latter has grown a java_compile_command--why doesn't/shouldn't this use the builtin Java compile action?
Java genproto is a bit of a special case. Since the output file names depend on the contents of the .proto file, it can't easily be fitted in as a normal Java compile (for normal Java compiles, you have to specify file names upfront.)
I'm going to mark this as WAI.
If you want to depend on C++ artifacts, use a macro. If you want to interoperate with C++ code in rules, https://github.com/google/bazel/issues/146 is the right bug.