rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

crate_universe: provider wrappers that pre-populate rust_library/binary

Open duarten opened this issue 2 years ago • 2 comments

Having crate_universe provide crate-specific wrappers for rust_library/rust_binary allows it to already populate the deps, aliases, and could even add Cargo.toml to compile_data. This way users wouldn't need to call all_crate_deps or aliases themselves in the general case.

duarten avatar Jun 08 '22 05:06 duarten

This sounds like a good idea. I forget who else mentioned it to me but what I understand the request to be is something that allows you to replace:

load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_library")

rust_library(
    name = "my_lib",
    srcs = glob(["**/*.rs"]),
    aliases = aliases(),
    edition = "2018",
    proc_macro_deps = all_crate_deps(proc_macro = True),
    deps = all_crate_deps(normal = True),
)

with:

# I'm not proposing `cargo_backed_rust_library`, I'm just bad at names :)
load("@crate_index//:defs.bzl", "cargo_backed_rust_library")

cargo_backed_rust_library(
    name = "my_lib",
    # All attributes from the example above are automatically
    # generated from a `Cargo.toml` file and would match the
    # example above.
)

Is this roughly the same thing you're describing?

UebelAndre avatar Jun 08 '22 14:06 UebelAndre

Yes, precisely!

duarten avatar Jun 08 '22 14:06 duarten