Compare commits
5 Commits
36f5429f11
...
a247d2a571
| Author | SHA1 | Date | |
|---|---|---|---|
|
a247d2a571
|
|||
|
b94b4e5d76
|
|||
|
3f12610ad0
|
|||
|
47538081c7
|
|||
|
30b0415b34
|
9
.gitignore
vendored
9
.gitignore
vendored
@@ -8,15 +8,6 @@ target
|
|||||||
Cargo.lock
|
Cargo.lock
|
||||||
node_modules/
|
node_modules/
|
||||||
rust/src/webserver/bundle.js
|
rust/src/webserver/bundle.js
|
||||||
rust/src/webserver/bundle.js.gz
|
|
||||||
rust/src/webserver/index.html
|
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/build/
|
||||||
rust/image.bin
|
rust/image.bin
|
||||||
rust/target/
|
|
||||||
rust/Cargo.lock
|
|
||||||
rust/src_webpack/node_modules/
|
|
||||||
|
|||||||
22
rust/all.sh
22
rust/all.sh
@@ -1,22 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
use vergen::EmitBuilder;
|
use vergen::EmitBuilder;
|
||||||
|
|
||||||
fn linker_be_nice() {
|
fn linker_be_nice() {
|
||||||
@@ -48,9 +50,72 @@ fn linker_be_nice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
webpack();
|
||||||
linker_be_nice();
|
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();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
Reference in New Issue
Block a user