From 88a7a04fdff187782393679dcab26d5c4be4c6e7 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Mon, 27 Oct 2025 20:59:16 +0000 Subject: [PATCH] demo: Don't hardcode binary name in build script This way, someone can copy & paste the build script into their own project. --- demo/build.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/demo/build.rs b/demo/build.rs index ecbfc70..58b93dd 100644 --- a/demo/build.rs +++ b/demo/build.rs @@ -8,8 +8,10 @@ pub fn main() { let rustc_lib: PathBuf = [&rustup_home, "toolchains", &toolchain, "lib"] .iter() .collect(); - println!( - "cargo:rustc-link-arg-bin=rpub-demo=-Wl,-rpath,{}", - rustc_lib.display() - ); + + // If your binary target has a different name to your package, you'll need + // to hardcode it here. + let bin_name = env::var("CARGO_PKG_NAME").unwrap(); + + println!("cargo:rustc-link-arg-bin={}=-Wl,-rpath,{}", bin_name, rustc_lib.display()); }