diff --git a/.gitignore b/.gitignore index feb02aa2..e2f54d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ ui_* moc_* qrc_* OpenRGB -Makefile \ No newline at end of file +Makefile +OpenRGB-x86_64.AppImage diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c21b12d..99d19350 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,20 +12,35 @@ stages: - build - + before_script: - echo "started by ${GITLAB_USER_NAME}" - - $esc = "$([char]27)" - - $count = 0 - - function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds } - - function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; } - - function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; } -build: +build_linux: + image: ubuntu:bionic + stage: build + script: + - apt update + - apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git + - ./scripts/build-appimage.sh + + artifacts: + paths: + - OpenRGB-x86_64.AppImage + expire_in: 1337 years + +build_windows: extends: - .shared_windows_runners stage: build script: + - $esc = "$([char]27)" + - $count = 0 + - function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds } + - function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; } + - function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; } + + - _fold_start_ 'configuring the msvc environment variables' - Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build" - '& cmd.exe /C "vcvarsall.bat x64 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }' @@ -81,4 +96,4 @@ build: artifacts: paths: - _build/*.7z - expire_in: 1337 years \ No newline at end of file + expire_in: 1337 years diff --git a/OpenRGB.pro b/OpenRGB.pro index 8a884cb4..7529f609 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -472,6 +472,21 @@ unix:!macx { RGBController/OpenRazerDetect.cpp \ RGBController/RGBController_Faustus.cpp \ RGBController/RGBController_OpenRazer.cpp \ + + #-------------------------------------------------------------------# + # Set up install paths # + # These install paths are used for AppImage and .deb packaging # + #-------------------------------------------------------------------# + isEmpty(PREFIX) { + PREFIX = /usr + } + + target.path=$$PREFIX/bin/ + desktop.path=$$PREFIX/share/applications/ + desktop.files+=qt/OpenRGB.desktop + pixmap.path=$$PREFIX/share/pixmaps/ + pixmap.files+=qt/OpenRGB.png + INSTALLS += target desktop pixmap } #-----------------------------------------------------------------------# diff --git a/qt/OpenRGB.desktop b/qt/OpenRGB.desktop new file mode 100644 index 00000000..e0fb0bcb --- /dev/null +++ b/qt/OpenRGB.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Encoding=UTF-8 +Name=OpenRGB +Comment=Control RGB lighting +Exec=OpenRGB +Icon=OpenRGB.png +Terminal=false +Categories=Utility; diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh new file mode 100755 index 00000000..731c7406 --- /dev/null +++ b/scripts/build-appimage.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +#-----------------------------------------------------------------------# +# OpenRGB AppImage Build Script # +#-----------------------------------------------------------------------# + +set -x +set -e + +#-----------------------------------------------------------------------# +# Build in a temporary directory to keep the system clean # +# Use RAM disk if possible (if available and not building on a CI # +# system like Travis) # +#-----------------------------------------------------------------------# +if [ "$CI" == "" ] && [ -d /dev/shm ]; then + TEMP_BASE=/dev/shm +else + TEMP_BASE=/tmp +fi + +BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX) + +#-----------------------------------------------------------------------# +# Make sure to clean up build dir, even if errors occur # +#-----------------------------------------------------------------------# +cleanup () { + if [ -d "$BUILD_DIR" ]; then + rm -rf "$BUILD_DIR" + fi +} +trap cleanup EXIT + +#-----------------------------------------------------------------------# +# Store repo root as variable # +#-----------------------------------------------------------------------# +REPO_ROOT=$(readlink -f $(dirname $(dirname $0))) +OLD_CWD=$(readlink -f .) + +#-----------------------------------------------------------------------# +# Switch to build dir # +#-----------------------------------------------------------------------# +pushd "$BUILD_DIR" + +#-----------------------------------------------------------------------# +# Configure build files with qmake # +# we need to explicitly set the install prefix, as qmake's default is # +# /usr/local for some reason... # +#-----------------------------------------------------------------------# +qmake "$REPO_ROOT" + +#-----------------------------------------------------------------------# +# Build project and install files into AppDir # +#-----------------------------------------------------------------------# +make -j$(nproc) +make install INSTALL_ROOT=AppDir + +#-----------------------------------------------------------------------# +# Now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt # +# Download linuxdeploy and its Qt plugin # +#-----------------------------------------------------------------------# +wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage + +#-----------------------------------------------------------------------# +# Make them executable # +#-----------------------------------------------------------------------# +chmod +x linuxdeploy*.AppImage + +#-----------------------------------------------------------------------# +# Make sure Qt plugin finds QML sources so it can deploy the imported # +# files # +export QML_SOURCES_PATHS="$REPO_ROOT"/src + +./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir -e OpenRGB -i "$REPO_ROOT"/qt/OpenRGB.png -d "$REPO_ROOT"/qt/OpenRGB.desktop +./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract-and-run --appdir AppDir +./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir --output appimage + +#-----------------------------------------------------------------------# +# Move built AppImage back into original CWD # +#-----------------------------------------------------------------------# +mv OpenRGB*.AppImage "$OLD_CWD" +