diff --git a/CMakeLists.txt b/CMakeLists.txt index a32048cb..871bd88b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,5 +9,5 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake) # "Trim" the build. Include the minimal set of components, main, and anything it depends on. idf_build_set_property(MINIMAL_BUILD ON) -set(PROJECT_VER "2.2.2") +set(PROJECT_VER "2.2.3") project(xiaozhi) diff --git a/scripts/release.py b/scripts/release.py index dc8de7cb..83681c22 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -101,27 +101,25 @@ def _collect_variants(config_filename: str = "config.json") -> list[dict[str, st -def _parse_board_config_map() -> dict[str, str]: - """Build the mapping of CONFIG_BOARD_TYPE_xxx and board_type from main/CMakeLists.txt""" - cmake_file = Path("main/CMakeLists.txt") - mapping: dict[str, str] = {} - lines = cmake_file.read_text(encoding="utf-8").splitlines() - for idx, line in enumerate(lines): - if "if(CONFIG_BOARD_TYPE_" in line: - config_name = line.strip().split("if(")[1].split(")")[0] - if idx + 1 < len(lines): - next_line = lines[idx + 1].strip() - if next_line.startswith("set(BOARD_TYPE"): - board_type = next_line.split('"')[1] - mapping[config_name] = board_type - return mapping - - def _find_board_config(board_type: str) -> Optional[str]: - """Find the corresponding CONFIG_BOARD_TYPE_xxx for the given board_type""" - for config, b_type in _parse_board_config_map().items(): - if b_type == board_type: - return config + """Find the corresponding CONFIG_BOARD_TYPE_xxx for the given board_type + + Search backwards from 'set(BOARD_TYPE "xxx")' to find the nearest if(CONFIG_BOARD_TYPE_). + """ + board_leaf = board_type.split("/")[-1] + pattern = f'set(BOARD_TYPE "{board_leaf}")' + + cmake_file = Path("main/CMakeLists.txt") + lines = cmake_file.read_text(encoding="utf-8").splitlines() + + for idx, line in enumerate(lines): + if pattern in line: + # Found the BOARD_TYPE line, search backwards for the config + for back_idx in range(idx - 1, -1, -1): + back_line = lines[back_idx] + if "if(CONFIG_BOARD_TYPE_" in back_line: + return back_line.strip().split("if(")[1].split(")")[0] + break return None