blob: 2912213a17169f3f23e9a16d8e9bb31f2b1bad84 [file] [log] [blame]
"""Constraints corresponding to product variables."""
load(":constants.bzl", "constants")
package(default_visibility = ["//visibility:public"])
# Generate one constraint_value for each product_variable
# The constraint_value for <var> can be within a select() to specify an
# attribute value for the same conditions product_variable.<var>, for most
# cases, that is when the value of <var> is true. For example,
#
# product_variables: {
# debuggable: {
# cflags: ["debug_flag1", "debug_flag2"],
# },
# }
#
# translates into:
#
# cflags = select({
# "//build/bazel/product_variables:debuggable": ["debug_flag1", "debug_flag2"],
# "//conditions:default": [],
# }),
[
(constraint_setting(name = product_variable+"_constraint"),
constraint_value(name = product_variable, constraint_setting = product_variable+"_constraint",)
)
for product_variable in constants.ProductVariables
]
# Caution: do not use these arch-variant product variables directly.
# If you have a complex combination of product variable and architecture/os/etc,
# prefer instead to craft an appropriate configuration in your BUILD file.
# See: https://docs.bazel.build/versions/master/configurable-attributes.html
# Within bp2build, :safestack-android should be used when an attribute value is
# conditional on both safestack:true and the os is android.
#
# e.g.
# target: {
# android: {
# product_variables: {
# safestack: {
# cflags: ["-Dsafestack-android"],
# },
# },
# },
# },
#
# would translate to:
#
# cflags = select({
# "//build/bazel/product_variables:safestack-android": ["-Dsafestack-android"],
# "//conditions:default": [],
# }),
[
[config_setting(
name = product_variable + "-" + variant,
constraint_values = [
":" + product_variable,
variantConstraint,
],
) for variant, variantConstraint in constants.ArchVariantToConstraints.items()]
for product_variable in constants.ArchVariantProductVariables
]