Search code examples
bazel

Reliable way to convert bazel target path into filesystem path?


Is there a reliable way for outside tools to reference files generated by Bazel? More specifically: how to I convert target paths into bazel-bin (or so) paths?

I can determine the outs of target:

$ bazel query 'labels(outs, //bababot:bababot_server_kube_dev_deployment_json)' //bababot:bababot_server_kube_dev_deployment.json

The //bababot:bababot_server_kube_dev_deployment.json is almost what I need, except that I need the string bazel-bin/bababot/bababot_server_kube_dev_deployment.json, or equivalent.

How can I get that reliably? I imagine that I can start by replacing // for bazel info bazel-bin and replacing : for /. Is there a less brittle way?

Thanks!


Solution

  • Bazel has a Build Event Protocol, check out the NamedSetOfFiles events