Skip to content

Commit

Permalink
chore(CPP/CI): setup CI for cmake build
Browse files Browse the repository at this point in the history
Linux docker build

Extra: add build configuration fixes for rest of the platforms

fixes: 5998
  • Loading branch information
stefandunca committed Jun 8, 2022
1 parent 757aa4a commit 61308d5
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 14 deletions.
33 changes: 19 additions & 14 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,42 @@ conan profile update settings.compiler.libcxx=libstdc++11 default

### 2. Install dependencies

```bash
conan install . --profile=<Platform specific conan profile> -s build_type=Release --build=missing -if=build/conan
```

Platform specific conan profile

- Macos:
- Intel: `vendor/conan-configs/apple-arm64.ini`
- Apple silicon: `vendor/conan-configs/apple-x86_64.ini`
- Intel: `conan install . --profile=vendor/conan-configs/apple-arm64.ini -s build_type=Release --build=missing -if=build/conan`
- Apple silicon: `conan install . --profile=vendor/conan-configs/apple-x86_64.ini -s build_type=Release --build=missing -if=build/conan`
- Windows: TODO
- Linux: TODO
- Linux: `conan install . -s build_type=Release --build=missing -if=build/conan`

## Buid, test & run

Platform specific Qt prefix path
## Buid, test & run

- Macos: `$HOME/Qt/6.3.0/macos`
- Windows: TODO
- Linux: TODO
Update `CMake` to the [Latest Release](https://cmake.org/download/)

### Build with conan

```bash
CMAKE_PREFIX_PATH=<Qt prefix path> conan build . -if=build/conan -bf=build
# linux
CMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/gcc_64" conan build . -if=build/conan -bf=build

# MacOS: CMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/macos" conan build . -if=build/conan -bf=build

# Windows: CMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/mingw_64" conan build . -if=build/conan -bf=build

ctest -VV -C Release
./status-desktop
```

### Build with cmake

```bash
cmake -B build -S . -DCMAKE_PREFIX_PATH=<Qt prefix path> -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan/conan_toolchain.cmake
# linux
cmake -B build -S . -DCMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/gcc_64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan/conan_toolchain.cmake

# MacOS: cmake -B build -S . -DCMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/macos" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan/conan_toolchain.cmake

# Windows: cmake -B build -S . -DCMAKE_PREFIX_PATH="$HOME/Qt/6.4.0/mingw_64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan/conan_toolchain.cmake

cmake --build build --config Release
```
70 changes: 70 additions & 0 deletions ci/Jenkinsfile.linux-cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
library 'status-jenkins-lib@v1.3.4'

pipeline {
agent {
docker {
label 'linux'
image 'stateoftheartio/qt6:6.3-gcc-aqt'
/* allows jenkins use cat and mounts '/dev/fuse' for linuxdeployqt */
args '-v ${PWD}:/home/user/project:ro -v ${PWD}/build:/home/user/build:rw --entrypoint="" --cap-add SYS_ADMIN --security-opt apparmor:unconfined --device /dev/fuse sh -c "sudo apt update; sudo apt install -y libgl-dev libvulkan-dev"'
}
}

parameters {
booleanParam(
name: 'RELEASE',
description: 'Decides whether binaries are built with debug symbols.',
defaultValue: params.RELEASE ?: false
)
}

options {
timestamps()
/* Prevent Jenkins jobs from running forever */
timeout(time: 20, unit: 'MINUTES')
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
artifactNumToKeepStr: '3',
))
}

environment {
TARGET = 'linux'
}

stages {
stage('Cmake Build') {
steps { sh 'qt-cmake /home/user/project -G Ninja -B /home/user/build; cmake --build /home/user/build; linuxdeploy --plugin qt -e "$(find /home/user/build -maxdepth 1 -type f -executable)" --appdir /home/user/build/deploy' }
}

// stage('Package') {
// steps { script {
// linux.bundle('tgz-linux')
// } }
// }

// stage('Parallel Upload') {
// parallel {
// stage('Upload') {
// steps { script {
// env.PKG_URL = s3.uploadArtifact(env.STATUS_CLIENT_TARBALL)
// jenkins.setBuildDesc(AppImage: env.PKG_URL)
// } }
// }
// stage('Archive') {
// steps { script {
// archiveArtifacts("${env.STATUS_CLIENT_TARBALL}*")
// } }
// }
// }
// }
}

post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
2 changes: 2 additions & 0 deletions cmake/platform_specific.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ if(WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/platform_specific/windows.cmake)
elseif(APPLE)
include(${CMAKE_CURRENT_LIST_DIR}/platform_specific/macos.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/platform_specific/linux.cmake)
endif()
3 changes: 3 additions & 0 deletions cmake/platform_specific/linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function(configure_app_os_specific TARGET_ARG URL_ORGANIZATION_NAME DOMAIN_ARG VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
# Noting here for now; helps simplifying main setup by removing platform if/else conditions
endfunction()

0 comments on commit 61308d5

Please sign in to comment.