mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 08:25:01 +01:00
Use native library name
This commit is contained in:
parent
cf6706ebd6
commit
ea5fb6e4ba
1 changed files with 3 additions and 10 deletions
|
|
@ -96,17 +96,9 @@ impl RustFunction {
|
||||||
|
|
||||||
std::fs::write(&source_path, full_file).context("writing source")?;
|
std::fs::write(&source_path, full_file).context("writing source")?;
|
||||||
|
|
||||||
let library_path = file.path().join("libhelper");
|
|
||||||
|
|
||||||
let mut rustc = Command::new("rustc");
|
let mut rustc = Command::new("rustc");
|
||||||
rustc.arg(source_path);
|
rustc.arg(source_path);
|
||||||
rustc.args([
|
rustc.args(["--crate-type=cdylib", "--crate-name=helper", "--emit=link"]);
|
||||||
"--crate-type=cdylib",
|
|
||||||
"--crate-name=helper",
|
|
||||||
"--emit=link",
|
|
||||||
"-o",
|
|
||||||
]);
|
|
||||||
rustc.arg(&library_path);
|
|
||||||
rustc.current_dir(file.path());
|
rustc.current_dir(file.path());
|
||||||
|
|
||||||
let output = rustc.output().context("running rustc")?;
|
let output = rustc.output().context("running rustc")?;
|
||||||
|
|
@ -117,7 +109,8 @@ impl RustFunction {
|
||||||
|
|
||||||
// SAFETY: We are loading a simple rust cdylib, which does not do weird things. But we cannot unload Rust dylibs, so we use MD below.
|
// SAFETY: We are loading a simple rust cdylib, which does not do weird things. But we cannot unload Rust dylibs, so we use MD below.
|
||||||
let dylib = unsafe {
|
let dylib = unsafe {
|
||||||
libloading::Library::new(&library_path).context("loading helper shared library")?
|
libloading::Library::new(file.path().join(libloading::library_filename("helper")))
|
||||||
|
.context("loading helper shared library")?
|
||||||
};
|
};
|
||||||
let dylib = ManuallyDrop::new(dylib);
|
let dylib = ManuallyDrop::new(dylib);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue