Concepts and Terminology
- Workspace
- Repositories
- Packages
- Targets
- files
- source files
- generated files
- rules
- files
- Labels
- labels belones to only the first parent package(otherwise, it will throw a error “crosses a package boundary”
Rules
Phases
It will be important to understand the three phases of a build (loading, analysis and execution)
Attributes
- Dependency attributes, such as
attr.labelandattr.label_list, declare a dependency from the target that owns the attribute to the target whose label appears in the attribute’s value. This kind of attribute forms the basis of the target graph.
Output attributes, such as
attr.outputandattr.output_list, declare an output file that the target generates.
Both dependency attributes and output attributes take in label values.
Private Attribute
Sometimes we want to not only provide a default value, but prevent the user from overriding this default. To do this, you can make the attribute private by giving it a name that begins with an underscore (
_). Private attributes must have default values. It generally only makes sense to use private attributes for implicit dependencies.
Implementation Function
Implementation functions take exactly one parameter: a rule context, conventionally named ctx. It can be used to:
access attribute values and obtain handles on declared input and output files;
create actions; and
pass information to other targets that depend on this one, via providers.