Buck: Build Target Pattern

Build Target Pattern

A build target pattern is a string that describes a set of one or more build targets. Build target patterns are used as command-line arguments to buck build, to buck query, and in the lists of values provided to the visibility argument of your build rules.

The simplest build target pattern matches the build target of same name:

# Matches '//apps/myapp:app'.

A build target pattern that ends with a colon matches any build targets that identify rules in the same build file:

# Matches '//apps/myapp:app_debug' and '//apps/myapp:app_release'.

A build target pattern that ends with /... matches any build target in the build file in the current directory and any build targets in build files in subdirectories:

# Matches '//apps:common' and '//apps/myapp:app'.

Note that build target patterns cannot be used with the deps argument to a build rule. Buck requires that you specify all dependencies explicitly as either fully-qualified or relative build targets. By making dependencies explicit, Buck prevents a build rule from inadvertently acquiring new dependencies; dependencies entail processing cost, so you should avoid including extraneous dependencies in your build rules.