A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

rbutil: Deploy support in cmake.

Add a "deploy" target that will create a distributable file.

- Linux: AppImage.
- Windows: zip file.
- MacOS: dmg.

Change-Id: Id8ae9c021bc5bbb1abf066205b57d943c3f3b327

+205 -2
+9
utils/CMakeLists.txt
··· 48 48 find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat Widgets Svg Multimedia Network LinguistTools 49 49 OPTIONAL_COMPONENTS Test) 50 50 endif() 51 + get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) 52 + get_filename_component(QT_BINDIR "${_qmake_executable}" DIRECTORY) 51 53 message("-- Found Qt${QT_VERSION_MAJOR}: ${Qt${QT_VERSION_MAJOR}_DIR}") 52 54 53 55 # If we're on Linux, try to find the used libs in the system. ··· 196 198 set_property(TARGET RockboxUtility PROPERTY AUTOMOC ON) 197 199 set_property(TARGET RockboxUtility PROPERTY AUTORCC ON) 198 200 set_property(TARGET RockboxUtility PROPERTY AUTOUIC ON) 201 + 202 + include(${CMAKE_CURRENT_LIST_DIR}/cmake/deploy.cmake) 203 + deploy_qt(RockboxUtility 204 + ${QT_BINDIR} 205 + ${CMAKE_CURRENT_LIST_DIR}/../docs/logo/rockbox-clef.svg 206 + ${CMAKE_CURRENT_LIST_DIR}/rbutilqt/RockboxUtility.desktop 207 + ${CMAKE_CURRENT_LIST_DIR}/rbutilqt/dmgbuild.cfg) 199 208 200 209 add_library(rbbase 201 210 ${CMAKE_CURRENT_LIST_DIR}/../tools/iriver.c
+141
utils/cmake/deploy.cmake
··· 1 + # 2 + # __________ __ ___. 3 + # Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + # \/ \/ \/ \/ \/ 8 + # 9 + # All files in this archive are subject to the GNU General Public License. 10 + # See the file COPYING in the source tree root for full license agreement. 11 + # 12 + # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 13 + # KIND, either express or implied. 14 + # 15 + 16 + # include this file to 17 + # - get a new target "deploy" 18 + # - get a function "deploy_qt()" which will add a deploy target that creates a 19 + # zip / AppImage / dmg and depends on "deploy". 20 + 21 + if(NOT have_deploy) 22 + add_custom_target(deploy) 23 + set(have_deploy ON) 24 + endif() 25 + 26 + # Linux: Build AppImage 27 + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 28 + set(LINUXDEPLOY ${CMAKE_CURRENT_BINARY_DIR}/linuxdeploy-x86_64.AppImage) 29 + add_custom_command( 30 + OUTPUT ${LINUXDEPLOY} 31 + COMMAND ${CMAKE_COMMAND} 32 + -DOUTDIR=${CMAKE_CURRENT_BINARY_DIR} 33 + -DURL=https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage 34 + -P ${CMAKE_CURRENT_LIST_DIR}/download.cmake 35 + COMMAND ${CMAKE_COMMAND} 36 + -DOUTDIR=${CMAKE_CURRENT_BINARY_DIR} 37 + -DURL=https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage 38 + -P ${CMAKE_CURRENT_LIST_DIR}/download.cmake 39 + ) 40 + 41 + function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) 42 + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 43 + message(WARNING "Deploying a Debug build.") 44 + endif() 45 + add_custom_command( 46 + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.AppImage 47 + COMMENT "Creating AppImage ${target}" 48 + COMMAND OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/${target}.AppImage 49 + ${LINUXDEPLOY} 50 + --icon-file=${iconfile} 51 + --desktop-file=${desktopfile} 52 + --executable=$<TARGET_FILE:${target}> 53 + --appdir=AppImage-${target} 54 + --output=appimage 55 + --verbosity=2 56 + DEPENDS ${target} 57 + ${LINUXDEPLOY} 58 + ) 59 + add_custom_target(deploy_${target} 60 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${target}.AppImage) 61 + add_dependencies(deploy deploy_${target}) 62 + endfunction() 63 + endif() 64 + 65 + # MacOS: Build dmg 66 + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 67 + function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) 68 + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 69 + message(WARNING "Deploying a Debug build.") 70 + endif() 71 + set(DMGBUILD ${CMAKE_CURRENT_BINARY_DIR}/venv/bin/dmgbuild) 72 + find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${qtbindir}") 73 + 74 + add_custom_command( 75 + COMMENT "Setting up dmgbuild virtualenv" 76 + OUTPUT ${DMGBUILD} 77 + COMMAND python3 -m venv ${CMAKE_CURRENT_BINARY_DIR}/venv 78 + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/venv/bin/python -m pip install -q dmgbuild biplist 79 + ) 80 + 81 + add_custom_command( 82 + # TODO: find a better way to figure the app bundle name. 83 + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dmg 84 + COMMENT "Running macdeployqt and creating dmg ${target}" 85 + COMMAND ${MACDEPLOYQT_EXECUTABLE} ${target}.app 86 + COMMAND ${DMGBUILD} -s ${dmgbuildcfg} 87 + -Dappbundle=${target}.app 88 + ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target}.dmg 89 + DEPENDS ${target} 90 + ${DMGBUILD} 91 + ) 92 + add_custom_target(deploy_${target} 93 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${target}.dmg) 94 + add_dependencies(deploy deploy_${target}) 95 + endfunction() 96 + endif() 97 + 98 + # Windows. Copy to dist folder, run windeployqt on the binary, compress to zip. 99 + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") 100 + function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) 101 + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 102 + message(WARNING "Deploying a Debug build.") 103 + endif() 104 + set(_targetfile ${target}.exe) # TODO: Use property. OUTPUT_NAME seems to fail. 105 + find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${qtbindir}") 106 + set(deploydir ${CMAKE_CURRENT_BINARY_DIR}/deploy-${target}) 107 + if(WINDEPLOYQT_EXECUTABLE) 108 + add_custom_command( 109 + COMMENT "Creating deploy folder and running windeployqt" 110 + OUTPUT ${deploydir}/${_targetfile} 111 + COMMAND ${CMAKE_COMMAND} -E make_directory ${deploydir} 112 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_targetfile} ${deploydir} 113 + COMMAND ${WINDEPLOYQT_EXECUTABLE} 114 + $<IF:$<CONFIG:Debug>,--debug,--release> # on MinGW, release is mistaken as debug. 115 + ${deploydir}/${_targetfile} 116 + DEPENDS ${target} 117 + ) 118 + else() 119 + add_custom_command( 120 + COMMENT "Creating deploy folder" 121 + OUTPUT ${deploydir}/${_targetfile} 122 + COMMAND ${CMAKE_COMMAND} -E make_directory ${deploydir} 123 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_targetfile} ${deploydir} 124 + DEPENDS ${target} 125 + ) 126 + endif() 127 + add_custom_command( 128 + COMMENT "Compressing to zip" 129 + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.zip 130 + WORKING_DIRECTORY ${deploydir} 131 + COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/${target}.zip 132 + --format=zip . 133 + DEPENDS ${deploydir}/${_targetfile} 134 + ) 135 + 136 + add_custom_target(deploy_${target} 137 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${target}.zip) 138 + add_dependencies(deploy deploy_${target}) 139 + endfunction() 140 + endif() 141 +
+47
utils/cmake/download.cmake
··· 1 + # 2 + # __________ __ ___. 3 + # Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + # \/ \/ \/ \/ \/ 8 + # 9 + # All files in this archive are subject to the GNU General Public License. 10 + # See the file COPYING in the source tree root for full license agreement. 11 + # 12 + # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 13 + # KIND, either express or implied. 14 + # 15 + 16 + # This is a separate cmake script, to be invoked as 17 + # cmake -P -DURL=<url-to-download> -DOUTDIR=<output-folder> 18 + # Downloads the file and store it in OUTDIR, using the file basename as output 19 + # filename. 20 + # The downloaded file gets its executable flag set. 21 + 22 + function(gettempdir basedir tmpdir) 23 + # Create a random filename in current directory. 24 + # Result stored in tmpdir. 25 + string(RANDOM LENGTH 24 _tmp) 26 + while(EXISTS "${basedir}/${_tmp}.tmp") 27 + string(RANDOM LENGTH 24 _tmp) 28 + endwhile() 29 + set("${tmpdir}" "${basedir}/${_tmp}.tmp" PARENT_SCOPE) 30 + endfunction() 31 + 32 + get_filename_component(fname "${URL}" NAME) 33 + 34 + if(EXISTS "${OUTDIR}/${fname}") 35 + message("-- Found ${fname}") 36 + else() 37 + message("-- Downloading ${URL} ...") 38 + gettempdir(${OUTDIR} tmp) 39 + 40 + # cmake CHOWN is 3.19+, thus download to a temporary folder, then copy. 41 + file(DOWNLOAD "${URL}" "${tmp}/${fname}") 42 + file(COPY "${tmp}/${fname}" DESTINATION "${OUTDIR}" 43 + FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) 44 + file(REMOVE_RECURSE "${tmp}") 45 + endif() 46 + 47 +
+8 -2
utils/rbutilqt/dmgbuild.cfg
··· 1 1 # Configuration for creating a dmg with dmgbuild 2 2 # (https://github.com/al45tair/dmgbuild) 3 + # Needs biplist as additional package. 3 4 4 5 import os 6 + import biplist 5 7 6 - files = [ 'RockboxUtility.app' ] 8 + _appbundle = defines['appbundle'] 9 + _plist = biplist.readPlist(os.path.join(_appbundle, 'Contents/Info.plist')) 10 + _iconfile = os.path.join(_appbundle, 'Contents/Resources', _plist['CFBundleIconFile']) 11 + 12 + files = [ _appbundle ] 13 + icon = _iconfile 7 14 background = '#c6d6f5' 8 - icon = os.path.join(defines['basepath'], 'rbutilqt/icons/rbutilqt.icns') 9 15