Add rule to materialize generated files into a `OUT_DIR`
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- rust
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu bằng cách đọc các entry point hiện có là BuildInfo.out_dir và cargo_dep_env(out_dir = ...), sau đó so sánh cách rust_bindgen cung cấp các tệp được tạo. Được xem là hoàn tất khi một rule công khai, mục đích chung có thể ánh xạ các tệp riêng lẻ đã khai báo vào bố cục OUT_DIR theo kiểu Cargo và cung cấp thư mục đó cho một Rust target sử dụng nó, bao gồm cả các đường dẫn lồng nhau.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
Cargo crates sometimes expect generated files to exist under OUT_DIR, for example:
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
This is common for crates that normally use a build.rs script, including FFI/sys crates. In Bazel, those generated files may already be produced by other rules, such as rust_bindgen, genrules, protobuf/schema generators, or checked-in generated files.
Today rules_rust can expose an existing directory artifact as OUT_DIR via BuildInfo.out_dir / cargo_dep_env(out_dir = ...), but there does not seem to be a general public helper for taking individual Bazel-produced files and materializing them into the directory layout expected by Cargo-style Rust code.
Describe the solution you'd like
Add a small general-purpose rule that materializes declared files into a Cargo-style OUT_DIR directory and exposes that directory to a consuming Rust target.
For example:
cargo_out_dir(
name = "bindings_out_dir",
files = {
"bindings.rs": ":bindings",
"nested/config.txt": ":config",
},
)
rust_library(
name = "my_sys_crate",
srcs = ["src/lib.rs"],
deps = [":bindings_out_dir"],
)
The consuming crate could then use:
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
This would provide a general solution for crates that need an OUT_DIR layout without requiring a dummy build.rs.
This could also supersede #3184. That issue asks for rust_bindgen to place generated files into OUT_DIR, but the underlying problem is not specific to bindgen. A general rule would allow rust_bindgen output to be mapped to bindings.rs, while also supporting other generators and files.
Describe alternatives you've considered
One alternative is to add a bindgen-specific option such as use_out_dir to rust_bindgen. I think a general rule would be cleaner because OUT_DIR is a convention of the consuming Rust crate, not of bindgen specifically.
Another alternative is to use cargo_dep_env(out_dir = ...) directly. That works if the user already has a directory artifact with the exact expected layout, but it does not solve the common case where the user has individual generated files that need to be assembled into that layout.
A third alternative is to run a dummy build.rs just to copy files into OUT_DIR, but that adds unnecessary build-script machinery when Bazel has already produced the files explicitly.
- Ngôn ngữ chính
- Starlark
- Star
- 857
- Fork
- 701
- Merge trung bình
- 4 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazelbuild/rules_rust
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfilesCó thể đã có người làm @Wito-1 đã nhận 65 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
bazelbuild/rules_rust#4309 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain conditionCó thể đã có người làm @Mattbusel đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bazelbuild/rules_rust#4266 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
rust.toolchain(strip_level = ...) is silently ignoredCó thể đã có người làm @Mattbusel đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bazelbuild/rules_rust#4223 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
bazelbuild/rules_rust#4152 · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
awaiting-response
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bazelbuild/rules_rust#3599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của bazelbuild/rules_rust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
bazelbuild/apple_support#707 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
blocky: new version 0.38.0Đang mởout-of-date
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blast/large refactor risk/low spend-dem
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
chriskelly/MusicWall#87 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
neilotoole/sq#1503 ·
Maintainer thường phản hồi trong vòng 1 ngày