Bazel: how to get path to output binary?

白昼怎懂夜的黑 提交于 2020-03-24 10:05:33

问题


Consider somepath/BUILD file:

load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")

proto_library(
    name = "bar_proto",
    srcs = ["bar.proto"],
)

java_proto_library(
    name = "bar_java_proto",
    deps = [":bar_proto"],
)

By inspecting bazel-bin folder, I find bazel-bin/somepath/libbar_proto-speed.jar.

How do I get bazel-bin/somepath/libbar_proto-speed.jar from //somepath:bar_java_proto using bazel query?


回答1:


You don't.

Knowing output paths requires executing Bazel's loading and analysis phases, i.e. (1) loading the BUILD files and (2) analyzing dependencies to come up with the execution plan and concrete build actions (called the "action graph").

Bazel query only runs the loading phase, not the analysis phase, therefore it doesn't know about output paths.

Bazel cquery ("configured query") runs after the analysis phase [1], but as far as I understand it also cannot return output paths.

[1] https://docs.bazel.build/versions/master/cquery.html



来源:https://stackoverflow.com/questions/51292429/bazel-how-to-get-path-to-output-binary

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!