Add rule to materialize generated files into a `OUT_DIR`
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- rust
- 領域
- build-system
調査の方向性
まず既存のエントリポイントである BuildInfo.out_dir と cargo_dep_env(out_dir = ...) を読み、次に rust_bindgen が生成ファイルをどのように公開しているかを比較します。宣言された個々のファイルを Cargo スタイルの OUT_DIR レイアウトにマッピングし、そのディレクトリを利用する Rust ターゲットに公開できる、汎用的な公開ルールを実装できれば完了です。ネストされたパスも含みます。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Starlark
- スター
- 857
- フォーク
- 701
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bazelbuild/rules_rust のほかの issue
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfiles対応中かも @Wito-1 が 65 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
bazelbuild/rules_rust#4309 ·
メンテナーはふだん 3 日以内に返信
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain condition対応中かも @Mattbusel が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bazelbuild/rules_rust#4266 ·
メンテナーはふだん 3 日以内に返信
-
rust.toolchain(strip_level = ...) is silently ignored対応中かも @Mattbusel が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bazelbuild/rules_rust#4223 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
bazelbuild/rules_rust#4152 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
awaiting-response
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bazelbuild/rules_rust#3599 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
bazelbuild/rules_rust の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
bazelbuild/apple_support#707 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
out-of-date
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
メンテナーはふだん 1 日以内に返信
-
blast/large refactor risk/low spend-dem
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chriskelly/MusicWall#87 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
neilotoole/sq#1503 ·
メンテナーはふだん 1 日以内に返信