rules_rust/test/rust_crate_group
William Smith a6b0a7f398
Rust library group (#1848)
* Add rust_crate_group rule for grouping dependencies together.

This PR introduces a rule `rust_crate_group` which groups together multiple
dependencies, but does not itself have any sources or provide a crate. In
other words, it is an alias for a set of other rust_library targets.
For example, the following two build files are equivalent:

No `rust_crate_group`:
```py
rust_library(
    name = "foobar",
    deps = [
        ":crate1",
        ":crate2",
    ],
    ...
)
```

With `rust_crate_group`:
```py
rust_crate_group(
    name = "crate_group",
    deps = [
        ":crate1",
        ":crate2",
    ],
)

rust_library(
    name = "foobar",
    deps = [":crate_group"],
    ...
)
```

In some situations, especially when heavy macros are involved, this is the
only to achieve certain things. We have a number of use cases where this is
necessary, but they are complicated. I can try to come up with a simple one
if you are interested in more motivation.

It is possible to create an "alias group" with the C++ and Python rules by
just having a `cc_library` or `py_library` with no sources, only deps. But
this is not possible with Rust since `rust_library` does not transparently
re-export its dependencies.

* add rust_crate_group test

* add runfiles to rust_crate_group

* add rust-analyzer support

* rename rust_crate_group -> rust_library_group

* add test verifying that rust_library_group can be consumed by rust_test

* add coverage support to rust_library_group

---------

Co-authored-by: UebelAndre <github@uebelandre.com>
2023-06-19 08:23:23 -07:00
..
BUILD.bazel Rust library group (#1848) 2023-06-19 08:23:23 -07:00
dep1.rs Rust library group (#1848) 2023-06-19 08:23:23 -07:00
dep2.rs Rust library group (#1848) 2023-06-19 08:23:23 -07:00
lib.rs Rust library group (#1848) 2023-06-19 08:23:23 -07:00
test.rs Rust library group (#1848) 2023-06-19 08:23:23 -07:00