1.. _west-manifests: 2 3West Manifests 4############## 5 6This page contains detailed information about west's multiple repository model, 7manifest files, and the ``west manifest`` command. For API documentation on the 8``west.manifest`` module, see :ref:`west-apis-manifest`. For a more general 9introduction and command overview, see :ref:`west-basics`. 10 11.. only:: html 12 13 .. contents:: 14 :depth: 3 15 16.. _west-mr-model: 17 18Multiple Repository Model 19************************* 20 21West's view of the repositories in a :term:`west workspace`, and their 22history, looks like the following figure (though some parts of this example are 23specific to upstream Zephyr's use of west): 24 25.. figure:: west-mr-model.png 26 :align: center 27 :alt: West multi-repo history 28 :figclass: align-center 29 30 West multi-repo history 31 32The history of the manifest repository is the line of Git commits which is 33"floating" on top of the gray plane. Parent commits point to child commits 34using solid arrows. The plane below contains the Git commit history of the 35repositories in the workspace, with each project repository boxed in by a 36rectangle. Parent/child commit relationships in each repository are also shown 37with solid arrows. 38 39The commits in the manifest repository (again, for upstream Zephyr this is the 40zephyr repository itself) each have a manifest file. The manifest file in each 41commit specifies the corresponding commits which it expects in each of the 42project repositories. This relationship is shown using dotted line arrows in the 43diagram. Each dotted line arrow points from a commit in the manifest repository 44to a corresponding commit in a project repository. 45 46Notice the following important details: 47 48- Projects can be added (like ``P1`` between manifest repository 49 commits ``D`` and ``E``) and removed (``P2`` between the same 50 manifest repository commits) 51 52- Project and manifest repository histories don't have to move 53 forwards or backwards together: 54 55 - ``P2`` stays the same from ``A → B``, as do ``P1`` and ``P3`` from ``F → 56 G``. 57 - ``P3`` moves forward from ``A → B``. 58 - ``P3`` moves backward from ``C → D``. 59 60 One use for moving backward in project history is to "revert" a regression by 61 going back to a revision before it was introduced. 62 63- Project repository commits can be "skipped": ``P3`` moves forward 64 multiple commits in its history from ``B → C``. 65 66- In the above diagram, no project repository has two revisions "at 67 the same time": every manifest file refers to exactly one commit in 68 the projects it cares about. This can be relaxed by using a branch 69 name as a manifest revision, at the cost of being able to bisect 70 manifest repository history. 71 72.. _west-manifest-files: 73 74Manifest Files 75************** 76 77West manifests are YAML files. Manifests have a top-level ``manifest`` section 78with some subsections, like this: 79 80.. code-block:: yaml 81 82 manifest: 83 remotes: 84 # short names for project URLs 85 projects: 86 # a list of projects managed by west 87 defaults: 88 # default project attributes 89 self: 90 # configuration related to the manifest repository itself, 91 # i.e. the repository containing west.yml 92 version: "<schema-version>" 93 group-filter: 94 # a list of project groups to enable or disable 95 96In YAML terms, the manifest file contains a mapping, with a ``manifest`` 97key. Any other keys and their contents are ignored (west v0.5 also required a 98``west`` key, but this is ignored starting with v0.6). 99 100The manifest contains subsections, like ``defaults``, ``remotes``, 101``projects``, and ``self``. In YAML terms, the value of the ``manifest`` key is 102also a mapping, with these "subsections" as keys. As of west v0.10, all of 103these "subsection" keys are optional. 104 105The ``projects`` value is a list of repositories managed by west and associated 106metadata. We'll discuss it soon, but first we will describe the ``remotes`` 107section, which can be used to save typing in the ``projects`` list. 108 109Remotes 110======= 111 112The ``remotes`` subsection contains a sequence which specifies the base URLs 113where projects can be fetched from. 114 115Each ``remotes`` element has a name and a "URL base". These are used to form 116the complete Git fetch URL for each project. A project's fetch URL can be set 117by appending a project-specific path onto a remote URL base. (As we'll see 118below, projects can also specify their complete fetch URLs.) 119 120For example: 121 122.. code-block:: yaml 123 124 manifest: 125 # ... 126 remotes: 127 - name: remote1 128 url-base: https://git.example.com/base1 129 - name: remote2 130 url-base: https://git.example.com/base2 131 132The ``remotes`` keys and their usage are in the following table. 133 134.. list-table:: remotes keys 135 :header-rows: 1 136 :widths: 1 5 137 138 * - Key 139 - Description 140 141 * - ``name`` 142 - Mandatory; a unique name for the remote. 143 144 * - ``url-base`` 145 - A prefix that is prepended to the fetch URL for each 146 project with this remote. 147 148Above, two remotes are given, with names ``remote1`` and ``remote2``. Their URL 149bases are respectively ``https://git.example.com/base1`` and 150``https://git.example.com/base2``. You can use SSH URL bases as well; for 151example, you might use ``git@example.com:base1`` if ``remote1`` supported Git 152over SSH as well. Anything acceptable to Git will work. 153 154.. _west-manifests-projects: 155 156Projects 157======== 158 159The ``projects`` subsection contains a sequence describing the project 160repositories in the west workspace. Every project has a unique name. You can 161specify what Git remote URLs to use when cloning and fetching the projects, 162what revisions to track, and where the project should be stored on the local 163file system. Note that west projects :ref:`are different from modules 164<modules-vs-projects>`. 165 166Here is an example. We'll assume the ``remotes`` given above. 167 168.. Note: if you change this example, keep the equivalent manifest below in 169 sync. 170 171.. code-block:: yaml 172 173 manifest: 174 # [... same remotes as above...] 175 projects: 176 - name: proj1 177 description: the first example project 178 remote: remote1 179 path: extra/project-1 180 - name: proj2 181 description: | 182 A multi-line description of the second example 183 project. 184 repo-path: my-path 185 remote: remote2 186 revision: v1.3 187 - name: proj3 188 url: https://github.com/user/project-three 189 revision: abcde413a111 190 191In this manifest: 192 193- ``proj1`` has remote ``remote1``, so its Git fetch URL is 194 ``https://git.example.com/base1/proj1``. The remote ``url-base`` is appended 195 with a ``/`` and the project ``name`` to form the URL. 196 197 Locally, this project will be cloned at path ``extra/project-1`` relative to 198 the west workspace's root directory, since it has an explicit ``path`` 199 attribute with this value. 200 201 Since the project has no ``revision`` specified, ``master`` is used by 202 default. The current tip of this branch will be fetched and checked out as a 203 detached ``HEAD`` when west next updates this project. 204 205- ``proj2`` has a ``remote`` and a ``repo-path``, so its fetch URL is 206 ``https://git.example.com/base2/my-path``. The ``repo-path`` attribute, if 207 present, overrides the default ``name`` when forming the fetch URL. 208 209 Since the project has no ``path`` attribute, its ``name`` is used by 210 default. It will be cloned into a directory named ``proj2``. The commit 211 pointed to by the ``v1.3`` tag will be checked out when west updates the 212 project. 213 214- ``proj3`` has an explicit ``url``, so it will be fetched from 215 ``https://github.com/user/project-three``. 216 217 Its local path defaults to its name, ``proj3``. Commit ``abcde413a111`` will 218 be checked out when it is next updated. 219 220The available project keys and their usage are in the following table. 221Sometimes we'll refer to the ``defaults`` subsection; it will be described 222next. 223 224.. list-table:: projects elements keys 225 :header-rows: 1 226 :widths: 1 5 227 228 * - Key(s) 229 - Description 230 231 * - ``name`` 232 - Mandatory; a unique name for the project. The name cannot be one of the 233 reserved values "west" or "manifest". The name must be unique in the 234 manifest file. 235 236 * - ``description`` 237 - Optional, an informational description of the project. Added in 238 west v1.2.0. 239 240 * - ``remote``, ``url`` 241 - Mandatory (one of the two, but not both). 242 243 If the project has a ``remote``, that remote's ``url-base`` will be 244 combined with the project's ``name`` (or ``repo-path``, if it has one) 245 to form the fetch URL instead. 246 247 If the project has a ``url``, that's the complete fetch URL for the 248 remote Git repository. 249 250 If the project has neither, the ``defaults`` section must specify a 251 ``remote``, which will be used as the project's remote. Otherwise, 252 the manifest is invalid. 253 254 * - ``repo-path`` 255 - Optional. If given, this is concatenated on to the remote's 256 ``url-base`` instead of the project's ``name`` to form its fetch URL. 257 Projects may not have both ``url`` and ``repo-path`` attributes. 258 259 * - ``revision`` 260 - Optional. The Git revision that ``west update`` should 261 check out. This will be checked out as a detached HEAD by default, to 262 avoid conflicting with local branch names. If not given, the 263 ``revision`` value from the ``defaults`` subsection will be used if 264 present. 265 266 A project revision can be a branch, tag, or SHA. 267 268 The default ``revision`` is ``master`` if not otherwise specified. 269 270 Using ``HEAD~0`` [#f1]_ as the ``revision`` will cause west to keep the current 271 state of the project. 272 273 * - ``path`` 274 - Optional. Relative path specifying where to clone the repository 275 locally, relative to the top directory in the west workspace. If missing, 276 the project's ``name`` is used as a directory name. 277 278 * - ``clone-depth`` 279 - Optional. If given, a positive integer which creates a shallow history 280 in the cloned repository limited to the given number of commits. This 281 can only be used if the ``revision`` is a branch or tag. 282 283 * - ``west-commands`` 284 - Optional. If given, a relative path to a YAML file within the project 285 which describes additional west commands provided by that project. This 286 file is named :file:`west-commands.yml` by convention. See 287 :ref:`west-extensions` for details. 288 289 * - ``import`` 290 - Optional. If ``true``, imports projects from manifest files in the 291 given repository into the current manifest. See 292 :ref:`west-manifest-import` for details. 293 294 * - ``groups`` 295 - Optional, a list of groups the project belongs to. See 296 :ref:`west-manifest-groups` for details. 297 298 * - ``submodules`` 299 - Optional. You can use this to make ``west update`` also update `Git 300 submodules`_ defined by the project. See 301 :ref:`west-manifest-submodules` for details. 302 303 * - ``userdata`` 304 - Optional. The value is an arbitrary YAML value. See 305 :ref:`west-project-userdata`. 306 307.. rubric:: Footnotes 308 309.. [#f1] In git, HEAD is a reference, whereas HEAD~<n> is a valid revision but 310 not a reference. West fetches references, such as refs/heads/main or 311 HEAD, and commits not available locally, but will not fetch commits if 312 they are already available. 313 HEAD~0 is resolved to a specific commit that is locally available, and 314 therefore west will simply checkout the locally available commit, 315 identified by HEAD~0. 316 317.. _Git submodules: https://git-scm.com/book/en/v2/Git-Tools-Submodules 318 319Defaults 320======== 321 322The ``defaults`` subsection can provide default values for project 323attributes. In particular, the default remote name and revision can be 324specified here. Another way to write the same manifest we have been describing 325so far using ``defaults`` is: 326 327.. code-block:: yaml 328 329 manifest: 330 defaults: 331 remote: remote1 332 revision: v1.3 333 334 remotes: 335 - name: remote1 336 url-base: https://git.example.com/base1 337 - name: remote2 338 url-base: https://git.example.com/base2 339 340 projects: 341 - name: proj1 342 description: the first example project 343 path: extra/project-1 344 revision: master 345 - name: proj2 346 description: | 347 A multi-line description of the second example 348 project. 349 repo-path: my-path 350 remote: remote2 351 - name: proj3 352 url: https://github.com/user/project-three 353 revision: abcde413a111 354 355The available ``defaults`` keys and their usage are in the following table. 356 357.. list-table:: defaults keys 358 :header-rows: 1 359 :widths: 1 5 360 361 * - Key 362 - Description 363 364 * - ``remote`` 365 - Optional. This will be used for a project's ``remote`` if it does not 366 have a ``url`` or ``remote`` key set. 367 368 * - ``revision`` 369 - Optional. This will be used for a project's ``revision`` if it does 370 not have one set. If not given, the default is ``master``. 371 372Self 373==== 374 375The ``self`` subsection can be used to control the manifest repository itself. 376 377As an example, let's consider this snippet from the zephyr repository's 378:file:`west.yml`: 379 380.. code-block:: yaml 381 382 manifest: 383 # ... 384 self: 385 path: zephyr 386 west-commands: scripts/west-commands.yml 387 388This ensures that the zephyr repository is cloned into path ``zephyr``, though 389as explained above that would have happened anyway if cloning from the default 390manifest URL, ``https://github.com/zephyrproject-rtos/zephyr``. Since the 391zephyr repository does contain extension commands, its ``self`` entry declares 392the location of the corresponding :file:`west-commands.yml` relative to the 393repository root. 394 395The available ``self`` keys and their usage are in the following table. 396 397.. list-table:: self keys 398 :header-rows: 1 399 :widths: 1 5 400 401 * - Key 402 - Description 403 404 * - ``path`` 405 - Optional. The path ``west init`` should clone the manifest repository 406 into, relative to the west workspace topdir. 407 408 If not given, the basename of the path component in the manifest 409 repository URL will be used by default. For example, if the URL is 410 ``https://git.example.com/project-repo``, the manifest repository would 411 be cloned to the directory :file:`project-repo`. 412 413 * - ``west-commands`` 414 - Optional. This is analogous to the same key in a project sequence 415 element. 416 417 * - ``import`` 418 - Optional. This is also analogous to the ``projects`` key, but allows 419 importing projects from other files in the manifest repository. See 420 :ref:`west-manifest-import`. 421 422.. _west-manifest-schema-version: 423 424Version 425======= 426 427The ``version`` subsection declares that the manifest file uses features which 428were introduced in some version of west. Attempts to load the manifest with 429older versions of west will fail with an error message that explains the 430minimum required version of west which is needed. 431 432Here is an example: 433 434.. code-block:: yaml 435 436 manifest: 437 # Marks that this file uses version 0.10 of the west manifest 438 # file format. 439 # 440 # An attempt to load this manifest file with west v0.8.0 will 441 # fail with an error message saying that west v0.10.0 or 442 # later is required. 443 version: "0.10" 444 445The pykwalify schema :file:`manifest-schema.yml` in the `west source code 446repository`_ is used to validate the manifest section. 447 448.. _west source code repository: 449 https://github.com/zephyrproject-rtos/west 450 451Here is a table with the valid ``version`` values, along with information 452about the manifest file features that were introduced in that version. 453 454.. list-table:: 455 :header-rows: 1 456 :widths: 1 4 457 458 * - ``version`` 459 - New features 460 461 * - ``"0.7"`` 462 - Initial support for the ``version`` feature. All manifest file features 463 that are not otherwise mentioned in this table were introduced in 464 west v0.7.0 or earlier. 465 466 * - ``"0.8"`` 467 - Support for ``import: path-prefix:`` (:ref:`west-manifest-import-map`) 468 469 * - ``"0.9"`` 470 - **Use of west v0.9.x is discouraged**. 471 472 This schema version is provided to allow users to explicitly request 473 compatibility with west :ref:`west_0_9_0`. However, west 474 :ref:`west_0_10_0` and later have incompatible behavior for features 475 that were introduced in west v0.9.0. You should ignore version "0.9" if 476 possible. 477 478 * - ``"0.10"`` 479 480 - Support for: 481 482 - ``submodules:`` in ``projects:`` (:ref:`west-manifest-submodules`) 483 - ``manifest: group-filter:``, and ``groups:`` in ``projects:`` 484 (:ref:`west-manifest-groups`) 485 - The ``import:`` feature now supports ``allowlist:`` and 486 ``blocklist:``; these are respectively recommended as replacements for 487 older names as part of a general Zephyr-wide inclusive language 488 change. The older key names are still supported for backwards 489 compatibility. (:ref:`west-manifest-import`, 490 :ref:`west-manifest-import-map`) 491 492 * - ``"0.12"`` 493 - Support for ``userdata:`` in ``projects:`` (:ref:`west-project-userdata`) 494 495 * - ``"0.13"`` 496 - Support for ``self: userdata:`` (:ref:`west-project-userdata`) 497 498 * - ``"1.0"`` 499 - Identical to ``"0.13"``, but available for use by users that 500 do not wish to use a ``"0.x"`` version field. 501 502 * - ``"1.2"`` 503 - Support for ``description:`` in ``projects:`` 504 (:ref:`west-manifests-projects`) 505 506.. note:: 507 508 Versions of west without any new features in the manifest file format do not 509 change the list of valid ``version`` values. For example, ``version: 510 "0.11"`` is **not** valid, because west v0.11.x did not introduce new 511 manifest file format features. 512 513Quoting the ``version`` value as shown above forces the YAML parser to treat it 514as a string. Without quotes, ``0.10`` in YAML is just the floating point value 515``0.1``. You can omit the quotes if the value is the same when cast to string, 516but it's best to include them. Always use quotes if you're not sure. 517 518If you do not include a ``version`` in your manifest, each new release of west 519assumes that it should try to load it using the features that were available in 520that release. This may result in error messages that are harder to understand 521if that version of west is too old to load the manifest. 522 523Group-filter 524============ 525 526See :ref:`west-manifest-groups`. 527 528.. _west-active-inactive-projects: 529 530Active and Inactive Projects 531**************************** 532 533Projects defined in the west manifest can be *inactive* or *active*. The 534difference is that an inactive project is generally ignored by west. For 535example, ``west update`` will not update inactive projects, and ``west list`` 536will not print information about them by default. As another example, any 537:ref:`west-manifest-import` in an inactive project will be ignored by west. 538 539There are two ways to make a project inactive: 540 5411. Using the ``manifest.project-filter`` configuration option. If a project is 542 made active or inactive using this option, then the rules related to making 543 a project inactive using its ``groups:`` are ignored. That is, if a regular 544 expression in ``manifest.project-filter`` applies to a project, the 545 project's groups have no effect on whether it is active or inactive. 546 547 See the entry for this option in :ref:`west-config-index` for details. 548 5492. Otherwise, if a project has groups, and they are all disabled, then the 550 project is inactive. 551 552 See the following section for details. 553 554.. _west-manifest-groups: 555 556Project Groups 557************** 558 559You can use the ``groups`` and ``group-filter`` keys briefly described 560:ref:`above <west-manifest-files>` to place projects into groups, and to 561enable or disable groups. 562 563For example, this lets you run a ``west forall`` command only on the projects 564in the group by using ``west forall --group``. This can also let you make 565projects inactive; see the previous section for more information on inactive 566projects. 567 568The next section introduces project groups. The following section describes 569:ref:`west-enabled-disabled-groups`. There are some basic examples in 570:ref:`west-project-group-examples`. Finally, :ref:`west-group-filter-imports` 571provides a simplified overview of how ``group-filter`` interacts with the 572:ref:`west-manifest-import` feature. 573 574Groups Basics 575============= 576 577The ``groups:`` and ``group-filter:`` keys appear in the manifest like this: 578 579.. code-block:: yaml 580 581 manifest: 582 projects: 583 - name: some-project 584 groups: ... 585 group-filter: ... 586 587The ``groups`` key's value is a list of group names. Group names are strings. 588 589You can enable or disable project groups using ``group-filter``. Projects whose 590groups are all disabled, and which are not otherwise made active by a 591``manifest.project-filter`` configuration option, are inactive. 592 593For example, in this manifest fragment: 594 595.. code-block:: yaml 596 597 manifest: 598 projects: 599 - name: project-1 600 groups: 601 - groupA 602 - name: project-2 603 groups: 604 - groupB 605 - groupC 606 - name: project-3 607 608The projects are in these groups: 609 610- ``project-1``: one group, named ``groupA`` 611- ``project-2``: two groups, named ``groupB`` and ``groupC`` 612- ``project-3``: no groups 613 614Project group names must not contain commas (,), colons (:), or whitespace. 615 616Group names must not begin with a dash (-) or the plus sign (+), but they may 617contain these characters elsewhere in their names. For example, ``foo-bar`` and 618``foo+bar`` are valid groups, but ``-foobar`` and ``+foobar`` are not. 619 620Group names are otherwise arbitrary strings. Group names are case sensitive. 621 622As a restriction, no project may use both ``import:`` and ``groups:``. (This 623is necessary to avoid some pathological edge cases.) 624 625.. _west-enabled-disabled-groups: 626 627Enabled and Disabled Project Groups 628=================================== 629 630All project groups are enabled by default. You can enable or disable groups in 631both your manifest file and :ref:`west-config`. 632 633Within a manifest file, ``manifest: group-filter:`` is a YAML list of groups to 634enable and disable. 635 636To enable a group, prefix its name with a plus sign (+). For example, 637``groupA`` is enabled in this manifest fragment: 638 639.. code-block:: yaml 640 641 manifest: 642 group-filter: [+groupA] 643 644Although this is redundant for groups that are already enabled by default, it 645can be used to override settings in an imported manifest file. See 646:ref:`west-group-filter-imports` for more information. 647 648To disable a group, prefix its name with a dash (-). For example, ``groupA`` 649and ``groupB`` are disabled in this manifest fragment: 650 651.. code-block:: yaml 652 653 manifest: 654 group-filter: [-groupA,-groupB] 655 656.. note:: 657 658 Since ``group-filter`` is a YAML list, you could have written this fragment 659 as follows: 660 661 .. code-block:: yaml 662 663 manifest: 664 group-filter: 665 - -groupA 666 - -groupB 667 668 However, this syntax is harder to read and therefore discouraged. 669 670In addition to the manifest file, you can control which groups are enabled and 671disabled using the ``manifest.group-filter`` configuration option. This option 672is a comma-separated list of groups to enable and/or disable. 673 674To enable a group, add its name to the list prefixed with ``+``. To disable a 675group, add its name prefixed with ``-``. For example, setting 676``manifest.group-filter`` to ``+groupA,-groupB`` enables ``groupA``, and 677disables ``groupB``. 678 679The value of the configuration option overrides any data in the manifest file. 680You can think of this as if the ``manifest.group-filter`` configuration option 681is appended to the ``manifest: group-filter:`` list from YAML, with "last entry 682wins" semantics. 683 684.. _west-project-group-examples: 685 686Project Group Examples 687====================== 688 689This section contains example situations involving project groups and active 690projects. The examples use both ``manifest: group-filter:`` YAML lists and 691``manifest.group-filter`` configuration lists, to show how they work together. 692 693Note that the ``defaults`` and ``remotes`` data in the following manifests 694isn't relevant except to make the examples complete and self-contained. 695 696.. note:: 697 698 In all of the examples that follow, the ``manifest.project-filter`` option 699 is assumed to be unset. 700 701Example 1: no disabled groups 702----------------------------- 703 704The entire manifest file is: 705 706.. code-block:: yaml 707 708 manifest: 709 projects: 710 - name: foo 711 groups: 712 - groupA 713 - name: bar 714 groups: 715 - groupA 716 - groupB 717 - name: baz 718 719 defaults: 720 remote: example-remote 721 remotes: 722 - name: example-remote 723 url-base: https://git.example.com 724 725The ``manifest.group-filter`` configuration option is not set (you can ensure 726this by running ``west config -D manifest.group-filter``). 727 728No groups are disabled, because all groups are enabled by default. Therefore, 729all three projects (``foo``, ``bar``, and ``baz``) are active. Note that there 730is no way to make project ``baz`` inactive, since it has no groups. 731 732Example 2: Disabling one group via manifest 733------------------------------------------- 734 735The entire manifest file is: 736 737.. code-block:: yaml 738 739 manifest: 740 projects: 741 - name: foo 742 groups: 743 - groupA 744 - name: bar 745 groups: 746 - groupA 747 - groupB 748 749 group-filter: [-groupA] 750 751 defaults: 752 remote: example-remote 753 remotes: 754 - name: example-remote 755 url-base: https://git.example.com 756 757The ``manifest.group-filter`` configuration option is not set (you can ensure 758this by running ``west config -D manifest.group-filter``). 759 760Since ``groupA`` is disabled, project ``foo`` is inactive. Project ``bar`` is 761active, because ``groupB`` is enabled. 762 763Example 3: Disabling multiple groups via manifest 764------------------------------------------------- 765 766The entire manifest file is: 767 768.. code-block:: yaml 769 770 manifest: 771 projects: 772 - name: foo 773 groups: 774 - groupA 775 - name: bar 776 groups: 777 - groupA 778 - groupB 779 780 group-filter: [-groupA,-groupB] 781 782 defaults: 783 remote: example-remote 784 remotes: 785 - name: example-remote 786 url-base: https://git.example.com 787 788The ``manifest.group-filter`` configuration option is not set (you can ensure 789this by running ``west config -D manifest.group-filter``). 790 791Both ``foo`` and ``bar`` are inactive, because all of their groups are 792disabled. 793 794Example 4: Disabling a group via configuration 795---------------------------------------------- 796 797The entire manifest file is: 798 799.. code-block:: yaml 800 801 manifest: 802 projects: 803 - name: foo 804 groups: 805 - groupA 806 - name: bar 807 groups: 808 - groupA 809 - groupB 810 811 defaults: 812 remote: example-remote 813 remotes: 814 - name: example-remote 815 url-base: https://git.example.com 816 817The ``manifest.group-filter`` configuration option is set to ``-groupA`` (you 818can ensure this by running ``west config manifest.group-filter -- -groupA``; 819the extra ``--`` is required so the argument parser does not treat ``-groupA`` 820as a command line option ``-g`` with value ``roupA``). 821 822Project ``foo`` is inactive because ``groupA`` has been disabled by the 823``manifest.group-filter`` configuration option. Project ``bar`` is active 824because ``groupB`` is enabled. 825 826Example 5: Overriding a disabled group via configuration 827-------------------------------------------------------- 828 829The entire manifest file is: 830 831.. code-block:: yaml 832 833 manifest: 834 projects: 835 - name: foo 836 - name: bar 837 groups: 838 - groupA 839 - name: baz 840 groups: 841 - groupA 842 - groupB 843 844 group-filter: [-groupA] 845 846 defaults: 847 remote: example-remote 848 remotes: 849 - name: example-remote 850 url-base: https://git.example.com 851 852The ``manifest.group-filter`` configuration option is set to ``+groupA`` (you 853can ensure this by running ``west config manifest.group-filter +groupA``). 854 855In this case, ``groupA`` is enabled: the ``manifest.group-filter`` 856configuration option has higher precedence than the ``manifest: group-filter: 857[-groupA]`` content in the manifest file. 858 859Therefore, projects ``foo`` and ``bar`` are both active. 860 861Example 6: Overriding multiple disabled groups via configuration 862---------------------------------------------------------------- 863 864The entire manifest file is: 865 866.. code-block:: yaml 867 868 manifest: 869 projects: 870 - name: foo 871 - name: bar 872 groups: 873 - groupA 874 - name: baz 875 groups: 876 - groupA 877 - groupB 878 879 group-filter: [-groupA,-groupB] 880 881 defaults: 882 remote: example-remote 883 remotes: 884 - name: example-remote 885 url-base: https://git.example.com 886 887The ``manifest.group-filter`` configuration option is set to 888``+groupA,+groupB`` (you can ensure this by running ``west config 889manifest.group-filter "+groupA,+groupB"``). 890 891In this case, both ``groupA`` and ``groupB`` are enabled, because the 892configuration value overrides the manifest file for both groups. 893 894Therefore, projects ``foo`` and ``bar`` are both active. 895 896Example 7: Disabling multiple groups via configuration 897------------------------------------------------------ 898 899The entire manifest file is: 900 901.. code-block:: yaml 902 903 manifest: 904 projects: 905 - name: foo 906 - name: bar 907 groups: 908 - groupA 909 - name: baz 910 groups: 911 - groupA 912 - groupB 913 914 defaults: 915 remote: example-remote 916 remotes: 917 - name: example-remote 918 url-base: https://git.example.com 919 920The ``manifest.group-filter`` configuration option is set to 921``-groupA,-groupB`` (you can ensure this by running ``west config 922manifest.group-filter -- "-groupA,-groupB"``). 923 924In this case, both ``groupA`` and ``groupB`` are disabled. 925 926Therefore, projects ``foo`` and ``bar`` are both inactive. 927 928.. _west-group-filter-imports: 929 930Group Filters and Imports 931========================= 932 933This section provides a simplified description of how the ``manifest: 934group-filter:`` value behaves when combined with :ref:`west-manifest-import`. 935For complete details, see :ref:`west-manifest-formal`. 936 937.. warning:: 938 939 The below semantics apply to west v0.10.0 and later. West v0.9.x semantics 940 are different, and combining ``group-filter`` with ``import`` in west v0.9.x 941 is discouraged. 942 943In short: 944 945- if you only import one manifest, any groups it disables in its 946 ``group-filter`` are also disabled in your manifest 947- you can override this in your manifest file's ``manifest: group-filter:`` 948 value, your workspace's ``manifest.group-filter`` configuration option, or 949 both 950 951Here are some examples. 952 953Example 1: no overrides 954----------------------- 955 956You are using this :file:`parent/west.yml` manifest: 957 958.. code-block:: yaml 959 960 # parent/west.yml: 961 manifest: 962 projects: 963 - name: child 964 url: https://git.example.com/child 965 import: true 966 - name: project-1 967 url: https://git.example.com/project-1 968 groups: 969 - unstable 970 971And :file:`child/west.yml` contains: 972 973.. code-block:: yaml 974 975 # child/west.yml: 976 manifest: 977 group-filter: [-unstable] 978 projects: 979 - name: project-2 980 url: https://git.example.com/project-2 981 - name: project-3 982 url: https://git.example.com/project-3 983 groups: 984 - unstable 985 986Only ``child`` and ``project-2`` are active in the resolved manifest. 987 988The ``unstable`` group is disabled in :file:`child/west.yml`, and that is not 989overridden in :file:`parent/west.yml`. Therefore, the final ``group-filter`` 990for the resolved manifest is ``[-unstable]``. 991 992Since ``project-1`` and ``project-3`` are in the ``unstable`` group and are not 993in any other group, they are inactive. 994 995Example 2: overriding an imported ``group-filter`` via manifest 996--------------------------------------------------------------- 997 998You are using this :file:`parent/west.yml` manifest: 999 1000.. code-block:: yaml 1001 1002 # parent/west.yml: 1003 manifest: 1004 group-filter: [+unstable,-optional] 1005 projects: 1006 - name: child 1007 url: https://git.example.com/child 1008 import: true 1009 - name: project-1 1010 url: https://git.example.com/project-1 1011 groups: 1012 - unstable 1013 1014And :file:`child/west.yml` contains: 1015 1016.. code-block:: yaml 1017 1018 # child/west.yml: 1019 manifest: 1020 group-filter: [-unstable] 1021 projects: 1022 - name: project-2 1023 url: https://git.example.com/project-2 1024 groups: 1025 - optional 1026 - name: project-3 1027 url: https://git.example.com/project-3 1028 groups: 1029 - unstable 1030 1031Only the ``child``, ``project-1``, and ``project-3`` projects are active. 1032 1033The ``[-unstable]`` group filter in :file:`child/west.yml` is overridden in 1034:file:`parent/west.yml`, so the ``unstable`` group is enabled. Since 1035``project-1`` and ``project-3`` are in the ``unstable`` group, they are active. 1036 1037The same :file:`parent/west.yml` file disables the ``optional`` group, so 1038``project-2`` is inactive. 1039 1040The final group filter specified by :file:`parent/west.yml` is 1041``[+unstable,-optional]``. 1042 1043Example 3: overriding an imported ``group-filter`` via configuration 1044-------------------------------------------------------------------- 1045 1046You are using this :file:`parent/west.yml` manifest: 1047 1048.. code-block:: yaml 1049 1050 # parent/west.yml: 1051 manifest: 1052 projects: 1053 - name: child 1054 url: https://git.example.com/child 1055 import: true 1056 - name: project-1 1057 url: https://git.example.com/project-1 1058 groups: 1059 - unstable 1060 1061And :file:`child/west.yml` contains: 1062 1063.. code-block:: yaml 1064 1065 # child/west.yml: 1066 manifest: 1067 group-filter: [-unstable] 1068 projects: 1069 - name: project-2 1070 url: https://git.example.com/project-2 1071 groups: 1072 - optional 1073 - name: project-3 1074 url: https://git.example.com/project-3 1075 groups: 1076 - unstable 1077 1078If you run: 1079 1080.. code-block:: shell 1081 1082 west config manifest.group-filter +unstable,-optional 1083 1084Then only the ``child``, ``project-1``, and ``project-3`` projects are active. 1085 1086The ``-unstable`` group filter in :file:`child/west.yml` is overridden in the 1087``manifest.group-filter`` configuration option, so the ``unstable`` group is 1088enabled. Since ``project-1`` and ``project-3`` are in the ``unstable`` group, 1089they are active. 1090 1091The same configuration option disables the ``optional`` group, so ``project-2`` 1092is inactive. 1093 1094The final group filter specified by :file:`parent/west.yml` and the 1095``manifest.group-filter`` configuration option is ``[+unstable,-optional]``. 1096 1097.. _west-manifest-submodules: 1098 1099Git Submodules in Projects 1100************************** 1101 1102You can use the ``submodules`` keys briefly described :ref:`above 1103<west-manifest-files>` to force ``west update`` to also handle any `Git 1104submodules`_ configured in project's git repository. The ``submodules`` key can 1105appear inside ``projects``, like this: 1106 1107.. code-block:: YAML 1108 1109 manifest: 1110 projects: 1111 - name: some-project 1112 submodules: ... 1113 1114The ``submodules`` key can be a boolean or a list of mappings. We'll describe 1115these in order. 1116 1117Option 1: Boolean 1118================= 1119 1120This is the easiest way to use ``submodules``. 1121 1122If ``submodules`` is ``true`` as a ``projects`` attribute, ``west update`` will 1123recursively update the project's Git submodules whenever it updates the project 1124itself. If it's ``false`` or missing, it has no effect. 1125 1126For example, let's say you have a source code repository ``foo``, which has 1127some submodules, and you want ``west update`` to keep all of them in sync, 1128along with another project named ``bar`` in the same workspace. 1129 1130You can do that with this manifest file: 1131 1132.. code-block:: yaml 1133 1134 manifest: 1135 projects: 1136 - name: foo 1137 submodules: true 1138 - name: bar 1139 1140Here, ``west update`` will initialize and update all submodules in ``foo``. If 1141``bar`` has any submodules, they are ignored, because ``bar`` does not have a 1142``submodules`` value. 1143 1144Option 2: List of mappings 1145========================== 1146 1147The ``submodules`` key may be a list of mappings, one list element for 1148each desired submodule. Each submodule listed is updated recursively. 1149You can still track and update unlisted submodules with ``git`` commands 1150manually; present or not they will be completely ignored by ``west``. 1151 1152The ``path`` key must match exactly the path of one submodule relative 1153to its parent west project, as shown in the output of ``git submodule 1154status``. The ``name`` key is optional and not used by west for now; 1155it's not passed to ``git submodule`` commands either. The ``name`` key 1156was briefly mandatory in west version 0.9.0, but was made optional in 0.9.1. 1157 1158For example, let's say you have a source code repository ``foo``, which has 1159many submodules, and you want ``west update`` to keep some but not all of them 1160in sync, along with another project named ``bar`` in the same workspace. 1161 1162You can do that with this manifest file: 1163 1164.. code-block:: yaml 1165 1166 manifest: 1167 projects: 1168 - name: foo 1169 submodules: 1170 - path: path/to/foo-first-sub 1171 - name: foo-second-sub 1172 path: path/to/foo-second-sub 1173 - name: bar 1174 1175Here, ``west update`` will recursively initialize and update just the 1176submodules in ``foo`` with paths ``path/to/foo-first-sub`` and 1177``path/to/foo-second-sub``. Any submodules in ``bar`` are still ignored. 1178 1179.. _west-project-userdata: 1180 1181Repository user data 1182******************** 1183 1184West versions v0.12 and later support an optional ``userdata`` key in projects. 1185 1186West versions v0.13 and later supports this key in the ``manifest: self:`` 1187section. 1188 1189It is meant for consumption by programs that require user-specific project 1190metadata. Beyond parsing it as YAML, west itself ignores the value completely. 1191 1192The key's value is arbitrary YAML. West parses the value and makes it 1193accessible to programs using :ref:`west-apis` as the ``userdata`` attribute of 1194the corresponding ``west.manifest.Project`` object. 1195 1196Example manifest fragment: 1197 1198.. code-block:: yaml 1199 1200 manifest: 1201 projects: 1202 - name: foo 1203 - name: bar 1204 userdata: a-string 1205 - name: baz 1206 userdata: 1207 key: value 1208 self: 1209 userdata: blub 1210 1211Example Python usage: 1212 1213.. code-block:: python 1214 1215 manifest = west.manifest.Manifest.from_file() 1216 1217 foo, bar, baz = manifest.get_projects(['foo', 'bar', 'baz']) 1218 1219 foo.userdata # None 1220 bar.userdata # 'a-string' 1221 baz.userdata # {'key': 'value'} 1222 manifest.userdata # 'blub' 1223 1224.. _west-manifest-import: 1225 1226Manifest Imports 1227**************** 1228 1229You can use the ``import`` key briefly described above to include projects from 1230other manifest files in your :file:`west.yml`. This key can be either a 1231``project`` or ``self`` section attribute: 1232 1233.. code-block:: yaml 1234 1235 manifest: 1236 projects: 1237 - name: some-project 1238 import: ... 1239 self: 1240 import: ... 1241 1242You can use a "self: import:" to load additional files from the repository 1243containing your :file:`west.yml`. You can use a "project: ... import:" to load 1244additional files defined in that project's Git history. 1245 1246West resolves the final manifest from individual manifest files in this order: 1247 1248#. imported files in ``self`` 1249#. your :file:`west.yml` file 1250#. imported files in ``projects`` 1251 1252During resolution, west ignores projects which have already been defined in 1253other files. For example, a project named ``foo`` in your :file:`west.yml` 1254makes west ignore other projects named ``foo`` imported from your ``projects`` 1255list. 1256 1257The ``import`` key can be a boolean, path, mapping, or sequence. We'll describe 1258these in order, using examples: 1259 1260- :ref:`Boolean <west-manifest-import-bool>` 1261 - :ref:`west-manifest-ex1.1` 1262 - :ref:`west-manifest-ex1.2` 1263 - :ref:`west-manifest-ex1.3` 1264- :ref:`Relative path <west-manifest-import-path>` 1265 - :ref:`west-manifest-ex2.1` 1266 - :ref:`west-manifest-ex2.2` 1267 - :ref:`west-manifest-ex2.3` 1268- :ref:`Mapping with additional configuration <west-manifest-import-map>` 1269 - :ref:`west-manifest-ex3.1` 1270 - :ref:`west-manifest-ex3.2` 1271 - :ref:`west-manifest-ex3.3` 1272 - :ref:`west-manifest-ex3.4` 1273- :ref:`Sequence of paths and mappings <west-manifest-import-seq>` 1274 - :ref:`west-manifest-ex4.1` 1275 - :ref:`west-manifest-ex4.2` 1276 1277A more :ref:`formal description <west-manifest-formal>` of how this works is 1278last, after the examples. 1279 1280Troubleshooting Note 1281==================== 1282 1283If you're using this feature and find west's behavior confusing, try 1284:ref:`resolving your manifest <west-manifest-resolve>` to see the final results 1285after imports are done. 1286 1287.. _west-manifest-import-bool: 1288 1289Option 1: Boolean 1290================= 1291 1292This is the easiest way to use ``import``. 1293 1294If ``import`` is ``true`` as a ``projects`` attribute, west imports projects 1295from the :file:`west.yml` file in that project's root directory. If it's 1296``false`` or missing, it has no effect. For example, this manifest would import 1297:file:`west.yml` from the ``p1`` git repository at revision ``v1.0``: 1298 1299.. code-block:: yaml 1300 1301 manifest: 1302 # ... 1303 projects: 1304 - name: p1 1305 revision: v1.0 1306 import: true # Import west.yml from p1's v1.0 git tag 1307 - name: p2 1308 import: false # Nothing is imported from p2. 1309 - name: p3 # Nothing is imported from p3 either. 1310 1311It's an error to set ``import`` to either ``true`` or ``false`` inside 1312``self``, like this: 1313 1314.. code-block:: yaml 1315 1316 manifest: 1317 # ... 1318 self: 1319 import: true # Error 1320 1321.. _west-manifest-ex1.1: 1322 1323Example 1.1: Downstream of a Zephyr release 1324------------------------------------------- 1325 1326You have a source code repository you want to use with Zephyr v1.14.1 LTS. You 1327want to maintain the whole thing using west. You don't want to modify any of 1328the mainline repositories. 1329 1330In other words, the west workspace you want looks like this: 1331 1332.. code-block:: none 1333 1334 my-downstream/ 1335 ├── .west/ # west directory 1336 ├── zephyr/ # mainline zephyr repository 1337 │ └── west.yml # the v1.14.1 version of this file is imported 1338 ├── modules/ # modules from mainline zephyr 1339 │ ├── hal/ 1340 │ └── [...other directories..] 1341 ├── [ ... other projects ...] # other mainline repositories 1342 └── my-repo/ # your downstream repository 1343 ├── west.yml # main manifest importing zephyr/west.yml v1.14.1 1344 └── [...other files..] 1345 1346You can do this with the following :file:`my-repo/west.yml`: 1347 1348.. code-block:: yaml 1349 1350 # my-repo/west.yml: 1351 manifest: 1352 remotes: 1353 - name: zephyrproject-rtos 1354 url-base: https://github.com/zephyrproject-rtos 1355 projects: 1356 - name: zephyr 1357 remote: zephyrproject-rtos 1358 revision: v1.14.1 1359 import: true 1360 1361You can then create the workspace on your computer like this, assuming 1362``my-repo`` is hosted at ``https://git.example.com/my-repo``: 1363 1364.. code-block:: console 1365 1366 west init -m https://git.example.com/my-repo my-downstream 1367 cd my-downstream 1368 west update 1369 1370After ``west init``, :file:`my-downstream/my-repo` will be cloned. 1371 1372After ``west update``, all of the projects defined in the ``zephyr`` 1373repository's :file:`west.yml` at revision ``v1.14.1`` will be cloned into 1374:file:`my-downstream` as well. 1375 1376You can add and commit any code to :file:`my-repo` you please at this point, 1377including your own Zephyr applications, drivers, etc. See :ref:`application`. 1378 1379.. _west-manifest-ex1.2: 1380 1381Example 1.2: "Rolling release" Zephyr downstream 1382------------------------------------------------ 1383 1384This is similar to :ref:`west-manifest-ex1.1`, except we'll use ``revision: 1385main`` for the zephyr repository: 1386 1387.. code-block:: yaml 1388 1389 # my-repo/west.yml: 1390 manifest: 1391 remotes: 1392 - name: zephyrproject-rtos 1393 url-base: https://github.com/zephyrproject-rtos 1394 projects: 1395 - name: zephyr 1396 remote: zephyrproject-rtos 1397 revision: main 1398 import: true 1399 1400You can create the workspace in the same way: 1401 1402.. code-block:: console 1403 1404 west init -m https://git.example.com/my-repo my-downstream 1405 cd my-downstream 1406 west update 1407 1408This time, whenever you run ``west update``, the special :ref:`manifest-rev 1409<west-manifest-rev>` branch in the ``zephyr`` repository will be updated to 1410point at a newly fetched ``main`` branch tip from the URL 1411https://github.com/zephyrproject-rtos/zephyr. 1412 1413The contents of :file:`zephyr/west.yml` at the new ``manifest-rev`` will then 1414be used to import projects from Zephyr. This lets you stay up to date with the 1415latest changes in the Zephyr project. The cost is that running ``west update`` 1416will not produce reproducible results, since the remote ``main`` branch can 1417change every time you run it. 1418 1419It's also important to understand that west **ignores your working tree's** 1420:file:`zephyr/west.yml` entirely when resolving imports. West always uses the 1421contents of imported manifests as they were committed to the latest 1422``manifest-rev`` when importing from a project. 1423 1424You can only import manifest from the file system if they are in your manifest 1425repository's working tree. See :ref:`west-manifest-ex2.2` for an example. 1426 1427.. _west-manifest-ex1.3: 1428 1429Example 1.3: Downstream of a Zephyr release, with module fork 1430------------------------------------------------------------- 1431 1432This manifest is similar to the one in :ref:`west-manifest-ex1.1`, except it: 1433 1434- is a downstream of Zephyr 2.0 1435- includes a downstream fork of the :file:`modules/hal/nordic` 1436 :ref:`module <modules>` which was included in that release 1437 1438.. code-block:: yaml 1439 1440 # my-repo/west.yml: 1441 manifest: 1442 remotes: 1443 - name: zephyrproject-rtos 1444 url-base: https://github.com/zephyrproject-rtos 1445 - name: my-remote 1446 url-base: https://git.example.com 1447 projects: 1448 - name: hal_nordic # higher precedence 1449 remote: my-remote 1450 revision: my-sha 1451 path: modules/hal/nordic 1452 - name: zephyr 1453 remote: zephyrproject-rtos 1454 revision: v2.0.0 1455 import: true # imported projects have lower precedence 1456 1457 # subset of zephyr/west.yml contents at v2.0.0: 1458 manifest: 1459 defaults: 1460 remote: zephyrproject-rtos 1461 remotes: 1462 - name: zephyrproject-rtos 1463 url-base: https://github.com/zephyrproject-rtos 1464 projects: 1465 # ... 1466 - name: hal_nordic # lower precedence, values ignored 1467 path: modules/hal/nordic 1468 revision: another-sha 1469 1470With this manifest file, the project named ``hal_nordic``: 1471 1472- is cloned from ``https://git.example.com/hal_nordic`` instead of 1473 ``https://github.com/zephyrproject-rtos/hal_nordic``. 1474- is updated to commit ``my-sha`` by ``west update``, instead of 1475 the mainline commit ``another-sha`` 1476 1477In other words, when your top-level manifest defines a project, like 1478``hal_nordic``, west will ignore any other definition it finds later on while 1479resolving imports. 1480 1481This does mean you have to copy the ``path: modules/hal/nordic`` value into 1482:file:`my-repo/west.yml` when defining ``hal_nordic`` there. The value from 1483:file:`zephyr/west.yml` is ignored entirely. See :ref:`west-manifest-resolve` 1484for troubleshooting advice if this gets confusing in practice. 1485 1486When you run ``west update``, west will: 1487 1488- update zephyr's ``manifest-rev`` to point at the ``v2.0.0`` tag 1489- import :file:`zephyr/west.yml` at that ``manifest-rev`` 1490- locally check out the ``v2.0.0`` revisions for all zephyr projects except 1491 ``hal_nordic`` 1492- update ``hal_nordic`` to ``my-sha`` instead of ``another-sha`` 1493 1494.. _west-manifest-import-path: 1495 1496Option 2: Relative path 1497======================= 1498 1499The ``import`` value can also be a relative path to a manifest file or a 1500directory containing manifest files. The path is relative to the root directory 1501of the ``projects`` or ``self`` repository the ``import`` key appears in. 1502 1503Here is an example: 1504 1505.. code-block:: yaml 1506 1507 manifest: 1508 projects: 1509 - name: project-1 1510 revision: v1.0 1511 import: west.yml 1512 - name: project-2 1513 revision: main 1514 import: p2-manifests 1515 self: 1516 import: submanifests 1517 1518This will import the following: 1519 1520- the contents of :file:`project-1/west.yml` at ``manifest-rev``, which points 1521 at tag ``v1.0`` after running ``west update`` 1522- any YAML files in the directory tree :file:`project-2/p2-manifests` 1523 at the latest commit in the ``main`` branch, as fetched by ``west update``, 1524 sorted by file name 1525- YAML files in :file:`submanifests` in your manifest repository, 1526 as they appear on your file system, sorted by file name 1527 1528Notice how ``projects`` imports get data from Git using ``manifest-rev``, while 1529``self`` imports get data from your file system. This is because as usual, west 1530leaves version control for your manifest repository up to you. 1531 1532.. _west-manifest-ex2.1: 1533 1534Example 2.1: Downstream of a Zephyr release with explicit path 1535-------------------------------------------------------------- 1536 1537This is an explicit way to write an equivalent manifest to the one in 1538:ref:`west-manifest-ex1.1`. 1539 1540.. code-block:: yaml 1541 1542 manifest: 1543 remotes: 1544 - name: zephyrproject-rtos 1545 url-base: https://github.com/zephyrproject-rtos 1546 projects: 1547 - name: zephyr 1548 remote: zephyrproject-rtos 1549 revision: v1.14.1 1550 import: west.yml 1551 1552The setting ``import: west.yml`` means to use the file :file:`west.yml` inside 1553the ``zephyr`` project. This example is contrived, but shows the idea. 1554 1555This can be useful in practice when the name of the manifest file you want to 1556import is not :file:`west.yml`. 1557 1558.. _west-manifest-ex2.2: 1559 1560Example 2.2: Downstream with directory of manifest files 1561-------------------------------------------------------- 1562 1563Your Zephyr downstream has a lot of additional repositories. So many, in fact, 1564that you want to split them up into multiple manifest files, but keep track of 1565them all in a single manifest repository, like this: 1566 1567.. code-block:: none 1568 1569 my-repo/ 1570 ├── submanifests 1571 │ ├── 01-libraries.yml 1572 │ ├── 02-vendor-hals.yml 1573 │ └── 03-applications.yml 1574 └── west.yml 1575 1576You want to add all the files in :file:`my-repo/submanifests` to the main 1577manifest file, :file:`my-repo/west.yml`, in addition to projects in 1578:file:`zephyr/west.yml`. You want to track the latest development code 1579in the Zephyr repository's ``main`` branch instead of using a fixed revision. 1580 1581Here's how: 1582 1583.. code-block:: yaml 1584 1585 # my-repo/west.yml: 1586 manifest: 1587 remotes: 1588 - name: zephyrproject-rtos 1589 url-base: https://github.com/zephyrproject-rtos 1590 projects: 1591 - name: zephyr 1592 remote: zephyrproject-rtos 1593 revision: main 1594 import: true 1595 self: 1596 import: submanifests 1597 1598Manifest files are imported in this order during resolution: 1599 1600#. :file:`my-repo/submanifests/01-libraries.yml` 1601#. :file:`my-repo/submanifests/02-vendor-hals.yml` 1602#. :file:`my-repo/submanifests/03-applications.yml` 1603#. :file:`my-repo/west.yml` 1604#. :file:`zephyr/west.yml` 1605 1606.. note:: 1607 1608 The :file:`.yml` file names are prefixed with numbers in this example to 1609 make sure they are imported in the specified order. 1610 1611 You can pick arbitrary names. West sorts files in a directory by name before 1612 importing. 1613 1614Notice how the manifests in :file:`submanifests` are imported *before* 1615:file:`my-repo/west.yml` and :file:`zephyr/west.yml`. In general, an ``import`` 1616in the ``self`` section is processed before the manifest files in ``projects`` 1617and the main manifest file. 1618 1619This means projects defined in :file:`my-repo/submanifests` take highest 1620precedence. For example, if :file:`01-libraries.yml` defines ``hal_nordic``, 1621the project by the same name in :file:`zephyr/west.yml` is simply ignored. As 1622usual, see :ref:`west-manifest-resolve` for troubleshooting advice. 1623 1624This may seem strange, but it allows you to redefine projects "after the fact", 1625as we'll see in the next example. 1626 1627.. _west-manifest-ex2.3: 1628 1629Example 2.3: Continuous Integration overrides 1630--------------------------------------------- 1631 1632Your continuous integration system needs to fetch and test multiple 1633repositories in your west workspace from a developer's forks instead of your 1634mainline development trees, to see if the changes all work well together. 1635 1636Starting with :ref:`west-manifest-ex2.2`, the CI scripts add a 1637file :file:`00-ci.yml` in :file:`my-repo/submanifests`, with these contents: 1638 1639.. code-block:: yaml 1640 1641 # my-repo/submanifests/00-ci.yml: 1642 manifest: 1643 projects: 1644 - name: a-vendor-hal 1645 url: https://github.com/a-developer/hal 1646 revision: a-pull-request-branch 1647 - name: an-application 1648 url: https://github.com/a-developer/application 1649 revision: another-pull-request-branch 1650 1651The CI scripts run ``west update`` after generating this file in 1652:file:`my-repo/submanifests`. The projects defined in :file:`00-ci.yml` have 1653higher precedence than other definitions in :file:`my-repo/submanifests`, 1654because the name :file:`00-ci.yml` comes before the other file names. 1655 1656Thus, ``west update`` always checks out the developer's branches in the 1657projects named ``a-vendor-hal`` and ``an-application``, even if those same 1658projects are also defined elsewhere. 1659 1660.. _west-manifest-import-map: 1661 1662Option 3: Mapping 1663================= 1664 1665The ``import`` key can also contain a mapping with the following keys: 1666 1667- ``file``: Optional. The name of the manifest file or directory to import. 1668 This defaults to :file:`west.yml` if not present. 1669- ``name-allowlist``: Optional. If present, a name or sequence of project names 1670 to include. 1671- ``path-allowlist``: Optional. If present, a path or sequence of project paths 1672 to match against. This is a shell-style globbing pattern, currently 1673 implemented with `pathlib`_. Note that this means case sensitivity is 1674 platform specific. 1675- ``name-blocklist``: Optional. Like ``name-allowlist``, but contains project 1676 names to exclude rather than include. 1677- ``path-blocklist``: Optional. Like ``path-allowlist``, but contains project 1678 paths to exclude rather than include. 1679- ``path-prefix``: Optional (new in v0.8.0). If given, this will be prepended 1680 to the project's path in the workspace, as well as the paths of any imported 1681 projects. This can be used to place these projects in a subdirectory of the 1682 workspace. 1683 1684.. _re: https://docs.python.org/3/library/re.html 1685.. _pathlib: 1686 https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.match 1687 1688Allowlists override blocklists if both are given. For example, if a project is 1689blocked by path, then allowed by name, it will still be imported. 1690 1691.. _west-manifest-ex3.1: 1692 1693Example 3.1: Downstream with name allowlist 1694------------------------------------------- 1695 1696Here is a pair of manifest files, representing a mainline and a 1697downstream. The downstream doesn't want to use all the mainline 1698projects, however. We'll assume the mainline :file:`west.yml` is 1699hosted at ``https://git.example.com/mainline/manifest``. 1700 1701.. code-block:: yaml 1702 1703 # mainline west.yml: 1704 manifest: 1705 projects: 1706 - name: mainline-app # included 1707 path: examples/app 1708 url: https://git.example.com/mainline/app 1709 - name: lib 1710 path: libraries/lib 1711 url: https://git.example.com/mainline/lib 1712 - name: lib2 # included 1713 path: libraries/lib2 1714 url: https://git.example.com/mainline/lib2 1715 1716 # downstream west.yml: 1717 manifest: 1718 projects: 1719 - name: mainline 1720 url: https://git.example.com/mainline/manifest 1721 import: 1722 name-allowlist: 1723 - mainline-app 1724 - lib2 1725 - name: downstream-app 1726 url: https://git.example.com/downstream/app 1727 - name: lib3 1728 path: libraries/lib3 1729 url: https://git.example.com/downstream/lib3 1730 1731An equivalent manifest in a single file would be: 1732 1733.. code-block:: yaml 1734 1735 manifest: 1736 projects: 1737 - name: mainline 1738 url: https://git.example.com/mainline/manifest 1739 - name: downstream-app 1740 url: https://git.example.com/downstream/app 1741 - name: lib3 1742 path: libraries/lib3 1743 url: https://git.example.com/downstream/lib3 1744 - name: mainline-app # imported 1745 path: examples/app 1746 url: https://git.example.com/mainline/app 1747 - name: lib2 # imported 1748 path: libraries/lib2 1749 url: https://git.example.com/mainline/lib2 1750 1751If an allowlist had not been used, the ``lib`` project from the mainline 1752manifest would have been imported. 1753 1754.. _west-manifest-ex3.2: 1755 1756Example 3.2: Downstream with path allowlist 1757------------------------------------------- 1758 1759Here is an example showing how to allowlist mainline's libraries only, 1760using ``path-allowlist``. 1761 1762.. code-block:: yaml 1763 1764 # mainline west.yml: 1765 manifest: 1766 projects: 1767 - name: app 1768 path: examples/app 1769 url: https://git.example.com/mainline/app 1770 - name: lib 1771 path: libraries/lib # included 1772 url: https://git.example.com/mainline/lib 1773 - name: lib2 1774 path: libraries/lib2 # included 1775 url: https://git.example.com/mainline/lib2 1776 1777 # downstream west.yml: 1778 manifest: 1779 projects: 1780 - name: mainline 1781 url: https://git.example.com/mainline/manifest 1782 import: 1783 path-allowlist: libraries/* 1784 - name: app 1785 url: https://git.example.com/downstream/app 1786 - name: lib3 1787 path: libraries/lib3 1788 url: https://git.example.com/downstream/lib3 1789 1790An equivalent manifest in a single file would be: 1791 1792.. code-block:: yaml 1793 1794 manifest: 1795 projects: 1796 - name: lib # imported 1797 path: libraries/lib 1798 url: https://git.example.com/mainline/lib 1799 - name: lib2 # imported 1800 path: libraries/lib2 1801 url: https://git.example.com/mainline/lib2 1802 - name: mainline 1803 url: https://git.example.com/mainline/manifest 1804 - name: app 1805 url: https://git.example.com/downstream/app 1806 - name: lib3 1807 path: libraries/lib3 1808 url: https://git.example.com/downstream/lib3 1809 1810.. _west-manifest-ex3.3: 1811 1812Example 3.3: Downstream with path blocklist 1813------------------------------------------- 1814 1815Here's an example showing how to block all vendor HALs from mainline by 1816common path prefix in the workspace, add your own version for the chip 1817you're targeting, and keep everything else. 1818 1819.. code-block:: yaml 1820 1821 # mainline west.yml: 1822 manifest: 1823 defaults: 1824 remote: mainline 1825 remotes: 1826 - name: mainline 1827 url-base: https://git.example.com/mainline 1828 projects: 1829 - name: app 1830 - name: lib 1831 path: libraries/lib 1832 - name: lib2 1833 path: libraries/lib2 1834 - name: hal_foo 1835 path: modules/hals/foo # excluded 1836 - name: hal_bar 1837 path: modules/hals/bar # excluded 1838 - name: hal_baz 1839 path: modules/hals/baz # excluded 1840 1841 # downstream west.yml: 1842 manifest: 1843 projects: 1844 - name: mainline 1845 url: https://git.example.com/mainline/manifest 1846 import: 1847 path-blocklist: modules/hals/* 1848 - name: hal_foo 1849 path: modules/hals/foo 1850 url: https://git.example.com/downstream/hal_foo 1851 1852An equivalent manifest in a single file would be: 1853 1854.. code-block:: yaml 1855 1856 manifest: 1857 defaults: 1858 remote: mainline 1859 remotes: 1860 - name: mainline 1861 url-base: https://git.example.com/mainline 1862 projects: 1863 - name: app # imported 1864 - name: lib # imported 1865 path: libraries/lib 1866 - name: lib2 # imported 1867 path: libraries/lib2 1868 - name: mainline 1869 repo-path: https://git.example.com/mainline/manifest 1870 - name: hal_foo 1871 path: modules/hals/foo 1872 url: https://git.example.com/downstream/hal_foo 1873 1874.. _west-manifest-ex3.4: 1875 1876Example 3.4: Import into a subdirectory 1877--------------------------------------- 1878 1879You want to import a manifest and its projects, placing everything into a 1880subdirectory of your :term:`west workspace`. 1881 1882For example, suppose you want to import this manifest from project ``foo``, 1883adding this project and its projects ``bar`` and ``baz`` to your workspace: 1884 1885.. code-block:: yaml 1886 1887 # foo/west.yml: 1888 manifest: 1889 defaults: 1890 remote: example 1891 remotes: 1892 - name: example 1893 url-base: https://git.example.com 1894 projects: 1895 - name: bar 1896 - name: baz 1897 1898Instead of importing these into the top level workspace, you want to place all 1899three project repositories in an :file:`external-code` subdirectory, like this: 1900 1901.. code-block:: none 1902 1903 workspace/ 1904 └── external-code/ 1905 ├── foo/ 1906 ├── bar/ 1907 └── baz/ 1908 1909You can do this using this manifest: 1910 1911.. code-block:: yaml 1912 1913 manifest: 1914 projects: 1915 - name: foo 1916 url: https://git.example.com/foo 1917 import: 1918 path-prefix: external-code 1919 1920An equivalent manifest in a single file would be: 1921 1922.. code-block:: yaml 1923 1924 # foo/west.yml: 1925 manifest: 1926 defaults: 1927 remote: example 1928 remotes: 1929 - name: example 1930 url-base: https://git.example.com 1931 projects: 1932 - name: foo 1933 path: external-code/foo 1934 - name: bar 1935 path: external-code/bar 1936 - name: baz 1937 path: external-code/baz 1938 1939.. _west-manifest-import-seq: 1940 1941Option 4: Sequence 1942================== 1943 1944The ``import`` key can also contain a sequence of files, directories, 1945and mappings. 1946 1947.. _west-manifest-ex4.1: 1948 1949Example 4.1: Downstream with sequence of manifest files 1950------------------------------------------------------- 1951 1952This example manifest is equivalent to the manifest in 1953:ref:`west-manifest-ex2.2`, with a sequence of explicitly named files. 1954 1955.. code-block:: yaml 1956 1957 # my-repo/west.yml: 1958 manifest: 1959 projects: 1960 - name: zephyr 1961 url: https://github.com/zephyrproject-rtos/zephyr 1962 import: west.yml 1963 self: 1964 import: 1965 - submanifests/01-libraries.yml 1966 - submanifests/02-vendor-hals.yml 1967 - submanifests/03-applications.yml 1968 1969.. _west-manifest-ex4.2: 1970 1971Example 4.2: Import order illustration 1972-------------------------------------- 1973 1974This more complicated example shows the order that west imports manifest files: 1975 1976.. code-block:: yaml 1977 1978 # my-repo/west.yml 1979 manifest: 1980 # ... 1981 projects: 1982 - name: my-library 1983 - name: my-app 1984 - name: zephyr 1985 import: true 1986 - name: another-manifest-repo 1987 import: submanifests 1988 self: 1989 import: 1990 - submanifests/libraries.yml 1991 - submanifests/vendor-hals.yml 1992 - submanifests/applications.yml 1993 defaults: 1994 remote: my-remote 1995 1996For this example, west resolves imports in this order: 1997 1998#. the listed files in :file:`my-repo/submanifests` are first, in the order 1999 they occur (e.g. :file:`libraries.yml` comes before 2000 :file:`applications.yml`, since this is a sequence of files), since the 2001 ``self: import:`` is always imported first 2002#. :file:`my-repo/west.yml` is next (with projects ``my-library`` etc. as long 2003 as they weren't already defined somewhere in :file:`submanifests`) 2004#. :file:`zephyr/west.yml` is after that, since that's the first ``import`` key 2005 in the ``projects`` list in :file:`my-repo/west.yml` 2006#. files in :file:`another-manifest-repo/submanifests` are last (sorted by file 2007 name), since that's the final project ``import`` 2008 2009.. _west-manifest-formal: 2010 2011Manifest Import Details 2012======================= 2013 2014This section describes how west resolves a manifest file that uses ``import`` a 2015bit more formally. 2016 2017Overview 2018-------- 2019 2020The ``import`` key can appear in a west manifest's ``projects`` and ``self`` 2021sections. The general case looks like this: 2022 2023.. code-block:: yaml 2024 2025 # Top-level manifest file. 2026 manifest: 2027 projects: 2028 - name: foo 2029 import: 2030 ... # import-1 2031 - name: bar 2032 import: 2033 ... # import-2 2034 # ... 2035 - name: baz 2036 import: 2037 ... # import-N 2038 self: 2039 import: 2040 ... # self-import 2041 2042Import keys are optional. If any of ``import-1, ..., import-N`` are missing, 2043west will not import additional manifest data from that project. If 2044``self-import`` is missing, no additional files in the manifest repository 2045(beyond the top-level file) are imported. 2046 2047The ultimate outcomes of resolving manifest imports are: 2048 2049- a ``projects`` list, which is produced by combining the ``projects`` defined 2050 in the top-level file with those defined in imported files 2051 2052- a set of extension commands, which are drawn from the ``west-commands`` 2053 keys in the top-level file and any imported files 2054 2055- a ``group-filter`` list, which is produced by combining the top-level and any 2056 imported filters 2057 2058Importing is done in this order: 2059 2060#. Manifests from ``self-import`` are imported first. 2061#. The top-level manifest file's definitions are handled next. 2062#. Manifests from ``import-1``, ..., ``import-N``, are imported in that order. 2063 2064When an individual ``import`` key refers to multiple manifest files, they are 2065processed in this order: 2066 2067- If the value is a relative path naming a directory (or a map whose ``file`` 2068 is a directory), the manifest files it contains are processed in 2069 lexicographic order -- i.e., sorted by file name. 2070- If the value is a sequence, its elements are recursively imported in the 2071 order they appear. 2072 2073This process recurses if necessary. E.g., if ``import-1`` produces a manifest 2074file that contains an ``import`` key, it is resolved recursively using the same 2075rules before its contents are processed further. 2076 2077The following sections describe these outcomes. 2078 2079Projects 2080-------- 2081 2082This section describes how the final ``projects`` list is created. 2083 2084Projects are identified by name. If the same name occurs in multiple manifests, 2085the first definition is used, and subsequent definitions are ignored. For 2086example, if ``import-1`` contains a project named ``bar``, that is ignored, 2087because the top-level :file:`west.yml` has already defined a project by that 2088name. 2089 2090The contents of files named by ``import-1`` through ``import-N`` are imported 2091from Git at the latest ``manifest-rev`` revisions in their projects. These 2092revisions can be updated to the values ``rev-1`` through ``rev-N`` by running 2093``west update``. If any ``manifest-rev`` reference is missing or out of date, 2094``west update`` also fetches project data from the remote fetch URL and updates 2095the reference. 2096 2097Also note that all imported manifests, from the root manifest to the repository 2098which defines a project ``P``, must be up to date in order for west to update 2099``P`` itself. For example, this means ``west update P`` would update 2100``manifest-rev`` in the ``baz`` project if :file:`baz/west.yml` defines ``P``, 2101as well as updating the ``manifest-rev`` branch in the local git clone of 2102``P``. Confusingly, updating ``baz`` may result in the removal of ``P`` 2103from :file:`baz/west.yml`, which "should" cause ``west update P`` to fail with an 2104unrecognized project! 2105 2106For this reason, it's not possible to run ``west update P`` if ``P`` is defined 2107in an imported manifest; you must update this project along with all the others 2108with a plain ``west update``. 2109 2110By default, west won't fetch any project data over the network if a project's 2111revision is a SHA or tag which is already available locally, so updating the 2112extra projects shouldn't take too much time unless it's really needed. See the 2113documentation for the :ref:`update.fetch <west-config-index>` configuration 2114option for more information. 2115 2116Extensions 2117---------- 2118 2119All extension commands defined using ``west-commands`` keys discovered while 2120handling imports are available in the resolved manifest. 2121 2122If an imported manifest file has a ``west-commands:`` definition in its 2123``self:`` section, the extension commands defined there are added to the set of 2124available extensions at the time the manifest is imported. They will thus take 2125precedence over any extension commands with the same names added later on. 2126 2127Group filters 2128------------- 2129 2130The resolved manifest has a ``group-filter`` value which is the result of 2131concatenating the ``group-filter`` values in the top-level manifest and any 2132imported manifests. 2133 2134Manifest files which appear earlier in the import order have higher precedence 2135and are therefore concatenated later into the final ``group-filter``. 2136 2137In other words, let: 2138 2139- the submanifest resolved from ``self-import`` have group filter ``self-filter`` 2140- the top-level manifest file have group filter ``top-filter`` 2141- the submanifests resolved from ``import-1`` through ``import-N`` have group 2142 filters ``filter-1`` through ``filter-N`` respectively 2143 2144The final resolved ``group-filter`` value is then ``filterN + ... + filter-2 + 2145filter-1 + top-filter + self-filter``, where ``+`` here refers to list 2146concatenation. 2147 2148.. important:: 2149 2150 The order that filters appear in the above list matters. 2151 2152 The last filter element in the final concatenated list "wins" and determines 2153 if the group is enabled or disabled. 2154 2155For example, in ``[-foo] + [+foo]``, group ``foo`` is *enabled*. 2156However, in ``[+foo] + [-foo]``, group ``foo`` is *disabled*. 2157 2158For simplicity, west and this documentation may elide concatenated group filter 2159elements which are redundant using these rules. For example, ``[+foo] + 2160[-foo]`` could be written more simply as ``[-foo]``, for the reasons given 2161above. As another example, ``[-foo] + [+foo]`` could be written as the empty 2162list ``[]``, since all groups are enabled by default. 2163 2164.. _west-manifest-cmd: 2165 2166Manifest Command 2167**************** 2168 2169The ``west manifest`` command can be used to manipulate manifest files. 2170It takes an action, and action-specific arguments. 2171 2172The following sections describe each action and provides a basic signature for 2173simple uses. Run ``west manifest --help`` for full details on all options. 2174 2175.. _west-manifest-resolve: 2176 2177Resolving Manifests 2178=================== 2179 2180The ``--resolve`` action outputs a single manifest file equivalent to your 2181current manifest and all its :ref:`imported manifests <west-manifest-import>`: 2182 2183.. code-block:: none 2184 2185 west manifest --resolve [-o outfile] 2186 2187The main use for this action is to see the "final" manifest contents after 2188performing any ``import``\ s. 2189 2190To print detailed information about each imported manifest file and how 2191projects are handled during manifest resolution, set the maximum verbosity 2192level using ``-v``: 2193 2194.. code-block:: console 2195 2196 west -v manifest --resolve 2197 2198Freezing Manifests 2199================== 2200 2201The ``--freeze`` action outputs a frozen manifest: 2202 2203.. code-block:: none 2204 2205 west manifest --freeze [-o outfile] 2206 2207A "frozen" manifest is a manifest file where every project's revision is a SHA. 2208You can use ``--freeze`` to produce a frozen manifest that's equivalent to your 2209current manifest file. The ``-o`` option specifies an output file; if not 2210given, standard output is used. 2211 2212Validating Manifests 2213==================== 2214 2215The ``--validate`` action either succeeds if the current manifest file is valid, 2216or fails with an error: 2217 2218.. code-block:: none 2219 2220 west manifest --validate 2221 2222The error message can help diagnose errors. 2223 2224Here, "invalid" means that the syntax of the manifest file doesn't follow the 2225rules documented on this page. 2226 2227If your manifest is valid but it's not working the way you want it to, turning 2228up the verbosity with ``-v`` is a good way to get detailed information about 2229what decisions west made about your manifest, and why: 2230 2231.. code-block:: none 2232 2233 west -v manifest --validate 2234 2235.. _west-manifest-path: 2236 2237Get the manifest path 2238===================== 2239 2240The ``--path`` action prints the path to the top level manifest file: 2241 2242.. code-block:: none 2243 2244 west manifest --path 2245 2246The output is something like ``/path/to/workspace/west.yml``. The path format 2247depends on your operating system. 2248