In make, an
include statement can include file paths with variables and will
ignore nonexistent files when prefixed with a minus. The product configuration
equivalent is the
inherit-product-if-exists function. Starlark uses
statements with files identified by string literal, and if a file doesn't
exist, Starlark throws an error.
To work around this limitation, the Starlark converter:
- finds all Makefiles that could match the path that involves variables
- emits Starlark
loadstatements for all of them
- chooses the correct one at runtime
Note that the generated Starlark code may look unnatural as it lists all the matching paths even though only one will be executed.
We recommend removing variable references in the
When variable references cannot be avoided, try to minimize the variable part. For example:
MY_DIR := path/to/$(TARGET_PRODUCT)
causes converter to generate a
load statement for each
file.mk in the source
restricts it to
file.mk files under
path/to. Of course,
removing the usage of
TARGET_PRODUCT as well would be ideal.