platform
077b29f
|
Platform project creates an easy-to-use abstraction for launching applications on various OS platforms. Its main goal is to provide:
Compiler configuration is provided via CMake toolchain file. It's aim is to set all required CMake variables in order to allow cross-compilation to the target platform. It also handles the basic set of compilation and linking flags for particular platform/compiler pair.
Launching main application thread is implemented by distinguishing the main()
function from the main thread. On desktop systems first app thread is executing directly code from main()
. On systems where a dedicated scheduler is launched (e.g. baremetal RTOS), it is required that in the first thread user has to call some sort of "scheduler start" function, which usually never returns (at least until all threads are destroyed). Previously mentioned separation requires, that the main application logic should be placed in appMain()
function. On desktop systems this function would be called directly from main()
. On RTOS systems, this function would be used as feed for a new user thread.
Original idea, design and implementation done by Grzegorz Heldt grzegorz.heldt@gmail.com
.
Note:
Platform
usage requires CMake build system.
In order to use platform
follow the steps below.
Code of platform
project can be included in another project in several ways.
This is already done by the platform project. All that is left to be done is to select which platform should be used and which compiler among all supported by that platform.
Application shouldn't rely on the fact that it runs directly from main or in a separate thread. With appMain()
introduced all OS specific bootstrapping is hidden in the platform library making business logic truly OS independent.
Set toolchain file for the selected platform:
Add platform to your build system:
Implement main application function:
Launch CMake with the desired platform and toolchain setup: