host#
Pigweed AI summary: The Pigweed host target is used for unit testing and some host side tooling. Pigweed has several preconfigured toolchains for compiling for the host, which may be used directly by downstream projects if desired. Pigweed also defines toolchains for testing with C++14 and C++20. To build for the host with a default configuration, invoke Ninja with the top-level host group as the target to build. Tests are automatically run as part of the host build, but can also be manually run
The Pigweed host target is used for unit testing and some host side tooling.
Toolchains#
Pigweed AI summary: The Pigweed software offers preconfigured toolchains for compiling for the host, including Clang and GCC with different optimization levels. These toolchains can be used directly by downstream projects, but Pigweed uses internal-only variants for upstream builds. Pigweed also provides toolchains for testing with C++14 and C++20, but these are only permitted for use in upstream Pigweed.
Pigweed several toolchains preconfigured for compiling for the host.
Toolchain name |
GN path |
Compiler |
Optimization |
|
|
Clang |
|
|
|
Clang |
|
|
|
Clang |
|
|
|
GCC |
|
|
|
GCC |
|
|
|
GCC |
|
These toolchains may be used directly by downstream projects if desired. For
upstream builds, Pigweed uses internal-only variants of these toolchains. The
upstream toolchains are defined in //targets/host/pigweed_internal
and are
prefixed with pw_strict_
. The upstream toolchains may not be used by
downstream projects.
Toolchains for other C++ standards#
Pigweed AI summary: Pigweed code requires C++17, but some modules work with C++14 and all code is compatible with C++20. Toolchains for testing with C++14 and C++20 are defined, including pw_strict_host_clang_debug_cpp14 and pw_strict_host_clang_size_optimized_cpp20. These toolchains are only allowed for use in upstream Pigweed, but downstream users can create similar ones if needed.
Most Pigweed code requires C++17, but a few modules, such as pw_tokenizer
,
work with C++14. All Pigweed code is compatible with C++20. Pigweed defines
toolchains for testing with C++14 and C++20.
pw_strict_host_clang_debug_cpp14
– Builds with-std=c++14
.pw_strict_host_clang_size_optimized_cpp20
– Builds with-std=c++20
.
These toolchains are only permitted for use in upstream pigweed, but downstream users may create similar toolchains as needed.
Building#
Pigweed AI summary: To build for the host with a default configuration, Ninja should be invoked with the top-level "host" group as the target to build. The command for this is "ninja -C out host". The "host" group can be replaced with more specific toolchains such as "host_clang" or "host_gcc", but not all toolchains are supported on all platforms. It is recommended to use the default unless working specifically on one toolchain.
To build for the host with a default configuration, invoke Ninja with the
top-level host
group as the target to build.
$ ninja -C out host
host
may be replaced with host_clang
, host_gcc
,
host_clang_debug
, etc. to build with a more specific host toolchain. Not all
toolchains are supported on all platforms. Unless working specifically on one
toolchain, it is recommended to use the default.
Running Tests#
Pigweed AI summary: This section explains how tests are automatically run during the host build process, but also provides instructions for manually running tests from a shell. An example command is given for reference.
Tests are automatically run as part of the host build, but if you desire to manually run tests, you may invoke them from a shell directly.
Example:
$ ./out/host_[compiler]_debug/obj/pw_status/status_test
RPC server#
Pigweed AI summary: The host target has a system RPC server that operates over a local socket on port 33000. To interact with a process using the host RPC server, use "pw rpc -s localhost:33000 <protos>".
The host target implements a system RPC server that runs over a local socket,
defaulting to port 33000. To communicate with a process running the host RPC
server, use pw rpc -s localhost:33000 <protos>
.