aboutsummaryrefslogtreecommitdiff
path: root/.run/src/verify.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-17 19:21:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-17 19:21:52 +0800
commit89bf57f33a9f0f5a96fc50e272c83d926fa35c4a (patch)
treecc5a72e850bdd9215b60dc1655f162e22ee97d12 /.run/src/verify.rs
parent40bb7ffd6954184fac718c8f99c9cdc3e054e4eb (diff)
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.
Diffstat (limited to '.run/src/verify.rs')
-rw-r--r--.run/src/verify.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/.run/src/verify.rs b/.run/src/verify.rs
index 0a4b354..b79bb73 100644
--- a/.run/src/verify.rs
+++ b/.run/src/verify.rs
@@ -215,16 +215,15 @@ pub fn generate_cargo_toml(block: &CodeBlock, package_name: &str, manifest_path:
)
};
- // Build-time blocks: add `builds` by default, merge with explicit features
+ // Build-time blocks: mirror the declared features into [build-dependencies]
+ // so that build.rs can use the same feature set as the crate itself.
let build_deps_section = if block.is_build_time {
- let mut all_feats = vec!["builds".to_string()];
- for f in &block.features {
- if f != "builds" {
- all_feats.push(f.clone());
- }
- }
- let feats_str: Vec<String> = all_feats.iter().map(|f| format!("\"{f}\"")).collect();
- let build_feats = format!("features = [{}]", feats_str.join(", "));
+ let feats_str: Vec<String> = block.features.iter().map(|f| format!("\"{f}\"")).collect();
+ let build_feats = if feats_str.is_empty() {
+ String::new()
+ } else {
+ format!("features = [{}]", feats_str.join(", "))
+ };
format!(
"\n[build-dependencies]\nmingling = {{ path = \"{mingling_path}\", {build_feats} }}\n"
)
@@ -292,14 +291,10 @@ pub fn generate_main_rs(block: &CodeBlock) -> String {
/// Generate build.rs for a build-time block
///
-/// Default: `use mingling::builds::*;`, code wrapped in `fn main() { }`.
+/// Default: code wrapped in `fn main() { }`.
pub fn generate_build_rs(block: &CodeBlock) -> String {
let mut output = String::from("#![allow(dead_code)]\n#![allow(unused)]\n");
- if !block.code.contains("use mingling::build::*;") {
- output.push_str("#[allow(unused_imports)]\nuse mingling::build::*;\n\n");
- }
-
if block.has_main {
output.push_str(&block.code);
} else {