0

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 query 'kind(cc_library, //...)'

I tried genrule to run command. But "bazel query" cannot be used in the bazel-bin folder.

I tried genquery, but "//..." is not allowed in genquery.

Is there way I can get the target information in BAZEL rule?

ReneSun
  • 23
  • 2
  • 5
  • To query in rules, then: bazel query 'kind(.*rule, //some/package:*)' //some/package:* could be substituted for any valid label expression, eg including all descending packages, //some/package/... – SG_Bazel Jun 15 '22 at 05:26

1 Answers1

2

bazel query is used to discover targets within a bazel workspace.

You can try:

If only interested in rules, then:

bazel query 'kind(.rule, //some/package:)'

//some/package:* could be substituted for any valid label expression, eg including all descending packages, //some/package/...

Reference : bazel query

SG_Bazel
  • 343
  • 2
  • 7