Skip to content

Commit 15b7d65

Browse files
committed
Adding select statements for build script environment and data attributes in bzlmod.
1 parent f04b2a6 commit 15b7d65

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

crate_universe/extensions.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,22 @@ def _crate_impl(module_ctx):
868868
repo_specific_annotations = {}
869869
for annotation_tag in mod.tags.annotation:
870870
annotation_dict = structs.to_dict(annotation_tag)
871+
if annotation_dict["build_script_data_select"]:
872+
annotation_dict["build_script_data"] = struct(
873+
common = annotation_dict["build_script_data"],
874+
selects = annotation_dict["build_script_data_select"],
875+
)
876+
annotation_dict.pop("build_script_data_select")
877+
if annotation_dict["build_script_env_select"]:
878+
annotation_dict["build_script_env"] = struct(
879+
common = annotation_dict["build_script_env"],
880+
selects = {
881+
k: json.decode(v)
882+
for k, v in annotation_dict["build_script_env_select"].items()
883+
},
884+
)
885+
annotation_dict.pop("build_script_env_select")
886+
871887
repositories = annotation_dict.pop("repositories")
872888
crate = annotation_dict.pop("crate")
873889

@@ -1082,6 +1098,9 @@ _annotation = tag_class(
10821098
"alias_rule": attr.string(
10831099
doc = "Alias rule to use instead of `native.alias()`. Overrides [render_config](#render_config)'s 'default_alias_rule'.",
10841100
),
1101+
"build_script_data_select": attr.string_list_dict(
1102+
doc = "A list of labels to add to a crate's `cargo_build_script::data` attribute. Keys should be the platform triplet. Value should be a list of labels.",
1103+
),
10851104
"build_script_data": _relative_label_list(
10861105
doc = "A list of labels to add to a crate's `cargo_build_script::data` attribute.",
10871106
),
@@ -1091,6 +1110,9 @@ _annotation = tag_class(
10911110
"build_script_deps": _relative_label_list(
10921111
doc = "A list of labels to add to a crate's `cargo_build_script::deps` attribute.",
10931112
),
1113+
"build_script_env_select": attr.string_dict(
1114+
doc = "Additional environment variables to set on a crate's `cargo_build_script::env` attribute. Key should be the platform triplet. Value should be a json string.",
1115+
),
10941116
"build_script_env": attr.string_dict(
10951117
doc = "Additional environment variables to set on a crate's `cargo_build_script::env` attribute.",
10961118
),

0 commit comments

Comments
 (0)