diff --git a/cc/cc_toolchain_config_lib.bzl b/cc/cc_toolchain_config_lib.bzl index 72645f7..3a259de 100644 --- a/cc/cc_toolchain_config_lib.bzl +++ b/cc/cc_toolchain_config_lib.bzl @@ -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.", diff --git a/third_party/com/github/bazelbuild/bazel/src/main/protobuf/crosstool_config.proto b/third_party/com/github/bazelbuild/bazel/src/main/protobuf/crosstool_config.proto index 7f94306..45ad1e5 100644 --- a/third_party/com/github/bazelbuild/bazel/src/main/protobuf/crosstool_config.proto +++ b/third_party/com/github/bazelbuild/bazel/src/main/protobuf/crosstool_config.proto @@ -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