Run ESP32 symbol analysis to identify optimization opportunities for binary size reduction.
(
arguments: dict[str, Any], project_root: Path
)
| 1931 | |
| 1932 | |
| 1933 | async def esp32_symbol_analysis( |
| 1934 | arguments: dict[str, Any], project_root: Path |
| 1935 | ) -> CallToolResult: |
| 1936 | """Run ESP32 symbol analysis to identify optimization opportunities for binary size reduction.""" |
| 1937 | import json |
| 1938 | import subprocess |
| 1939 | from pathlib import Path |
| 1940 | |
| 1941 | board = arguments.get("board", "auto") |
| 1942 | example = arguments.get("example", "Blink") |
| 1943 | skip_on_failure = arguments.get("skip_on_failure", True) |
| 1944 | output_json = arguments.get("output_json", False) |
| 1945 | focus_on_fastled = arguments.get("focus_on_fastled", True) |
| 1946 | |
| 1947 | result_text = "# ESP32 Symbol Analysis Report\n\n" |
| 1948 | |
| 1949 | try: |
| 1950 | # Define ESP32 boards |
| 1951 | esp32_boards = [ |
| 1952 | "esp32dev", |
| 1953 | "esp32", |
| 1954 | "esp32s2", |
| 1955 | "esp32s3", |
| 1956 | "esp32c3", |
| 1957 | "esp32c6", |
| 1958 | "esp32h2", |
| 1959 | "esp32p4", |
| 1960 | "esp32c2", |
| 1961 | ] |
| 1962 | |
| 1963 | # Find build directory |
| 1964 | build_dir = project_root / ".build" |
| 1965 | if not build_dir.exists(): |
| 1966 | return CallToolResult( |
| 1967 | content=[ |
| 1968 | TextContent( |
| 1969 | type="text", |
| 1970 | text="Build directory (.build) not found. Please compile an example first.", |
| 1971 | ) |
| 1972 | ], |
| 1973 | isError=not skip_on_failure, |
| 1974 | ) |
| 1975 | |
| 1976 | # Auto-detect board if needed |
| 1977 | if board == "auto": |
| 1978 | detected_boards: list[str] = [] |
| 1979 | for esp32_board in esp32_boards: |
| 1980 | candidate_dir = build_dir / esp32_board |
| 1981 | if ( |
| 1982 | candidate_dir.exists() |
| 1983 | and (candidate_dir / "build_info.json").exists() |
| 1984 | ): |
| 1985 | detected_boards.append(esp32_board) |
| 1986 | |
| 1987 | if not detected_boards: |
| 1988 | return CallToolResult( |
| 1989 | content=[ |
| 1990 | TextContent( |