diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 32ce62256b..904c4e5ad4 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -738,6 +738,11 @@ _common_attrs = { "edition": attr.string( doc = "The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.", ), + "extra_outdirs": attr.string_list( + doc = dedent("""\ + List of additional output directories which are expected to be written by the compiler. + """), + ), "lint_config": attr.label( doc = "Set of lints to apply when building this crate.", providers = [LintsInfo], diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 5f4b2267c7..58f9d86901 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1395,6 +1395,9 @@ def rustc_compile_action( interface_library = ctx.actions.declare_file(crate_info.output.basename + ".lib", sibling = crate_info.output) outputs.append(interface_library) + if hasattr(ctx.attr, "extra_outdirs"): + outputs.extend([ctx.actions.declare_directory(outdir) for outdir in ctx.attr.extra_outdirs]) + # The action might generate extra output that we don't want to include in the `DefaultInfo` files. action_outputs = list(outputs) if rustc_output: