问题
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