• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load(":android_product.bzl", "all_android_product_labels")
2
3package(default_visibility = ["//visibility:public"])
4
5# The current product we're building for. We could've chosen this product via a --platforms flag,
6# or transitioned into it. This is used to select() on the current product in the product_vars
7# target below. Note that this represents the current android _product_ as defined in pre-bazel
8# terms. There are several bazel platforms that can resolve to the same product, for example the
9# host platform and the device platform.
10constraint_setting(name = "current_product")
11
12# This target can be used to read product variables that aren't represented by other constraint
13# values (like the arch is).
14#
15# You may ask why every product variable isn't represented as a constraint setting. There are a
16# couple reasons for this:
17#  - Some variables represent files to use in rule implementations, like the default app
18#    certificate. Constraint settings would not allow adding a dependency on another file.
19#  - Some variables have more complicated data than a simple enum, like TidyChecks which is a list
20#    of strings. While this may be possible to extract from the name of a constraint value, it
21#    would be awkward.
22#  - Not all configuration variables need to be used in toolchain resolution.
23#
24# This target has 2 providers:
25#  - TemplateVariableInfo: this is a native platform_common.TemplateVariableInfo provider that
26#    contains a subset of the product variables to be available for expansion using make-like syntax
27#    on certain rule attributes. Soong had this feature, so it was ported to bazel.
28#  - ProductVariablesInfo: A custom provider that is supposed to replace direct accesses of
29#    soong.variables. You'd use this rule instead of reading from soong.variables directly so that
30#    when you transition into another product, you get the updated product config variables.
31#
32# This method of accessing product variables can't be used from macros / the bazel loading phase.
33# This is intentional, because if you could read them during the loading phase, you wouldn't be
34# able to transition into new values. Instead, please defer accesses to the analysis phase.
35#
36# All android_product()s must register their label here.
37alias(
38    name = "product_vars",
39    actual = select({
40        label + "_constraint_value": label + "_product_vars"
41        for label in all_android_product_labels
42    }),
43)
44