Add support for expand_if_available for env_entry

PiperOrigin-RevId: 548694860
Change-Id: I90f46902058fe1ac3a75bb25bddbbf6e181fbabd
This commit is contained in:
Googler 2023-07-17 08:11:50 -07:00 committed by Copybara-Service
parent 1dbb691712
commit 5a8cab742c
2 changed files with 12 additions and 3 deletions

View File

@ -45,10 +45,10 @@ def _check_is_nonempty_list(obj, parameter_name, method_name):
EnvEntryInfo = provider(
"A key/value pair to be added as an environment variable.",
fields = ["key", "value", "type_name"],
fields = ["key", "value", "expand_if_available", "type_name"],
)
def env_entry(key, value):
def env_entry(key, value, expand_if_available = None):
""" A key/value pair to be added as an environment variable.
The returned EnvEntry provider finds its use in EnvSet creation through
@ -60,13 +60,21 @@ def env_entry(key, value):
Args:
key: a string literal representing the name of the variable.
value: the value to be expanded.
expand_if_available: A build variable that needs to be available
in order to expand the env_entry.
Returns:
An EnvEntryInfo provider.
"""
_check_is_nonempty_string(key, "key", "env_entry")
_check_is_nonempty_string(value, "value", "env_entry")
return EnvEntryInfo(key = key, value = value, type_name = "env_entry")
_check_is_none_or_right_type(expand_if_available, "string", "expand_if_available", "env_entry")
return EnvEntryInfo(
key = key,
value = value,
expand_if_available = expand_if_available,
type_name = "env_entry",
)
VariableWithValueInfo = provider(
"Represents equality check between a variable and a certain value.",

View File

@ -114,6 +114,7 @@ message CToolchain {
message EnvEntry {
required string key = 1;
required string value = 2;
repeated string expand_if_all_available = 3;
}
// A set of features; used to support logical 'and' when specifying feature