This project is an adaptation of the Protocol Buffers (Protobuf™) for KasperskyOS. It is based on the 3.19.4 version of the Protocol Buffers and includes an example that demonstrates its use in KasperskyOS.
Protocol Buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. For more information, see the Protocol Buffers Documentation.
For additional details on KasperskyOS, including its limitations and known issues, please refer to the KasperskyOS Community Edition Online Help.
- Install KasperskyOS Community Edition SDK. You can download the latest version of the KasperskyOS Community Edition for free from os.kaspersky.com. The minimum required version of KasperskyOS Community Edition SDK is 1.3. For more information, see System requirements.
- Copy source files to your project directory.
The build of the protobuf for KasperskyOS is implemented through a cross-compilation process. The protobuf for KasperskyOS is built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK.
To build and install the protobuf for KasperskyOS, you need to install the protobuf compiler (protoc) and the protobuf C++ runtime.
There are two methods for doing this. The recommended method is to use the scripts described in the Protobuf compiler
and the Protobuf C++ runtime sections. As an alternative, please refer to the
C++ Installation Instructions.
The protoc (used to compile *.proto files) must be built with the host toolchain.
This is because the protoc will be run on the host when building solutions for KasperskyOS.
To build and install the protoc for the host, go to the ./kos directory and execute the host-build.sh script.
The environment variable INSTALL_PREFIX specifies the installation path of the protoc.
If not specified, the protoc will be installed in the ./install/host directory.
Syntax for using the host-build.sh script:
$ host-build.sh [-i INSTALL_PREFIX]The parameter -i, --install-prefix INSTALL_PREFIX specifies the installation path of the protoc.
The value specified in this parameter takes precedence over the value of the INSTALL_PREFIX environment variable.
By default, the build type is set to Debug, the build libraries are static (BUILD_SHARED_LIBS=OFF),
and the build path is set to ./build/host. To change this, edit the host-build.sh script as needed.
For example:
$ ./host-build.shTo build and install the protobuf libraries, go to the ./kos directory and execute the cross-build.sh script.
There are environment variables that affect the build and installation of the libraries:
SDK_PREFIXspecifies the path to the installed version of the KasperskyOS Community Edition SDK. The value of this environment variable must be set.INSTALL_PREFIXspecifies the installation path of the protobuf libraries. If not specified, the libraries will be installed in the./install/kosdirectory.TARGETspecifies the target platform. If not specified, the platform will be determined automatically.
Syntax for using the cross-build.sh script:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> [TARGET="aarch64-kos"] ./cross-build.sh,
where version specifies the latest version number of the KasperskyOS Community Edition SDK.
By default, the build type is set to Debug, the build libraries are dynamic (BUILD_SHARED_LIBS=ON),
and the build path is set to ./build/kos. To change this, edit the cross-build.sh script as needed.
For CMake build system to find the protobuf libraries, make sure that the directory where the libraries were installed
is listed in the environment variable CMAKE_FIND_ROOT_PATH.
The protobuf's tests have been adapted to run on KasperskyOS. The tests have the following limitations:
- Unit tests for KasperskyOS are currently available only for QEMU.
- Only IPv4 tests are compatible with KasperskyOS.
- Some tests are skipped:
CommandLineInterfaceTestsince KasperskyOS does not have a protobuf command-line interface (CLI).RubyGeneratorTestsince KasperskyOS only supports C++ programming language.AnyTest.TestPackFromSerializationExceedsSizeLimit,MessageTest.2G, andIoTest.LargeOutputsince they require more than 2GB of memory.
Tests use an out-of-source build. The build tree is located in the generated ./build/tests_kos directory.
For each test suite, a separate image will be created. As it can be taxing on disk space, the tests will be run sequentially.
To build and run the tests, go to the ./kos directory and execute the build-tests.sh script.
There are environment variables that affect the build and installation of the tests:
SDK_PREFIXspecifies the path to the installed version of the KasperskyOS Community Edition SDK. The value of this environment variable must be set.PROTOC_EXECspecifies the path to the previously installedprotoc. If not specified, the path./install/host/bin/protocwill be used. (If theprotocwas not previously installed, the scriptbuild-tests.shwill install it.)TARGETspecifies the target platform. (Currently only theaarch64-kosplatform is supported.)
Syntax for using the build-tests.sh script:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> [TARGET="aarch64-kos"] [PROTOC_EXEC=./install/host/bin/protoc] ./build-tests.sh [--help] [--list] [-n TEST_NAME_1] ... [-n TEST_NAME_N] [-t TIMEOUT] [-o OUT_PATH] [-j N_JOBS],
where:
-
versionLatest version number of the KasperskyOS Community Edition SDK.
-
-h, --helpHelp text.
-
-l, --listList of tests that can be run.
-
-n, --name TEST_NAMETest name to execute. The parameter can be repeated multiple times. If not specified, all tests will be executed.
-
-t, --timeout TIMEOUTTime, in seconds, allotted to start and execute a single test case. Default value is 300 seconds.
-
-o, --out OUT_PATHPath where the results of the test run will be stored. If not specified, the results will be stored in the
./build/tests-kos/logsdirectory. -
-j, --jobs N_JOBSNumber of jobs for parallel build. If not specified, the default value obtained from the
nproccommand is used.
The CMake files for building the tests are located in the ./cmake/kos directory.
When you develop a KasperskyOS-based solution, use the recommended structure of project directories to simplify usage of CMake scripts.
The cross-build.sh script builds only runtime libraries.
To generate source files from *.proto files your must use the host protoc.
To get it you can use the find_program function. For example:
find_program(protoc NAMES protoc REQUIRED)
For more on using the previously built protobuf on KasperskyOS, see the README.md file for the project's example.
Registered trademarks and endpoint marks are the property of their respective owners.
AIX, IBM, PowerPC, z/OS are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.
Android, Closure, GoogleTest, Dart, Protobuf are a trademark of Google LLC.
Apple, Cocoa, Finder, macOS, Mac OS, Xcode, OS X, Objective-C, Safari, TrueType are trademarks of Apple Inc.
Intel, Core are trademarks of Intel Corporation or its subsidiaries.
Fedora is a registered trademark of Red Hat, Inc. or its subsidiaries in the United States and other countries.
FreeBSD is a registered trademark of The FreeBSD Foundation.
gRPC is a registered trademark of The Linux Foundation in the United States and other countries.
Juniper Networks and JUNOS are trademarks or registered trademarks of Juniper Networks, Inc. in the United States and other countries
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
MS-DOS, Win32, Windows, Windows Phone, Silverlight, Visual Studio are trademarks of the Microsoft group of companies.
Solaris is a registered trademarks of Oracle and/or its affiliates.
Python is a trademark or registered trademark of the Python Software Foundation.
IOS is a registered trademark of Cisco Systems, Inc. and/or its affiliates in the United States and certain other countries.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.
Only KasperskyOS-specific changes can be approved. See CONTRIBUTING.md for detailed instructions on code contribution.
This project is licensed under the terms of the 3-Clause BSD License. See LICENSE for more information.
© 2025 AO Kaspersky Lab