The Vehicle App Template for C++ allows to create Vehicle Apps
from the Velocitas development model in the C++ programming language.
Important
We successfully migrated our C++ repositories to use version 2 of the Conan package manager.
Unfortunately, those changes are not backwards compatible. So, please be aware that recent versions of this C++ app template repository
(everything since the conan2
tag) require usage of the Velocitas C++ SDK >= 0.7.0,
packages devcontainer-setup >= v3 and
github-workflows >= v7, and
base images >= v0.4.
If you like to migrate older app repositories created from this template before Conan 2, please have a look at the Conan 2 migration guide below.
- 📁
app
- base directory for a vehicle app- 📁
src
- source code of the vehicle app - 📁
tests
- tests for the vehicle app
- 📁
To build the App, run the build script:
./build.sh
Open the Run Task
view in VSCode and select Local Runtime - Up
.
With the runtime running in the background, you can run the app. The app must have been build before (see above).
Open the Run Task
view in VSCode and select Local Runtime - Run VehicleApp
.
You can simply launch the example in the Debugging Tab. Make sure the VehicleApp - Debug (Native)
is selected at the top. After the selection is done, you can also simply hit F5
, to start the debugging session.
Note: This launch task will also make sure to re-build the app if it has been modified!
docker run --rm -it --net="host" -e SDV_MIDDLEWARE_TYPE="native" -e SDV_MQTT_ADDRESS="localhost:1883" -e SDV_VEHICLEDATABROKER_ADDRESS="localhost:55555" localhost:12345/vehicleapp:local
GitHub Codespaces currently restrict the token that is used within the Codespace to just the current repository. Working on cloned repositories or
submodules will not be possible without further setup. To work on other repos, you need to create a personal access token (PAT) here which has full "repo" access. Copy the contents of the PAT and create a Codespace secret called MY_GH_TOKEN
and paste the content of your PAT. Finally you need to give the Codespace secret access to the repository of the Codespace, in this case vehicle-app-cpp-template
.
- Setup and Explore Development Environment
- Develop your own Vehicle Model
- Develop your own Vehicle App
All dependencies of the application should be downloaded and installed automatically once the VSCode DevContainer is created. Should this process fail for whatever reason, you can trigger the manual installation this command:
./install_dependencies.sh
If you have app repositories created from this template basing on Conan 1 and you like to migrate them to the latest state/Conan 2, here are some hints how to achieve that:
-
You should run
velocitas upgrade --ignore-bounds
and upgrade packagesdevenv-github-workflows
to a version >= v7.0.0 anddevenv-devcontainer-setup
to a version >= v3.0.0.
This will migrate the base image and required Velocitas components to Conan 2.
-
Run
velocitas sync
to automatically update some local files. -
You should make sure to update the cli-version to something recent (>= 13.2). Set the version in
.velocitas.json
.
Now some local files need to be updated manually:
-
conanfile.txt
:In the
[requires]
section:- Make sure you are referencing all packages used by the app directly.
Don't rely on indirect requirements provide by e.g. the C++ SDK:
Update the SDK to a version >= 0.7.0:
[requires] +fmt/11.1.1 +nlohmann_json/3.11.3
In thevehicle-app-sdk/0.7.0
[generators]
section replacecmake
as follows:[generators] -cmake +CMakeDeps +CMakeToolchain
- Make sure you are referencing all packages used by the app directly.
Don't rely on indirect requirements provide by e.g. the C++ SDK:
-
Python
requirements.in
: Upgrade Conan to version 2-conan==1.x.y +conan>=2,<3
Update
requirements.txt
usingpip-compile requirements.in
-
.pre-commit-config.yaml
: You should modify the suppression for the build folder:-"--suppress=*:build/*", +"--suppress=*:build*/*",
-
.gitignore
: Add an entry to ignoreCMakeUserPresets.json
files+CMakeUserPresets.json
-
app/Dockerfile
- if you are using containerized apps:- Update the base-image:
You can remove the Conan 1 environment variable (no replacement needed):
-FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/cpp:v0.3 as builder +FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/cpp:v0.4 AS builder
-ENV CONAN_USER_HOME /home/vscode/ -
- Update the base-image:
-
Now comes the - potentially - tricky part: Update the
CMakelist.txt
files. Instead of referencing all packages pulled in via Conan using the cmake variableCONAN_LIBS
the dependent package now need to be found one by one viafind_package
. For migration it's best if you compare the changes in theCMakeLists.txt
files of this repository between the commit tagged withconan2
and the commit before that and take over the required changes.
Note
If you are using a conanfile.py
instead of the conanfile.txt
variant, here are some hints:
- The Python file variant is not supported by the Velcitas tooling (especially the gPRC interface tools)!
- Make sure you don't configure
cmake_layout
in the layout section: This will conflict with the build script provieded by componentbuild-system
.