diff --git a/src/main.rs b/src/main.rs index 424f1e2..def5926 100644 --- a/src/main.rs +++ b/src/main.rs @@ -382,6 +382,10 @@ fn process_file( }; let res = engine.eval::(cond).unwrap(); include.push(res && *include.last().unwrap()); + } else if trimmed.starts_with("#ELSE") || trimmed.starts_with("//ELSE") { + let res = !*include.last().unwrap(); + include.pop(); + include.push(res); } else if trimmed.starts_with("#ENDIF") || trimmed.starts_with("//ENDIF") { include.pop(); // Trim #+ and //+ diff --git a/template/.cargo/config.toml b/template/.cargo/config.toml index 28f504c..f9f8b2f 100644 --- a/template/.cargo/config.toml +++ b/template/.cargo/config.toml @@ -1,19 +1,17 @@ #REPLACE riscv32imac-unknown-none-elf rust_target [target.riscv32imac-unknown-none-elf] -#IF !option("probe-rs") -runner = "espflash flash --monitor" -#ENDIF #IF option("probe-rs") #REPLACE esp32c6 mcu -#+runner = "probe-rs run --chip=esp32c6" +runner = "probe-rs run --chip=esp32c6" +#ELSE +#+runner = "espflash flash --monitor" #ENDIF [env] -#IF !option("probe-rs") -ESP_LOGLEVEL="INFO" -#ENDIF #IF option("probe-rs") DEFMT_LOG="info" +#ELSE +ESP_LOGLEVEL="INFO" #ENDIF [build] @@ -37,7 +35,6 @@ target = "riscv32imac-unknown-none-elf" [unstable] #IF option("alloc") build-std = ["alloc", "core"] -#ENDIF -#IF !option("alloc") +#ELSE #+build-std = ["core"] #ENDIF diff --git a/template/Cargo.toml b/template/Cargo.toml index 5126657..f5e2c46 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -10,11 +10,10 @@ esp-backtrace = { version = "0.14.1", features = [ "esp32c6", "exception-handler", "panic-handler", - #IF !option("probe-rs") - "println", - #ENDIF #IF option("probe-rs") #+"defmt", + #ELSE + "println", #ENDIF ]} @@ -28,8 +27,6 @@ esp-hal = { version = "0.20.1", features = [ #IF !option("probe-rs") #REPLACE esp32c6 mcu esp-println = { version = "0.11.0", features = ["esp32c6", "log"] } -#ENDIF -#IF !option("probe-rs") log = { version = "0.4.21" } #ENDIF #IF option("alloc") diff --git a/template/src/bin/main.rs b/template/src/bin/main.rs index c350a29..8efbdcd 100644 --- a/template/src/bin/main.rs +++ b/template/src/bin/main.rs @@ -14,8 +14,7 @@ use esp_hal::timer::timg::TimerGroup; //IF option("probe-rs") //+ use defmt_rtt as _; //+ use defmt::info; -//ENDIF -//IF !option("probe-rs") +//ELSE use log::info; //ENDIF