Buck: buck audit

buck audit

Provide build information about build targets and outputs.

Syntax:

buck audit <command> [ <parameter> . . . ] <target>  . . .

Example:

buck audit input //java/com/example/app:amazing

For more examples, see the Examples section below.

Commands

  • alias --list List the aliases declared in either .buckconfig or .buckconfig.local.
  • classpath <targets> List the classpath used to build the given targets. This does not work for all build rule types.
  • config <section.property> [,...] List values from .buckconfig (and .buckconfig.local) for the specified sections and properties. Use --tab to get tab-delimited details. For example, to get the C and C++ compiler, use
    buck audit config invalid_section.novalue cxx.cc cxx.cxx
    
    [cxx]
        cc = /usr/bin/gcc
        cxx = /usr/bin/g++
    

    or

    buck audit config --tab invalid_section.novalue cxx.cc cxx.cxx
    
    invalid_section.novalue	
    cxx.cc	/usr/bin/gcc
    cxx.cxx	/usr/bin/g++
    
  • dependencies <targets> List the dependencies used to build the given targets. Results are listed in alphabetical order. By default, only direct dependencies are listed; to show transitive dependencies, use the --transitive parameter. To show tests for a rule, use the --include-tests parameter. 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-tests with the --transitive parameter.
  • flavors <targets> List the flavors that are available for the specified targets and what the default flavor is for each target. If the flavors command prints no flavors, it indicates that, although the target rule supports flavors, Buck was not able to extract any. If the flavors command prints unknown, it indicates that the target rule doesn't support flavors. The flavors command supports the --json parameter for JSON-formatted output.
  • input <targets> List the input source and resource files used to build the given targets.
  • includes <build_file> List the build files, and their extensions, that are included in the given build file.
  • modules List the modules known by Buck as well as their content hashes and dependencies.
  • tests <targets> List the tests for the given targets. Results are listed in alphabetical order. Only tests for the given 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 dependencies command. 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-tests Show the tests for the specified targets. Can be combined with the --transitive parameter. For more information, see the dependencies command.
  • --json Output the results as JSON.
  • --list List .buckconfig and .buckconfig.local aliases. Used only with the aliases command. For more information, see that command.
  • --tab Output the results using tab delimiters. Used only with the config command. For more information, see that command.
  • --transitive Show transitive dependencies in addition to direct dependencies. Can be combined with the --include-tests parameter. For more information, see the dependencies command.

Examples

# 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' ],
)
Lists 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
Outputs 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"],
}
Lists all of the rules that the one library directly depends on
buck audit dependencies //examples:one
//examples:three
//examples:two
Lists 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
Outputs 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"]
}
Outputs 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"]
}

See also

.buckconfig

build file