From 28f915a5437ebd72dd21ecc5877561c0042e0f80 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 10 Feb 2025 20:07:56 +0800 Subject: [PATCH] Fix cargo run uniffi-bindgen when cross compiling --- src/module_writer.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/module_writer.rs b/src/module_writer.rs index 455358f75..c97fa7f6c 100644 --- a/src/module_writer.rs +++ b/src/module_writer.rs @@ -1053,14 +1053,18 @@ fn uniffi_bindgen_command(crate_dir: &Path) -> Result { let command = if has_uniffi_bindgen_target { let mut command = Command::new("cargo"); - command.args(["run", "--bin", "uniffi-bindgen", "--manifest-path"]); - command.arg(manifest_path); - command.current_dir(crate_dir); + command + .args(["run", "--bin", "uniffi-bindgen", "--manifest-path"]) + .arg(manifest_path) + .current_dir(crate_dir) + .env_remove("CARGO_BUILD_TARGET"); command } else if has_uniffi_bindgen_workspace_package { let mut command = Command::new("cargo"); - command.args(["run", "--bin", "uniffi-bindgen"]); - command.current_dir(cargo_metadata.workspace_root); + command + .args(["run", "--bin", "uniffi-bindgen"]) + .current_dir(cargo_metadata.workspace_root) + .env_remove("CARGO_BUILD_TARGET"); command } else { let mut command = Command::new("uniffi-bindgen");