Skip to contentSkip to conversation

rust/qemu-api: Fix binding path in source directory

PATCH Applied Zhao Liu 2 participants 2 messages Jun 23, 2025 – Jul 8, 2025 Rust

lore
Share & tools
lore

Zhao Liu

author
#0 lore raw

PATCH 1/1 rust/qemu-api: Fix binding path in source directory

The build.rs had supported placing bindings.inc.rs in rust/qemu-api/src, but this "not encouraged" feature is broken.

Considering that manually copying bindings.inc.rs to the development directory is also useful, fix the bindings.inc.rs path generation to give this feature another chance.

Fixes commit 1ae4ca0463d7 ("rust: move rust.bindgen to qemu-api crate")
---
 rust/qemu-api/build.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
rust/qemu-api/build.rs +7 -5
index 7849486c1baf..29d09456257c 100644
@@ -9,12 +9,14 @@
 use std::{env, fs::remove_file, io::Result, path::Path};
 
 fn main() -> Result<()> {
-    // Placing bindings.inc.rs in the source directory is supported
-    // but not documented or encouraged.
-    let path = env::var("MESON_BUILD_ROOT")
-        .unwrap_or_else(|_| format!("{}/src", env!("CARGO_MANIFEST_DIR")));
+    let file = if let Ok(root) = env::var("MESON_BUILD_ROOT") {
+        format!("{root}/rust/qemu-api/bindings.inc.rs")
+    } else {
+        // Placing bindings.inc.rs in the source directory is supported
+        // but not documented or encouraged.
+        format!("{}/src/bindings.inc.rs", env!("CARGO_MANIFEST_DIR"))
+    };
 
-    let file = format!("{path}/rust/qemu-api/bindings.inc.rs");
     let file = Path::new(&file);
     if !Path::new(&file).exists() {
         panic!(concat!(
Signature · 1 line
2.34.1