Skip to content

Commit

Permalink
chore(CPP/CI): basic CI setup for linux cmake build
Browse files Browse the repository at this point in the history
Linux dockerized build and AppDir generation for compilation errors

Also added AppImage TODOs, basic setup for MacOS and Windows but they
still need work to have at least validation running

Temporary disable CPP windows/mac until limitations are
addressed in a follow up commit

Extra: add build configuration fixes for rest of the platforms

closes: #5998
  • Loading branch information
stefandunca committed Jun 30, 2022
1 parent 5a1f0a3 commit 4029a39
Show file tree
Hide file tree
Showing 17 changed files with 342 additions and 14 deletions.
19 changes: 19 additions & 0 deletions AppRun-cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
APPDIR="$(dirname "$(readlink -f "${0}")")"
export GST_PLUGIN_SCANNER="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PLUGIN_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${LD_LIBRARY_PATH}"
export QT_QPA_PLATFORM="xcb"

DEFAULT_LANG=en_US.UTF-8
if [[ "$LANG" == "C.UTF-8" ]]
then
export LANG=$DEFAULT_LANG
else
export LANG="${VARIABLE:=$DEFAULT_LANG}"
fi

exec "${APPDIR}/usr/bin/status-desktop" "$@"
5 changes: 5 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ target_link_libraries(${PROJECT_NAME}
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qml;${QML_IMPORT_PATH} CACHE STRING "For QtCreator" FORCE)
list(REMOVE_DUPLICATES QML_IMPORT_PATH)

