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