build.rs (2031B)
1 fn main() { 2 linker_be_nice(); 3 // make sure linkall.x is the last linker script (otherwise might cause problems with flip-link) 4 println!("cargo:rustc-link-arg=-Tlinkall.x"); 5 } 6 7 fn linker_be_nice() { 8 let args: Vec<String> = std::env::args().collect(); 9 if args.len() > 1 { 10 let kind = &args[1]; 11 let what = &args[2]; 12 13 match kind.as_str() { 14 "undefined-symbol" => match what.as_str() { 15 "_defmt_timestamp" => { 16 eprintln!(); 17 eprintln!( 18 "💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`" 19 ); 20 eprintln!(); 21 } 22 "_stack_start" => { 23 eprintln!(); 24 eprintln!("💡 Is the linker script `linkall.x` missing?"); 25 eprintln!(); 26 } 27 "esp_rtos_initialized" | "esp_rtos_yield_task" | "esp_rtos_task_create" => { 28 eprintln!(); 29 eprintln!( 30 "💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided an external scheduler." 31 ); 32 eprintln!(); 33 } 34 "embedded_test_linker_file_not_added_to_rustflags" => { 35 eprintln!(); 36 eprintln!( 37 "💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests" 38 ); 39 eprintln!(); 40 } 41 _ => (), 42 }, 43 // we don't have anything helpful for "missing-lib" yet 44 _ => { 45 std::process::exit(1); 46 } 47 } 48 49 std::process::exit(0); 50 } 51 52 println!( 53 "cargo:rustc-link-arg=--error-handling-script={}", 54 std::env::current_exe().unwrap().display() 55 ); 56 }