@@ -536,6 +536,9 @@ def _cargo_build_script_impl(ctx):
536536
537537 build_script_inputs = []
538538
539+ build_script_inputs .extend (ctx .files .build_script_env_files )
540+ args .add_all (ctx .files .build_script_env_files , format_each = "--input_dep_env_path=%s" )
541+
539542 for dep in ctx .attr .link_deps :
540543 if rust_common .dep_info in dep and dep [rust_common .dep_info ].dep_env :
541544 dep_env_file = dep [rust_common .dep_info ].dep_env
@@ -614,6 +617,25 @@ cargo_build_script = rule(
614617 "build_script_env" : attr .string_dict (
615618 doc = "Environment variables for build scripts." ,
616619 ),
620+ "build_script_env_files" : attr .label_list (
621+ doc = dedent ("""\
622+ Files containing additional environment variables to set for rustc.
623+
624+ These files should contain a single variable per line, of format
625+ `NAME=value`, and newlines may be included in a value by ending a
626+ line with a trailing back-slash (`\\ \\ `).
627+
628+ The order that these files will be processed is unspecified, so
629+ multiple definitions of a particular variable are discouraged.
630+
631+ Note that the variables here are subject to
632+ [workspace status](https://docs.bazel.build/versions/main/user-manual.html#workspace_status)
633+ stamping should the `stamp` attribute be enabled. Stamp variables
634+ should be wrapped in brackets in order to be resolved. E.g.
635+ `NAME={WORKSPACE_STATUS_VARIABLE}`.
636+ """ ),
637+ allow_files = True ,
638+ ),
617639 "crate_features" : attr .string_list (
618640 doc = "The list of rust features that the build script should consider activated." ,
619641 ),
0 commit comments