Parse an environment section into a typed dataclass.
(
config: configparser.ConfigParser, section_name: str
)
| 645 | |
| 646 | |
| 647 | def _parse_env_section( |
| 648 | config: configparser.ConfigParser, section_name: str |
| 649 | ) -> EnvironmentSection: |
| 650 | """ |
| 651 | Parse an environment section into a typed dataclass. |
| 652 | """ |
| 653 | section = config[section_name] |
| 654 | |
| 655 | # Extract environment name from section name (e.g., "env:esp32s3" -> "esp32s3") |
| 656 | env_name = section_name[4:] if section_name.startswith("env:") else section_name |
| 657 | |
| 658 | # Parse list-based options with variable resolution |
| 659 | build_flags = _resolve_list_variables( |
| 660 | _parse_list_value(section.get("build_flags", "")), config |
| 661 | ) |
| 662 | build_src_filter = _resolve_list_variables( |
| 663 | _parse_list_value(section.get("build_src_filter", "")), config |
| 664 | ) |
| 665 | targets = _resolve_list_variables( |
| 666 | _parse_list_value(section.get("targets", "")), config |
| 667 | ) |
| 668 | lib_deps = _resolve_list_variables( |
| 669 | _parse_list_value(section.get("lib_deps", "")), config |
| 670 | ) |
| 671 | lib_ignore = _resolve_list_variables( |
| 672 | _parse_list_value(section.get("lib_ignore", "")), config |
| 673 | ) |
| 674 | lib_extra_dirs = _resolve_list_variables( |
| 675 | _parse_list_value(section.get("lib_extra_dirs", "")), config |
| 676 | ) |
| 677 | monitor_filters = _resolve_list_variables( |
| 678 | _parse_list_value(section.get("monitor_filters", "")), config |
| 679 | ) |
| 680 | extra_scripts = _resolve_list_variables( |
| 681 | _parse_list_value(section.get("extra_scripts", "")), config |
| 682 | ) |
| 683 | |
| 684 | # Handle custom options (anything not in standard fields) |
| 685 | standard_options = { |
| 686 | "platform", |
| 687 | "framework", |
| 688 | "board", |
| 689 | "extends", |
| 690 | "build_type", |
| 691 | "build_flags", |
| 692 | "build_src_filter", |
| 693 | "targets", |
| 694 | "lib_deps", |
| 695 | "lib_ignore", |
| 696 | "lib_extra_dirs", |
| 697 | "lib_ldf_mode", |
| 698 | "upload_port", |
| 699 | "upload_protocol", |
| 700 | "upload_speed", |
| 701 | "monitor_port", |
| 702 | "monitor_speed", |
| 703 | "monitor_filters", |
| 704 | "board_build.mcu", |
no test coverage detected