Skip to content

Commit b621c6d

Browse files
committed
Merge branch 'copy_to_deps' into copy_dll
2 parents c088ef9 + 79252c2 commit b621c6d

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

sdl2-sys/build.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -570,26 +570,22 @@ fn copy_dynamic_libraries(sdl2_compiled_path: &PathBuf, target_os: &str) {
570570
if target_os.contains("windows") {
571571
let sdl2_dll_name = format!("SDL2{}.dll", debug_postfix());
572572
let sdl2_bin_path = sdl2_compiled_path.join("bin");
573-
// Copy the file to both the target dir (as a product ship product of the build)
574-
// and to the deps sub directory, as comment example testing doesn't pick up the library
575-
// search path otherwise and fails.
576-
let target_path = find_cargo_target_dir();
577-
let deps_path = target_path.join("deps");
578-
579573
let src_dll_path = sdl2_bin_path.join(&sdl2_dll_name);
580-
let dst_dll_target_path = target_path.join(&sdl2_dll_name);
581-
let dst_dll_deps_path = deps_path.join(&sdl2_dll_name);
582574

583-
fs::copy(&src_dll_path, &dst_dll_target_path).expect(&format!(
584-
"Failed to copy SDL2 dynamic library from {} to {}",
585-
src_dll_path.to_string_lossy(),
586-
dst_dll_target_path.to_string_lossy()
587-
));
588-
fs::copy(&src_dll_path, &dst_dll_deps_path).expect(&format!(
589-
"Failed to copy SDL2 dynamic library from {} to {}",
590-
src_dll_path.to_string_lossy(),
591-
dst_dll_deps_path.to_string_lossy()
592-
));
575+
// Copy the dll to:
576+
// * target dir: as a product ship product of the build,
577+
// * deps directory: as comment example testing doesn't pick up the library search path
578+
// otherwise and fails.
579+
let target_path = find_cargo_target_dir();
580+
let deps_path = target_path.join("deps");
581+
for path in &[target_path, deps_path] {
582+
let dst_dll_path = path.join(&sdl2_dll_name);
583+
fs::copy(&src_dll_path, &dst_dll_path).expect(&format!(
584+
"Failed to copy SDL2 dynamic library from {} to {}",
585+
src_dll_path.to_string_lossy(),
586+
dst_dll_path.to_string_lossy()
587+
));
588+
}
593589
}
594590
}
595591

0 commit comments

Comments
 (0)