buck audit
Provide information about build configuration parameters, targets, and rules.
Syntax:
buck audit <command> [ <parameter> . . . ] <target> . . .
Example:
buck audit input //java/com/example/app:amazing
For more examples, see the command descriptions and Examples section below.
Commands
alias --listList the aliases declared in
.buckconfigand.buckconfig.local. This command lists only the aliases, not their values. To see the values, use thebuck audit configcommand.buck audit cellList the absolute paths to the cells that are specified in the
[repositories]section of the.buckconfigfile that is in the root of the current cell. The path to each cell is prefixed with the specified alias for that cell. For example:$ buck audit cell buck: /Users/buxster/local/buck bazel_skylib: /Users/buxster/local/buck/third-party/skylark/bazel-skylib
(In this example,
buxsteris the name of the current user.)If you specify the
--paths-onlyparameter, Buck outputs only the absolute paths to the cells, without the aliases.$ buck audit cell --paths-only /Users/buxster/local/buck /Users/buxster/local/buck/third-party/skylark/bazel-skylib
If your
.buckconfigdoes not contain a[repositories]section, thenbuck audit celldoesn't return any output.classpath <targets>List the Java classpath used to run the specified targets. This does not work for all build rule types.
config {<section> | <section.property>} [...]List the values from
.buckconfig(and.buckconfig.local) for the specified sections and properties.If you specify only the section name,
buck audit configlists all the properties and values for that section.Note that properties and values specified with
--configare not surfaced by this command, and those properties and values override both.buckconfigand.buckconfig.local.Use
--tabto get tab-delimited output.Example: To get the C compiler and the C++ compiler, use
buck audit config cxx.cc cxx.cxx
[cxx] cc = /usr/bin/gcc cxx = /usr/bin/g++or (with
--tab)buck audit config --tab cxx.cc cxx.cxx
cxx.cc /usr/bin/gcc cxx.cxx /usr/bin/g++
dependencies <targets>List the dependencies used to build the specified targets. Results are listed in alphabetical order. By default, only direct dependencies are listed; to show transitive dependencies, use the
--transitiveparameter. To show tests for a rule, use the--include-testsparameter. This prints out a rule's tests as if they were dependencies of the rule. To print out all of the test's dependencies as well, combine--include-testswith the--transitiveparameter.flavors <targets>List the flavors that are available for the specified targets and what the default flavor is for each target. If the
flavorscommand printsno flavors, it indicates that, although the target rule supports flavors, Buck was not able to extract any. If theflavorscommand printsunknown, it indicates that the target rule doesn't support flavors. Theflavorscommand supports the--jsonparameter for JSON-formatted output.input <targets>List the input source and resource files used to build the specified targets.
includes <build_file>List the build files, and their extensions, that are included in the specified build file.
modulesList the Java modules known by Buck as well as their content hashes and dependencies.
ruletype <rule>Print the Python signature for the specified rule.
The following command line uses
buck audit ruletypeto view the arguments supported by theremote_filerule.buck audit ruletype remote_file
def remote_file ( name, sha1, url, labels = None, licenses = None, out = None, type = None, ): ...ruletypesList all the rules that Buck supports, in alphabetical order.
Example
The following example prints all the rules that Buck supports. Note that the output is truncated for brevity.
buck audit ruletypes
android_aar android_app_modularity android_binary android_build_config android_bundle android_instrumentation_apk android_instrumentation_test android_library android_manifest android_prebuilt_aar android_resource apk_genrule apple_asset_catalog apple_binary <truncated>
Example
The following command line uses
buck audit ruletypeswith thegrepcommand to print all the build rules that have the stringandroidin their names.buck audit ruletypes | grep android
Note that these are not all the rules that Buck provides for Android development. For example, the rules
apk_genruleandndk_librarysupport Android development, but do not themselves contain the stringandroidin their names.tests <targets> [...]List the tests for the specified targets. Results are listed in alphabetical order. Only tests for the specified targets are printed, though multiple targets may be specified on a single command line. This command is intended to be used in conjunction with the
audit dependenciescommand. For example, to retrieve a list of all tests for a given project, use:buck audit dependencies --transitive PROJECT | xargs buck audit tests
Parameters
--include-testsShow the tests for the specified targets. Can be combined with the
--transitiveparameter. For more information, see thedependenciescommand.--jsonOutput the results as JSON.
--listList
.buckconfigand.buckconfig.localaliases. Used only with thealiasescommand. For more information, see that command.--tabOutput the results using tab delimiters. Used only with the
configcommand. For more information, see that command.--transitiveShow transitive dependencies in addition to direct dependencies. Can be combined with the
--include-testsparameter. For more information, see thedependenciescommand.
Examples
#
# BUCK
#
# For all of the following examples, assume this BUCK file exists in
# the `examples` directory.
#
java_library(
name = 'one',
srcs = [ '1.txt' ],
deps = [
':two',
':three',
],
)
java_library(
name = 'two',
srcs = [ '2.txt' ],
deps = [
':four',
],
)
java_library(
name = 'three',
srcs = [ '3.txt' ],
deps = [
':four',
':five',
],
)
java_library(
name = 'four',
srcs = [ '4.txt' ],
deps = [
':five',
],
)
java_library(
name = 'five',
srcs = [ '5.txt' ],
)
List all of the source files used to build the one library
buck audit input //examples:one
examples/1.txt examples/2.txt examples/3.txt examples/4.txt examples/5.txt
Output a JSON representation of all of the source files used to build the two library. In this JSON object, each key is a build target and each value is an array of the source paths used to build that rule.
buck audit input --json //examples:two
{
"//examples:two": ["examples/2.txt"],
"//examples:four": ["examples/4.txt"],
"//examples:five": ["examples/5.txt"],
}
List all of the rules that the one library directly depends on
buck audit dependencies //examples:one
//examples:three //examples:two
List all of the rules that the one library transitively depends on
buck audit dependencies --transitive //examples:one
//examples:five //examples:four //examples:three //examples:two
Output a JSON representation of all of the rules that the two library transitively depends on.
buck audit dependencies --transitive --json //examples:two
{
"//examples:two": ["//examples:five","//examples:four"]
}
Output a JSON representation of the direct dependencies of the two and three libraries.
buck audit dependencies --json //examples:two //examples:three
{
"//examples:three": ["//examples:five","//examples:four"],
"//examples:two": ["//examples:four"]
}