xref: /aosp_15_r20/external/pigweed/third_party/fuchsia/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1.. _module-pw_third_party_fuchsia:
2
3=================
4Fuchsia libraries
5=================
6`Fuchsia <https://fuchsia.dev/>`_ is a modern open source operating system
7developed by Google.
8
9Pigweed does not use the Fuchsia operating system itself, but uses some
10low-level libraries developed for it.
11
12--------
13Features
14--------
15Parts of two Fuchsia libraries are used in Pigweed:
16
17- `FIT <https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/lib/fit/>`_ --
18  Portable library of low-level C++ features.
19- `stdcompat <https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/lib/stdcompat/>`_ --
20  Implements newer C++ features for older standards.
21
22--------------------
23Code synchronization
24--------------------
25Unlike other third party libraries used by Pigweed, some Fuchsia source code is
26included in tree. A few factors drove this decision:
27
28- Core Pigweed features like :cpp:type:`pw::Function` depend on these Fuchsia
29  libraries. Including the source in-tree avoids having Pigweed require an
30  an external repository.
31- The Fuchsia repository is too large to require downstream projects to clone.
32
33If Fuchsia moves ``stdcompat`` and ``fit`` to separate repositories, the
34decision to include Fuchsia code in tree may be reconsidered.
35
36Files are synced from Fuchsia repository to the ``third_party/fuchsia/repo``
37directory in Pigweed. The files maintain their original paths under that
38directory. The Copybara script applies patches to adapt the sources for use in
39Pigweed. For example, ``__builtin_abort`` is replaced with ``PW_ASSERT``.
40
41Process
42=======
43Code is synchronized between the `Fuchsia repository
44<https://fuchsia.googlesource.com/fuchsia>`_ and the `Pigweed repository
45<https://pigweed.googlesource.com/pigweed/pigweed>`_ using the
46`third_party/fuchsia/copy.bara.sky
47<https://cs.opensource.google/pigweed/pigweed/+/main:third_party/fuchsia/copy.bara.sky>`_
48`Copybara <https://github.com/google/copybara>`_ script.
49
50To synchronize with the Fuchsia repository, run the ``copybara`` tool with the
51script:
52
53.. code-block:: bash
54
55   copybara third_party/fuchsia/copy.bara.sky
56
57That creates a Gerrit change with updates from the Fuchsia repo, if any.
58
59If the ``copybara`` command fails, the Copybara script or patch file may need to
60be updated. Try the following:
61
62- Ensure that the source files in ``copy.bara.sky`` are up-to-date. Fix the list
63  if any files were renamed in Fuchsia.
64- Update the patch file Copybara applies by running ``python
65  third_party/fuchsia/generate_fuchsia_patch.py``.
66