Tricky build scenario

⚓ Rust    📅 2025-07-11    👤 surdeus    👁️ 2      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Tricky build scenario

I have a build scenario that's not completely straightforward because I'm using rust on Windows to build a dll with a C API for use with a non-rust application. Everything is working correctly except that I have to manually copy some files to different locations. I'd rather have these copies done by cargo.

I have the following to build my package:
src/lib.rs
src/main.rs
build.rs // prints "cargo:rustc-link-search=..." so lib directory is used for linker input

lib/static-support-lib.lib
lib/support2.lib // support2.dll import library
lib/support2.dll

The build artifacts under target are
my-test-app.exe
my-dll.dll
my-dll.dll.lib // my-dll.dll import library

So what I'd really like to happen is:
lib.rs is built to generate my-dll.dll and my-dll.dll.lib
my-dll.dll.lib is copied to lib/
main.rs is built to generate my-test.app.exe
support2.dll is copied to appropriate target subdirectory

What would be the best practice to accomplish this?

Do I need to go to a cargo workspace?

Should I bring in a tool like just?

Also, although it's working, I'm not sure if what I'm doing with build.rs is best practice since I didn't do a deep dive on this. The build.rs mechanism seems powerful but a bit cumbersome to specify a fixed bit of configuration.

1 post - 1 participant

Read full topic

🏷️ rust_feed