|
|
|
@@ -1,5 +1,9 @@ |
|
|
|
use eyre::{bail, Context}; |
|
|
|
use std::path::Path; |
|
|
|
use std::{ |
|
|
|
env::consts::{DLL_PREFIX, DLL_SUFFIX}, |
|
|
|
ffi::{OsStr, OsString}, |
|
|
|
path::Path, |
|
|
|
}; |
|
|
|
|
|
|
|
#[tokio::main] |
|
|
|
async fn main() -> eyre::Result<()> { |
|
|
|
@@ -88,7 +92,7 @@ async fn build_cxx_operator(path: &Path, out_name: &str) -> eyre::Result<()> { |
|
|
|
let mut link = tokio::process::Command::new("clang++"); |
|
|
|
link.arg("-shared").arg(&object_file_path); |
|
|
|
link.arg("-o") |
|
|
|
.arg(Path::new("../build").join(format!("lib{out_name}.so"))); |
|
|
|
.arg(Path::new("../build").join(library_filename(out_name))); |
|
|
|
if let Some(parent) = path.parent() { |
|
|
|
link.current_dir(parent); |
|
|
|
} |
|
|
|
@@ -98,3 +102,14 @@ async fn build_cxx_operator(path: &Path, out_name: &str) -> eyre::Result<()> { |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
|
|
|
|
// taken from `rust_libloading` crate by Simonas Kazlauskas, licensed under the ISC license ( |
|
|
|
// see https://github.com/nagisa/rust_libloading/blob/master/LICENSE) |
|
|
|
pub fn library_filename<S: AsRef<OsStr>>(name: S) -> OsString { |
|
|
|
let name = name.as_ref(); |
|
|
|
let mut string = OsString::with_capacity(name.len() + DLL_PREFIX.len() + DLL_SUFFIX.len()); |
|
|
|
string.push(DLL_PREFIX); |
|
|
|
string.push(name); |
|
|
|
string.push(DLL_SUFFIX); |
|
|
|
string |
|
|
|
} |