|
12 | 12 | from .build import BuildTool, nuttx_builder |
13 | 13 | from .config import ConfigManager |
14 | 14 | from .env_data import clear_ntx_env, create_base_env_file, load_ntx_env |
| 15 | +from .nuttx import NuttxBoardExplorer |
15 | 16 | from .setup import download_nuttx_apps_repo, download_nuttx_repo |
16 | 17 | from .toolchains import ManagePath, ToolchainInstaller |
17 | 18 | from .utils import NUTTX_APPS_DEFAULT_DIR_NAME, NUTTX_DEFAULT_DIR_NAME, find_nuttx_root |
@@ -512,5 +513,77 @@ def menuconfig(menuconfig): |
512 | 513 | sys.exit(1) |
513 | 514 |
|
514 | 515 |
|
| 516 | +@main.group() |
| 517 | +def list(): # noqa: F811 |
| 518 | + """List available boards and defconfigs. |
| 519 | +
|
| 520 | + Provides commands to list boards and defconfigs in the NuttX repository. |
| 521 | + """ |
| 522 | + pass |
| 523 | + |
| 524 | + |
| 525 | +@list.command() |
| 526 | +@click.argument("soc") |
| 527 | +@click.option("--nuttx-dir", help="NuttX directory", default=NUTTX_DEFAULT_DIR_NAME) |
| 528 | +@click.option("--apps-dir", help="Apps directory", default=NUTTX_APPS_DEFAULT_DIR_NAME) |
| 529 | +def boards(soc, nuttx_dir, apps_dir): |
| 530 | + """List available boards for a specific SoC/chip. |
| 531 | +
|
| 532 | + Example usage: |
| 533 | + ntxbuild list boards <soc> |
| 534 | + """ |
| 535 | + current_dir = Path.cwd() |
| 536 | + logger.debug(f"Search for nuttx directory in: {current_dir}") |
| 537 | + |
| 538 | + # This validates the directory structure. We don't use prepare_env |
| 539 | + # because we don't need to load the environment just to check |
| 540 | + # available boards. |
| 541 | + nuttxspace = find_nuttx_root(current_dir, nuttx_dir, apps_dir) |
| 542 | + |
| 543 | + try: |
| 544 | + nuttx_path = nuttxspace / nuttx_dir |
| 545 | + explorer = NuttxBoardExplorer(nuttx_path) |
| 546 | + boards_list = explorer.set_soc(soc).boards |
| 547 | + if not boards_list: |
| 548 | + click.echo(f"No boards found for SoC: {soc}") |
| 549 | + sys.exit(0) |
| 550 | + explorer.print_board_summary() |
| 551 | + sys.exit(0) |
| 552 | + except Exception as e: |
| 553 | + click.echo(f"❌ {e}") |
| 554 | + sys.exit(1) |
| 555 | + |
| 556 | + |
| 557 | +@list.command() |
| 558 | +@click.argument("board") |
| 559 | +@click.option("--nuttx-dir", help="NuttX directory", default=NUTTX_DEFAULT_DIR_NAME) |
| 560 | +@click.option("--apps-dir", help="Apps directory", default=NUTTX_APPS_DEFAULT_DIR_NAME) |
| 561 | +def defconfigs(board, nuttx_dir, apps_dir): |
| 562 | + """List available defconfigs for a specific board. |
| 563 | +
|
| 564 | + Example usage: |
| 565 | + ntxbuild list defconfigs <board> |
| 566 | + """ |
| 567 | + current_dir = Path.cwd() |
| 568 | + logger.debug(f"Search for nuttx directory in: {current_dir}") |
| 569 | + |
| 570 | + # This validates the directory structure. We don't use prepare_env |
| 571 | + # because we don't need to load the environment just to check |
| 572 | + # available defconfigs. |
| 573 | + nuttxspace = find_nuttx_root(current_dir, nuttx_dir, apps_dir) |
| 574 | + try: |
| 575 | + nuttx_path = nuttxspace / nuttx_dir |
| 576 | + explorer = NuttxBoardExplorer(nuttx_path) |
| 577 | + boards_list = explorer.set_board(board).boards |
| 578 | + if not boards_list: |
| 579 | + click.echo(f"Board not found: {board}") |
| 580 | + sys.exit(0) |
| 581 | + boards_list[0].print_defconfig_summary() |
| 582 | + sys.exit(0) |
| 583 | + except Exception as e: |
| 584 | + click.echo(f"❌ {e}") |
| 585 | + sys.exit(1) |
| 586 | + |
| 587 | + |
515 | 588 | if __name__ == "__main__": |
516 | 589 | main() |
0 commit comments