hello_corrosion example
This example demonstrates how to let your solution include a simple program that was developed based on Rust and uses Corrosion, which is a set of libraries for integrating Rust into CMake projects.
Example directory in the SDK
The code of the example and build scripts are available at the following path:
List of programs
The solution includes the Hello
application, which prints a message to the standard error output. This program was developed using the Rust language.
Initialization description
The solution initialization description file named init.yaml
is generated during the solution build process based on the following template:
./einit/src/init.yaml.in
During the example build, the @INIT_hello_ENTITY_CONNECTIONS@
macro in the init.yaml
file is replaced with the list of IPC channels containing all system programs that are linked to the Hello
application.
During the build, the @INIT_EXTERNAL_ENTITIES@
macro in the init.yaml.in
template in the init.yaml
file is replaced by a list of system programs that are linked to applications. This list contains the IPC channels of system programs, the run parameters of the main()
function, and the values of environment variables.
For more details, see init.yaml.in template.
Security policy description
The security.psl
file contains the solution security policy description and is generated based on the following template during the solution build process:
./einit/src/security.psl.in
During the solution build, the @INIT_EXTERNAL_ENTITIES@
macro in the security.psl.in
template is replaced with a list of system programs that are included in the KasperskyOS SDK. For more details, refer to security.psl.in template.
The solution security policy description in this example allows any interaction between different processes and between processes and the kernel. This solution security policy is used to simplify the example. It would be unacceptable to apply such a policy in a real-world solution.
Resources
The directory ./resources
contains an EDL description of the Hello
program.
Operating scenario
The Hello
program prints the message Hello, world!
to standard error.
Building and running the example
The CMake build system from the KasperskyOS SDK is used during the solution build.
To synchronize the target platform for building Rust-based source code with the target platform of the C compiler, you must add the following command to the ./CMakeList.txt
file:
set (Rust_CARGO_TARGET ${CMAKE_C_COMPILER_TARGET})
To use Corrosion in your solution, you must add the following command to this same file:
find_package (Corrosion REQUIRED)
To integrate Rust-based source code into your solution, you must call the following function in the ./hello/CMakeList.txt
file:
corrosion_import_crate (MANIFEST_PATH ${CMAKE_SOURCE_DIR}/hello/Cargo.toml)
This function compiles the hello
executable file that will be included in the solution.
See Building and running examples section.