diff options
author | Zhao Liu <zhao1.liu@intel.com> | 2025-06-23 15:34:36 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-07-10 18:33:51 +0200 |
commit | bffbb430ee045c616dfe13ad4fd44823f18e6b21 (patch) | |
tree | 3095b2d2ef99dbabf992e7f15191a0b937dd1117 /rust | |
parent | df6fe2abf2e990f767ce755d426bc439c7bba336 (diff) | |
download | qemu-bffbb430ee045c616dfe13ad4fd44823f18e6b21.zip qemu-bffbb430ee045c616dfe13ad4fd44823f18e6b21.tar.gz qemu-bffbb430ee045c616dfe13ad4fd44823f18e6b21.tar.bz2 |
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")
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250623073436.1833357-1-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust')
-rw-r--r-- | rust/qemu-api/build.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 7849486..29d0945 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -9,12 +9,14 @@ use std::os::windows::fs::symlink_file; 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!( |