Skip to content

Commit cf623eb

Browse files
authored
Merge pull request #46 from Osspial/master
Use proper generator configuration in MinGW Windows toolchain
2 parents 4170366 + 9a9e548 commit cf623eb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,21 @@ impl Config {
307307
// studio build system but instead use makefiles that MinGW can
308308
// use to build.
309309
if self.generator.is_none() {
310-
cmd.arg("-G").arg("MSYS Makefiles");
310+
// If make.exe isn't found, that means we may be using a MinGW
311+
// toolchain instead of a MSYS2 toolchain. If neither is found,
312+
// the build cannot continue.
313+
let has_msys2 = Command::new("make").arg("--version").output().err()
314+
.map(|e| e.kind() != ErrorKind::NotFound).unwrap_or(true);
315+
let has_mingw32 = Command::new("mingw32-make").arg("--version").output().err()
316+
.map(|e| e.kind() != ErrorKind::NotFound).unwrap_or(true);
317+
318+
let generator = match (has_msys2, has_mingw32) {
319+
(true, _) => "MSYS Makefiles",
320+
(false, true) => "MinGW Makefiles",
321+
(false, false) => fail("no valid generator found for GNU toolchain; MSYS or MinGW must be installed")
322+
};
323+
324+
cmd.arg("-G").arg(generator);
311325
}
312326
} else {
313327
// If we're cross compiling onto windows, then set some

0 commit comments

Comments
 (0)