Skip to content

Commit c7cd6d4

Browse files
demo: Don't hardcode binary name in build script (#112)
This way, someone can copy & paste the build script into their own project.
1 parent 6500c72 commit c7cd6d4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

demo/build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ pub fn main() {
88
let rustc_lib: PathBuf = [&rustup_home, "toolchains", &toolchain, "lib"]
99
.iter()
1010
.collect();
11-
println!(
12-
"cargo:rustc-link-arg-bin=rpub-demo=-Wl,-rpath,{}",
13-
rustc_lib.display()
14-
);
11+
12+
// If your binary target has a different name to your package, you'll need
13+
// to hardcode it here.
14+
let bin_name = env::var("CARGO_PKG_NAME").unwrap();
15+
16+
println!("cargo:rustc-link-arg-bin={}=-Wl,-rpath,{}", bin_name, rustc_lib.display());
1517
}

0 commit comments

Comments
 (0)