Source files: bazel query 'kind("source file", deps(//path/to/target/foo/.))' | grep java$ What's the complete set of Java source files required to build foo? Let cls = kind(cc_.*library, deps($jbs)) in Now find the definitions of all the Java binaries that depend on them bazel query 'let jbs = kind(java_binary, //java/com/example/frontend/.) in bazel query 'some(kind(cc_.*library, deps(kind(java_binary, //java/com/example/frontend/.))))' -output location. What genproto rules does bar depend upon? bazel query 'kind(genproto, deps(bar/.))' Find the definition of some JNI (C++) library that is transitively depended upon by a Java binary rule in the servlet tree. except foo/contrib/.)' -output package What rule dependencies exist. What packages does the foo tree depend on, excluding foo/contrib? bazel query 'deps(foo/. Referenced by subinclude see the reference manual for details. What packages does foo depend on? (What do I need to check out to build foo) bazel query 'buildfiles(deps(//foo:foo))' -output package Note: buildfiles is required in order to correctly obtain all files It's similar to doing bazel query 'kind(".*_test rule", //foo/.)' | grep -E 'pa?t' What package contains file path/to/file/bar.java? bazel query path/to/file/bar.java -output=package What is the build label for path/to/file/bar.java? bazel query path/to/file/bar.java What rule target(s) contain file path/to/file/bar.java as a source?įullname=$(bazel query path/to/file/bar.java)īazel query "attr('srcs', $fullname, $:*)" The pattern is a regex and is applied to the full name of the rule. ![]() What are the tests beneath foo that match a pattern? bazel query 'filter("pa?t", kind(".*_test rule", //foo/.))' ![]() What packages exist beneath foo? bazel query 'foo/.' -output package What rules are defined in the foo package? bazel query 'kind(rule, foo:*)' -output label_kind What files are generated by rules in the foo package? bazel query 'kind("generated file", //foo:*)' What targets are generated by starlark macro foo? bazel query 'attr(generator_function, foo, //path/to/search/.)' What's the set of BUILD files needed to build //foo? bazel query 'buildfiles(deps(//foo))' | cut -f1 -d: What are the individual tests that a test_suite expands to? bazel query 'tests(//foo:smoke_tests)' Which of those are C++ tests? bazel query 'kind(cc_.*, tests(//foo:smoke_tests))' Which of those are small? Medium? Large?īazel query 'attr(size, small, tests(//foo:smoke_tests))'īazel query 'attr(size, medium, tests(//foo:smoke_tests))'īazel query 'attr(size, large, tests(//foo:smoke_tests))' You can use bazel query to analyze many dependency relationships. Supports the allrdeps function which allows you to query reverse dependencies You can use rdeps(u, x) to find the reverseĭependencies of the targets in x within the transitive closure of u. If you're going to change some code, you might want to know what other code You might want to know the set of targets that depends on some target. For cquery, this will include resolved toolchains. Using -noimplicit_deps allows you to filter out The full set of implicit dependencies isĬurrently undocumented. These dependencies are not mentioned in the build file,īut added in by the build tool. So, where's the direct dependency?Ĭertain rules include implicit dependencies on additional libraries or tools.įor example, to build a genproto rule, you need first to build the ProtocolĬompiler, so every genproto rule carries an implicit dependency on the The BUILD file for //foo never references $ bazel query "allpaths(//foo, third_party/.)" You will get a flattened list of the dependency graph. If you do not specify -output graph with allpaths, $ bazel query "somepath(//foo:foo, third_party/zlib:zlibonly)" When a dependency graph is big and complicated, it can be helpful start with a single path: Note: dot supports other image formats, just replace svg with the $ bazel query "allpaths(//foo, third_party/.)" -notool_deps -output graph | dot -Tsvg > /tmp/deps.svg To visualize the graph of all dependencies, pipe the bazel query output through What is included in the artifact you built, and not every possible job. Tooling dependencies with -notool_deps if you care only about We trace this dependency path? There are two useful functions here:Īllpaths and somepath. The library //third_party/zlib:zlibonly isn't in the BUILD file for Tracing the dependency chain between two packages This is the set of all targets required to build //foo. To see the dependencies of //foo, use the ![]() To execute a query while ignoring errors such as missing targets, use the Typing bazel help query or bazel help cquery on the This page covers how to get started using Bazel's query language to traceįor a language details and -output flag details, please see theĪnd Bazel cquery reference.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |