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