repo: 引入 Spark 构建,支持构建 Appimage

This commit is contained in:
zinface 2023-02-01 20:09:49 +08:00
parent 2b28d310d6
commit b8d855c95f
4 changed files with 180 additions and 0 deletions

View File

@ -80,6 +80,14 @@ if(CMAKE_HOST_UNIX)
spark_install_file(/usr/share/notepad--/icons/ assets/spark.png)
spark_install_target(/usr/bin/ ${PROJECT_NAME})
# 1. Appimage
include(cmake/SparkAppimageConfig.cmake) # Spark Appimage
add_appimage_icon(assets/spark.png) # Appimage
add_appimage_desktop() # Appimage 中的默认desktop(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop))
add_appimage() # Appimage
# 注释行(使用方式)
find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR})
add_package_descript(cmake/package-deb.descript)

View File

@ -59,3 +59,26 @@ enter-qdebug-mode:
# 进入新的 bash 环境
@# export QT_LOGGING_RULES=".debug=true; qt.*.debug=false; dtk.*.debug=false; dde.*.debug=false; qtc*=false; " && bash
export QT_LOGGING_RULES=".debug=true" && bash
# Appimage 的构建流 --
# 在 Makefile 进行构建目标构建 Appimage (要求提供工具的绝对路径然后可依次进行linuxdeployqt, genrate-appimage)
# 来自于 https://github.com/probonopd/linuxdeployqt 的 linuxdeployqt
# 来自于 https://github.com/AppImage/AppImageKit 的 appimagetool
# 来自于 https://gitlink.org.cn/zinface/bundle-linuxdeployqt.git 托管存储的工具
# 或指定你所想存放克隆项目的位置
BUNDLE_LINUXDEPLOYQT := $(shell pwd)/build/bundle-linuxdeployqt
download-bundle-linuxdeploytools:
-git clone https://gitlink.org.cn/zinface/bundle-linuxdeployqt.git $(BUNDLE_LINUXDEPLOYQT)
LINUXDEPLOYQT := "$(BUNDLE_LINUXDEPLOYQT)/linuxdeployqt-continuous-x86_64.AppImage"
APPIMAGETOOL := "$(BUNDLE_LINUXDEPLOYQT)/appimagetool-x86_64.AppImage"
linuxdeploy: release download-bundle-linuxdeploytools
cd build && cmake .. -DLINUXDEPLOYQT=$(LINUXDEPLOYQT) -DAPPIMAGETOOL=$(APPIMAGETOOL)
cd build && make linuxdeploy
genrate-appimage:
cd build && cmake .. -DLINUXDEPLOYQT=$(LINUXDEPLOYQT) -DAPPIMAGETOOL=$(APPIMAGETOOL)
cd build && make appimage

View File

