Buck: buck audit

buck audit

Provide build information about build targets and outputs.

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

Commands

  • alias --list Lists the set of aliases declared in either .buckconfig or .buckconfig.local. (Currently, --list is the only flag supported by buck audit alias, but we are considering others.)
  • classpath <targets> Lists the classpath used to build the given targets. This does not work for all build rule types.
  • config <section.property>[,...] Outputs 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, one might run one of
    buck audit config invalid_section.novalue cxx.cc cxx.cxx
    buck audit config --tab invalid_section.novalue cxx.cc cxx.cxx
    
    [cxx]
        cc = /usr/bin/gcc
        cxx = /usr/bin/g++
    
    invalid_section.novalue	
    cxx.cc	/usr/bin/gcc
    cxx.cxx	/usr/bin/g++
    
  • dependencies <targets> Lists 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 flag. To show tests for a rule, use the --include-tests flag. This prints out a rule's tests as if they were a dependency of the rule. Combined with the --transitive flag, this will print out all of the test's dependencies as well.
  • input <targets> Lists the input source and resource files used to build the given targets.
  • includes <build_file> Lists build files and their extensions included in given build file.
  • tests <targets> Lists 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 provided at once. This command is meant 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

  • --json Outputs the results as JSON.

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"]
}