Skip to content

Commit

Permalink
Branch by arch in cmake generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Oct 17, 2023
1 parent 03c2dfe commit 49a51f5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmake/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[template]
cargo_generate_version = ">=0.17.4"

[hooks]
pre = ["pre-script.rhai"]

[placeholders.advanced]
type = "bool"
prompt = "Configure advanced template options?"
Expand Down
59 changes: 59 additions & 0 deletions cmake/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
let targets = #{
esp32: #{
arch: "xtensa",
rust_target: "xtensa-esp32-espidf",
gcc_target: "xtensa-esp32-elf",
wokwi_board: "board-esp32-devkit-v1",
},
esp32c2: #{
arch: "riscv",
rust_target: "riscv32imc-esp-espidf",
gcc_target: "riscv32-esp-elf",
wokwi_board: "",
},
esp32c3: #{
arch: "riscv",
rust_target: "riscv32imc-esp-espidf",
gcc_target: "riscv32-esp-elf",
wokwi_board: "board-esp32-c3-devkitm-1",
},
esp32c6: #{
arch: "riscv",
rust_target: "riscv32imac-esp-espidf",
gcc_target: "riscv32-esp-elf",
wokwi_board: "board-esp32-c6-devkitm-1",
},
esp32h2: #{
arch: "riscv",
rust_target: "riscv32imac-esp-espidf",
gcc_target: "riscv32-esp-elf",
wokwi_board: "",
},
esp32s2: #{
arch: "xtensa",
rust_target: "xtensa-esp32s2-espidf",
gcc_target: "xtensa-esp32s2-elf",
wokwi_board: "board-esp32-s2-devkitm-1",
},
esp32s3: #{
arch: "xtensa",
rust_target: "xtensa-esp32s3-espidf",
gcc_target: "xtensa-esp32s3-elf",
wokwi_board: "board-esp32-s3-devkitc-1",
},
};

let target = variable::get("mcu");
let target_properties = targets.get(target);
for key in target_properties.keys() {
variable::set(key, target_properties.get(key));
}

let advanced = variable::get("advanced");
if !advanced {
variable::set("hal", true);
variable::set("std", true);
variable::set("espidfver", "v5.1");
variable::set("devcontainer", false);
variable::set("wokwi", false);
}

0 comments on commit 49a51f5

Please sign in to comment.