xref: /aosp_15_r20/external/pigweed/docs/faq.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _docs-faq:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker--------------------------
4*61c4878aSAndroid Build Coastguard WorkerFrequently Asked Questions
5*61c4878aSAndroid Build Coastguard Worker--------------------------
6*61c4878aSAndroid Build Coastguard Worker
7*61c4878aSAndroid Build Coastguard WorkerIs Pigweed a framework?
8*61c4878aSAndroid Build Coastguard Worker-----------------------
9*61c4878aSAndroid Build Coastguard WorkerThere are three core components of Pigweed's offering:
10*61c4878aSAndroid Build Coastguard Worker
11*61c4878aSAndroid Build Coastguard Worker1. The environment setup system (bootstrap and activate)
12*61c4878aSAndroid Build Coastguard Worker2. The GN-based build and test system
13*61c4878aSAndroid Build Coastguard Worker3. The individual modules (mostly C++ code)
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard WorkerWe consider #1 and #2 combined as the "Pigweed Monolith" - since it has an
16*61c4878aSAndroid Build Coastguard Workerintegrated environment setup and build system. However, this part of the system
17*61c4878aSAndroid Build Coastguard Workeris entirely optional; it is not only possible, but encouraged to take
18*61c4878aSAndroid Build Coastguard Workerindividual modules (like for example ``pw_tokenizer`` or ``pw_ring_buffer``)
19*61c4878aSAndroid Build Coastguard Workerand integrate them into your existing environment setup approach and build
20*61c4878aSAndroid Build Coastguard Workersystem.
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard WorkerSo, to answer the question:
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Worker1. **Is Pigweed's environment setup system a framework?** No. This component
25*61c4878aSAndroid Build Coastguard Worker   solves (a) downloading compilers and (b) setting up a Python virtual
26*61c4878aSAndroid Build Coastguard Worker   environment; what you do with the environment is up to you.
27*61c4878aSAndroid Build Coastguard Worker2. **Is Pigweed's GN-based build & test setup system a framework?** In short,
28*61c4878aSAndroid Build Coastguard Worker   yes. This is the most framework-like part of Pigweed, since you build your
29*61c4878aSAndroid Build Coastguard Worker   code using Pigweed's GN-based primitives. However, it is optional.
30*61c4878aSAndroid Build Coastguard Worker3. **Are Pigweed's C++ modules a framework?** No. They are libraries you can
31*61c4878aSAndroid Build Coastguard Worker   independently take into your project and use like any other C++ library.
32*61c4878aSAndroid Build Coastguard Worker
33*61c4878aSAndroid Build Coastguard WorkerIsn't C++ bloated and slow?
34*61c4878aSAndroid Build Coastguard Worker---------------------------
35*61c4878aSAndroid Build Coastguard WorkerIn general, no, but it is important to follow some guidelines as discussed in
36*61c4878aSAndroid Build Coastguard Workerthe :ref:`Embedded C++ Guide <docs-embedded-cpp>`.
37*61c4878aSAndroid Build Coastguard Worker
38*61c4878aSAndroid Build Coastguard WorkerAt Google, we have made some quantitative analysis of various common embedded
39*61c4878aSAndroid Build Coastguard Workerpatterns in C++ to evaluate the cost of various constructs. We will open source
40*61c4878aSAndroid Build Coastguard Workerthis work at some point.
41*61c4878aSAndroid Build Coastguard Worker
42*61c4878aSAndroid Build Coastguard WorkerHow do I setup Pigweed for my project?
43*61c4878aSAndroid Build Coastguard Worker--------------------------------------
44*61c4878aSAndroid Build Coastguard Worker
45*61c4878aSAndroid Build Coastguard Worker.. attention::
46*61c4878aSAndroid Build Coastguard Worker
47*61c4878aSAndroid Build Coastguard Worker  This FAQ entry should be an entire article, but isn't one yet; sorry!
48*61c4878aSAndroid Build Coastguard Worker
49*61c4878aSAndroid Build Coastguard WorkerTo use Pigweed, you must decide the answer to one question: Do you wish to use
50*61c4878aSAndroid Build Coastguard Workerthe Pigweed integrated environment and build, or just use individual modules?
51*61c4878aSAndroid Build Coastguard Worker
52*61c4878aSAndroid Build Coastguard WorkerA la carte: Individual modules only
53*61c4878aSAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54*61c4878aSAndroid Build Coastguard WorkerThis option can work for small projects with a pre-existing build system in
55*61c4878aSAndroid Build Coastguard Workerplace. Large projects will probably need a more maintainable and scalable
56*61c4878aSAndroid Build Coastguard Workersolution.
57*61c4878aSAndroid Build Coastguard Worker
58*61c4878aSAndroid Build Coastguard WorkerTo use the libraries, submodule or copy the relevant Pigweed modules into your
59*61c4878aSAndroid Build Coastguard Workerproject, and use them like any other C++ library. You'll need to also copy over
60*61c4878aSAndroid Build Coastguard Workerthe `transitive dependencies`_ of any module you use. You can find a module's
61*61c4878aSAndroid Build Coastguard Workertransitive dependencies by inspecting its build files. If your project uses
62*61c4878aSAndroid Build Coastguard WorkerCMake, you can directly import Pigweed's build from your project with CMake's
63*61c4878aSAndroid Build Coastguard Workerexternal project system, or just use a CMake include statement.
64*61c4878aSAndroid Build Coastguard Worker
65*61c4878aSAndroid Build Coastguard Worker.. _transitive dependencies: https://en.wikipedia.org/wiki/Transitive_dependency#Computer_programs
66*61c4878aSAndroid Build Coastguard Worker
67*61c4878aSAndroid Build Coastguard WorkerMonolith: Using the integrated system
68*61c4878aSAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69*61c4878aSAndroid Build Coastguard WorkerThis may be a good option if you are starting a new project. However,
70*61c4878aSAndroid Build Coastguard Workerthere is a gap in our documentation and examples at the moment; sorry about
71*61c4878aSAndroid Build Coastguard Workerthat! You may need to ask us for help; try the mailing list or chat room.
72*61c4878aSAndroid Build Coastguard Worker
73*61c4878aSAndroid Build Coastguard WorkerNote: Pigweed isn't quite ready for masses of projects to use the whole system
74*61c4878aSAndroid Build Coastguard Workerjust yet. We will be offering examples and material for this eventually.
75*61c4878aSAndroid Build Coastguard Worker
76*61c4878aSAndroid Build Coastguard WorkerThe summary is:
77*61c4878aSAndroid Build Coastguard Worker
78*61c4878aSAndroid Build Coastguard Worker- Create a new repository
79*61c4878aSAndroid Build Coastguard Worker- Add Pigweed as a submodule; we suggest under ``third_party/pigweed`` or
80*61c4878aSAndroid Build Coastguard Worker  ``vendor/pigweed``. It is also possible to use Android's repo tool, but we
81*61c4878aSAndroid Build Coastguard Worker  suggest submodules.
82*61c4878aSAndroid Build Coastguard Worker- Create your own ``BUILD.gn`` and ``BUILDCONFIG.gn``; we suggest starting by
83*61c4878aSAndroid Build Coastguard Worker  copying the ones from Pigweed. You'll need to create your own toplevel
84*61c4878aSAndroid Build Coastguard Worker  targets like those in Pigweed's root ``BUILD.gn``.
85*61c4878aSAndroid Build Coastguard Worker- Create a bootstrap script in your project root that optionally does some
86*61c4878aSAndroid Build Coastguard Worker  project specific setup, then invokes the Pigweed upstream bootstrap (or in
87*61c4878aSAndroid Build Coastguard Worker  the other order).
88*61c4878aSAndroid Build Coastguard Worker- If you have custom hardware, you will want to create a *target*. See the
89*61c4878aSAndroid Build Coastguard Worker  `targets/` directory for examples like the STM32F429i-Discovery.
90*61c4878aSAndroid Build Coastguard Worker
91*61c4878aSAndroid Build Coastguard Worker.. attention::
92*61c4878aSAndroid Build Coastguard Worker
93*61c4878aSAndroid Build Coastguard Worker  This section is incomplete; if you need help please reach out in chat or on
94*61c4878aSAndroid Build Coastguard Worker  the mailing list. We know this part of Pigweed is incomplete and will help
95*61c4878aSAndroid Build Coastguard Worker  those who are interested in giving Pigweed a try.
96*61c4878aSAndroid Build Coastguard Worker
97*61c4878aSAndroid Build Coastguard WorkerWhy doesn't Pigweed allow shell scripting?
98*61c4878aSAndroid Build Coastguard Worker------------------------------------------
99*61c4878aSAndroid Build Coastguard WorkerPigweed supports multiple platforms. The native shells on these differ and
100*61c4878aSAndroid Build Coastguard Workeradditionally "compatible" shells often have sububle differences in behavior.
101*61c4878aSAndroid Build Coastguard WorkerPigweed uses Python instead of shell scripting wherever practical and changes to
102*61c4878aSAndroid Build Coastguard WorkerPigweed that include shell scripting will likely be rejected. Users of Pigweed
103*61c4878aSAndroid Build Coastguard Workermay use shell scripts in their own code and we have included support for
104*61c4878aSAndroid Build Coastguard Worker`Shellcheck <https://www.shellcheck.net/>`_ during presubmit checks that is
105*61c4878aSAndroid Build Coastguard Workerautomatically enabled if ``shellcheck`` found in the path.
106*61c4878aSAndroid Build Coastguard Worker
107*61c4878aSAndroid Build Coastguard WorkerWhat development hosts are supported?
108*61c4878aSAndroid Build Coastguard Worker-------------------------------------
109*61c4878aSAndroid Build Coastguard WorkerWe support the following platforms:
110*61c4878aSAndroid Build Coastguard Worker
111*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
112*61c4878aSAndroid Build Coastguard Worker| **Development host**          | **Comments**                          |
113*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
114*61c4878aSAndroid Build Coastguard Worker| Linux on x86-64               | Most recent Linux distributions       |
115*61c4878aSAndroid Build Coastguard Worker|                               | will work.                            |
116*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
117*61c4878aSAndroid Build Coastguard Worker| macOS on arm64                | Support in progress, file bugs for    |
118*61c4878aSAndroid Build Coastguard Worker|                               | any issues. Control whether Rosetta   |
119*61c4878aSAndroid Build Coastguard Worker|                               | is used via ``pigweed.json``.         |
120*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
121*61c4878aSAndroid Build Coastguard Worker| macOS on x86-64               | Mojave or newer should work.          |
122*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
123*61c4878aSAndroid Build Coastguard Worker| Windows 10 on x86-64          | Native Windows only; WSL1 or 2 not    |
124*61c4878aSAndroid Build Coastguard Worker|                               | supported.                            |
125*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
126*61c4878aSAndroid Build Coastguard Worker| Docker on x86-64              | Containers based on Ubuntu 18.04      |
127*61c4878aSAndroid Build Coastguard Worker|                               | and newer.                            |
128*61c4878aSAndroid Build Coastguard Worker+-------------------------------+---------------------------------------+
129*61c4878aSAndroid Build Coastguard Worker
130*61c4878aSAndroid Build Coastguard Worker.. attention::
131*61c4878aSAndroid Build Coastguard Worker
132*61c4878aSAndroid Build Coastguard Worker  In all of the above supported platforms, the support is contingent on using
133*61c4878aSAndroid Build Coastguard Worker  Pigweed's bootstrap (env setup) system. While it is possible to use Pigweed
134*61c4878aSAndroid Build Coastguard Worker  without bootstrap, it is unsupported and undocumented at this time.
135*61c4878aSAndroid Build Coastguard Worker
136*61c4878aSAndroid Build Coastguard WorkerPartially supported host platform: Chrome OS
137*61c4878aSAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138*61c4878aSAndroid Build Coastguard WorkerChromebooks are able to run some of the Pigweed components; notably all the
139*61c4878aSAndroid Build Coastguard Worker"host" target builds and runs. However, due to USB access issues, it is not
140*61c4878aSAndroid Build Coastguard Workerpossible to flash and run on real hardware (like for example the STM32F429i
141*61c4878aSAndroid Build Coastguard WorkerDiscovery).
142*61c4878aSAndroid Build Coastguard Worker
143*61c4878aSAndroid Build Coastguard WorkerTo run on ChromeOS:
144*61c4878aSAndroid Build Coastguard Worker
145*61c4878aSAndroid Build Coastguard Worker1. `Enable the Linux shell <https://support.google.com/chromebook/answer/9145439>`_
146*61c4878aSAndroid Build Coastguard Worker2. ``sudo apt-install build-essential``
147*61c4878aSAndroid Build Coastguard Worker3. Go through Pigweed setup.
148*61c4878aSAndroid Build Coastguard Worker
149*61c4878aSAndroid Build Coastguard WorkerWhat about other host platforms?
150*61c4878aSAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151*61c4878aSAndroid Build Coastguard WorkerThere are two key issues that make running the host tooling on other platforms
152*61c4878aSAndroid Build Coastguard Workerchallenging:
153*61c4878aSAndroid Build Coastguard Worker
154*61c4878aSAndroid Build Coastguard Worker1. Availability of up-to-date compilers
155*61c4878aSAndroid Build Coastguard Worker2. Availability of up-to-date Python
156*61c4878aSAndroid Build Coastguard Worker
157*61c4878aSAndroid Build Coastguard WorkerFor both of these, Pigweed relies on Google-maintained binaries packaged in
158*61c4878aSAndroid Build Coastguard WorkerCIPD, which includes daily builds of LLVM, and recent versions of the ARM GCC
159*61c4878aSAndroid Build Coastguard Workertoolchains. Platforms other than Mac/Windows/Linux running on x86-64 will need
160*61c4878aSAndroid Build Coastguard Workerto provide equivalent binaries, which is some effort.
161*61c4878aSAndroid Build Coastguard Worker
162*61c4878aSAndroid Build Coastguard WorkerHost platforms that we are likely to support in the future
163*61c4878aSAndroid Build Coastguard Worker..........................................................
164*61c4878aSAndroid Build Coastguard Worker
165*61c4878aSAndroid Build Coastguard Worker- **Linux on ARM** - We do not support ARM-based Linux host platforms. However,
166*61c4878aSAndroid Build Coastguard Worker  we would like to support this eventually. In many cases we have configured
167*61c4878aSAndroid Build Coastguard Worker  things so packages are downloaded correctly when on this platform
168*61c4878aSAndroid Build Coastguard Worker- **Windows on WSL2 x86-64** - There are some minor issues preventing WSL2 on
169*61c4878aSAndroid Build Coastguard Worker  Windows from being a smooth experience, but we are working on them.
170*61c4878aSAndroid Build Coastguard Worker
171*61c4878aSAndroid Build Coastguard WorkerPlatforms that we are unlikely to support
172*61c4878aSAndroid Build Coastguard Worker.........................................
173*61c4878aSAndroid Build Coastguard Worker
174*61c4878aSAndroid Build Coastguard Worker- **Anything on x86-32** - While it's possible 32-bit x86 could be made to
175*61c4878aSAndroid Build Coastguard Worker  work, we don't have enough users to make this worthwhile. If this is
176*61c4878aSAndroid Build Coastguard Worker  something you are interested in and would be willing to support, let us know.
177*61c4878aSAndroid Build Coastguard Worker
178*61c4878aSAndroid Build Coastguard WorkerWhy name the project Pigweed?
179*61c4878aSAndroid Build Coastguard Worker-----------------------------
180*61c4878aSAndroid Build Coastguard WorkerPigweed, also known as amaranth, is a nutritious grain and leafy salad green
181*61c4878aSAndroid Build Coastguard Workerthat is also a rapidly growing weed. When developing the project that
182*61c4878aSAndroid Build Coastguard Workereventually became Pigweed, we wanted to find a name that was fun, playful, and
183*61c4878aSAndroid Build Coastguard Workerreflective of how we saw Pigweed growing. Teams would start out using one
184*61c4878aSAndroid Build Coastguard Workermodule that catches their eye, and after that goes well, they’d quickly start
185*61c4878aSAndroid Build Coastguard Workerusing more.
186*61c4878aSAndroid Build Coastguard Worker
187*61c4878aSAndroid Build Coastguard WorkerSo far, so good ��
188