mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 04:10:28 +00:00
Improve xtask
on Windows (#1632)
* Improve `xtask` on Windows * Use already existing `windows_safe_path` function
This commit is contained in:
parent
0ad4ee0c91
commit
7c25750e3a
@ -7,6 +7,8 @@ use std::{
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use crate::windows_safe_path;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum CargoAction {
|
||||
Build,
|
||||
@ -19,6 +21,12 @@ pub fn run(args: &[String], cwd: &Path) -> Result<()> {
|
||||
bail!("The `cwd` argument MUST be a directory");
|
||||
}
|
||||
|
||||
// Make sure to not use a UNC as CWD!
|
||||
// That would make `OUT_DIR` a UNC which will trigger things like the one fixed in https://github.com/dtolnay/rustversion/pull/51
|
||||
// While it's fixed in `rustversion` it's not fixed for other crates we are
|
||||
// using now or in future!
|
||||
let cwd = windows_safe_path(cwd);
|
||||
|
||||
let status = Command::new(get_cargo())
|
||||
.args(args)
|
||||
.current_dir(cwd)
|
||||
@ -37,6 +45,9 @@ pub fn run(args: &[String], cwd: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
fn get_cargo() -> String {
|
||||
// On Windows when executed via `cargo run` (e.g. via the xtask alias) the
|
||||
// `cargo` on the search path is NOT the cargo-wrapper but the `cargo` from the
|
||||
// toolchain - that one doesn't understand `+toolchain`
|
||||
#[cfg(target_os = "windows")]
|
||||
let cargo = if let Ok(cargo) = std::env::var("CARGO_HOME") {
|
||||
format!("{cargo}/bin/cargo")
|
||||
|
Loading…
x
Reference in New Issue
Block a user