Skip to content

Commit dc6f555

Browse files
Replace slashes in NDK path when building for android on windows (#1462)
On windows the ANDROID_NDK_HOME path can use backslashes. This causes issues in cmake. Replaces \ with / on windows compilation hosts. Co-authored-by: ciciplusplus <[email protected]>
1 parent bccd248 commit dc6f555

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sdl2-sys/build.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ fn compile_sdl2(sdl2_build_path: &Path, target_os: &str) -> PathBuf {
136136
}
137137

138138
if target_os == "android" {
139-
cfg.define(
140-
"ANDROID_NDK",
141-
env::var("ANDROID_NDK_HOME").expect(
142-
"ANDROID_NDK_HOME environment variable must be set when compiling for Android",
143-
),
144-
);
139+
let ndk_home = env::var("ANDROID_NDK_HOME")
140+
.expect("ANDROID_NDK_HOME environment variable must be set when compiling for Android");
141+
142+
#[cfg(target_os = "windows")]
143+
let ndk_home = ndk_home.replace("\\", "/");
144+
145+
cfg.define("ANDROID_NDK", ndk_home);
145146
}
146147

147148
if cfg!(feature = "static-link") {

0 commit comments

Comments
 (0)