From 89bf57f33a9f0f5a96fc50e272c83d926fa35c4a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 17 Aug 2026 19:21:52 +0800 Subject: refactor!: replace build.rs with compile-time macro build steps BREAKING CHANGE: Replace the `build`/`builds` feature system with compile-time macro-driven generation. `gen_program!()` now automatically invokes `build_comp!()` and `build_pathf!()` when the `comp`/`pathf` features are enabled, eliminating the need for `build.rs` and `[build-dependencies]` blocks. This removes the `build` feature, the `mingling::build` module, and all related build-time API functions. Completion scripts are now written to `{target_directory}/mingling/` instead of `target/release/`. The `mingling_cli` uses `build_comp!("mling")` for its custom binary name. --- .../example-combine-pathf-dispatch-tree/Cargo.lock | 92 +++++++++++++++++++++- .../example-combine-pathf-dispatch-tree/Cargo.toml | 13 --- .../example-combine-pathf-dispatch-tree/build.rs | 3 - .../example-combine-pathf-dispatch-tree/page.toml | 4 +- .../src/main.rs | 8 +- 5 files changed, 98 insertions(+), 22 deletions(-) delete mode 100644 examples/example-combine-pathf-dispatch-tree/build.rs (limited to 'examples/example-combine-pathf-dispatch-tree') diff --git a/examples/example-combine-pathf-dispatch-tree/Cargo.lock b/examples/example-combine-pathf-dispatch-tree/Cargo.lock index 9fdbf4f..3603db8 100644 --- a/examples/example-combine-pathf-dispatch-tree/Cargo.lock +++ b/examples/example-combine-pathf-dispatch-tree/Cargo.lock @@ -2,6 +2,39 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "camino" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-platform" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "cargo_metadata" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -31,6 +64,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + [[package]] name = "just_fmt" version = "0.2.0" @@ -69,7 +108,6 @@ version = "0.5.0" dependencies = [ "just_fmt", "might_be_async", - "mingling_pathf", ] [[package]] @@ -77,6 +115,7 @@ name = "mingling_macros" version = "0.5.0" dependencies = [ "just_fmt", + "mingling_pathf", "proc-macro2", "quote", "syn 2.0.118", @@ -86,6 +125,7 @@ dependencies = [ name = "mingling_pathf" version = "0.5.0" dependencies = [ + "cargo_metadata", "just_fmt", "proc-macro2", "syn 2.0.118", @@ -109,6 +149,16 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + [[package]] name = "serde" version = "1.0.229" @@ -116,6 +166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", + "serde_derive", ] [[package]] @@ -138,6 +189,19 @@ dependencies = [ "syn 3.0.3", ] +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + [[package]] name = "serde_spanned" version = "0.6.9" @@ -169,6 +233,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "toml" version = "0.8.23" @@ -224,3 +308,9 @@ checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/examples/example-combine-pathf-dispatch-tree/Cargo.toml b/examples/example-combine-pathf-dispatch-tree/Cargo.toml index 2c866f7..6fcfc48 100644 --- a/examples/example-combine-pathf-dispatch-tree/Cargo.toml +++ b/examples/example-combine-pathf-dispatch-tree/Cargo.toml @@ -10,17 +10,4 @@ mingling = { path = "../../mingling", features = [ "pathf", ] } -[build-dependencies] -mingling = { path = "../../mingling", features = [ - "builds", - - # --------- IMPORTANT --------- - # To use pathf under dispatch_tree - # **must** enable the `dispatch_tree` - # feature in build dependencies - "dispatch_tree", - "pathf", - # --------- IMPORTANT --------- -] } - [workspace] diff --git a/examples/example-combine-pathf-dispatch-tree/build.rs b/examples/example-combine-pathf-dispatch-tree/build.rs deleted file mode 100644 index d909431..0000000 --- a/examples/example-combine-pathf-dispatch-tree/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - mingling::build::analyze_and_build_type_mapping().unwrap(); -} diff --git a/examples/example-combine-pathf-dispatch-tree/page.toml b/examples/example-combine-pathf-dispatch-tree/page.toml index 88557af..b4e64e9 100644 --- a/examples/example-combine-pathf-dispatch-tree/page.toml +++ b/examples/example-combine-pathf-dispatch-tree/page.toml @@ -6,5 +6,5 @@ category = "advanced" desc = """ Demonstrates combining the `pathf` and `dispatch_tree` features. Types are defined in submodules and automatically resolved. Requires `dispatch_tree` in both `[dependencies]` and `[build-dependencies]`. """ -tags = ["pathf", "dispatch_tree", "extras", "build.rs"] -files = ["src/main.rs", "src/sub/mod.rs", "build.rs", "Cargo.toml"] +tags = ["pathf", "dispatch_tree", "extras"] +files = ["src/main.rs", "src/sub/mod.rs", "Cargo.toml"] diff --git a/examples/example-combine-pathf-dispatch-tree/src/main.rs b/examples/example-combine-pathf-dispatch-tree/src/main.rs index 75888ee..a93e7ae 100644 --- a/examples/example-combine-pathf-dispatch-tree/src/main.rs +++ b/examples/example-combine-pathf-dispatch-tree/src/main.rs @@ -4,11 +4,13 @@ //! > Types are defined in a submodule (`sub`), and `gen_program!()` resolves //! > them automatically via pathf without explicit `use` imports. //! > -//! > **Important**: `dispatch_tree` must be enabled in BOTH `[dependencies]` -//! > AND `[build-dependencies]` so that pathf's builder can detect -//! > `__internal_dispatcher_*` types needed by the dispatch tree. +//! > **Important**: `dispatch_tree` must be enabled so that pathf's builder can +//! > detect `__internal_dispatcher_*` types needed by the dispatch tree. //! > //! > Also requires `extras` for the implicit `dispatcher!("hello")` form. +//! > +//! > With the `pathf` feature, `gen_program!()` automatically invokes +//! > `build_pathf!()` at compile time — no `build.rs` needed. //! //! Run: //! ```bash -- cgit