Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uniffi-bindgen in cargo workspaces #1909

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,27 @@ fn uniffi_bindgen_command(crate_dir: &Path) -> Result<Command> {
.any(|target| target.name == "uniffi-bindgen" && target.is_bin())
})
.unwrap_or(false);
let has_uniffi_bindgen_workspace_package = cargo_metadata.packages.iter().any(|pkg| {
pkg.targets
.iter()
.any(|target| target.name == "uniffi-bindgen" && target.is_bin())
});

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
} 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
} else {
Command::new("uniffi-bindgen")
let mut command = Command::new("uniffi-bindgen");
command.current_dir(crate_dir);
command
};
Ok(command)
}
Expand Down Expand Up @@ -922,7 +936,6 @@ fn generate_uniffi_bindings(
};

let mut cmd = uniffi_bindgen_command(crate_dir)?;
cmd.current_dir(crate_dir);
cmd.args([
"generate",
"--no-format",
Expand Down
Loading