Skip to content

Commit 8bae639

Browse files
waychCobrand
authored andcommitted
Fix windows bundled example tests
Fixed by staging dll in deps directory. This is required for running comment examples as tests, which otherwise don't seem to be picking up the dll in library path when it is only dropped in the top most target_path. Fixes ``` failures: src/sdl2\event.rs - event::EventSender::push_custom_event (line 2874) src/sdl2\event.rs - event::crate::EventSubsystem::add_event_watch (line 244) src/sdl2\event.rs - event::crate::EventSubsystem::push_custom_event (line 203) src/sdl2\event.rs - event::crate::EventSubsystem::register_event (line 135) src/sdl2\rect.rs - rect::Rect::has_intersection (line 482) src/sdl2\rect.rs - rect::Rect::intersection (line 504) src/sdl2\rect.rs - rect::Rect::union (line 536) ``` when running `cargo test --features bundled` on Windows.
1 parent fd365de commit 8bae639

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sdl2-sys/build.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,16 +554,22 @@ fn copy_dynamic_libraries(sdl2_compiled_path: &PathBuf, target_os: &str) {
554554
if target_os.contains("windows") {
555555
let sdl2_dll_name = "SDL2.dll";
556556
let sdl2_bin_path = sdl2_compiled_path.join("bin");
557-
let target_path = find_cargo_target_dir();
558-
559557
let src_dll_path = sdl2_bin_path.join(sdl2_dll_name);
560-
let dst_dll_path = target_path.join(sdl2_dll_name);
561558

562-
fs::copy(&src_dll_path, &dst_dll_path).expect(&format!(
563-
"Failed to copy SDL2 dynamic library from {} to {}",
564-
src_dll_path.to_string_lossy(),
565-
dst_dll_path.to_string_lossy()
566-
));
559+
// Copy the dll to:
560+
// * target dir: as a product ship product of the build,
561+
// * deps directory: as comment example testing doesn't pick up the library search path
562+
// otherwise and fails.
563+
let target_path = find_cargo_target_dir();
564+
let deps_path = target_path.join("deps");
565+
for path in &[target_path, deps_path] {
566+
let dst_dll_path = path.join(&sdl2_dll_name);
567+
fs::copy(&src_dll_path, &dst_dll_path).expect(&format!(
568+
"Failed to copy SDL2 dynamic library from {} to {}",
569+
src_dll_path.to_string_lossy(),
570+
dst_dll_path.to_string_lossy()
571+
));
572+
}
567573
}
568574
}
569575

0 commit comments

Comments
 (0)