Skip to content

Commit

Permalink
Merge pull request #22 from calavera/fix_zig_detection
Browse files Browse the repository at this point in the history
Fix Zig detection on Windows.
  • Loading branch information
messense authored Mar 31, 2022
2 parents ec99f3f + 9c227f7 commit d3ca67e
Showing 1 changed file with 18 additions and 4 deletions.
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

0 comments on commit d3ca67e

Please sign in to comment.