Browse Source

Merge pull request #191 from dora-rs/tweaks

Simplify: Replace `library_filename` function with `format!` call
tags/v0.2.0-candidate
Philipp Oppermann GitHub 2 years ago
parent
commit
c74c2c97e3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 24 deletions
  1. +1
    -12
      examples/c++-dataflow/run.rs
  2. +1
    -12
      examples/c-dataflow/run.rs

+ 1
- 12
examples/c++-dataflow/run.rs View File

@@ -257,7 +257,7 @@ async fn build_cxx_operator(
link.arg("-fms-runtime-lib=static");
}
link.arg("-o")
.arg(Path::new("../build").join(library_filename(out_name)));
.arg(Path::new("../build").join(format!("{DLL_PREFIX}{out_name}{DLL_SUFFIX}")));
if let Some(parent) = paths[0].parent() {
link.current_dir(parent);
}
@@ -267,14 +267,3 @@ async fn build_cxx_operator(

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
}

+ 1
- 12
examples/c-dataflow/run.rs View File

@@ -117,21 +117,10 @@ async fn build_c_operator() -> eyre::Result<()> {
let mut link = tokio::process::Command::new("clang");
link.arg("-shared").arg("build/operator.o");
link.arg("-o")
.arg(Path::new("build").join(library_filename("operator")));
.arg(Path::new("build").join(format!("{DLL_PREFIX}operator{DLL_SUFFIX}")));
if !link.status().await?.success() {
bail!("failed to link c operator");
};

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
}

Loading…
Cancel
Save