The CMakeLists.txt
file for building the Einit
initializing program must contain the following commands:
include (platform/image)
connects the CMake
library that contains the solution image build scripts.project_header_default ("STANDARD_GNU_11:YES" "STRICT_WARNINGS:NO"
) sets the flags of the compiler and linker.find_package ()
command.set_target_properties ()
command.CMake
descriptions of system programs and drivers provided in KasperskyOS Community Edition, and descriptions of their exported variables and properties are located in the corresponding files at /opt/KasperskyOS-Community-Edition-<version>/sysroot-aarch64-kos/lib/cmake/<program name>/<program name>-config.cmake
init.yaml
file when building a solution, you must add these channels to the EXTRA_CONNECTIONS
property for the corresponding programs.Please note the indentations at the beginning of strings in the EXTRA_CONNECTIONS
property. These indentations are necessary to correctly insert values into the init.yaml
file and must comply with its syntax requirements.
For example, the VFS
program does not have a channel for connecting to the Env
program by default. To automatically add a description of this channel to the init.yaml file during a solution build, you must add the following call to the CMakeLists.txt
file for building the Einit
program:
set_target_properties (${vfs_ENTITY} PROPERTIES
EXTRA_CONNECTIONS
" - target: env.Env
id: {var: ENV_SERVICE_NAME, include: env/env.h}"
When building this solution, the description of this IPC channel will be automatically added to the init.yaml
file when processing macros of the init.yaml.in template.
main()
function and a dictionary of environment variables to the init.yaml
file when building a solution, you must define the EXTRA_ARGS
and EXTRA_ENV
properties and assign the appropriate values to them.Note the indentations at the beginning of strings in the EXTRA_ARGS
and EXTRA_ENV
properties. These indentations are necessary to correctly insert values into the init.yaml
file and must comply with its syntax requirements.
Example of sending the VfsEntity
program the "-f fstab"
argument of the main()
function and the environment variable ROOTFS
set to ramdisk0,0 / ext2 0
:
set_target_properties (${vfs_ENTITY} PROPERTIES
EXTRA_ARGS
" - \"-f\"
- \"fstab\""
EXTRA_ENV
" ROOTFS: ramdisk0,0 / ext2 0")
When building this solution, the description of the main()
function argument and the environment variable value will be automatically added to the init.yaml
file when processing macros of the init.yaml.in template.
set(ENTITIES <full list of programs included in the solution>)
defines the ENTITIES
variable containing a list of executable files of all programs included in the solution.Example CMakeLists.txt file for building the Einit program
CMakeLists.txt
project (einit)
# Connect the library containing solution image build scripts.
include (platform/image)
# Set compile flags.
project_header_default ("STANDARD_GNU_11:YES" "STRICT_WARNINGS:NO")
# Configure the VFS program.
# By default, the VFS program is not mapped to a program implementing a block device.
# If you need to use a block device, such as ata from the ata component,
# you must define this device in the variable ${blkdev_ENTITY}_REPLACEMENT
# For more information about exported variables and properties of the VFS program,
# see /opt/KasperskyOS-Community-Edition-<version>/sysroot-aarch64-kos/lib/cmake/vfs/vfs-config.cmake
# find_package(ata)
# set_target_properties (${vfs_ENTITY} PROPERTIES ${blkdev_ENTITY}_REPLACEMENT ${ata_ENTITY})
# In the simplest case, you do not need to interact with a drive.
# For this reason, we set the value of the ${blkdev_ENTITY}_REPLACEMENT variable equal to an empty string
set_target_properties (${vfs_ENTITY} PROPERTIES ${blkdev_ENTITY}_REPLACEMENT "")
# Define the ENTITIES variable with a list of executable files of programs.
# It is important to include all programs that are part of the project, except the Einit program.
# Please note that the name of the executable file of a program must
# match the name of the target indicated in add_executable() in the CMakeLists.txt file for building this program.
set(ENTITIES
${vfs_ENTITY}
Hello_app
)
# Create the build target named kos-image, which is a solution image for the hardware platform.
build_kos_hw_image (kos-image
EINIT_ENTITY EinitHw
CONNECTIONS_CFG "src/init.yaml.in" # template of the init.yaml file
SECURITY_PSL "src/security.psl.in" # template of the security.psl file
IMAGE_FILES ${ENTITIES}
)
# Create the build target named kos-qemu-image, which is a solution image for QEMU.
build_kos_qemu_image (kos-qemu-image
EINIT_ENTITY EinitQemu
CONNECTIONS_CFG "src/init.yaml.in"
SECURITY_PSL "src/security.psl.in"
IMAGE_FILES ${ENTITIES}
)
Page top