How zephyrproject-rtos/west works
Project type and purpose
• West is a Python-based CLI meta-tool for managing multiple Git repositories according to a YAML “manifest” file.
• It’s not a web service or GUI; it’s a single binary (console) application that orchestrates Git operations, parses manifests, and provides an extensible command framework.
File structure
• Top-level:
• Configuration & metadata: pyproject.toml, README.rst, LICENSE, tox.ini, CI workflows under .github, docker-testing
• Source code under src/west:
– __main__.py: CLI entrypoint
– commands.py: top-level sub-command dispatcher
– app/: core implementation (config.py, main.py, project.py, manifest/schema)
– util.py, log.py, configuration.py, version.py
– manifest.py & manifest-schema.yml: manifest parsing & validation
– west-commands-schema.yml: extension/plugin schema
• Tests under tests/ using pytest via tox.
• docker-testing: containerized environment for distro-specific testing.
README for additional insights
• Lists major commands: init, update, extensible sub-commands.
• Emphasizes plugin/extension support (“add new commands without modifying its source code”).
• Describes workflows: pip install, tox test, docker testing.
Main components & interactions
a. CLI Layer
• Entrypoint (src/west/__main__.py) invokes commands.py
• Command dispatcher routes to built-in or extension commands
b. Core Application Layer (src/west/app)
• Configuration Manager (config.py): loads pyproject, CLI args, manifest defaults
• Manifest Processor (manifest.py + schema): parses, validates YAML manifest; builds internal manifest model
• Project Manager (project.py): given manifest model, computes repository list, local paths, remote URLs
• Main Orchestrator (main.py): coordinates init, update, other operations; calls Git subprocesses
c. Utility Layer
• Logging (log.py): sets up console/file logging
• Generic helpers (util.py): filesystem, subprocess, path manipulation
• Version (version.py): package version metadata
d. Extension/Plugin Layer
• west-commands-schema.yml defines how external commands hook into commands.py
• CLI dispatcher dynamically loads plugin entry points
e. External Systems
• Remote Git servers (manifest remotes)
• Local file system for clone/update
• CI/CD (tox, GitHub Actions, Docker)
f. Testing Infrastructure
• pytest tests under tests/
• docker-testing directory for distro-specific container tests
• CI workflows (.github/workflows/*.yml) invoke lint, test, security scans
Architectural patterns
• Modular CLI with plugin architecture (extension points via entry points and schema)
• Clear separation: CLI dispatch -> core services -> utilities -> external
• Model-View-Controller analogy:
• Controller = command dispatcher
• Model = manifest & project representations
• View = console output via logging