将 bazel 目标路径转换为文件系统路径的可靠方法?

Reliable way to convert bazel target path into filesystem path?

外部工具是否有可靠的方法来引用 Bazel 生成的文件?更具体地说:如何将目标路径转换为 ​​bazel-bin(或左右)路径?

我可以确定目标outs

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

//bababot:bababot_server_kube_dev_deployment.json 几乎 我所需要的,只是我需要字符串 bazel-bin/bababot/bababot_server_kube_dev_deployment.json 或等效字符串。

我怎样才能可靠地得到它?我想我可以从 bazel info bazel-bin 替换 /// 替换 : 开始。有没有更简单的方法?

谢谢!

Bazel 有 Build Event Protocol,查看 NamedSetOfFiles 事件