cpp-project-template
v1.4.3
Published
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=racing-cpp-project-template&metric=alert_status&token=6933f085ef1f81f5a191ae512e7e27da57334ef9)](https://sonarcloud.io/summary/new_code?id=racing-cpp-project-template) [![Cov
Downloads
1,068
Readme
cpp-project-template
A template for C++ projects
Requirements:
- Docker https://docs.docker.com/get-docker/ (do not miss post install steps: https://docs.docker.com/engine/install/linux-postinstall/)
- Docker Compose v2 https://docs.docker.com/compose/install/
- (Optional) Nvidia driver version >= 555 (e.g. 555.58.02)
- (Optional) Nvidia container toolkit ( and afterwards run
sudo systemctl restart docker
) https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
Useful links:
- Conan documentation: https://docs.conan.io/en/latest/
- oh-my-zsh plugins: https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
Host setup
There are a few steps to perform before you can start.
- Create a JFrog Identity Token for your account.
- Access ARRC's JFrog instance with your TII's GitLab account.
- Go to the top-right corner > drop-down menu > Edit User Profile
- Click on 'Generate an Identity Token'.
- Save the token in a safe place, or just copy it (you won't see it again, you'll have to generate a new one if needed).
- Use it as a password for Docker and Conan in the next steps.
Docker
Setup insecure docker registry (necessary until we get ssl certificates):
- Login to the Docker registry:
docker login --username=<your-jfrog-username> repo.arrc.tii.ae # paste your Identity Token when prompted.
New project from template
These steps are to be performed only once, when creating a new project starting from this template.
Clone the project template repository and its submodules:
mkdir <project-name> && cd <project-name> git init git fetch --depth=1 -n [email protected]:tii-arrc/racing-bots/templates/cpp-project-template.git git reset --hard $(git commit-tree FETCH_HEAD^{tree} -m "initial commit") git submodule update --init
or, if you already cloned the repository:
git reset --hard $(git commit-tree FETCH_HEAD^{tree} -m "initial commit") git submodule update --init
Create a
main
branch if it's not the default.Initialize the project folder
./common-helpers/scripts/update_commons.sh
Change the values of the project-specific variables in the
.env
file:RDE_PROJ_NAME=<project-name> RDE_PROJ_BRIEF="A decent, but brief project description." RDE_PROJ_TYPE=cpp RDE_GROUP_NAME=<project-group-name> RDE_NVIDIA_ON=<true|false> # to enable NVIDIA support in the devcontainer.
Now you should be able to open your project as a devcontainer.
Project update
As the files in common-helpers
will be updated over time, the respective submodule should be kept up-to-date with the upstream. To update the commmon helpers, run:
cd common-helpers/
git pull origin main
cd ..
git add common-helpers # [others...]
git commit -m "common-helpers update."
And run the VSCode command 'Rebuild Container Without Cache'.
Development workflow (Conan)
If the authentication info are not already stored in your cache (i.e. you never logged in with this user from another RDE container), login to the ARRC remote with the command:
conan user -p <your-jfrog-identity-token> -r arrc <your-jfrog-username>
In case this error comes up:
ERROR: No remote 'arrc' defined in remotes
it is a known issue due to the VSCode DevContainer plugin. A quick fix is to switch back to the extension version v0.275.1
. This should be done on your host installation of VSCode, not inside the container.
The conan user
command can be used without arguments to verify the authentication status. If authenticated correctly, the output should be similar to:
conan user
should produce:
Current user of remote 'conancenter' set to: 'None' (anonymous)
Current user of remote 'arrc' set to: '<your-jfrog-username>' [Authenticated]
Now you can install the project dependencies (specified in conanfile.py
) and compile.
Install the package dependencies specified in the conanfile.py
(recipe).
Dependencies are pulled from the conancenter and arrc remotes, by default.
Dependencies configurations for which a binary is not available can be built with the --build=missing option (good luck).
conan install . -pr:b=release # --build=missing
Build the package according to the build() method in the conan-rde.RDECmakePackage base recipe.
conan build .
Local package development
To work on more than one repositories in the dependency tree, you can create a conan package in your local cache and then reference it in the dependent package's conanfile.py
.
Example (proj-a depends on proj-b):
Create the proj-b
package in the local cache.
The configure, install, source, build, and other steps are called in the local conan cache.
The produced package is tagget with local/dev
user and cannel attributes.
conan create . proj-b/test@local/dev
Now you can access to the reference proj-b/test@local/dev
in any other local project.
This is possible because the conan cache is mounted as a named voulume in all the RDE containers.
In ./proj-a/conanfile.py
add the following line
class ProjAConan(ConanFile):
# ...
def requirements(self):
# ...
self.requires("proj-b/test@local/dev")