diff --git a/.github/workflows/linux_cpn.yml b/.github/workflows/linux_cpn.yml new file mode 100644 index 000000000..7890009fb --- /dev/null +++ b/.github/workflows/linux_cpn.yml @@ -0,0 +1,60 @@ +name: Linux Companion + +on: + push: + branches: + - '2.5' + - 'main' + tags: + - v* + paths: + - '.github/workflows/linux_cpn.yml' + - 'companion/**' + - 'tools/build-companion-nightly.sh' + + pull_request: + branches: + - '2.5' + - 'main' + paths: + - '.github/workflows/linux_cpn.yml' + - 'companion/**' + - 'tools/build-companion-nightly.sh' + + workflow_dispatch: + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ghcr.io/edgetx/edgetx-dev + volumes: + - ${{ github.workspace }}:/src + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Build + working-directory: ${{github.workspace}} + shell: bash + run: | + mkdir output && \ + tools/build-companion-nightly.sh $(pwd) $(pwd)/output/ + + - name: Compose release filename + # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions + run: echo "artifact_name=edgetx-cpn-linux-${GITHUB_REF##*/}" >> $GITHUB_ENV + + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: "${{ env.artifact_name }}" + path: ${{github.workspace}}/output + retention-days: 15 diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 9b2507101..0ec52527b 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -5,12 +5,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|FreeBSD)") set(COMPANION_NAME "companion${C9X_NAME_SUFFIX}") set(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}") if (NOT ${SIMULATOR_INSTALL_PREFIX} STREQUAL "") - set(SIMULATOR_LIB_PATH ${SIMULATOR_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX}) + set(SIMULATOR_LIB_PATH ${SIMULATOR_INSTALL_PREFIX}/lib/${COMPANION_NAME}) else() - set(SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX}) + set(SIMULATOR_LIB_PATH "../lib/${COMPANION_NAME}") endif() message(STATUS "Simulators library search path: " ${SIMULATOR_LIB_PATH}) - set(SIMULATOR_LIB_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX}) + set(SIMULATOR_LIB_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/${COMPANION_NAME}) else() set(COMPANION_NAME "companion") set(SIMULATOR_NAME "simulator") @@ -532,24 +532,7 @@ IF(APPLE) " COMPONENT Runtime) endif() -find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") - -if(DPKG_PROGRAM) - set(CPACK_GENERATOR "DEB") - execute_process( - COMMAND ${DPKG_PROGRAM} --print-architecture - OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Raphael Coeffic") - set(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION}) - set(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) - set(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) - set(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR)) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins") - set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -elseif(APPLE) +if(APPLE) set(CPACK_GENERATOR "DragNDrop") # set(CPACK_GENERATOR "TGZ") # for quick testing set(CPACK_BINARY_DRAGNDROP ON) @@ -557,12 +540,43 @@ elseif(APPLE) set(CPACK_DMG_VOLUME_NAME "EdgeTX Companion") set(CPACK_DMG_DS_STORE ${PROJECT_SOURCE_DIR}/companion/targets/mac/DS_Store) set(CPACK_PACKAGE_FILE_NAME "opentx-${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}") -else(DPKG_PROGRAM) - set(CPACK_GENERATOR "RPM") - set(CPACK_RPM_PACKAGE_VERSION ${VERSION}) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}") - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib /lib/udev /lib/udev/rules.d") -endif(DPKG_PROGRAM) +endif(APPLE) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + get_filename_component(_qt_bin_dir "${QT_QMAKE_EXECUTABLE}" DIRECTORY) + find_program(LINUXDEPLOY_EXECUTABLE linuxdeployqt HINTS "${_qt_bin_dir}") + + if(NOT LINUXDEPLOY_EXECUTABLE) + message(STATUS "linuxdeployqt will be downloaded") + + set(LINUXDEPLOY_EXECUTABLE "${CMAKE_BINARY_DIR}/deployqt/AppRun") + + set(LINUXDEPLOY_URL "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage") + set(LINUXDEPLOY_BUNDLE "linuxdeployqt.AppImage") + + if (NOT EXISTS "${LINUXDEPLOY_EXECUTABLE}") + + file(DOWNLOAD "${LINUXDEPLOY_URL}" ${LINUXDEPLOY_BUNDLE}) + execute_process( + COMMAND chmod +x ${LINUXDEPLOY_BUNDLE} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + execute_process( + COMMAND ./${LINUXDEPLOY_BUNDLE} --appimage-extract + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + + file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/deployqt) + execute_process( + COMMAND mv squashfs-root deployqt + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + file(REMOVE ${CMAKE_BINARY_DIR}/${LINUXDEPLOY_BUNDLE}) + endif() + endif() + + set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}") + set(CPACK_GENERATOR "External") + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CPackLinuxDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake" @ONLY) + set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake") +endif() include(CPack) diff --git a/companion/src/CPackLinuxDeployQt.cmake.in b/companion/src/CPackLinuxDeployQt.cmake.in new file mode 100644 index 000000000..497d532cb --- /dev/null +++ b/companion/src/CPackLinuxDeployQt.cmake.in @@ -0,0 +1,17 @@ +set(APP_DIR "@CPACK_PACKAGE_DIRECTORY@/_CPack_Packages/Linux/External/AppImage") + +execute_process(COMMAND @CMAKE_MAKE_PROGRAM@ DESTDIR=${APP_DIR} install + WORKING_DIRECTORY @CMAKE_BINARY_DIR@) + +file(GLOB simulator_plugins "${APP_DIR}@CMAKE_INSTALL_PREFIX@/lib/@COMPANION_NAME@/*@CMAKE_SHARED_LIBRARY_SUFFIX@") +message("Simulator plugins: ${simulator_plugins}") + +if(simulator_plugins) + list(TRANSFORM simulator_plugins PREPEND "-executable=" + OUTPUT_VARIABLE exe_list_cmd) +endif() + +message("exe_list_cmd = ${exe_list_cmd}") +set(desktop_file ${APP_DIR}@CMAKE_INSTALL_PREFIX@/share/applications/@COMPANION_NAME@.desktop) +execute_process(COMMAND env QMAKE=@QT_QMAKE_EXECUTABLE@ @LINUXDEPLOY_EXECUTABLE@ ${desktop_file} -appimage ${exe_list_cmd} + WORKING_DIRECTORY @CMAKE_BINARY_DIR@) diff --git a/companion/src/companion.desktop.in b/companion/src/companion.desktop.in index 58614f40f..293ad8a4b 100644 --- a/companion/src/companion.desktop.in +++ b/companion/src/companion.desktop.in @@ -1,11 +1,10 @@ [Desktop Entry] Type=Application -Encoding=UTF-8 -Name=Companion @VERSION@ +Name=EdgeTx Companion @VERSION@ GenericName=Transmitter Companion App Comment=The Ultimate Transmitter Companion Icon=@COMPANION_NAME@ -Exec='@COMPANION_NAME@' +Exec=@COMPANION_NAME@ Terminal=false StartupNotify=false -Categories=Application +Categories=Application; diff --git a/companion/src/simulation/simulatorinterface.cpp b/companion/src/simulation/simulatorinterface.cpp index 1ed9cc520..dd71e3400 100644 --- a/companion/src/simulation/simulatorinterface.cpp +++ b/companion/src/simulation/simulatorinterface.cpp @@ -86,7 +86,7 @@ int SimulatorLoader::registerSimulators(const QDir & dir) void SimulatorLoader::registerSimulators() { - QDir dir("."); + QDir dir(QCoreApplication::applicationDirPath()); if (registerSimulators(dir)) { return; } @@ -100,9 +100,13 @@ void SimulatorLoader::registerSimulators() path.truncate(path.lastIndexOf('\\')); dir.setPath(path); #else - dir.setPath(SIMULATOR_LIB_SEARCH_PATH); + if (QDir::isAbsolutePath(SIMULATOR_LIB_SEARCH_PATH)) { + dir.setPath(SIMULATOR_LIB_SEARCH_PATH); + } else { + dir.setPath(QCoreApplication::applicationDirPath() + "/" SIMULATOR_LIB_SEARCH_PATH); + } #endif - registerSimulators(dir); + registerSimulators(dir.absolutePath()); } void SimulatorLoader::unregisterSimulators() diff --git a/companion/src/simulator.desktop.in b/companion/src/simulator.desktop.in index c5715ac24..54489a095 100644 --- a/companion/src/simulator.desktop.in +++ b/companion/src/simulator.desktop.in @@ -1,11 +1,10 @@ [Desktop Entry] Type=Application -Encoding=UTF-8 Name=Simulator @VERSION@ GenericName=Transmitter Simulator App Comment=The Ultimate Transmitter Simulator Icon=@COMPANION_NAME@ -Exec='@SIMULATOR_NAME@' +Exec=@SIMULATOR_NAME@ Terminal=false StartupNotify=false -Categories=Application +Categories=Application; diff --git a/tools/build-companion-nightly.sh b/tools/build-companion-nightly.sh index 38c8f532b..4bb9bd2d3 100755 --- a/tools/build-companion-nightly.sh +++ b/tools/build-companion-nightly.sh @@ -133,7 +133,7 @@ if [ "$(uname)" = "Darwin" ]; then cp *.dmg ${OUTDIR} elif [ "$(uname)" = "Linux" ]; then make -j${JOBS} package - cp *.deb ${OUTDIR} + cp *.AppImage ${OUTDIR} else make installer cp companion/*.exe ${OUTDIR}