Scanframe DevOps Trial App
0.0.1
|
Contains .cmake
files for:
Bellow an excerpt of a CMakeLists.txt
to use the repository as CMake-package. Disadvantage is that the shell scripts are not accessible before CMake make has been run and a chicken and egg problem occurs.
The preferred way is to create a Git submodule lib
in the <project-root>/cmake
A project directory tree could look like this.
Path | Description |
---|---|
src | Application source files. |
src/test | Test application source files. |
bin | Root for compiled results from builds. |
bin/gcov | Coverage report files from unittests. |
bin/lnx64 | Binaries from Linux 64-bit builds. |
bin/pkg | Packages from all builds. |
bin/man | Generated documentation builds. |
doc | DoxgGen document project source. |
The directory bin
and holds a placeholder file named __output__
to find the designated bin
build output directory for subprojects. Reason for building only subprojects instead of all is to speed up debugging by compiling only the dynamic loaded library separately. When directories are empty but needed then add a file called __placeholder__
so is not ignoring them.
To get a head start look into the tpl/root directory for files that will give a head start getting a project going.
For generating documentation from the code using Doxygen the doc
subdirectory is to be added. in the main CMakeLists.txt
.
The doc
directory CMakeLists.txt
looks like this where header files are added to the config file.
Look at Doxygen website for the syntax in C++ header comment blocks or Markdown files.
To create a version tag with this library there are 2 options.
Create a release tag like v1.2.3
or a release candidate tag like 1.2.3-rc.4
.
The CMake coding picks this up using function Sf_GetGitTagVersion returns the version depending on the result of the next Git-command.
Possible results from this command are:
The CMake function Sf_GetGitTagVersion
creates a versions list from the result.
For example when the result is v1.2.3-rc.4-56-g914edbb-dirty
.
Index | Description | Value |
---|---|---|
0 | Main version number | 1.2.3 |
1 | Optional release candidate number | 4 |
2 | Commit count since the tag | 56 |
Index positions 1 and 2 are empty when not applicable.
For this item a separate page is created so see: Semantic Versioning
There are 3 Nexus apt-repositories which can be described to:
Name | Usage |
---|---|
stable | Actual releases. |
staging | Release candidates. |
develop | Development and testing. |
In order to have the latest release subscribe only to stable
. To have update when a release candidate (RC) becomes available subscribe additionally to staging
. When developing and testing debian packages subscribe additionally to develop
.
Debian packages are deployed/uploaded to the appropriate apt-repository depending on if it:
main
.MR | RC | PRB | CMT | Destination |
---|---|---|---|---|
No | No | Yes | No | stable |
No | No | Yes | Yes | staging |
No | No | No | * | n/a |
No | Yes | Yes | * | staging |
No | Yes | No | * | develop |
Yes | * | * | * | develop |
Windows ZIP and installer EXE files are uploaded to a
dist/<destination>
directory.
The tools for this are gcov
and gcovr
of
The functions needed to perform coverage are located in SfBaseConfig.cmake.
Function | Description |
---|---|
Sf_AddTargetForCoverage | Sets compiler and linker options for the target depending on the target type. |
Sf_AddAsCoverageTest | Adds a test to the list which is used as a dependency for the test generating the report. |
Sf_AddTestCoverageReport | Adds the test generating the report calling the script coverage-report.sh. |
To enable format check before a commit modify or add the script .git/hooks/pre-commit
with the following content. It calls the check-format.sh script which in directly calls the clang-format.sh
script from the CMake support library. It also checks if it is a commit to the main or master branch and prevents it.
This same script is used in the main pipeline configuration script main.gitlab-ci.yml
in the job named 'check-env'.
So when the format is incorrect the pipeline will fail.