Skip to content
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

Fix Zig detection on Windows. #22

Merged
merged 1 commit into from
Mar 31, 2022
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
22 changes: 18 additions & 4 deletions src/zig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,14 @@ impl Zig {

/// Detect the plain zig binary
fn find_zig_bin() -> Result<(String, Vec<String>)> {
let output = Command::new("zig").arg("version").output()?;
let output = if cfg!(target_os = "windows") {
Command::new("cmd.exe")
.args(&["/c", "zig", "version"])
.output()?
} else {
Command::new("zig").arg("version").output()?
};

let version_str =
str::from_utf8(&output.stdout).context("`zig version` didn't return utf8 output")?;
Self::validate_zig_version(version_str)?;
Expand All @@ -178,9 +185,16 @@ impl Zig {

/// Detect the Python ziglang package
fn find_zig_python() -> Result<(String, Vec<String>)> {
let output = Command::new("python3")
.args(&["-m", "ziglang", "version"])
.output()?;
let output = if cfg!(target_os = "windows") {
Command::new("cmd.exe")
.args(&["/c", "python3", "-m", "ziglang", "version"])
.output()?
} else {
Command::new("python3")
.args(&["-m", "ziglang", "version"])
.output()?
};

let version_str = str::from_utf8(&output.stdout)
.context("`python3 -m ziglang version` didn't return utf8 output")?;
Self::validate_zig_version(version_str)?;
Expand Down