mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-08 19:06:14 -08:00
fix(build): resolve Windows library paths from the crate directory (#2616)
When another project uses easytier as a dependency on Windows, linking can fail because the build script emits relative native-library search paths such as easytier/third_party/x86_64/. These paths depend on the consuming project's directory layout instead of locating the libraries bundled with the easytier crate. Build an absolute search path from CARGO_MANIFEST_DIR, followed by third_party and the target architecture directory (x86_64, i686, or arm64). This lets the linker locate the bundled libraries regardless of where the consuming project is built.
This commit is contained in:
1 parent
3da349f4ee
commit
cea877ca77
1 file changed
+12
-6
+12
-6
@@ -9,14 +9,20 @@ impl WindowsBuild {
|
||||
pub fn check_for_win() {
|
||||
// add third_party dir to link search path
|
||||
let target = std::env::var("TARGET").unwrap_or_default();
|
||||
|
||||
if target.contains("x86_64") {
|
||||
println!("cargo:rustc-link-search=native=easytier/third_party/x86_64/");
|
||||
let variant = if target.contains("x86_64") {
|
||||
"x86_64"
|
||||
} else if target.contains("i686") {
|
||||
println!("cargo:rustc-link-search=native=easytier/third_party/i686/");
|
||||
"i686"
|
||||
} else if target.contains("aarch64") {
|
||||
println!("cargo:rustc-link-search=native=easytier/third_party/arm64/");
|
||||
}
|
||||
"arm64"
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut path = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
path.push("third_party");
|
||||
path.push(variant);
|
||||
println!("cargo:rustc-link-search=native={}", path.to_str().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user