Skip to content

Use proper generator configuration in MinGW Windows toolchain #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,21 @@ impl Config {
// studio build system but instead use makefiles that MinGW can
// use to build.
if self.generator.is_none() {
cmd.arg("-G").arg("MSYS Makefiles");
// If make.exe isn't found, that means we may be using a MinGW
// toolchain instead of a MSYS2 toolchain. If neither is found,
// the build cannot continue.
let has_msys2 = Command::new("make").arg("--version").output().err()
.map(|e| e.kind() != ErrorKind::NotFound).unwrap_or(true);
let has_mingw32 = Command::new("mingw32-make").arg("--version").output().err()
.map(|e| e.kind() != ErrorKind::NotFound).unwrap_or(true);

let generator = match (has_msys2, has_mingw32) {
(true, _) => "MSYS Makefiles",
(false, true) => "MinGW Makefiles",
(false, false) => fail("no valid generator found for GNU toolchain; MSYS or MinGW must be installed")
};

cmd.arg("-G").arg(generator);
}
} else {
// If we're cross compiling onto windows, then set some
Expand Down