OpenThread is an open-source implementation of the Thread networking protocol, released by Google. It is designed to be OS and platform-agnostic, with a small memory footprint, making it highly portable. It supports both system-on-chip (SoC) and network co-processor (NCP) designs and is a Thread Certified Component.
The project is primarily written in C and C++, with Python used for scripting and tooling. It uses a variety of build systems, including CMake and GN, and is actively maintained with a strong emphasis on code quality and style, enforced through continuous integration.
The project uses both CMake and GN as build systems. A collection of scripts in the script/ directory simplifies the build and test process.
- Compilers:
gccandclang - Build tools:
make,ninja-build - Other tools:
python3,yapf(v0.43.0),clang-format(v19),pylint,shellcheck,iwyu
A bootstrap script is provided to install the required tools:
./script/bootstrapThe project provides CMake presets for easier configuration.
Configure:
cmake --preset simulationBuild:
cmake --build --preset simulationThe script/ directory contains several scripts for building the project for different configurations:
- Simulation Build:
script/check-simulation-build
- POSIX Build:
script/check-posix-build
- ARM Build:
script/check-arm-build
- GN Build:
script/check-gn-build
The project uses CTest for testing.
To run the tests after building with the simulation preset:
ctest --preset simulationNexus is a test framework that allows simulating multiple OpenThread nodes within a single process, enabling faster and more scalable network simulations.
Build Nexus tests:
top_builddir=nexus_test ./tests/nexus/build.shRun all Nexus tests:
top_builddir=nexus_test ./tests/nexus/run_nexus_tests.shRun a specific Nexus test:
top_builddir=nexus_test ./tests/nexus/run_nexus_tests.sh <test_name>For more details, see tests/nexus/README.md.
The project has a strict coding style, which is enforced by the script/make-pretty script. Before submitting a pull request, ensure your code is formatted correctly.
Check code style:
script/make-pretty checkFormat code:
script/make-prettyKey style points:
- Indentation: 4 spaces.
- Naming:
UpperCamelCasefor types (classes, structs, enums), methods, functions.lowerCamelCasefor variables.gprefix for globals,sfor statics,mfor members,afor arguments.
- Comments: Doxygen is used for API documentation.
For more details, see the STYLE_GUIDE.md.
The project follows the "Fork-and-Pull" model. All contributions must be accompanied by a Contributor License Agreement (CLA). Pull requests are tested using GitHub Actions, and all checks must pass before merging.
For more details, see the CONTRIBUTING.md.