aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoogler <waltl@google.com>2023-07-17 08:11:50 -0700
committerCopybara-Service <copybara-worker@google.com>2023-07-17 08:12:34 -0700
commit5a8cab742c3868ae5fc813745c8677f676444cf1 (patch)
treed7cff7634061f7147d8d28c6428868fc68bbbcae
parent1dbb6917128da0ef5e35df3e8b060488e8c2acdc (diff)
downloadbazelbuild-rules_cc-5a8cab742c3868ae5fc813745c8677f676444cf1.tar.gz
Add support for expand_if_available for env_entry
PiperOrigin-RevId: 548694860 Change-Id: I90f46902058fe1ac3a75bb25bddbbf6e181fbabd
-rw-r--r--cc/cc_toolchain_config_lib.bzl14
-rw-r--r--third_party/com/github/bazelbuild/bazel/src/main/protobuf/crosstool_config.proto1
2 files changed, 12 insertions, 3 deletions
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