Skip to content

Commit

Permalink
Unbreak .def generation
Browse files Browse the repository at this point in the history
Fixes #426.
  • Loading branch information
lu-zero committed Nov 29, 2024
1 parent c027fcf commit b022ff1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,23 @@ fn build_def_file(
// Create the .def output file
let def_file = cargo_util::paths::create(targetdir.join(format!("{name}.def")))?;

write_def_file(dll_file, def_file)?;
write_def_file(name, dll_file, def_file)?;
}

Ok(())
}

fn write_def_file<W: std::io::Write>(dll_file: object::File, mut def_file: W) -> anyhow::Result<W> {
fn write_def_file<W: std::io::Write>(
name: &str,
dll_file: object::File,
mut def_file: W,
) -> anyhow::Result<W> {
use object::read::Object;

writeln!(def_file, "LIBRARY \"{name}.dll\"")?;
writeln!(def_file, "EXPORTS")?;

for export in dll_file.exports()? {
def_file.write_all(b"\t")?;
def_file.write_all(export.name())?;
def_file.write_all(b"\n")?;
}
Expand Down

0 comments on commit b022ff1

Please sign in to comment.