Merge branch 'feature/build-scripts-from-develop' into legacy/v3-support
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -8,6 +8,15 @@ 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
Executable file
22
rust/all.sh
Executable file
@@ -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
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use vergen::EmitBuilder;
|
use vergen::EmitBuilder;
|
||||||
|
|
||||||
fn linker_be_nice() {
|
fn linker_be_nice() {
|
||||||
@@ -50,72 +48,9 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
21
rust/build_website.sh
Executable file
21
rust/build_website.sh
Executable file
@@ -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
|
||||||
7
rust/erase_ota.sh
Executable file
7
rust/erase_ota.sh
Executable file
@@ -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"
|
||||||
15
rust/flash.sh
Executable file
15
rust/flash.sh
Executable file
@@ -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
|
||||||
17
rust/image_build.sh
Executable file
17
rust/image_build.sh
Executable file
@@ -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"
|
||||||
Reference in New Issue
Block a user