install(
TARGETS
${PROJECT_NAME}
RUNTIME
)
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
```
83 changes: 83 additions & 0 deletions ci/Jenkinsfile.linux-cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
library 'status-jenkins-lib@v1.3.4'

pipeline {
agent {
dockerfile {
label 'linux'
dir 'ci/cpp'
filename 'Dockerfile-linux'
/* allows jenkins use cat and mounts '/dev/fuse' for linuxdeployqt */
args '--entrypoint="" --cap-add SYS_ADMIN --security-opt apparmor:unconfined --device /dev/fuse'
}
}

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-cpp'
/* Control output the filename */
STATUS_CLIENT_APPIMAGE = "pkg/${utils.pkgFilename(ext: 'AppImage')}"
}

// TODO: Move all stages to the Makefile as targets "*-linux-using-docker"
stages {
stage('CMake Build') {
steps {
sh "qt-cmake ${env.WORKSPACE} -G Ninja -B ${env.WORKSPACE}/build -DCMAKE_BUILD_TYPE=Release"
sh "cmake --build ${env.WORKSPACE}/build"
}
}

stage('Package') {
steps {
sh "linuxdeploy --plugin qt --executable=${env.WORKSPACE}/build/status-desktop --appdir ${env.WORKSPACE}/build/AppDir --desktop-file=${env.WORKSPACE}/status.desktop --icon-file=${env.WORKSPACE}/status.svg --custom-apprun=${env.WORKSPACE}/AppRun-cpp"
sh "cmake --install ${env.WORKSPACE}/build --prefix=${env.WORKSPACE}/build/install"
sh "cp ${env.WORKSPACE}/build/install/lib/* ${env.WORKSPACE}/build/AppDir/usr/lib/"
// TODO enable after deploying appimage plugin in the corresponding docker
//sh "linuxdeploy --appdir ${env.WORKSPACE}/build/AppDir --output=appimage"
// sh "mkdir pkg && cp \"\$(find ${env.WORKSPACE}/build/AppDir -maxdepth 2 -type f -iname \"*.AppImage\")\" ${env.STATUS_CLIENT_APPIMAGE}"
}
}

// TODO: enable after generating the AppImage
// stage('Parallel Upload') {
// parallel {
// stage('Upload') {
// steps { script {
// env.PKG_URL = s3.uploadArtifact(env.STATUS_CLIENT_APPIMAGE)
// jenkins.setBuildDesc(AppImage: env.PKG_URL)
// } }
// }
// stage('Archive') {
// steps { script {
// archiveArtifacts("${env.STATUS_CLIENT_APPIMAGE}*")
// } }
// }
// }
// }
}

post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
75 changes: 75 additions & 0 deletions ci/Jenkinsfile.mac-cpp.todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
library 'status-jenkins-lib@v1.3.4'

pipeline {
agent {
docker {
label 'linux'
image 'stateoftheartio/qt6:6.3-macos-aqt'
}
}

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 = 'macos-cpp'
/* Control output the filename */
STATUS_CLIENT_DMG = "pkg/${utils.pkgFilename(ext: 'dmg')}"
}

// TODO: Move all stages to the Makefile as targets "*-mac-using-docker"
stages {
stage('CMake Build') {
steps {
sh "qt-cmake ${env.WORKSPACE} -G Ninja -B ${env.WORKSPACE}/build -DCMAKE_BUILD_TYPE=Release"
sh "cmake --build ${env.WORKSPACE}/build"
}
}

stage('Package') {
steps {
sh "macdeployqt ${env.WORKSPACE}/build/*.app -verbose=1 -dmg -qmldir=${env.WORKSPACE}"
sh "mkdir pkg && cp \"\$(find ${env.WORKSPACE}/build -maxdepth 2 -type f -iname \"*.dmg\")\" ${env.STATUS_CLIENT_DMG}"
}
}

stage('Parallel Upload') {
parallel {
stage('Upload') {
steps { script {
env.PKG_URL = s3.uploadArtifact(env.STATUS_CLIENT_DMG)
jenkins.setBuildDesc(Dmg: env.PKG_URL)
} }
}
stage('Archive') {
steps { script {
archiveArtifacts(env.STATUS_CLIENT_DMG)
} }
}
}
}
}

post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
76 changes: 76 additions & 0 deletions ci/Jenkinsfile.windows-cpp.todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
library 'status-jenkins-lib@v1.3.4'

pipeline {
agent {
docker {
label 'linux'
image 'stateoftheartio/qt6:6.3-mingw-aqt'
}
}

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 = 'windows-cpp'
/* Control output the filename */
STATUS_CLIENT_ZIP = "pkg/${utils.pkgFilename(ext: 'zip')}"
}

// TODO: Move all stages to the Makefile as targets "*-windows-using-docker"
stages {
stage('CMake Build') {
steps {
sh "qt-cmake ${env.WORKSPACE} -G Ninja -B ${env.WORKSPACE}/build -DCMAKE_BUILD_TYPE=Release"
sh "cmake --build ${env.WORKSPACE}/build"
}
}

stage('Package') {
steps {
sh "windeployqt --qmldir ${env.WORKSPACE} --dir ${env.WORKSPACE}/build/deploy --libdir ${env.WORKSPACE}/build/deploy/libs --plugindir ${env.WORKSPACE}/build/deploy/plugins ${env.WORKSPACE}/build/*.exe"
sh "zip -r ${STATUS_CLIENT_ZIP} build/deploy/"
}
}

stage('Parallel Upload') {
parallel {
stage('Upload') {
steps { script {
exe_url = s3.uploadArtifact(env.STATUS_CLIENT_ZIP)
env.PKG_URL = exe_url
jenkins.setBuildDesc(Zip: zip_url, Exe: exe_url)
} }
}
stage('Archive') {
steps { script {
archiveArtifacts(env.STATUS_CLIENT_ZIP)
} }
}
}
}
}

post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
always { cleanWs() }
}
}
10 changes: 10 additions & 0 deletions ci/cpp/Dockerfile-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM stateoftheartio/qt6:6.3-gcc-aqt

RUN export DEBIAN_FRONTEND=noninteractive \
&& sudo apt update -yq \
&& sudo apt install -yq libgl-dev libvulkan-dev libxcb*-dev libxkbcommon-x11-dev

# TODO finish installing dependencies then enable building the appimage in CI
# RUN cd /tmp && git clone --single-branch --recursive https://github.com/AppImage/AppImageKit && cd AppImageKit/ && cmake -B ./build -S .
# If still needed
# RUN cd /tmp && git clone --single-branch --recursive https://github.com/linuxdeploy/linuxdeploy-plugin-appimage.git && cd AppImageKit/ && cmake -B ./build -S .
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()
6 changes: 6 additions & 0 deletions libs/Assets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ target_link_libraries(${PROJECT_NAME}
# QtCreator needs this
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qml;${QML_IMPORT_PATH} CACHE STRING "For QtCreator" FORCE)
list(REMOVE_DUPLICATES QML_IMPORT_PATH)

install(
TARGETS
${PROJECT_NAME}
RUNTIME
)
6 changes: 6 additions & 0 deletions libs/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ target_link_libraries(${PROJECT_NAME}
Qt6::Quick
Qt6::Qml
)

install(
TARGETS
${PROJECT_NAME}
RUNTIME
)
6 changes: 6 additions & 0 deletions libs/Helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ target_link_libraries(${PROJECT_NAME}
Qt6::Quick
Qt6::Qml
)

install(
TARGETS
${PROJECT_NAME}
RUNTIME
)
6 changes: 6 additions & 0 deletions libs/Onboarding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ target_link_libraries(${PROJECT_NAME}
# QtCreator needs this
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qml;${QML_IMPORT_PATH} CACHE STRING "For QtCreator" FORCE)
list(REMOVE_DUPLICATES QML_IMPORT_PATH)

install(
TARGETS
${PROJECT_NAME}
RUNTIME
)
Loading

0 comments on commit 4029a39

Please sign in to comment.