替换语句

通过将 override 关键字用作变量赋值的前缀,可防止该变量的值再次被更改;除了通过另一个 override 语句更改以外。Starlark 不支持此功能。

您可以通过在为变量重新赋值前检查该变量是否已定义来移除该语句。例如,将:

override MY_VAR := foo
MY_VAR := bar
# MY_VAR is foo here

替换成:

MY_VAR := foo

# Generally this would be in a separate file that is included
ifndef MY_VAR
MY_VAR := bar
enddef

# MY_VAR is foo here