xref: /aosp_15_r20/external/pigweed/targets/host/target_docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _target-host:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker====
4*61c4878aSAndroid Build Coastguard Workerhost
5*61c4878aSAndroid Build Coastguard Worker====
6*61c4878aSAndroid Build Coastguard WorkerThe Pigweed host target is used for unit testing and some host side tooling.
7*61c4878aSAndroid Build Coastguard Worker
8*61c4878aSAndroid Build Coastguard Worker----------
9*61c4878aSAndroid Build Coastguard WorkerToolchains
10*61c4878aSAndroid Build Coastguard Worker----------
11*61c4878aSAndroid Build Coastguard WorkerPigweed several toolchains preconfigured for compiling for the host.
12*61c4878aSAndroid Build Coastguard Worker
13*61c4878aSAndroid Build Coastguard Worker.. list-table::
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Worker  * - Toolchain name
16*61c4878aSAndroid Build Coastguard Worker    - GN path
17*61c4878aSAndroid Build Coastguard Worker    - Compiler
18*61c4878aSAndroid Build Coastguard Worker    - Optimization
19*61c4878aSAndroid Build Coastguard Worker  * - ``host_clang_debug``
20*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_clang_debug``
21*61c4878aSAndroid Build Coastguard Worker    - Clang
22*61c4878aSAndroid Build Coastguard Worker    - ``-Og``
23*61c4878aSAndroid Build Coastguard Worker  * - ``host_clang_size_optimized``
24*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_clang_size_optimized``
25*61c4878aSAndroid Build Coastguard Worker    - Clang
26*61c4878aSAndroid Build Coastguard Worker    - ``-Os``
27*61c4878aSAndroid Build Coastguard Worker  * - ``host_clang_speed_optimized``
28*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_clang_speed_optimized``
29*61c4878aSAndroid Build Coastguard Worker    - Clang
30*61c4878aSAndroid Build Coastguard Worker    - ``-O2``
31*61c4878aSAndroid Build Coastguard Worker  * - ``host_gcc_debug``
32*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_gcc_debug``
33*61c4878aSAndroid Build Coastguard Worker    - GCC
34*61c4878aSAndroid Build Coastguard Worker    - ``-Og``
35*61c4878aSAndroid Build Coastguard Worker  * - ``host_gcc_size_optimized``
36*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_gcc_size_optimized``
37*61c4878aSAndroid Build Coastguard Worker    - GCC
38*61c4878aSAndroid Build Coastguard Worker    - ``-Os``
39*61c4878aSAndroid Build Coastguard Worker  * - ``host_gcc_speed_optimized``
40*61c4878aSAndroid Build Coastguard Worker    - ``//targets/host:host_gcc_speed_optimized``
41*61c4878aSAndroid Build Coastguard Worker    - GCC
42*61c4878aSAndroid Build Coastguard Worker    - ``-O2``
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard WorkerThese toolchains may be used directly by downstream projects if desired. For
45*61c4878aSAndroid Build Coastguard Workerupstream builds, Pigweed uses internal-only variants of these toolchains. The
46*61c4878aSAndroid Build Coastguard Workerupstream toolchains are defined in ``//targets/host/pigweed_internal`` and are
47*61c4878aSAndroid Build Coastguard Workerprefixed with ``pw_strict_``. The upstream toolchains may not be used by
48*61c4878aSAndroid Build Coastguard Workerdownstream projects.
49*61c4878aSAndroid Build Coastguard Worker
50*61c4878aSAndroid Build Coastguard WorkerToolchains for other C++ standards
51*61c4878aSAndroid Build Coastguard Worker==================================
52*61c4878aSAndroid Build Coastguard WorkerPigweed code requires C++17 or newer and is fully compatible with C++20. Pigweed
53*61c4878aSAndroid Build Coastguard Workerdefines a toolchain for testing with C++20.
54*61c4878aSAndroid Build Coastguard Worker
55*61c4878aSAndroid Build Coastguard Worker* ``pw_strict_host_clang_size_optimized_cpp20`` -- Builds with ``-std=c++20``.
56*61c4878aSAndroid Build Coastguard Worker
57*61c4878aSAndroid Build Coastguard WorkerThis toolchains is only permitted for use in upstream pigweed, but downstream
58*61c4878aSAndroid Build Coastguard Workerusers may create similar toolchains as needed.
59*61c4878aSAndroid Build Coastguard Worker
60*61c4878aSAndroid Build Coastguard Worker--------
61*61c4878aSAndroid Build Coastguard WorkerBuilding
62*61c4878aSAndroid Build Coastguard Worker--------
63*61c4878aSAndroid Build Coastguard WorkerTo build for the host with a default configuration, invoke Ninja with the
64*61c4878aSAndroid Build Coastguard Workertop-level ``host`` group as the target to build.
65*61c4878aSAndroid Build Coastguard Worker
66*61c4878aSAndroid Build Coastguard Worker.. code-block:: sh
67*61c4878aSAndroid Build Coastguard Worker
68*61c4878aSAndroid Build Coastguard Worker   $ ninja -C out host
69*61c4878aSAndroid Build Coastguard Worker
70*61c4878aSAndroid Build Coastguard Worker
71*61c4878aSAndroid Build Coastguard Worker``host`` may be replaced with ``host_clang``, ``host_gcc``,
72*61c4878aSAndroid Build Coastguard Worker``host_clang_debug``, etc. to build with a more specific host toolchain. Not all
73*61c4878aSAndroid Build Coastguard Workertoolchains are supported on all platforms. Unless working specifically on one
74*61c4878aSAndroid Build Coastguard Workertoolchain, it is recommended to use the default.
75*61c4878aSAndroid Build Coastguard Worker
76*61c4878aSAndroid Build Coastguard Worker-------------
77*61c4878aSAndroid Build Coastguard WorkerRunning Tests
78*61c4878aSAndroid Build Coastguard Worker-------------
79*61c4878aSAndroid Build Coastguard WorkerTests are automatically run as part of the host build, but if you desire to
80*61c4878aSAndroid Build Coastguard Workermanually run tests, you may invoke them from a shell directly.
81*61c4878aSAndroid Build Coastguard Worker
82*61c4878aSAndroid Build Coastguard WorkerExample:
83*61c4878aSAndroid Build Coastguard Worker
84*61c4878aSAndroid Build Coastguard Worker.. code-block:: sh
85*61c4878aSAndroid Build Coastguard Worker
86*61c4878aSAndroid Build Coastguard Worker   $ ./out/host_[compiler]_debug/obj/pw_status/status_test
87*61c4878aSAndroid Build Coastguard Worker
88*61c4878aSAndroid Build Coastguard Worker----------
89*61c4878aSAndroid Build Coastguard WorkerRPC server
90*61c4878aSAndroid Build Coastguard Worker----------
91*61c4878aSAndroid Build Coastguard WorkerThe host target implements a system RPC server that runs over a local socket,
92*61c4878aSAndroid Build Coastguard Workerdefaulting to port 33000. To communicate with a process running the host RPC
93*61c4878aSAndroid Build Coastguard Workerserver, use ``pw rpc -s localhost:33000 <protos>``.
94