Build Instructions

All trusted service builds use CMake to create native build files for building and installing service binaries and other build products. Details about the tools needed for building are specified here: Software Requirements.

All top-level build files are located beneath the ‘deployments’ parent directory under a sub-directory for each deployment. For more information about the project directory structure, see: Project Structure.

Build Flow

All deployment builds follow a common flow that results in the creation of executable binaries or libraries and the installation of files into an output directory. Deploying the contents of the output directory into the target environment is handled in an environment specific way and is not part of the common build flow. The build flow conforms to the conventional CMake process where building takes place in to following two stages:

  1. Native build files, such as makefiles, are generated from CMake configuration files.

  2. Native build tools, such as make, are used to build and install items, ready for deployment.

The following activity diagram illustrates the common deployment build flow. The green activity states lie outside of the common build flow. Environment specific instructions are provided for deploying into different environments:

'-------------------------------------------------------------------------------
' Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
'
' SPDX-License-Identifier: BSD-3-Clause
'
'-------------------------------------------------------------------------------

@startuml

(*) --> [cmake command] "Generating"
note right
    Generate native build files from deployment
    configuration files. External components are
    fetched and built.  Child deployments are
    generated, built and installed.
end note

If "success"
    --> [false]"Generation Errors" #Red
else
    --> [true]"Generated"
Endif

--> [make install command] "Building"
note right
    Compile and link to create build output.
end note

If "success"
    --> [false]"Build Errors" #Red
else
    --> [true]"Built"
Endif

--> "Installing"
note right
    Copy build output files to installation
    directory specified by CMAKE_INSTALL_PREFIX.
end note

If "success"
    --> [false]"Install Errors" #Red
else
    --> [true]"Installed"
Endif

--> "Deploying" #Green
note right
    Perform environment specific
    deployment steps.
end note

--> "Deployed" #Green

@enduml

Selecting the build type

The build type selects code optimization and debug information related compiler settings. The build system follows the standard CMake methodology and uses the CMAKE_BUILD_TYPE variable.

The build system uses the following build types:

Supported build types

Build type

Purpose

Description

Debug

For debugging purposes.

Optimization is off, debugging information generation is enabled.

MinSizeRel

Size optimized release build.

Optimization is configured to prefer small code size, debugging information is not generated.

MinSizWithDebInfo

For debugging size optimized release build.

Optimization is configured to prefer small code size, debugging information generation is enabled.

Release

Speed optimized release build.

Optimization is configured to prefer execution speed, debugging information is not generated.

RelWithDebugInfo

For debugging speed optimized release build.

Optimization is configured to prefer execution speed, debugging information generation is enabled.

Build type of external components can be configured with command line parameters. Parameter names follow this pattern: -D<upper case component name>_BUILD_TYPE=<value> e.g. -DNANOPB_BUILD_TYPE=Release. Supported values are component specific, please refer to the appropriate cmake file under <TS_ROOT>/external/<name>.

Building and Installing

When building from a clean environment where no generated build files exist, it is necessary to run the CMake command, specifying the source directory, the build directory and optionally, the install directory where build output is installed.

To illustrate the steps involved, we will build the ‘component-test’ executable to run in the ‘linux-pc’ environment. The built executable is a standalone program that uses the CppUTest framework to run a set of component level tests on components from within the project. For this example, it is assumed that we are building under Linux and ‘make’ is used as the native build tool.

The described steps may be used for any of the deployments under the top-level deployments directory.

Starting from the project root directory, change directory to the relevant deployment directory:

cd deployments/component-test/linux-pc

Build file generation is performed using the CMake command. If no CMAKE_INSTALL_PREFIX path is specified, build output will be installed in the default location (build/install). To generate build files that install to the default location, use:

cmake -S . -B build

To generate build files that install to an alternative location, use:

cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<install_dir>

Having successfully generated build files, the native build tool may be run to build and install files using:

cd build
make install

In the above example, all build output is written to a sub-directory called ‘build’. You are free to choose any location for build output.

Dependencies on external components and in-tree built objects, such as libraries, are handled automatically by the build system during the generating phase. External components are fetched from the relevant source repository and built as part of the build context for the deployment binary being built. This allows deployment specific configuration and compiler options to be applied to the external component without impacting other builds. Dependencies on in-tree built libraries are handled in a similar manner.

For information on running tests, see: Running Tests.

For more information on deployments, see: Deployments.

Installed build output files

On successfully completing the building phase of the build flow, a set of build output files are installed to the directory specified by CMAKE_INSTALL_PREFIX. The set of installed files will depend on the type of build and the environment in which the files will be deployed. The following table summarizes what files are installed for different typed of build during the installing phase of the build flow:

Example build output files

Deployment type

Environment

Files installed

Binary executable

linux-pc, arm-linux

bin/ - program binary

Shared library

linux-pc, arm-linux

include/ - public header files
lib/ - shared library
lib/cmake/ - cmake target import file

SP image

opteesp

bin/ - stripped elf file for SP
lib/make - OP-TEE helper makefile

SP collection

opteesp

bin/ - set of stripped elf files
lib/make/ - set of OP-TEE helper makefiles

Deploying installed files

Having built and installed build output files to a known directory, further steps may be needed to deploy the files into the target processing environment. The nature of these steps will be different for different environments.

To avoid overly complicating the common Trusted Services build system, details of how installed files are deployed into the target execution environment are handled separately and may rely on environment specific tools.

Some example deployment methods are:

  • A filesystem share exists between a build machine and the target machine. Files installed into the shared directory are directly accessible by the target.

  • Installed files are incorporated into a third-party build process e.g. OP-TEE.

The following guides provide instructions on deploying services and running programs on FVP:

Batch Building

To support batching building of a set of deployments, a tool called b-test is included. For more information, see b-test page


Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.

SPDX-License-Identifier: BSD-3-Clause