From d2e02495c11e2613d47a24b4d9ccf4cb95af3c97 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Sun, 23 Nov 2025 12:58:17 -0800 Subject: [PATCH 1/3] feat(rust_common): allow compile actions to declare that extra folders will be created This technique is sometimes needed when a proc_macro derives information from the build, and it needs to be consumed by some other tool --- rust/private/rust.bzl | 5 +++++ rust/private/rustc.bzl | 3 +++ 2 files changed, 8 insertions(+) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 864cdec93e..7246e7c206 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -753,6 +753,11 @@ _common_attrs = { cfg = "exec", providers = [[CrateInfo], [CrateGroupInfo]], ), + "extra_outdirs": attr.string_list( + doc = dedent("""\ + List of additional output directories which are expected to be written by the compiler. + """), + ), "rustc_env": attr.string_dict( doc = dedent("""\ Dictionary of additional `"key": "value"` environment variables to set for rustc. diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 9af140e45e..f4a7e0e063 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1367,6 +1367,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: From 795dc62b5b651df023790c3cd905c490eae2ab2f Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 26 Nov 2025 15:30:34 -0800 Subject: [PATCH 2/3] fix merge --- rust/private/rust.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 2d3cdd82df..f30ac12cd4 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -757,6 +757,7 @@ _common_attrs = { doc = dedent("""\ List of additional output directories which are expected to be written by the compiler. """), + ), "require_explicit_unstable_features": attr.int( doc = ( "Whether to require all unstable features to be explicitly opted in to using " + From f8ffde9d98a262c3a8a9779db36f222703e2a38b Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 26 Nov 2025 15:37:54 -0800 Subject: [PATCH 3/3] sort --- rust/private/rust.bzl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index f30ac12cd4..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], @@ -753,11 +758,6 @@ _common_attrs = { cfg = "exec", providers = [[CrateInfo], [CrateGroupInfo]], ), - "extra_outdirs": attr.string_list( - doc = dedent("""\ - List of additional output directories which are expected to be written by the compiler. - """), - ), "require_explicit_unstable_features": attr.int( doc = ( "Whether to require all unstable features to be explicitly opted in to using " +