Restructured project for separate plugins

This commit is contained in:
Ebu
2025-12-04 09:34:55 +01:00
parent 3cf22b7189
commit 28f14ba713
29 changed files with 364 additions and 248 deletions

6
helpers/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "helpers"
version = "0.1.0"
edition = "2024"
[dependencies]

40
helpers/src/lib.rs Normal file
View File

@@ -0,0 +1,40 @@
use std::{
env, fs,
path::{Path, PathBuf},
};
#[cfg(debug_assertions)]
const CONFIG: &str = "debug";
#[cfg(not(debug_assertions))]
const CONFIG: &str = "release";
#[cfg(target_os = "macos")]
const OS_LIB_EXT: &str = "dylib";
#[cfg(target_os = "windows")]
const OS_LIB_EXT: &str = "dll";
#[cfg(target_os = "linux")]
const OS_LIB_EXT: &str = "so";
#[cfg(target_os = "macos")]
const OS_NAME: &str = "macOS";
#[cfg(target_os = "windows")]
const OS_NAME: &str = "Windows";
#[cfg(target_os = "linux")]
const OS_NAME: &str = "Linux";
pub fn built_lib_path(lib_name: &str) -> PathBuf {
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or("".to_owned()))
.join(format!("target/{CONFIG}/lib{lib_name}.{OS_LIB_EXT}"))
}
pub fn copy_artifact_to_out_dir(lib_name: &str, pretty_name: &str) {
let src_path = built_lib_path(lib_name);
let dst_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or("".to_owned())).join(
format!("target/build/{CONFIG}/{pretty_name}_{OS_NAME}.clap"),
);
fs::create_dir_all(dst_path.parent().unwrap())
.expect("Failed to create artifact output directory");
fs::copy(src_path, dst_path).expect("Failed to move artifact");
}