From 556e64740a11cdc579f59a8af40e508eecaf0828 Mon Sep 17 00:00:00 2001 From: Empire Date: Sat, 17 Feb 2024 18:40:11 +0100 Subject: [PATCH] allow build to run on windows as well --- rust/.cargo/config.toml | 4 ++-- rust/build.rs | 40 ++++++++++++++++++++++++++++++---------- rust/rust-toolchain.toml | 2 +- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/rust/.cargo/config.toml b/rust/.cargo/config.toml index 29aa76a..8b89996 100644 --- a/rust/.cargo/config.toml +++ b/rust/.cargo/config.toml @@ -4,8 +4,8 @@ target = "xtensa-esp32-espidf" [target.xtensa-esp32-espidf] linker = "ldproxy" #runner = "espflash flash --monitor --partition-table partitions.csv" # Select this runner for espflash v2.x.x -runner = "espflash flash --monitor --baud 921600 --partition-table partitions.csv" # Select this runner for espflash v2.x.x -#runner = "cargo runner" +#runner = "espflash flash --monitor --baud 921600 --partition-table partitions.csv" # Select this runner for espflash v2.x.x +runner = "cargo runner" rustflags = [ "--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 [unstable] diff --git a/rust/build.rs b/rust/build.rs index af70f78..73c9573 100644 --- a/rust/build.rs +++ b/rust/build.rs @@ -6,19 +6,39 @@ fn main() { Command::new("rm") .arg("./src/webserver/bundle.js") .output() - .expect("failed to execute process"); + .unwrap(); - let output = Command::new("npx") - .arg("webpack") - .current_dir("./src_webpack") - .output() - .expect("failed to execute process"); + match Command::new("cmd").spawn() { + Ok(_) => { + println!("Assuming build on windows"); + let output = Command::new("cmd") + .arg("/K") + .arg("npx") + .arg("webpack") + .current_dir("./src_webpack") + .output() + .unwrap(); + println!("status: {}", output.status); + println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); + println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + assert!(output.status.success()); + }, + Err(_) => { + println!("Assuming build on linux"); + let output = Command::new("bash") + .arg("webpack") + .current_dir("./src_webpack") + .output() + .unwrap(); + println!("status: {}", output.status); + println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); + println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + assert!(output.status.success()); + }, + + } - println!("status: {}", output.status); - println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); - println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); - assert!(output.status.success()); embuild::espidf::sysenv::output(); let _ = EmitBuilder::builder().all_git().emit(); diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index a25e7e0..fd2fa13 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] channel = "nightly" - +toolchain = "esp"