bazelbuild / bazelbuild/rules_rust
Direct Packages support for subcrate
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Using the following does not result create a `@crate_index//:wasmtime-c-api` target:
```starlark
RUST_PACKAGES = {
"wasmtime": crate.spec(
version = "7.0.0",
),
"wasmtime-c-api": crate.spec(
package = "wasmtime-c-api",
git = "https://github.com/bytecodealliance/wasmtime",
tag = "v7.0.0",
),
}
```
```starlark
http_archive(
name = "rules_rust",
sha256 = "b4e622a36904b5dd2d2211e40008fc473421c8b51c9efca746ab2ecf11dca08e",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.19.1/rules_rust-v0.19.1.tar.gz"],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
rules_rust_dependencies()
rust_register_toolchains(
edition = "2021",
versions = [
"nightly/2023-03-24",
],
extra_target_triples = [
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
"wasm32-unknown-unknown",
"wasm32-wasi",
],
)
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "render_config")
load("//bazel:rust.bzl", "RUST_PACKAGES")
crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
generate_binaries = True,
lockfile = "//:Cargo.Bazel.lock",
packages = RUST_PACKAGES,
render_config = render_config(
default_package_name = "",
),
rust_version = "nightly/2023-03-05",
)
load("@crate_index//:defs.bzl", "crate_repositories")
crate_repositories()
load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
rust_analyzer_dependencies()
```
I'd expect that it would have created a target that provides headers and library outputs that would be usable from a C/C++ target as shown in [c_calling_rust](https://github.com/bazelbuild/rules_rust/blob/6571cde64cbd72542ea012fe91d678031eb15fbf/examples/ffi/c_calling_rust/BUILD.bazel#L14-L18), but it does not:
```shell
$ CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
[REDACTED]
$ bazel query @crate_index//... | grep wasmtime
Loading: 0 packages loaded
@crate_index//:wasmtime
Loading: 0 packages loaded
```
Is producing subcrate target an unimplemented feature? What would be the workarounds in the meantime if not supported? Vendor in `wasmtime-c-api` myself? Just write my own C API wrapper that exposes what I need? The [Wasmtime C API](https://docs.wasmtime.dev/c-api/) is the example I'd like to make work.
Contributor guide
Assessment
This issue has not been assessed yet.