@ -0,0 +1,139 @@
# export PATH=/usr/lib/x86_64-linux-gnu/qt5/bin:$PATH
# export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
# export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins:$QT_PLUGIN_PATH
# export QML2_IMPORT_PATH=/usr/lib/x86_64-linux-gnu/qt5/qml:$QML2_IMPORT_PATH
# export PATH=/usr/lib/x86_64-linux-gnu/qt5/bin:$PATH
# ~/linuxdeployqt-continuous-x86_64.AppImage spark-store-submitter -appimage
# cd ..
# ~/appimagetool-x86_64.AppImage appimage/
# LINUXDEPLOYQT=/home/zinface/linuxdeployqt-continuous-x86_64.AppImage
# APPIMAGETOOL=/home/zinface/appimagetool-x86_64.AppImage
# if ()
set(APPIMAGE_OUTPUT "${CMAKE_BINARY_DIR}/appimage")
set(APPIMAGE_ICON "${APPIMAGE_OUTPUT}/default.png")
set(APPIMAGE_DESTKOP "${APPIMAGE_OUTPUT}/default.desktop")
# set(LINUXDEPLOYQT)
# set(APPIMAGETOOL)
function(execute_linuxdeploy _PATH)
execute_process(COMMAND ${LINUXDEPLOYQT}
WORKING_DIRECTORY "${APPIMAGE_OUTPUT}"
)
endfunction(execute_linuxdeploy _PATH)
function(target_linuxdeploy)
add_custom_target(linuxdeploy pwd
BYPRODUCTS appimage
COMMAND cp ../${PROJECT_NAME} .
COMMAND "${LINUXDEPLOYQT}" ${PROJECT_NAME} -appimage -unsupported-allow-new-glibc -verbose=3 -no-strip|| true
COMMAND cp ../spark-appimage.desktop default.desktop
COMMAND cp ../spark-appimage.png default.png
WORKING_DIRECTORY "${APPIMAGE_OUTPUT}")
endfunction(target_linuxdeploy)
function(target_appimage)
add_custom_target(copy-desktop-appimage
COMMAND cp ../spark-appimage.desktop default.desktop
COMMAND cp ../spark-appimage.png default.png
WORKING_DIRECTORY "${APPIMAGE_OUTPUT}")
add_custom_target(appimage pwd
COMMAND ${APPIMAGETOOL} ${APPIMAGE_OUTPUT}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS copy-desktop-appimage)
endfunction(target_appimage)
function(add_appimage)
# check linuxdeploy
if(NOT DEFINED LINUXDEPLOYQT)
message("AppImage> Not Found LINUXDEPLOYQT Variable!")
return()
endif(NOT DEFINED LINUXDEPLOYQT)
if(CMAKE_VERSION VERSION_LESS 3.19 AND NOT EXISTS ${LINUXDEPLOYQT})
message("> cmake version is less than 3.19")
message(WARNING "!Relative paths are not supported!")
else()
file(REAL_PATH ${LINUXDEPLOYQT} LINUXDEPLOYQT_REAL_PATH)
endif(CMAKE_VERSION VERSION_LESS 3.19 AND NOT EXISTS ${LINUXDEPLOYQT})
message("AppImage> Found LINUXDEPLOYQT Variable: ${LINUXDEPLOYQT_REAL_PATH}")
# check appimagetool
if(NOT DEFINED APPIMAGETOOL)
message("AppImage> Not Found APPIMAGETOOL Variable!")
return()
endif(NOT DEFINED APPIMAGETOOL)
if(CMAKE_VERSION VERSION_LESS 3.19 AND NOT EXISTS ${LINUXDEPLOYQT})
# execute_process(COMMAND realpath ${APPIMAGETOOL} OUTPUT_VARIABLE APPIMAGETOOL_REAL_PATH)
message("> cmake version is less than 3.19")
message(WARNING "!Relative paths are not supported!")
else()
file(REAL_PATH ${APPIMAGETOOL} APPIMAGETOOL_REAL_PATH)
endif(CMAKE_VERSION VERSION_LESS 3.19 AND NOT EXISTS ${LINUXDEPLOYQT})
message("AppImage> Found APPIMAGETOOL Variable: ${LINUXDEPLOYQT_REAL_PATH}")
# do add_custome_target
make_directory(${APPIMAGE_OUTPUT})
target_linuxdeploy()
target_appimage()
endfunction(add_appimage)
function(add_appimage_desktop)
configure_file(cmake/spark-appimage.desktop.in
${CMAKE_BINARY_DIR}/spark-appimage.desktop @ONLY)
endfunction(add_appimage_desktop)
function(add_appimage_icon _ICON_PATH)
if(CMAKE_VERSION VERSION_LESS 3.21)
message("> cmake version is less than 3.21")
configure_file(${_ICON_PATH} ${CMAKE_BINARY_DIR}/spark-appimage.png COPYONLY)
else()
file(COPY_FILE ${_ICON_PATH} ${CMAKE_BINARY_DIR}/spark-appimage.png)
endif(CMAKE_VERSION VERSION_LESS 3.21)
endfunction(add_appimage_icon _ICON_PATH)
# glic>=2.27, -unsupported-allow-new-glibc (意思就是不再低版本发行版使用了)
# -unsupported-bundle-everything
# -unsupported-bundle-everything
# ld-linux.so glibc使
# -unsupported-allow-new-glibc
# linuxdeployqt Ubuntu LTS AppImage
# ./linuxdeployqt-7-x86_64.AppImage / -appimage -unsupported-allow-new-glibc
# ./linuxdeployqt-7-x86_64.AppImage / -appimage -unsupported-bundle-everything
# 1. Appimage
# include(cmake/SparkAppimageConfig.cmake) # Spark Appimage
# add_appimage_icon(assets/spark.png) # Appimage
# add_appimage_desktop() # Appimage 中的默认desktop(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop))
# add_appimage() # Appimage
# 2. Makefile Appimage --
# Makefile Appimage (要求提供工具的绝对路径然后可依次进行linuxdeployqt, genrate-appimage)
# https://github.com/probonopd/linuxdeployqt linuxdeployqt
# https://github.com/AppImage/AppImageKit appimagetool
# https://gitlink.org.cn/zinface/bundle-linuxdeployqt.git
#
# BUNDLE_LINUXDEPLOYQT := $(shell pwd)/build/bundle-linuxdeployqt
# download-bundle-linuxdeploytools:
# -git clone https://gitlink.org.cn/zinface/bundle-linuxdeployqt.git $(BUNDLE_LINUXDEPLOYQT)
# LINUXDEPLOYQT := "$(BUNDLE_LINUXDEPLOYQT)/linuxdeployqt-continuous-x86_64.AppImage"
# APPIMAGETOOL := "$(BUNDLE_LINUXDEPLOYQT)/appimagetool-x86_64.AppImage"
# linuxdeploy: release download-bundle-linuxdeploytools
# cd build && cmake .. -DLINUXDEPLOYQT=$(LINUXDEPLOYQT) -DAPPIMAGETOOL=$(APPIMAGETOOL)
# cd build && make linuxdeploy
# genrate-appimage:
# cd build && cmake .. -DLINUXDEPLOYQT=$(LINUXDEPLOYQT) -DAPPIMAGETOOL=$(APPIMAGETOOL)
# cd build && make appimage

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Name=@APP_NAME@
Name[zh_CN]=@APP_NAME_ZH_CN@
Exec=AppRun %F
Icon=default
Comment=@APP_COMMENT@
Terminal=true
Type=Application
Categories=@APP_CATEGORIES@
MimeType=text/plain