Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for else clauses #5

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ fn process_file(
};
let res = engine.eval::<bool>(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 //+
Expand Down
15 changes: 6 additions & 9 deletions template/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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
7 changes: 2 additions & 5 deletions template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
]}

Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions template/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down