chore(xtask): add ffi install task

This task is for installing all the requirements for ffi tasks.
(That is: `diplomat-tool`.)
This commit is contained in:
Benoît CORTIER
2025-03-24 23:23:26 +01:00
committed by Benoît Cortier
parent 248588371a
commit aa210204a7
6 changed files with 29 additions and 6 deletions
Generated
+1 -1
View File
@@ -1508,7 +1508,7 @@ dependencies = [
[[package]]
name = "ffi"
version = "0.1.0"
version = "0.0.0"
dependencies = [
"diplomat",
"diplomat-runtime",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "ffi"
version = "0.1.0"
version = "0.0.0"
edition = "2021"
publish = false
+1
View File
@@ -8,5 +8,6 @@ pub const CARGO_LLVM_COV: CargoPackage = CargoPackage::new("cargo-llvm-cov", "0.
pub const GRCOV: CargoPackage = CargoPackage::new("grcov", "0.8.20");
pub const WASM_PACK: CargoPackage = CargoPackage::new("wasm-pack", "0.13.1");
pub const TYPOS_CLI: CargoPackage = CargoPackage::new("typos-cli", "1.29.5").with_binary_name("typos");
pub const DIPLOMAT_TOOL: CargoPackage = CargoPackage::new("diplomat-tool", "0.7.1");
pub const WABT_VERSION: &str = "1.0.36";
+3
View File
@@ -36,6 +36,7 @@ TASKS:
web check Ensure Web Client is building without error
web install Install dependencies required to build and run Web Client
web run Run SvelteKit-based standalone Web Client
ffi install Install all requirements for ffi tasks
ffi build [--release] Build DLL for FFI (default is debug)
ffi bindings [--skip-dotnet-build]
Generate C# bindings for FFI, optionally skipping the .NET build
@@ -88,6 +89,7 @@ pub enum Action {
WebCheck,
WebInstall,
WebRun,
FfiInstall,
FfiBuildDll {
release: bool,
},
@@ -162,6 +164,7 @@ pub fn parse_args() -> anyhow::Result<Args> {
None => Action::ShowHelp,
},
Some("ffi") => match args.subcommand()?.as_deref() {
Some("install") => Action::FfiInstall,
Some("build") => Action::FfiBuildDll {
release: args.contains("--release"),
},
+21 -3
View File
@@ -3,6 +3,8 @@ use std::path::{Path, PathBuf};
use anyhow::Context as _;
use crate::prelude::*;
#[cfg(target_os = "windows")]
const OUTPUT_LIB_NAME: &str = "ironrdp.dll";
#[cfg(target_os = "linux")]
@@ -24,7 +26,17 @@ const DOTNET_NATIVE_LIB_PATH: &str = "dependencies/runtimes/linux-x64/native/";
#[cfg(target_os = "macos")]
const DOTNET_NATIVE_LIB_PATH: &str = "dependencies/runtimes/osx-x64/native/";
pub(crate) fn build_dynamic_lib(sh: &xshell::Shell, release: bool) -> anyhow::Result<()> {
pub(crate) fn install(sh: &Shell) -> anyhow::Result<()> {
let _s = Section::new("FFI-INSTALL");
cargo_install(sh, &DIPLOMAT_TOOL)?;
Ok(())
}
pub(crate) fn build_dynamic_lib(sh: &Shell, release: bool) -> anyhow::Result<()> {
let _s = Section::new("BUILD-DYNAMIC-LIBRARY");
println!("Build IronRDP DLL");
let mut args = vec!["build", "--package", "ffi"];
@@ -64,7 +76,13 @@ pub(crate) fn build_dynamic_lib(sh: &xshell::Shell, release: bool) -> anyhow::Re
Ok(())
}
pub(crate) fn build_bindings(sh: &xshell::Shell, skip_dotnet_build: bool) -> anyhow::Result<()> {
pub(crate) fn build_bindings(sh: &Shell, skip_dotnet_build: bool) -> anyhow::Result<()> {
let _s = Section::new("BUILD-BINDINGS");
if !is_installed(sh, "diplomat-tool") {
anyhow::bail!("`diplomat-tool` binary is missing. Please run `cargo xtask ffi install`.");
}
let dotnet_generated_path = "./dotnet/Devolutions.IronRdp/Generated/";
let diplomat_config = "./dotnet-interop-conf.toml";
@@ -90,7 +108,7 @@ pub(crate) fn build_bindings(sh: &xshell::Shell, skip_dotnet_build: bool) -> any
sh.change_dir("./dotnet/Devolutions.IronRdp/");
sh.cmd("dotnet").arg("build").run()?;
cmd!(sh, "dotnet build").run()?;
Ok(())
}
+2 -1
View File
@@ -112,7 +112,8 @@ fn main() -> anyhow::Result<()> {
Action::WebCheck => web::check(&sh)?,
Action::WebInstall => web::install(&sh)?,
Action::WebRun => web::run(&sh)?,
Action::FfiBuildDll { release: debug } => ffi::build_dynamic_lib(&sh, debug)?,
Action::FfiInstall => ffi::install(&sh)?,
Action::FfiBuildDll { release } => ffi::build_dynamic_lib(&sh, release)?,
Action::FfiBuildBindings { skip_dotnet_build } => ffi::build_bindings(&sh, skip_dotnet_build)?,
}