118 lines
4.1 KiB
Rust
118 lines
4.1 KiB
Rust
use std::process::Command;
|
|
|
|
use vergen::EmitBuilder;
|
|
|
|
fn linker_be_nice() {
|
|
let args: Vec<String> = std::env::args().collect();
|
|
if args.len() > 1 {
|
|
let kind = &args[1];
|
|
let what = &args[2];
|
|
|
|
match kind.as_str() {
|
|
"undefined-symbol" => match what.as_str() {
|
|
"_defmt_timestamp" => {
|
|
eprintln!();
|
|
eprintln!("💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`");
|
|
eprintln!();
|
|
}
|
|
"_stack_start" => {
|
|
eprintln!();
|
|
eprintln!("💡 Is the linker script `linkall.x` missing?");
|
|
eprintln!();
|
|
}
|
|
"esp_wifi_preempt_enable"
|
|
| "esp_wifi_preempt_yield_task"
|
|
| "esp_wifi_preempt_task_create" => {
|
|
eprintln!();
|
|
eprintln!("💡 `esp-wifi` has no scheduler enabled. Make sure you have the `builtin-scheduler` feature enabled, or that you provide an external scheduler.");
|
|
eprintln!();
|
|
}
|
|
"embedded_test_linker_file_not_added_to_rustflags" => {
|
|
eprintln!();
|
|
eprintln!("💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests");
|
|
eprintln!();
|
|
}
|
|
_ => (),
|
|
},
|
|
// we don't have anything helpful for "missing-lib" yet
|
|
_ => {
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
|
|
std::process::exit(0);
|
|
}
|
|
|
|
println!(
|
|
"cargo:rustc-link-arg=--error-handling-script={}",
|
|
std::env::current_exe().unwrap().display()
|
|
);
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=./src/src_webpack");
|
|
Command::new("rm")
|
|
.arg("./src/webserver/bundle.js")
|
|
.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")
|
|
.arg("./src/webserver")
|
|
.output()
|
|
.unwrap();
|
|
let _ = Command::new("cmd")
|
|
.arg("/K")
|
|
.arg("move")
|
|
.arg("./src_webpack/index.html")
|
|
.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")
|
|
.arg("./src/webserver")
|
|
.output()
|
|
.unwrap();
|
|
let _ = Command::new("mv")
|
|
.arg("./src_webpack/index.html")
|
|
.arg("./src/webserver")
|
|
.output()
|
|
.unwrap();
|
|
}
|
|
}
|
|
linker_be_nice();
|
|
let _ = EmitBuilder::builder().all_git().all_build().emit();
|
|
}
|