From 2ff219a1cbbf6c058fc8d346293b9241db2f1588 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 10 May 2026 14:39:16 +0200 Subject: [PATCH 1/5] build: add reusable build_website.sh script --- rust/build_website.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 rust/build_website.sh diff --git a/rust/build_website.sh b/rust/build_website.sh new file mode 100755 index 0000000..c198aef --- /dev/null +++ b/rust/build_website.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +WEBPACK_DIR="${SCRIPT_DIR}/src_webpack" +WEBSERVER_DIR="${SCRIPT_DIR}/src/webserver" + +rm -f "${WEBSERVER_DIR}/index.html.gz" +rm -f "${WEBSERVER_DIR}/bundle.js.gz" +rm -f "${WEBPACK_DIR}/index.html.gz" +rm -f "${WEBPACK_DIR}/bundle.js.gz" +rm -f "${WEBPACK_DIR}/index.html" +rm -f "${WEBPACK_DIR}/bundle.js" + +pushd "${WEBPACK_DIR}" +npm install +npx webpack build +cp index.html.gz "${WEBSERVER_DIR}/index.html.gz" +cp bundle.js.gz "${WEBSERVER_DIR}/bundle.js.gz" +popd From 578379c0d9888d48128bbcd96e1e84f7b7aba40b Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 10 May 2026 14:39:19 +0200 Subject: [PATCH 2/5] build: remove webpack integration from build.rs and add always-rebuild sentinel --- rust/build.rs | 71 +++------------------------------------------------ 1 file changed, 3 insertions(+), 68 deletions(-) diff --git a/rust/build.rs b/rust/build.rs index 05b5381..ec20e04 100644 --- a/rust/build.rs +++ b/rust/build.rs @@ -1,5 +1,3 @@ -use std::process::Command; - use vergen::EmitBuilder; fn linker_be_nice() { @@ -50,72 +48,9 @@ fn linker_be_nice() { } fn main() { - webpack(); linker_be_nice(); + // Non-existent path causes Cargo to always re-run this script, + // keeping VERGEN_BUILD_TIMESTAMP fresh on every build. + println!("cargo:rerun-if-changed=ALWAYS_REBUILD_SENTINEL"); let _ = EmitBuilder::builder().all_git().all_build().emit(); } - -fn webpack() { - //println!("cargo:rerun-if-changed=./src/src_webpack"); - Command::new("rm") - .arg("./src/webserver/bundle.js.gz") - .output() - .unwrap(); - - 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()); - - // move webpack results to rust webserver src - let _ = Command::new("cmd") - .arg("/K") - .arg("move") - .arg("./src_webpack/bundle.js.gz") - .arg("./src/webserver") - .output() - .unwrap(); - let _ = Command::new("cmd") - .arg("/K") - .arg("move") - .arg("./src_webpack/index.html.gz") - .arg("./src/webserver") - .output() - .unwrap(); - } - Err(_) => { - println!("Assuming build on linux"); - let output = Command::new("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()); - - // move webpack results to rust webserver src - let _ = Command::new("mv") - .arg("./src_webpack/bundle.js.gz") - .arg("./src/webserver") - .output() - .unwrap(); - let _ = Command::new("mv") - .arg("./src_webpack/index.html.gz") - .arg("./src/webserver") - .output() - .unwrap(); - } - } -} From cfe1c2c6d881b8cd8de4e32478d9d93823deecc6 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 10 May 2026 14:39:20 +0200 Subject: [PATCH 3/5] build: add flash.sh and all.sh scripts --- rust/all.sh | 22 ++++++++++++++++++++++ rust/flash.sh | 15 +++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 rust/all.sh create mode 100755 rust/flash.sh diff --git a/rust/all.sh b/rust/all.sh new file mode 100755 index 0000000..befcff7 --- /dev/null +++ b/rust/all.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +"${SCRIPT_DIR}/build_website.sh" + +cargo build --release +espflash save-image \ + --bootloader "${SCRIPT_DIR}/bootloader.bin" \ + --partition-table "${SCRIPT_DIR}/partitions.csv" \ + --chip esp32c6 \ + target/riscv32imac-unknown-none-elf/release/plant-ctrl2 \ + "${SCRIPT_DIR}/image.bin" + +espflash flash --monitor \ + --bootloader "${SCRIPT_DIR}/bootloader.bin" \ + --chip esp32c6 \ + --baud 921600 \ + --partition-table "${SCRIPT_DIR}/partitions.csv" \ + target/riscv32imac-unknown-none-elf/release/plant-ctrl2 diff --git a/rust/flash.sh b/rust/flash.sh new file mode 100755 index 0000000..67ad0ac --- /dev/null +++ b/rust/flash.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +"${SCRIPT_DIR}/build_website.sh" + +cargo build --release +espflash flash --monitor \ + --bootloader "${SCRIPT_DIR}/bootloader.bin" \ + --chip esp32c6 \ + --baud 921600 \ + --partition-table "${SCRIPT_DIR}/partitions.csv" \ + target/riscv32imac-unknown-none-elf/release/plant-ctrl2 From ae73f12d1c6e603399614ce1e11f7eb81dd440bb Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 10 May 2026 14:39:22 +0200 Subject: [PATCH 4/5] build: add image_build.sh and erase_ota.sh scripts --- rust/erase_ota.sh | 7 +++++++ rust/image_build.sh | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 rust/erase_ota.sh create mode 100755 rust/image_build.sh diff --git a/rust/erase_ota.sh b/rust/erase_ota.sh new file mode 100755 index 0000000..079ce36 --- /dev/null +++ b/rust/erase_ota.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +cargo espflash erase-parts otadata --partition-table "${SCRIPT_DIR}/partitions.csv" diff --git a/rust/image_build.sh b/rust/image_build.sh new file mode 100755 index 0000000..d4e0175 --- /dev/null +++ b/rust/image_build.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +rm -f "${SCRIPT_DIR}/image.bin" + +"${SCRIPT_DIR}/build_website.sh" + +cargo build --release +espflash save-image \ + --bootloader "${SCRIPT_DIR}/bootloader.bin" \ + --partition-table "${SCRIPT_DIR}/partitions.csv" \ + --chip esp32c6 \ + target/riscv32imac-unknown-none-elf/release/plant-ctrl2 \ + "${SCRIPT_DIR}/image.bin" From 0ab1ea3635883d7d7c17245d396152d3625dd1d6 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 10 May 2026 14:39:24 +0200 Subject: [PATCH 5/5] build: add build artifacts to .gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 2feaf34..209914f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,15 @@ target Cargo.lock node_modules/ rust/src/webserver/bundle.js +rust/src/webserver/bundle.js.gz rust/src/webserver/index.html +rust/src/webserver/index.html.gz +rust/src_webpack/bundle.js +rust/src_webpack/bundle.js.gz +rust/src_webpack/index.html +rust/src_webpack/index.html.gz rust/build/ rust/image.bin +rust/target/ +rust/Cargo.lock +rust/src_webpack/node_modules/