[英]BAZEL: Query all targets in bazel rule
Here is code structure这是代码结构
| //base_folder
├── file0.txt
├── BUILD
├── folder1
| ├── BUILD
| ├── file1
├── folder2
| ├── BUILD
| ├── file2
I'd like to know all the files or target information to do a further process.我想知道所有文件或目标信息以进行进一步处理。
I can use bazel query command but I cannot get them in the BAZEL rule implement.我可以使用 bazel 查询命令,但无法在 BAZEL 规则实现中获取它们。
bazel query 'kind(cc_library, //...)' bazel查询'种类(cc_library,//...)'
I tried genrule to run command.我尝试使用 genrule 运行命令。 But "bazel query" cannot be used in the bazel-bin folder.
但是bazel-bin文件夹中不能使用“bazel查询”。
I tried genquery, but "//..." is not allowed in genquery.我尝试了 genquery,但在 genquery 中不允许使用“//...”。
Is there way I can get the target information in BAZEL rule?有没有办法在 BAZEL 规则中获取目标信息?
bazel query is used to discover targets within a bazel workspace. bazel 查询用于发现 bazel 工作区中的目标。
You can try:你可以试试:
If only interested in rules, then:如果只对规则感兴趣,那么:
bazel query 'kind(. rule, //some/package: )'
bazel查询'种类(。规则,//一些/包:)'
//some/package:* could be substituted for any valid label expression, eg including all descending packages, //some/package/... //some/package:* 可以替换任何有效的 label 表达式,例如包括所有降序包,//some/package/...
Reference: bazel query参考: bazel查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.