Zephyr开发中的Manifest文件完全解析
引言
在Zephyr RTOS开发中,Manifest文件是一个至关重要的配置文件,它定义了整个项目的仓库结构、依赖关系和版本管理。作为West工具的核心配置,Manifest文件让开发者能够轻松管理多个Git仓库,实现模块化开发和版本控制。
本文将深入解析Manifest文件的概念、作用、功能、文件格式、内容和语法,帮助您全面理解这一关键配置文件。
一、Manifest文件是什么
1.1 定义与概念
Manifest文件是一个YAML格式的配置文件,用于定义Zephyr项目中包含的所有Git仓库及其相关信息。它是West多仓库管理工具的核心配置文件。
#mermaid-svg-NkNGO5xPHJYrpMNC{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-NkNGO5xPHJYrpMNC .error-icon{fill:#552222;}#mermaid-svg-NkNGO5xPHJYrpMNC .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-NkNGO5xPHJYrpMNC .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-NkNGO5xPHJYrpMNC .marker{fill:#333333;stroke:#333333;}#mermaid-svg-NkNGO5xPHJYrpMNC .marker.cross{stroke:#333333;}#mermaid-svg-NkNGO5xPHJYrpMNC svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-NkNGO5xPHJYrpMNC p{margin:0;}#mermaid-svg-NkNGO5xPHJYrpMNC .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster-label text{fill:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster-label span{color:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster-label span p{background-color:transparent;}#mermaid-svg-NkNGO5xPHJYrpMNC .label text,#mermaid-svg-NkNGO5xPHJYrpMNC span{fill:#333;color:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC .node rect,#mermaid-svg-NkNGO5xPHJYrpMNC .node circle,#mermaid-svg-NkNGO5xPHJYrpMNC .node ellipse,#mermaid-svg-NkNGO5xPHJYrpMNC .node polygon,#mermaid-svg-NkNGO5xPHJYrpMNC .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-NkNGO5xPHJYrpMNC .rough-node .label text,#mermaid-svg-NkNGO5xPHJYrpMNC .node .label text,#mermaid-svg-NkNGO5xPHJYrpMNC .image-shape .label,#mermaid-svg-NkNGO5xPHJYrpMNC .icon-shape .label{text-anchor:middle;}#mermaid-svg-NkNGO5xPHJYrpMNC .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-NkNGO5xPHJYrpMNC .rough-node .label,#mermaid-svg-NkNGO5xPHJYrpMNC .node .label,#mermaid-svg-NkNGO5xPHJYrpMNC .image-shape .label,#mermaid-svg-NkNGO5xPHJYrpMNC .icon-shape .label{text-align:center;}#mermaid-svg-NkNGO5xPHJYrpMNC .node.clickable{cursor:pointer;}#mermaid-svg-NkNGO5xPHJYrpMNC .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-NkNGO5xPHJYrpMNC .arrowheadPath{fill:#333333;}#mermaid-svg-NkNGO5xPHJYrpMNC .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-NkNGO5xPHJYrpMNC .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-NkNGO5xPHJYrpMNC .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-NkNGO5xPHJYrpMNC .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-NkNGO5xPHJYrpMNC .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-NkNGO5xPHJYrpMNC .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster text{fill:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC .cluster span{color:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-NkNGO5xPHJYrpMNC .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-NkNGO5xPHJYrpMNC rect.text{fill:none;stroke-width:0;}#mermaid-svg-NkNGO5xPHJYrpMNC .icon-shape,#mermaid-svg-NkNGO5xPHJYrpMNC .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-NkNGO5xPHJYrpMNC .icon-shape p,#mermaid-svg-NkNGO5xPHJYrpMNC .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-NkNGO5xPHJYrpMNC .icon-shape .label rect,#mermaid-svg-NkNGO5xPHJYrpMNC .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-NkNGO5xPHJYrpMNC .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-NkNGO5xPHJYrpMNC .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-NkNGO5xPHJYrpMNC :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Manifest文件
定义仓库列表
指定版本信息
配置路径结构
管理依赖关系
项目名称
仓库URL
分支/标签
Commit SHA
本地路径
目录结构
仓库依赖
导入规则
1.2 Manifest文件的作用
Manifest文件在Zephyr开发中扮演着项目蓝图的角色:
| 作用 | 描述 |
|---|---|
| 仓库管理 | 定义项目包含的所有Git仓库 |
| 版本控制 | 指定每个仓库的版本(分支、标签或Commit) |
| 路径映射 | 定义仓库在本地工作区的存放路径 |
| 依赖解析 | 管理仓库之间的依赖关系 |
| 模块化开发 | 支持按需加载不同的组件和模块 |
1.3 Manifest文件的位置
#mermaid-svg-uwtcgPwqLhb2xM51{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-uwtcgPwqLhb2xM51 .error-icon{fill:#552222;}#mermaid-svg-uwtcgPwqLhb2xM51 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-uwtcgPwqLhb2xM51 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-uwtcgPwqLhb2xM51 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-uwtcgPwqLhb2xM51 .marker.cross{stroke:#333333;}#mermaid-svg-uwtcgPwqLhb2xM51 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-uwtcgPwqLhb2xM51 p{margin:0;}#mermaid-svg-uwtcgPwqLhb2xM51 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster-label text{fill:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster-label span{color:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster-label span p{background-color:transparent;}#mermaid-svg-uwtcgPwqLhb2xM51 .label text,#mermaid-svg-uwtcgPwqLhb2xM51 span{fill:#333;color:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 .node rect,#mermaid-svg-uwtcgPwqLhb2xM51 .node circle,#mermaid-svg-uwtcgPwqLhb2xM51 .node ellipse,#mermaid-svg-uwtcgPwqLhb2xM51 .node polygon,#mermaid-svg-uwtcgPwqLhb2xM51 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-uwtcgPwqLhb2xM51 .rough-node .label text,#mermaid-svg-uwtcgPwqLhb2xM51 .node .label text,#mermaid-svg-uwtcgPwqLhb2xM51 .image-shape .label,#mermaid-svg-uwtcgPwqLhb2xM51 .icon-shape .label{text-anchor:middle;}#mermaid-svg-uwtcgPwqLhb2xM51 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-uwtcgPwqLhb2xM51 .rough-node .label,#mermaid-svg-uwtcgPwqLhb2xM51 .node .label,#mermaid-svg-uwtcgPwqLhb2xM51 .image-shape .label,#mermaid-svg-uwtcgPwqLhb2xM51 .icon-shape .label{text-align:center;}#mermaid-svg-uwtcgPwqLhb2xM51 .node.clickable{cursor:pointer;}#mermaid-svg-uwtcgPwqLhb2xM51 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-uwtcgPwqLhb2xM51 .arrowheadPath{fill:#333333;}#mermaid-svg-uwtcgPwqLhb2xM51 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-uwtcgPwqLhb2xM51 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-uwtcgPwqLhb2xM51 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-uwtcgPwqLhb2xM51 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-uwtcgPwqLhb2xM51 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-uwtcgPwqLhb2xM51 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster text{fill:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 .cluster span{color:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-uwtcgPwqLhb2xM51 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-uwtcgPwqLhb2xM51 rect.text{fill:none;stroke-width:0;}#mermaid-svg-uwtcgPwqLhb2xM51 .icon-shape,#mermaid-svg-uwtcgPwqLhb2xM51 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-uwtcgPwqLhb2xM51 .icon-shape p,#mermaid-svg-uwtcgPwqLhb2xM51 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-uwtcgPwqLhb2xM51 .icon-shape .label rect,#mermaid-svg-uwtcgPwqLhb2xM51 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-uwtcgPwqLhb2xM51 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-uwtcgPwqLhb2xM51 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-uwtcgPwqLhb2xM51 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 工作区根目录
west.yml
.west/config
.west/local/
主Manifest文件
配置指向
本地扩展文件
默认位置
自定义扩展
Manifest文件的典型位置:
~/zephyrproject/
├── .west/
│ ├── config # West配置文件
│ ├── manifest.xml # Manifest缓存(自动生成)
│ └── local/ # 本地Manifest扩展目录
│ ├── extra.yml # 扩展Manifest文件
│ └── addons.yml # 扩展Manifest文件
├── west.yml # 主Manifest文件(默认)
└── zephyr/
└── west.yml # Zephyr核心仓库的Manifest
二、Manifest文件的功能
2.1 核心功能概览
#mermaid-svg-inh7hvClHrbG0Zox{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-inh7hvClHrbG0Zox .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-inh7hvClHrbG0Zox .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-inh7hvClHrbG0Zox .error-icon{fill:#552222;}#mermaid-svg-inh7hvClHrbG0Zox .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-inh7hvClHrbG0Zox .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-inh7hvClHrbG0Zox .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-inh7hvClHrbG0Zox .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-inh7hvClHrbG0Zox .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-inh7hvClHrbG0Zox .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-inh7hvClHrbG0Zox .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-inh7hvClHrbG0Zox .marker{fill:#333333;stroke:#333333;}#mermaid-svg-inh7hvClHrbG0Zox .marker.cross{stroke:#333333;}#mermaid-svg-inh7hvClHrbG0Zox svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-inh7hvClHrbG0Zox p{margin:0;}#mermaid-svg-inh7hvClHrbG0Zox .edge{stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .section--1 rect,#mermaid-svg-inh7hvClHrbG0Zox .section--1 path,#mermaid-svg-inh7hvClHrbG0Zox .section--1 circle,#mermaid-svg-inh7hvClHrbG0Zox .section--1 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section--1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section--1 text{fill:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon--1{font-size:40px;color:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge--1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth--1{stroke-width:17;}#mermaid-svg-inh7hvClHrbG0Zox .section--1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-0 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-0 path,#mermaid-svg-inh7hvClHrbG0Zox .section-0 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-0 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-inh7hvClHrbG0Zox .section-0 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-0{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-0{stroke-width:14;}#mermaid-svg-inh7hvClHrbG0Zox .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-1 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-1 path,#mermaid-svg-inh7hvClHrbG0Zox .section-1 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-1 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-1 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-1{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-1{stroke-width:11;}#mermaid-svg-inh7hvClHrbG0Zox .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-2 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-2 path,#mermaid-svg-inh7hvClHrbG0Zox .section-2 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-2 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-2 text{fill:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-2{stroke-width:8;}#mermaid-svg-inh7hvClHrbG0Zox .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-3 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-3 path,#mermaid-svg-inh7hvClHrbG0Zox .section-3 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-3 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-3 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-3{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-3{stroke-width:5;}#mermaid-svg-inh7hvClHrbG0Zox .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-4 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-4 path,#mermaid-svg-inh7hvClHrbG0Zox .section-4 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-4 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-4 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-4{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-4{stroke-width:2;}#mermaid-svg-inh7hvClHrbG0Zox .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-5 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-5 path,#mermaid-svg-inh7hvClHrbG0Zox .section-5 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-5 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-5 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-5{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-5{stroke-width:-1;}#mermaid-svg-inh7hvClHrbG0Zox .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-6 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-6 path,#mermaid-svg-inh7hvClHrbG0Zox .section-6 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-6 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-6 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-6{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-6{stroke-width:-4;}#mermaid-svg-inh7hvClHrbG0Zox .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-7 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-7 path,#mermaid-svg-inh7hvClHrbG0Zox .section-7 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-7 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-7 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-7{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-7{stroke-width:-7;}#mermaid-svg-inh7hvClHrbG0Zox .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-8 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-8 path,#mermaid-svg-inh7hvClHrbG0Zox .section-8 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-8 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-8 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-8{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-8{stroke-width:-10;}#mermaid-svg-inh7hvClHrbG0Zox .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-9 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-9 path,#mermaid-svg-inh7hvClHrbG0Zox .section-9 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-9 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-9 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-9{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-9{stroke-width:-13;}#mermaid-svg-inh7hvClHrbG0Zox .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-10 rect,#mermaid-svg-inh7hvClHrbG0Zox .section-10 path,#mermaid-svg-inh7hvClHrbG0Zox .section-10 circle,#mermaid-svg-inh7hvClHrbG0Zox .section-10 polygon,#mermaid-svg-inh7hvClHrbG0Zox .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-10 text{fill:black;}#mermaid-svg-inh7hvClHrbG0Zox .node-icon-10{font-size:40px;color:black;}#mermaid-svg-inh7hvClHrbG0Zox .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .edge-depth-10{stroke-width:-16;}#mermaid-svg-inh7hvClHrbG0Zox .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-inh7hvClHrbG0Zox .disabled,#mermaid-svg-inh7hvClHrbG0Zox .disabled circle,#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:lightgray;}#mermaid-svg-inh7hvClHrbG0Zox .disabled text{fill:#efefef;}#mermaid-svg-inh7hvClHrbG0Zox .section-root rect,#mermaid-svg-inh7hvClHrbG0Zox .section-root path,#mermaid-svg-inh7hvClHrbG0Zox .section-root circle,#mermaid-svg-inh7hvClHrbG0Zox .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-inh7hvClHrbG0Zox .section-root text{fill:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .section-root span{color:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .section-2 span{color:#ffffff;}#mermaid-svg-inh7hvClHrbG0Zox .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-inh7hvClHrbG0Zox .edge{fill:none;}#mermaid-svg-inh7hvClHrbG0Zox .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-inh7hvClHrbG0Zox :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Manifest功能
仓库定义
项目名称
Git URL
本地路径
版本信息
远程配置
远程名称
URL基础路径
多远程支持
版本管理
分支指定
标签锁定
Commit SHA
clone-depth
依赖管理
仓库依赖
导入规则
项目过滤
扩展机制
自包含
导入外部
本地扩展
2.2 仓库管理功能
Manifest文件定义了项目包含的所有仓库:
yaml
manifest:
projects:
- name: zephyr
url: https://github.com/zephyrproject-rtos/zephyr
path: zephyr
revision: main
- name: hal_nordic
url: https://github.com/zephyrproject-rtos/hal_nordic
path: modules/hal/nordic
revision: main
2.3 版本控制功能
通过Manifest文件,可以精确控制每个仓库的版本:
yaml
# 使用分支
revision: main
# 使用标签
revision: v3.5.0
# 使用Commit SHA
revision: abc123def456...
# 使用浅克隆
clone-depth: 1
2.4 依赖管理功能
Manifest支持复杂的依赖关系管理:
yaml
manifest:
projects:
- name: mbedtls
url: https://github.com/zephyrproject-rtos/mbedtls
revision: main
# 依赖其他项目
depends:
- zephyr
2.5 项目过滤功能
通过project-filter实现按需加载:
bash
# 禁用特定模块
west config manifest.project-filter -- -hal_stm32
# 启用可选模块
west config manifest.project-filter -- +tflite-micro
三、Manifest文件格式
3.1 YAML格式基础
Manifest文件使用YAML格式,具有以下特点:
| 特点 | 说明 |
|---|---|
| 可读性强 | 使用缩进和简洁的语法 |
| 层级清晰 | 支持嵌套结构 |
| 注释支持 | 使用#添加注释 |
| 数据类型 | 支持字符串、列表、字典等 |
3.2 基本结构
yaml
# Manifest文件基本结构
manifest:
# 版本号(可选)
version: "0.17.2"
# 远程仓库定义
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
# 项目列表
projects:
- name: zephyr
remote: zephyr
revision: main
path: zephyr
# 自包含项目(可选)
self:
path: zephyr
west-commands: scripts/west-commands.yml
3.3 结构层次图
#mermaid-svg-CPzm5njEeMuKtCW5{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-CPzm5njEeMuKtCW5 .error-icon{fill:#552222;}#mermaid-svg-CPzm5njEeMuKtCW5 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-CPzm5njEeMuKtCW5 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-CPzm5njEeMuKtCW5 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-CPzm5njEeMuKtCW5 .marker.cross{stroke:#333333;}#mermaid-svg-CPzm5njEeMuKtCW5 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-CPzm5njEeMuKtCW5 p{margin:0;}#mermaid-svg-CPzm5njEeMuKtCW5 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster-label text{fill:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster-label span{color:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster-label span p{background-color:transparent;}#mermaid-svg-CPzm5njEeMuKtCW5 .label text,#mermaid-svg-CPzm5njEeMuKtCW5 span{fill:#333;color:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 .node rect,#mermaid-svg-CPzm5njEeMuKtCW5 .node circle,#mermaid-svg-CPzm5njEeMuKtCW5 .node ellipse,#mermaid-svg-CPzm5njEeMuKtCW5 .node polygon,#mermaid-svg-CPzm5njEeMuKtCW5 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-CPzm5njEeMuKtCW5 .rough-node .label text,#mermaid-svg-CPzm5njEeMuKtCW5 .node .label text,#mermaid-svg-CPzm5njEeMuKtCW5 .image-shape .label,#mermaid-svg-CPzm5njEeMuKtCW5 .icon-shape .label{text-anchor:middle;}#mermaid-svg-CPzm5njEeMuKtCW5 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-CPzm5njEeMuKtCW5 .rough-node .label,#mermaid-svg-CPzm5njEeMuKtCW5 .node .label,#mermaid-svg-CPzm5njEeMuKtCW5 .image-shape .label,#mermaid-svg-CPzm5njEeMuKtCW5 .icon-shape .label{text-align:center;}#mermaid-svg-CPzm5njEeMuKtCW5 .node.clickable{cursor:pointer;}#mermaid-svg-CPzm5njEeMuKtCW5 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-CPzm5njEeMuKtCW5 .arrowheadPath{fill:#333333;}#mermaid-svg-CPzm5njEeMuKtCW5 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-CPzm5njEeMuKtCW5 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-CPzm5njEeMuKtCW5 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-CPzm5njEeMuKtCW5 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-CPzm5njEeMuKtCW5 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-CPzm5njEeMuKtCW5 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster text{fill:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 .cluster span{color:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-CPzm5njEeMuKtCW5 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-CPzm5njEeMuKtCW5 rect.text{fill:none;stroke-width:0;}#mermaid-svg-CPzm5njEeMuKtCW5 .icon-shape,#mermaid-svg-CPzm5njEeMuKtCW5 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-CPzm5njEeMuKtCW5 .icon-shape p,#mermaid-svg-CPzm5njEeMuKtCW5 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-CPzm5njEeMuKtCW5 .icon-shape .label rect,#mermaid-svg-CPzm5njEeMuKtCW5 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-CPzm5njEeMuKtCW5 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-CPzm5njEeMuKtCW5 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-CPzm5njEeMuKtCW5 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} manifest
version
remotes
projects
self
defaults
name
url-base
name
remote/url
revision
path
clone-depth
depends
path
west-commands
remote
revision
四、Manifest文件内容详解
4.1 remotes部分
remotes定义了远程仓库的基础信息:
yaml
manifest:
remotes:
# Zephyr官方仓库
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
# Nordic官方仓库
- name: nordic
url-base: https://github.com/nrfconnect
# 自定义仓库
- name: mycompany
url-base: https://github.com/mycompany
字段说明:
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
name |
字符串 | 是 | 远程仓库的名称标识 |
url-base |
字符串 | 是 | URL基础路径 |
4.2 projects部分
projects定义了具体的仓库项目:
yaml
manifest:
projects:
# 使用remote引用
- name: cmsis
remote: zephyr
revision: main
path: modules/hal/cmsis
# 使用完整URL
- name: hal_nordic
url: https://github.com/nrfconnect/sdk-hal_nordic
revision: main
path: modules/hal/nordic
clone-depth: 1
# 带依赖的项目
- name: mbedtls
remote: zephyr
revision: main
path: modules/lib/mbedtls
depends:
- zephyr
字段详解:
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
name |
字符串 | 是 | 项目名称 |
remote |
字符串 | 条件 | 远程仓库引用(与url二选一) |
url |
字符串 | 条件 | 完整Git URL(与remote二选一) |
revision |
字符串 | 是 | 版本标识(分支/标签/Commit) |
path |
字符串 | 否 | 本地路径(默认为name) |
clone-depth |
整数 | 否 | 浅克隆深度 |
depends |
列表 | 否 | 依赖的项目列表 |
fetch-depth |
整数 | 否 | fetch深度 |
4.3 defaults部分
defaults定义了项目的默认配置:
yaml
manifest:
defaults:
remote: zephyr
revision: main
clone-depth: 1
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
projects:
# 使用默认配置
- name: cmsis
path: modules/hal/cmsis
# 覆盖默认revision
- name: mbedtls
revision: v3.5.0
4.4 self部分
self定义了包含Manifest文件的项目本身:
yaml
manifest:
self:
# 项目路径
path: zephyr
# West命令脚本
west-commands: scripts/west-commands.yml
# 导入其他Manifest
import:
- name: hal_nordic
path: modules/hal/nordic
五、Manifest文件语法详解
5.1 基本语法规则
yaml
# 1. 使用缩进表示层级(推荐2空格)
manifest:
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
# 2. 列表使用 - 符号
projects:
- name: zephyr
- name: cmsis
# 3. 字典使用键值对
name: zephyr
revision: main
# 4. 注释使用 # 符号
# 这是一个注释
5.2 revision语法
revision字段支持多种版本指定方式:
yaml
# 分支名称
revision: main
revision: master
revision: develop
# 标签名称
revision: v3.5.0
revision: v0.17.2
revision: release-1.0
# Commit SHA(完整或简短)
revision: abc123def456789...
revision: abc123
# 特殊关键字
revision: HEAD # 当前HEAD
5.3 URL语法
URL可以通过两种方式指定:
yaml
# 方式1:使用remote + name组合
manifest:
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
projects:
- name: cmsis
remote: zephyr
# 实际URL: https://github.com/zephyrproject-rtos/cmsis
# 方式2:使用完整URL
manifest:
projects:
- name: hal_nordic
url: https://github.com/nrfconnect/sdk-hal_nordic
5.4 path语法
path定义了仓库在本地工作区的路径:
yaml
# 相对路径(相对于工作区根目录)
path: zephyr
path: modules/hal/nordic
path: bootloader/mcuboot
# 默认行为:path = name
- name: cmsis
# 默认path为cmsis
# 自定义路径
- name: cmsis
path: modules/hal/cmsis
5.5 import语法
import用于导入其他Manifest文件:
yaml
manifest:
self:
import:
# 导入单个项目
- name: hal_nordic
# 导入指定路径
- name: hal_nordic
path: modules/hal/nordic
# 导入外部Manifest
- url: https://example.com/manifest.yml
# 导入并过滤
- name: zephyr
path: zephyr
import:
project-filter:
- -hal_stm32
- +tflite-micro
5.6 depends语法
depends定义了项目之间的依赖关系:
yaml
manifest:
projects:
- name: mbedtls
depends:
# 单个依赖
- zephyr
# 多个依赖
- zephyr
- cmsis
# 条件依赖
- name: hal_nordic
if: CONFIG_NORDIC
六、完整Manifest文件示例
6.1 最小化Manifest示例
yaml
# minimal.yml - 最小化配置
manifest:
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyr
revision: main
path: zephyr
self:
path: zephyr
6.2 Nordic开发环境Manifest
yaml
# nordic-dev.yml - Nordic开发环境
manifest:
version: "0.17.2"
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
- name: nordic
url-base: https://github.com/nrfconnect
defaults:
remote: zephyr
revision: main
clone-depth: 1
projects:
# Zephyr核心
- name: zephyr
remote: zephyr
revision: main
path: zephyr
# Nordic HAL
- name: hal_nordic
remote: nordic
revision: main
path: modules/hal/nordic
# CMSIS支持
- name: cmsis
path: modules/hal/cmsis
# 安全库
- name: mbedtls
path: modules/lib/mbedtls
# 引导加载器
- name: mcuboot
url: https://github.com/mcu-tools/mcuboot
revision: main
path: bootloader/mcuboot
self:
path: zephyr
west-commands: scripts/west-commands.yml
6.3 多架构开发Manifest
yaml
# multi-arch.yml - 多架构开发环境
manifest:
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
defaults:
remote: zephyr
revision: main
clone-depth: 1
projects:
# 核心仓库
- name: zephyr
path: zephyr
# ARM HAL
- name: hal_nordic
path: modules/hal/nordic
- name: hal_stm32
path: modules/hal/stm32
# RISC-V HAL
- name: hal_riscv
path: modules/hal/riscv
# ESP32 HAL
- name: hal_espressif
path: modules/hal/espressif
# 通用组件
- name: cmsis
path: modules/hal/cmsis
- name: mbedtls
path: modules/lib/mbedtls
- name: littlefs
path: modules/fs/littlefs
self:
path: zephyr
6.4 带导入的Manifest示例
yaml
# with-import.yml - 带导入功能
manifest:
remotes:
- name: zephyr
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyr
revision: main
path: zephyr
import:
# 导入Zephyr官方Manifest
- west.yml
# 过滤不需要的HAL
project-filter:
- -hal_stm32
- -hal_nxp
- -hal_espressif
- name: hal_nordic
remote: zephyr
revision: main
path: modules/hal/nordic
self:
path: zephyr
import:
# 导入本地扩展
- .west/local/extra.yml
七、Manifest文件操作命令
7.1 查看Manifest内容
bash
# 查看当前Manifest
west manifest
# 查看冻结的Manifest(包含具体Commit SHA)
west manifest --freeze
# 查看Manifest路径
west manifest --path
# 导出Manifest到文件
west manifest --freeze > manifest-lock.yml
7.2 验证Manifest语法
bash
# 验证Manifest文件
west manifest --validate
# 验证指定文件
west manifest --validate my-manifest.yml
7.3 使用自定义Manifest
bash
# 使用指定Manifest初始化
west init -m https://example.com/my-manifest.yml
# 使用本地Manifest
west init -m ./my-manifest.yml
# 切换Manifest文件
west config manifest.file my-manifest.yml
7.4 Manifest相关配置
bash
# 查看Manifest配置
west config manifest
# 设置Manifest文件路径
west config manifest.file west.yml
# 设置项目过滤
west config manifest.project-filter -- -hal_stm32
# 查看所有配置
west config --list
八、常见问题与解决方案
8.1 Manifest语法错误
问题 :west.manifest.MalformedManifest: invalid YAML
解决:
bash
# 验证YAML语法
west manifest --validate
# 使用在线YAML验证器
# https://www.yamllint.com/
8.2 项目路径冲突
问题 :path 'modules/hal/nordic' is already used
解决:
yaml
# 确保每个项目的path唯一
manifest:
projects:
- name: hal_nordic
path: modules/hal/nordic
- name: hal_nordic_new
path: modules/hal/nordic_new # 使用不同路径
8.3 远程仓库未定义
问题 :undefined remote 'myremote'
解决:
yaml
# 确保remote已定义
manifest:
remotes:
- name: myremote
url-base: https://github.com/mycompany
projects:
- name: myproject
remote: myremote # 使用已定义的remote
8.4 版本不存在
问题 :revision 'v3.5.0' not found
解决:
bash
# 检查远程仓库的分支和标签
git ls-remote --heads https://github.com/zephyrproject-rtos/zephyr
git ls-remote --tags https://github.com/zephyrproject-rtos/zephyr
# 使用正确的版本
revision: main # 或其他存在的分支/标签
8.5 导入冲突
问题:多个Manifest导入相同项目
解决:
yaml
# 使用project-filter过滤
manifest:
self:
import:
- name: zephyr
import:
project-filter:
- -hal_stm32 # 禁用冲突的项目
九、Manifest文件最佳实践
9.1 版本锁定策略
#mermaid-svg-tmQWg8SOhIMPOuDT{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-tmQWg8SOhIMPOuDT .error-icon{fill:#552222;}#mermaid-svg-tmQWg8SOhIMPOuDT .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-tmQWg8SOhIMPOuDT .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-tmQWg8SOhIMPOuDT .marker{fill:#333333;stroke:#333333;}#mermaid-svg-tmQWg8SOhIMPOuDT .marker.cross{stroke:#333333;}#mermaid-svg-tmQWg8SOhIMPOuDT svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-tmQWg8SOhIMPOuDT p{margin:0;}#mermaid-svg-tmQWg8SOhIMPOuDT .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster-label text{fill:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster-label span{color:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster-label span p{background-color:transparent;}#mermaid-svg-tmQWg8SOhIMPOuDT .label text,#mermaid-svg-tmQWg8SOhIMPOuDT span{fill:#333;color:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT .node rect,#mermaid-svg-tmQWg8SOhIMPOuDT .node circle,#mermaid-svg-tmQWg8SOhIMPOuDT .node ellipse,#mermaid-svg-tmQWg8SOhIMPOuDT .node polygon,#mermaid-svg-tmQWg8SOhIMPOuDT .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-tmQWg8SOhIMPOuDT .rough-node .label text,#mermaid-svg-tmQWg8SOhIMPOuDT .node .label text,#mermaid-svg-tmQWg8SOhIMPOuDT .image-shape .label,#mermaid-svg-tmQWg8SOhIMPOuDT .icon-shape .label{text-anchor:middle;}#mermaid-svg-tmQWg8SOhIMPOuDT .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-tmQWg8SOhIMPOuDT .rough-node .label,#mermaid-svg-tmQWg8SOhIMPOuDT .node .label,#mermaid-svg-tmQWg8SOhIMPOuDT .image-shape .label,#mermaid-svg-tmQWg8SOhIMPOuDT .icon-shape .label{text-align:center;}#mermaid-svg-tmQWg8SOhIMPOuDT .node.clickable{cursor:pointer;}#mermaid-svg-tmQWg8SOhIMPOuDT .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-tmQWg8SOhIMPOuDT .arrowheadPath{fill:#333333;}#mermaid-svg-tmQWg8SOhIMPOuDT .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-tmQWg8SOhIMPOuDT .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-tmQWg8SOhIMPOuDT .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tmQWg8SOhIMPOuDT .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-tmQWg8SOhIMPOuDT .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tmQWg8SOhIMPOuDT .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster text{fill:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT .cluster span{color:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-tmQWg8SOhIMPOuDT .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-tmQWg8SOhIMPOuDT rect.text{fill:none;stroke-width:0;}#mermaid-svg-tmQWg8SOhIMPOuDT .icon-shape,#mermaid-svg-tmQWg8SOhIMPOuDT .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tmQWg8SOhIMPOuDT .icon-shape p,#mermaid-svg-tmQWg8SOhIMPOuDT .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-tmQWg8SOhIMPOuDT .icon-shape .label rect,#mermaid-svg-tmQWg8SOhIMPOuDT .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tmQWg8SOhIMPOuDT .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-tmQWg8SOhIMPOuDT .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-tmQWg8SOhIMPOuDT :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 版本策略
开发阶段
测试阶段
发布阶段
使用分支: main/develop
使用标签: v3.5.0-rc1
使用Commit SHA: abc123
yaml
# 开发阶段:使用分支
revision: main
# 测试阶段:使用标签
revision: v3.5.0-rc1
# 发布阶段:使用Commit SHA
revision: abc123def456789
9.2 模块化设计原则
yaml
# 核心模块(必须)
manifest:
projects:
- name: zephyr
path: zephyr
- name: cmsis
path: modules/hal/cmsis
# HAL模块(按需)
- name: hal_nordic
path: modules/hal/nordic
if: CONFIG_NORDIC
# 可选模块(可选)
- name: tflite-micro
path: modules/lib/tflite-micro
if: CONFIG_TFLITE
9.3 浅克隆优化
yaml
# 全局默认浅克隆
manifest:
defaults:
clone-depth: 1
projects:
- name: zephyr
# 使用默认clone-depth: 1
- name: mbedtls
clone-depth: 50 # 需要更多历史
9.4 Manifest文件组织
project/
├── west.yml # 主Manifest
├── .west/
│ └── local/
│ ├── hal.yml # HAL扩展
│ ├── libs.yml # 库扩展
│ └── tools.yml # 工具扩展
└── manifests/
├── minimal.yml # 最小化配置
├── full.yml # 完整配置
└── ci.yml # CI专用配置
十、Manifest文件与其他配置的关系
10.1 与West配置的关系
#mermaid-svg-5wmTk7PcHJxcwwL5{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-5wmTk7PcHJxcwwL5 .error-icon{fill:#552222;}#mermaid-svg-5wmTk7PcHJxcwwL5 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-5wmTk7PcHJxcwwL5 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .marker.cross{stroke:#333333;}#mermaid-svg-5wmTk7PcHJxcwwL5 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-5wmTk7PcHJxcwwL5 p{margin:0;}#mermaid-svg-5wmTk7PcHJxcwwL5 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster-label text{fill:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster-label span{color:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster-label span p{background-color:transparent;}#mermaid-svg-5wmTk7PcHJxcwwL5 .label text,#mermaid-svg-5wmTk7PcHJxcwwL5 span{fill:#333;color:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .node rect,#mermaid-svg-5wmTk7PcHJxcwwL5 .node circle,#mermaid-svg-5wmTk7PcHJxcwwL5 .node ellipse,#mermaid-svg-5wmTk7PcHJxcwwL5 .node polygon,#mermaid-svg-5wmTk7PcHJxcwwL5 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .rough-node .label text,#mermaid-svg-5wmTk7PcHJxcwwL5 .node .label text,#mermaid-svg-5wmTk7PcHJxcwwL5 .image-shape .label,#mermaid-svg-5wmTk7PcHJxcwwL5 .icon-shape .label{text-anchor:middle;}#mermaid-svg-5wmTk7PcHJxcwwL5 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .rough-node .label,#mermaid-svg-5wmTk7PcHJxcwwL5 .node .label,#mermaid-svg-5wmTk7PcHJxcwwL5 .image-shape .label,#mermaid-svg-5wmTk7PcHJxcwwL5 .icon-shape .label{text-align:center;}#mermaid-svg-5wmTk7PcHJxcwwL5 .node.clickable{cursor:pointer;}#mermaid-svg-5wmTk7PcHJxcwwL5 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .arrowheadPath{fill:#333333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-5wmTk7PcHJxcwwL5 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-5wmTk7PcHJxcwwL5 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-5wmTk7PcHJxcwwL5 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster text{fill:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 .cluster span{color:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-5wmTk7PcHJxcwwL5 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-5wmTk7PcHJxcwwL5 rect.text{fill:none;stroke-width:0;}#mermaid-svg-5wmTk7PcHJxcwwL5 .icon-shape,#mermaid-svg-5wmTk7PcHJxcwwL5 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-5wmTk7PcHJxcwwL5 .icon-shape p,#mermaid-svg-5wmTk7PcHJxcwwL5 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-5wmTk7PcHJxcwwL5 .icon-shape .label rect,#mermaid-svg-5wmTk7PcHJxcwwL5 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-5wmTk7PcHJxcwwL5 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-5wmTk7PcHJxcwwL5 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-5wmTk7PcHJxcwwL5 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} west.yml
West工具
.west/config
环境变量
解析Manifest
仓库管理
版本控制
依赖解析
10.2 与CMake的关系
Manifest定义的路径会影响CMake构建:
cmake
# CMakeLists.txt中使用Manifest定义的路径
set(ZEPHYR_MODULES
${ZEPHYR_BASE}/modules/hal/nordic
${ZEPHYR_BASE}/modules/lib/mbedtls
)
10.3 与Kconfig的关系
Manifest中的项目可以通过Kconfig控制:
yaml
# Manifest中使用条件导入
manifest:
projects:
- name: hal_nordic
if: CONFIG_NORDIC
结束语
通过本文的深入解析,相信您已经全面理解了Zephyr开发中的Manifest文件:
| 知识点 | 内容 |
|---|---|
| 概念 | YAML格式的多仓库配置文件 |
| 作用 | 仓库管理、版本控制、路径映射、依赖解析 |
| 格式 | remotes、projects、defaults、self |
| 语法 | revision、url、path、import、depends |
| 操作 | west manifest命令、验证、配置 |
| 最佳实践 | 版本锁定、模块化、浅克隆、组织结构 |
Manifest文件是Zephyr多仓库管理的核心,掌握它的使用对于高效开发至关重要。建议在实际项目中:
- 使用版本锁定:发布版本使用Commit SHA
- 模块化设计:按需加载HAL和组件
- 浅克隆优化:节省空间和时间
- 定期验证:确保Manifest语法正确
参考资料: