Skip to content

Commit ee36f08

Browse files
Fix compilation of the xtask package under Windows
The qemu code makes use of some APIs from the `nix` crate, which causes compilation to fail on Windows (native, not WSL). The qemu code can't be easily made to work on Windows, but the rest of xtask should still work fine building, running clippy, etc. Fix by adding `#![cfg(unix)]` to the `qemu` module, as well as the `disk` and `net` modules that are only used by the qemu code. Also changed the `run_vm_tests` action to panic on non-Unix targets.
1 parent 959b9f4 commit ee36f08

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ publish = false
66

77
[dependencies]
88
anyhow = "1.0.51"
9+
cfg-if = "1.0.0"
910
clap = { version = "3.0.13", features = ["derive"] }
1011
# The latest fatfs release (0.3.5) is old, use git instead to pick up some fixes.
1112
fatfs = { git = "https://github.com/rafalh/rust-fatfs.git", rev = "87fc1ed5074a32b4e0344fcdde77359ef9e75432" }

xtask/src/disk.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(unix)]
2+
13
use anyhow::Result;
24
use fatfs::{Date, DateTime, FileSystem, FormatVolumeOptions, FsOptions, StdIoWrapper, Time};
35
use mbrman::{MBRPartitionEntry, CHS, MBR};

xtask/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod util;
88

99
use anyhow::Result;
1010
use cargo::{Cargo, CargoAction, Feature, Package};
11+
use cfg_if::cfg_if;
1112
use clap::Parser;
1213
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, MiriOpt, Opt, QemuOpt};
1314
use std::process::Command;
@@ -102,7 +103,13 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
102103
};
103104
run_cmd(cargo.command()?)?;
104105

105-
qemu::run_qemu(*opt.target, opt)
106+
cfg_if! {
107+
if #[cfg(unix)] {
108+
qemu::run_qemu(*opt.target, opt)
109+
} else {
110+
panic!("vm tests are only supported on unix targets");
111+
}
112+
}
106113
}
107114

108115
/// Run unit tests and doctests on the host. Most of uefi-rs is tested

xtask/src/net.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(unix)]
2+
13
use std::net::UdpSocket;
24

35
/// Start a thread that listens on UDP port 21572 and simulates a simple echo

xtask/src/qemu.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(unix)]
2+
13
use crate::arch::UefiArch;
24
use crate::disk::{check_mbr_test_disk, create_mbr_test_disk};
35
use crate::net;

0 commit comments

Comments
 (0)