Don't define new make functions in the product/board configuration, for two reasons:
- If the function is later used in an
Android.mk
file, it will no longer be defined when the product configuration is converted to Starlark, and theAndroid.mk
file may not work as intended. - The Makefile to Starlark converter only looks at one file at a time, and function definitions are often in different files than where they're invoked.
While a make function is really just a variable that's evaluated using the
built-in $(call)
function, the Make to Starlark converter will assume any
variable defined with the define
keyword is a function definition and reject
it. So a function would look like:
define my-func
Some text, arg1: $(1)
enddef
$(call my-func,foo)
We provide scripts to automatically replace some common functions with ones that are defined in the core build system Makefiles. They can be found at build/bazel/mk2rbc.