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