Skip to content

Commit

Permalink
else-if
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Feb 10, 2025
1 parent 01378f1 commit a5db018
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,15 @@ fn process_file(
};
let res = engine.eval::<bool>(cond).unwrap();
include.push(res && *include.last().unwrap());
} else if trimmed.starts_with("#ELIF ") || trimmed.starts_with("//ELIF ") {
let cond = if trimmed.starts_with("#ELIF ") {
trimmed.strip_prefix("#ELIF ").unwrap()
} else {
trimmed.strip_prefix("//ELIF ").unwrap()
};
let res = engine.eval::<bool>(cond).unwrap();
let last = include.pop();
include.push(res && !last.unwrap());
} else if trimmed.starts_with("#ELSE") || trimmed.starts_with("//ELSE") {
let res = !*include.last().unwrap();
include.pop();
Expand Down
3 changes: 1 addition & 2 deletions template/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ ESP_LOG="INFO"
rustflags = [
#IF option("xtensa")
"-C", "link-arg=-nostartfiles",
#ENDIF
#IF option("riscv")
#ELIF option("riscv")
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",
Expand Down
14 changes: 7 additions & 7 deletions template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ esp-hal = { version = "0.23.1", features = [
"unstable",
#IF option("probe-rs")
#+"defmt",
#ELSE
"log",
#ENDIF
] }
#IF !option("probe-rs")
#REPLACE esp32c6 mcu
esp-println = { version = "0.13.0", features = ["esp32c6", "log"] }
log = { version = "0.4.21" }
#ELSE
#+defmt = "0.3.10"
#+defmt-rtt = "0.4.1"
#ENDIF
#IF option("alloc")
esp-alloc = { version = "0.6.0" }
Expand Down Expand Up @@ -61,8 +66,7 @@ esp-wifi = { version = "0.12.0", default-features=false, features = [
"esp-alloc",
#IF option("probe-rs")
#+"defmt",
#ENDIF
#IF !option("probe-rs")
#ELSE
"log",
#ENDIF
] }
Expand All @@ -86,15 +90,11 @@ smoltcp = { version = "0.12.0", default-features = false, features = [
#IF option("ble")
#+bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
#ENDIF
#IF option("probe-rs")
#+defmt = "0.3.10"
#+defmt-rtt = "0.4.1"
#ENDIF
#IF option("embassy")
embassy-executor = { version = "0.7.0", features = [
"task-arena-size-20480",
#IF option("probe-rs")
"defmt"
#+"defmt"
#ENDIF
] }
embassy-time = { version = "0.4.0", features = ["generic-queue-8"] }
Expand Down
3 changes: 1 addition & 2 deletions template/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ channel = "stable"
components = ["rust-src"]
#REPLACE riscv32imac-unknown-none-elf rust_target
targets = ["riscv32imac-unknown-none-elf"]
#ENDIF
#IF option("xtensa")
#ELIF option("xtensa")
#+channel = "esp"
#ENDIF
11 changes: 5 additions & 6 deletions template/src/bin/async_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use esp_hal::clock::CpuClock;
//IF option("probe-rs")
//+ use defmt_rtt as _;
//+ use defmt::info;
//ENDIF
//IF !option("probe-rs")
//ELSE
use log::info;
//ENDIF

Expand All @@ -24,17 +23,17 @@ async fn main(spawner: Spawner) {
//REPLACE generate-version generate-version
// generator version: generate-version

//IF !option("probe-rs")
esp_println::logger::init_logger_from_env();
//ENDIF

let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);

//IF option("alloc")
esp_alloc::heap_allocator!(72 * 1024);
//ENDIF

//IF !option("probe-rs")
esp_println::logger::init_logger_from_env();
//ENDIF

//IF !option("esp32")
let timer0 = esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER);
esp_hal_embassy::init(timer0.alarm0);
Expand Down
8 changes: 4 additions & 4 deletions template/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ fn main() -> ! {
//REPLACE generate-version generate-version
// generator version: generate-version

//IF !option("probe-rs")
esp_println::logger::init_logger_from_env();
//ENDIF

let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
//IF option("wifi") || option("ble")
let peripherals = esp_hal::init(config);
//ELSE
//+let _peripherals = esp_hal::init(config);
//ENDIF

//IF !option("probe-rs")
esp_println::logger::init_logger_from_env();
//ENDIF

//IF option("alloc")
esp_alloc::heap_allocator!(72 * 1024);
//ENDIF
Expand Down

0 comments on commit a5db018

Please sign in to comment.