Rules
constraint_setting
View rule sourceopen_in_newconstraint_setting named “glibc_version” to represent
the capability for platforms to have different versions of the glibc library installed.
For more details, see the
Platforms page.
Each constraint_setting has an extensible set of associated
constraint_values. Usually these are defined in the same package, but sometimes a
different package will introduce new values for an existing setting. For instance, the predefined
setting @platforms//cpu:cpu can be extended with a custom value in order to
define a platform targeting an obscure cpu architecture.
Arguments
constraint_value
View rule sourceopen_in_newExample
The following creates a new possible value for the predefinedconstraint_value
representing cpu architecture.
mips architecture as an alternative to
x86_64, arm, and so on.
Arguments
platform
View rule sourceopen_in_newExample
This defines a platform that describes any environment running Linux on ARM.Platform Inheritance
Platforms may use theparents attribute to specify another platform that they will
inherit constraint values from. Although the parents attribute takes a list, no
more than a single value is currently supported, and specifying multiple parents is an error.
When checking for the value of a constraint setting in a platform, first the values directly set
(via the constraint_values attribute) are checked, and then the constraint values on
the parent. This continues recursively up the chain of parent platforms. In this manner, any
values set directly on a platform will override the values set on the parent.
Platforms inherit the exec_properties attribute from the parent platform.
The dictionary entries in exec_properties of the parent and child platforms
will be combined.
If the same key appears in both the parent’s and the child’s exec_properties,
the child’s value will be used. If the child platform specifies an empty string as a value, the
corresponding property will be unset.
Platforms can also inherit the (deprecated) remote_execution_properties attribute
from the parent platform. Note: new code should use exec_properties instead. The
logic described below is maintained to be compatible with legacy behavior but will be removed
in the future.
The logic for setting the remote_execution_platform is as follows when there
is a parent platform:
- If
remote_execution_propertyis not set on the child platform, the parent’sremote_execution_propertieswill be used. - If
remote_execution_propertyis set on the child platform, and contains the literal string {PARENT_REMOTE_EXECUTION_PROPERTIES}, that macro will be replaced with the contents of the parent’sremote_execution_propertyattribute. - If
remote_execution_propertyis set on the child platform, and does not contain the macro, the child’sremote_execution_propertywill be used unchanged.
remote_execution_properties is deprecated and will be phased out, mixing
remote_execution_properties and exec_properties in the same
inheritance chain is not allowed.
Prefer to use exec_properties over the deprecated
remote_execution_properties.
Example: Constraint Values
child_ahas the constraint values@platforms//os:linux(inherited from the parent) and@platforms//cpu:x86_64(set directly on the platform).child_binherits all constraint values from the parent, and doesn’t set any of its own.
Example: Execution properties
child_ainherits the “exec_properties” of the parent and does not set its own.child_binherits the parent’sexec_propertiesand overrides the value ofk1. Itsexec_propertieswill be:{ "k1": "child", "k2": "v2" }.child_cinherits the parent’sexec_propertiesand unsetsk1. Itsexec_propertieswill be:{ "k2": "v2" }.child_dinherits the parent’sexec_propertiesand adds a new property. Itsexec_propertieswill be:{ "k1": "v1", "k2": "v2", "k3": "v3" }.