diff --git a/.gitignore b/.gitignore index 633238688b12f8317b62877cbc2d05b081f88096..c7b13dede2a03b3392aa0d1bc8913c69a2dd4b3f 100644 --- a/.gitignore +++ b/.gitignore @@ -475,3 +475,55 @@ compile_commands.json [Bb]uild/ .vscode/ .vs/ +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + + + +# Ignore the build directory generated by the vsocde cmake extension +build/ +# Ignore the build directory generated by the vsocde clangd extension +.cache + +# Created by https://www.toptal.com/developers/gitignore/api/cmake +# Edit at https://www.toptal.com/developers/gitignore?templates=cmake + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +# End of https://www.toptal.com/developers/gitignore/api/cmake +!/Makefile + + +#################### Visual Studio 2022 #################### +/out + +################ Customizable build templates. ################ +# If you copy here and customize the build form, its changes will be ignored. + +# Windows cmd or powershell supported files.. +/windows-msvc-ninja.bat \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5cd6b86a67892b862324e2aa09ffaf08f2255051 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,128 @@ +cmake_minimum_required(VERSION 3.20) + +project(Notepad-- VERSION 2.0.0) + +# -------------- Notepad -- 全局构建配置 ------------- # +option(USE_QT6 "使用 Qt6 进行编译本项目与随带所有内容" OFF) + +include(cmake/SparkEnvConfig.cmake) +include(cmake/SparkMacrosConfig.cmake) +if(USE_QT6) + include(cmake/SparkFindQt6Config.cmake) +else() + include(cmake/SparkFindQt5Config.cmake) +endif(USE_QT6) +include(cmake/SparkMacrosExtendConfig.cmake) + + +# ----------------- 构建之前 全局定义 ----------------- # +# 在 Windows 中开启 UNICODE 以支持 TCHAR 功能 +if(WIN32) + add_compile_definitions(_UNICODE= UNICODE=) +endif() +# 符合 2.0.0 代码预期的版本处理, 核心编辑器组件 2.11 +add_compile_definitions(TEST_PRE) + +# ----------------- 构建 QSci 库 ----------------- # +if(TRUE) + include(cmake/modules/QScint.cmake) +endif(TRUE) + + +# ----------------- 构建 Notepad-- 程序 ----------------- # +if(TRUE) + include(cmake/modules/Notepad--.cmake) +endif(TRUE) + +# ----------------- Notepad-- 其它主线构建相关 ----------------- # +option(USE_WINDOWS_UNIVERSAL "通用 Windows 平台构建" OFF) +option(USE_WINDOWS_MINGW "通用 Windows 平台 MinGW 构建" OFF) +option(USE_WINDOWS_MSVC "通用 Windows 平台 MSVC 构建" OFF) +# +option(WINDOWS_DEPLOY_QT "通用 Windows 平台 Qt 部署" OFF) +option(WINDOWS_DEPLOY_QT5 "通用 Windows 平台指定 Qt5 部署 windeployqt" OFF) +option(WINDOWS_DEPLOY_QT6 "通用 Windows 平台指定 Qt6 部署 windeployqt" OFF) +# +option(USE_LINUX_UNIVERSAL "通用 Linux 平台构建" OFF) +option(USE_LINUX_DEBIAN "通用 Debian Linux 平台构建" OFF) +option(USE_LINUX_APPIMAGE "通用 Appimage Linux 平台构建" OFF) +option(USE_LINUX_UOS "独立 Linux 平台的 Uos 构建" OFF) +# +option(USE_MACOSX_UNIVERSAL "通用 MacOSX 平台构建" OFF) + +# 使用 windows.cmake / linux.cmake / macos.cmake 维护构建. + + # 在 Windows 中此处将由通用构建、MinGW 构建、MSVC 构建组成 +if(WIN32) + + # 通用 Windows 平台构建,一切的起始 + if(USE_WINDOWS_UNIVERSAL) + include(cmake/platforms/windows-universal.cmake) + + # 为 Windows 中构建的应用进行 windeployqt 的配方 + include(cmake/platforms/windows-deployqt.cmake) + + # 通用平台的 Windows MinGW 构建 + if(USE_WINDOWS_MINGW) + # include(cmake/platforms/windows-mingw.cmake) + endif() + + # 通用平台的 Windows MSVC 构建 + if(USE_WINDOWS_MSVC) + # include(cmake/platforms/windows-msvc.cmake) + endif() + + # 其它 Windows 平台的构建 + else() + # include(cmake/platforms/windows-other.cmake) + endif(USE_WINDOWS_UNIVERSAL) + + # 在 Linux 中此处将由通用构建、Debian 打包构建、Appimage 打包构建、Uos 打包构建组成 +elseif(UNIX AND NOT APPLE AND NOT WIN32 AND NOT ANDROID) + + # 通用 Linux 平台构建,一切的起始 + if(USE_LINUX_UNIVERSAL) + include(cmake/platforms/linux-universal.cmake) + + # 通用 Linux 平台的 Debian deb 构建 + if(USE_LINUX_DEBIAN) + include(cmake/platforms/linux-debian.cmake) + endif() + + # 通用 Linux 平台的 Appimage 构建 + if(USE_LINUX_APPIMAGE) + include(cmake/platforms/linux-appimage.cmake) + endif() + + # 独立 Linux 平台的 Uos 构建 + elseif(USE_LINUX_UOS) + include(cmake/platforms/linux-uos.cmake) + + # 其它 Linux 平台的构建 + else() + # include(cmake/platforms/linux-other.cmake) + endif(USE_LINUX_UNIVERSAL) + + # 通用 MacOSX 平台的构建 +elseif(APPLE) + + # 通用 MacOSX 平台构建,一切的起始 + if(USE_MACOSX_UNIVERSAL) + include(cmake/platforms/macos-universal.cmake) + + endif(USE_MACOSX_UNIVERSAL) + +endif() + +# ----------------- Notepad-- 其它主线构建相关 ----------------- # + +if(USE_QT6) + # Qt5/Qt6 兼容性构建检查文件检查 + include(cmake/platforms/utils.cmake) + qt5_qt6_compatible_check(cmake/qt5_qt6_compatible_check QT56_PASS) + if(NOT QT56_PASS) + message(SEND_ERROR "[${QT56_PASS}] Qt5/Qt6 兼容性检查文件当前未能检查通过,不建议构建 Qt6。") + else() + message(NOTICE "[${QT56_PASS}] Qt5/Qt6 兼容性检查文件当前检查通过。") + endif(NOT QT56_PASS) +endif(USE_QT6) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..bd4b430473867c324df4a8fb48a0f1c6cd41afa8 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +# 主体构建入口 + +# 1. 在 Windows 中 $(OS) 为 Windows_NT +# 2. 在 Linux 中 $(OS) 为空的,此时应该使用 uname + # 注意:在 Linux 中 uanme -s 显示为 Linux + # 注意:在 Linux 中某些内核 uanme -p 显示为 unknow +# 3. 待验证:在 OSX 中 $(OS) 为空的,此时应该使用 uname + # 待验证:在 OSX 中 uname -s 显示为 Darwin + # 待验证:在 OSX 中 uname -p 显示为 ? + +# Windows 平台相关 +ifeq ($(OS),Windows_NT) + include windows.mk +# Unix 平台相关 +else + UNAME_S := $(shell uname -s) + # Linux 构建 + ifeq ($(UNAME_S),Linux) + include linux.mk + endif + + # MacOS 构建 + ifeq ($(UNAME_S),Darwin) + include macos.mk + endif +endif + diff --git a/README.md b/README.md index 05565ec370802d2a5218638b26f5d86ebd1f7471..159727dc6a324dcb57f1895f3d8ecc0aabc58ead 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,164 @@ NDD 具备插件编写功能,如果您愿意开发插件,还请提交给我 ![输入图片说明](6688.png) +## 编译 + +**CMake工具链编译说明:** + +- Windows 系统通用构建 - 基于 Batch 脚本进行构建 + + ```batch + ;; 将 Batch 脚本复制到项目目录 + copy cmake/make-batch-powershell/windows-msvc-ninja.bat . + + ;; 使用脚本进行构建,它将会询问如何进行构建 + windows-msvc-ninja.bat + ``` + +- Windows 系统 VSCode 构建 - 基于 VSCode 配置模板进行调整构建 + + ```batch + ;; 拷贝一份 cmake/vscode/windows-vs-2022-cmake-ninja.json 作为你的 .vscode/settings.json + ;; 修改配置中的 -DCMAKE_PREFIX_PATH 部分为你的 Qt 路径,或你自行编译的 Qt 路径, + ;; 例如: + ;; "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64", + ``` + +- MacOSX 平台构建方案 + + ```shell + Build with the following configuration: + 1. make macosx-universal + 通用 MacOSX 平台构建(Debug). + 2. make macosx-universal-release + 通用 MacOSX 平台构建(Release). + 3. make package + 通用 MacOSX 平台构建 CPack 打包. + + # 由 CPack 驱动的打包: + # 将在 build/macosx-universal 目录中产生 dmg 文件 + # 可在 CPack 的生成目录尝试进行手动 macdeployqt 处理 + # 注:目前M1平台使用原生Qt执行此操作会损坏此包,将需要开发者签证 + ``` + +- 当前的 Linux 平台构建方案 + + ```shell + Build with the following configuration: + 1. make -f linux-universal.mk + 默认的通用 Linux 平台构建. + 2. make -f linux-debian.mk package + 通用 Linux 平台的 Debian deb 构建. + 3. make -f linux-appimage.mk package + 通用 Linux 平台的 Appimage 构建. + 4. make -f linux-uos.mk package + 独立 Linux 平台的 Uos 构建. + ``` + +- Linux 通用构建系列(*仅适合**配合其它打包方案**操作*) - 基于默认的通用 Linux 平台构建. + + ```shell + # 构建默认的 + make -f linux-universal.mk + # 进入构建目录 + cd build/linux-universal + # 执行 make install 安装到 out 目录,得到一个标准 linux 的目录结构 + make DESTDIR=out install + ``` + +- Ubuntu/Debian - 基于通用 Linux 平台的 Debian deb 构建 + + ```shell + # 安装编译环境 + sudo apt-get install g++ make cmake + # 安装qt工具和库 + sudo apt-get install qtbase5-dev qt5-qmake qtbase5-dev-tools \ + libqt5printsupport5 libqt5xmlpatterns5-dev + # 构建 Linux Debian 通用平台 + make -f linux-debian.mk package + + # 将在 build/linux-debian 目录中产生 deb 文件 + # 其它相关内容将不定期更新说明 + ``` + +- Linux 跨发行版构建 Appimage - 基于通用 Linux 平台的 Appimage 构建 + + ```shell + # 在支持编译 Notepad-- 或 Qt 程序的 Linux 平台中 + make -f linux-appimage.mk package + + # 将在 build/linux-appimage 目录中产生 Appimage 文件 + ``` + +- Linux Uos 发行版构建(仅可在 Uos 中构建) - 基于独立 Linux 平台的 Uos 构建. + + ```shell + # 在支持编译 Notepad-- 或 Qt 程序的 Uos 平台中 + make -f linux-uos.mk package + + # 将在 build/linux-uos 目录中产生 deb 文件 + # 所有的内容将安装到 /opt/apps/com.hmja.notepad + # 仅适用于 Uos 系统构建,切不可使用其它发行版本,原生Qt库版本较低 + ``` + +- ArchLinux + + ```shell + # 此部分使用 AUR 中提供的 notepad---git 软件包 + # https://aur.archlinux.org/packages/notepad---git + + # 查看 notepad---git 中提供的 PKGBUILD + curl https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=notepad---git + + # 或克隆仓库以查看 PKGBUILD + git clone https://aur.archlinux.org/notepad---git.git + cd notepad---git + cat PKGBUILD + + # 使用 makepkg 即可进行基于源代码构建软件包 + # 构建工具: gcc cmake make ninja + # 软件包运行时: qt5-tools qt5-base qt5-xmlpatterns + + # 以上是基于源代码构建软件,而安装预编译的二进制则可以使用 archlinuxcn 仓库 + # 查看使用说明 https://www.archlinuxcn.org/archlinux-cn-repo-and-mirror + [archlinuxcn] + Server = https://repo.archlinuxcn.org/$arch + # ArchLinuxCN 明确说明在 ArchLinux 衍生版本中使用时出现问题时不进行任何处理 + + # 以上是基于源代码构建或配置预编译软件仓库进行安装现有的二进制软件包 + # 另外,可使用 yay 来下载并编译或安装软件包 + # + yay -S notepad---git # 将从 AUR 中安装该软件包 + # + yay -S archlinuxcn/notepad---git + # 将从 archlinuxcn 源,下载并安装 notepad---git 软件包 + # + yay -S archlinuxcn/notepad---git-debug + # 注: 这是一个调试符号表包,旨在调试 notepad---git 时使用 + # 有关说明可查看: https://wiki.archlinux.org/title/Debuginfod + ``` + +- openSUSE Tumbleweed + +1. 安装编译环境和Qt工具库 `sudo zypper in -t pattern devel_C_C++ devel_basis devel_qt5 ` +1. 配置 `cmake -B build -DCMAKE_BUILD_TYPE=Release ` +1. 编译 `cd build && make -j ` +1. 打包使用 OBS (Open Build Service) + +**Qt工程编译说明:** + +1)使用qtcreator 或 vs 先打开qscint/src/qscintilla.pro 。先编译出这个qscintlla的依赖库。 + +2)再打开RealCompare.pro 加载后编译。 + +3)由于编译的平台较多,涉及windows/linux/mac,有任何编译问题,还请加qq群 959439826 。欢迎广大网友实现新功能后提交代码给我们。 + +代码上线不久,删除了商业的对比功能和注册功能(这部分有商业原因,请理解),除此以外,所有功能全部保留。 + +4)Arch Linux 及其衍生版可以通过 AUR 仓库安装:[notepad---git](https://aur.archlinux.org/packages/notepad---git) +``` +yay -S notepad---git +``` ## 联络方式 QQ群:372613546(已满) 959439826(已满)728578708(空闲) 用户群,做NDD的问题反馈、功能建议等。 diff --git a/how_build/THIRDPARTY.md b/THIRDPARTY.md similarity index 100% rename from how_build/THIRDPARTY.md rename to THIRDPARTY.md diff --git a/assets/spark.png b/assets/spark.png new file mode 100644 index 0000000000000000000000000000000000000000..bac324f1a8a025c65ea260274ebf078f6f52ce39 Binary files /dev/null and b/assets/spark.png differ diff --git a/cmake/NoteadPlugin-Linux-Development.md b/cmake/NoteadPlugin-Linux-Development.md new file mode 100644 index 0000000000000000000000000000000000000000..c642fc7e9cb7b9e04729935ad97e3ea78eeb2408 --- /dev/null +++ b/cmake/NoteadPlugin-Linux-Development.md @@ -0,0 +1,164 @@ +# NotepadPlugin 开发说明 + +> 当前插件实现的提供 Linux 层开发说明 + +- 引用 NotepadPluginConfig.cmake 中的说明 + + ```cmake + # NotepadPluginConfig.cmake + # 用于 Notepad-- 插件实现的 CMake 模块初级定义 + + # 在 Linux 中,它的布局应该如下: + # /usr/lib/x86_64-linux-gnu/cmake/NotepadPlugin/NotepadPluginConfig.cmake + + # 在 插件开发层中,它的使用如下: + # 1. 查找 NotepadPlugin 模块 + # find_package(NotepadPlugin) + # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) + # add_notepad_plugin( ...) + ``` + +- 着手进行实现插件 + + > 将项目中的 src/plugin/helloworld 复制为单个项目,并使用 CMake 进行构建 + + ```cmake + cmake_minimum_required(VERSION 3.5.1) + + project(template LANGUAGES CXX VERSION 0.0.1) + + # 1. 查找 NotepadPlugin 模块 + find_package(NotepadPlugin REQUIRED) + + # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) + add_notepad_plugin(Helloworld + helloworld/helloworldexport.cpp + helloworld/qttestclass.cpp + helloworld/qttestclass.h + helloworld/qttestclass.ui + ) + + # 以上将会构建出一个名叫 libHelloworld.so 的插件扩展 + ``` + +- 一些 NotepadPluginConfig.cmake 中的变量声明 + + ```cmake + + # NOTEPAD_PLUGIN [不重要]CMake 模块名称 + # NOTEPAD_PLUGIN_CONFIG [不重要]CMake 模块文件名名称 + # NOTEPAD_PLUGIN_INCLUDEDIR [插件 头文件目录]插件开发者可自行使用 + # NOTEPAD_PLUGIN_LIBDIR [插件 库存放目录]插件开发者可自行使用 + # NOTEPAD_PLUGIN_CORELIB [插件 核心库名称]插件开发者可自行使用 + # NOTEPAD_PLUGIN_EXTERNAL_INCLUDES [插件 扩展的头文件目录]插件开发者可自行使用 + # NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY [插件 扩展插件安装目录(位置)]插件开发者可自行使用 + + # NOTEPAD_BUILD_BY_QT5 + # NOTEPAD_BUILD_BY_QT6 + [NOTEPAD_BUILD_BY_约定]如果在构建 Notepad-- 时开启了此项,将会向 CMake 构建系统询问相关模块 + + 例如: + 询问 Qt5 基本模块: 将会在 find_package(NotepadPlugin REQUIRED) 时自动加入 + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) + find_package(Qt5 COMPONENTS Core Widgets REQUIRED) + + 为开发者自动添加 Qt5 模块依赖: 将会在 add_notepad_plugin 时自动加入 + if(NOTEPAD_PLUGIN_QT5) + target_link_libraries(${PLUGIN_VAR} Qt5::Core Qt5::Widgets) + endif(NOTEPAD_PLUGIN_QT5) + + ``` + +- 当前提供插件的 Linux 目录结构 + + ``` + build/_CPack_Packages/Linux/DEB/notepad---1.22.0-Linux + ├── control + ├── control.tar.gz + ├── data.tar.gz + ├── debian-binary + ├── md5sums + └── usr + ├── bin + │   └── notepad-- + ├── include + │   └── NotepadPlugin + │   ├── pluginGl.h + │   └── Qsci + │   ├── qsciabstractapis.h + │   ├── qsciapis.h + │   ├── qscicommand.h + │   ├── qscicommandset.h + │   ├── qscidocument.h + │   ├── qsciglobal.h + │   ├── qscilexerasm.h + │   ├── qscilexeravs.h + │   ├── qscilexerbash.h + │   ├── qscilexerbatch.h + │   ├── qscilexercmake.h + │   ├── qscilexercoffeescript.h + │   ├── qscilexercpp.h + │   ├── qscilexercsharp.h + │   ├── qscilexercss.h + │   ├── qscilexercustom.h + │   ├── qscilexerd.h + │   ├── qscilexerdiff.h + │   ├── qscilexeredifact.h + │   ├── qscilexerfortran77.h + │   ├── qscilexerfortran.h + │   ├── qscilexerglobal.h + │   ├── qscilexergo.h + │   ├── qscilexer.h + │   ├── qscilexerhtml.h + │   ├── qscilexeridl.h + │   ├── qscilexerjava.h + │   ├── qscilexerjavascript.h + │   ├── qscilexerjson.h + │   ├── qscilexerlua.h + │   ├── qscilexermakefile.h + │   ├── qscilexermarkdown.h + │   ├── qscilexermatlab.h + │   ├── qscilexernsis.h + │   ├── qscilexeroctave.h + │   ├── qscilexerpascal.h + │   ├── qscilexerperl.h + │   ├── qscilexerpo.h + │   ├── qscilexerpostscript.h + │   ├── qscilexerpov.h + │   ├── qscilexerproperties.h + │   ├── qscilexerpython.h + │   ├── qscilexerruby.h + │   ├── qscilexerrust.h + │   ├── qscilexerspice.h + │   ├── qscilexersql.h + │   ├── qscilexertcl.h + │   ├── qscilexertex.h + │   ├── qscilexertext.h + │   ├── qscilexervb.h + │   ├── qscilexerverilog.h + │   ├── qscilexervhdl.h + │   ├── qscilexerxml.h + │   ├── qscilexeryaml.h + │   ├── qscimacro.h + │   ├── qsciprinter.h + │   ├── qsciscintillabase.h + │   ├── qsciscintilla.h + │   ├── qscistyledtext.h + │   └── qscistyle.h + ├── lib + │   ├── cmake + │   │   └── NotepadPlugin + │   │   └── NotepadPluginConfig.cmake + │   └── NotepadPlugin + │   └── libQSci.a + └── share + ├── applications + │   └── notepad--.desktop + └── notepad-- + └── icons + └── spark.png + + 13 directories, 71 files + + ``` \ No newline at end of file diff --git a/cmake/NotepadPluginConfig.cmake.in b/cmake/NotepadPluginConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..6a6e865c046165d541e19f8c7591770a962e5d62 --- /dev/null +++ b/cmake/NotepadPluginConfig.cmake.in @@ -0,0 +1,230 @@ +# NotepadPluginConfig.cmake +# 用于 Notepad-- 插件实现的 CMake 模块初级定义 + +# 在 Linux 中,它的布局应该如下: +# /usr/lib/x86_64-linux-gnu/cmake/NotepadPlugin/NotepadPluginConfig.cmake + +# 在 插件开发层中,它的使用如下: + # 1. 查找 NotepadPlugin 模块 + # find_package(NotepadPlugin) + # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) + # add_notepad_plugin( ...) + +# 一些无关紧要的部分,如果需要实现插件安装操作时,即可进行使用 +# include(CMakePackageConfigHelpers) +# include(GNUInstallDirs) + +# 主要内容,在构建时的填充 +set(NOTEPAD_PLUGIN @NOTEPAD_PLUGIN@) +set(NOTEPAD_BUILD_BY_QT5 @NOTEPAD_BUILD_BY_QT5@) +set(NOTEPAD_BUILD_BY_QT6 @NOTEPAD_BUILD_BY_QT6@) +set(NOTEPAD_BUILD_BY_SHARED @NOTEPAD_BUILD_BY_SHARED@) +set(NOTEPAD_PLUGIN_CORELIB @NOTEPAD_PLUGIN_CORELIB@) +set(NOTEPAD_PLUGIN_CORELIB_NAME @NOTEPAD_PLUGIN_CORELIB_NAME@) + +# 由插件开发者进行参考的 "Notepad 提供的插件安装目录(位置)" +set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY + @NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_DIRECTORY@) + +# 这些是被废除的内容 +# set(NOTEPAD_PLUGIN_INCLUDEDIR @NOTEPAD_PLUGIN_INCLUDEDIR@) +# set(NOTEPAD_PLUGIN_LIBDIR @NOTEPAD_PLUGIN_LIBDIR@) + +# 一些核心位置设定参考 +# ./usr/bin/ +# ./usr/bin/notepad-- +# ./usr/include/ +# ./usr/include/NotepadPlugin/ +# ./usr/include/NotepadPlugin/Qsci/ +# ./usr/include/NotepadPlugin/Qsci/... +# ./usr/include/NotepadPlugin/qscint/ +# ./usr/include/NotepadPlugin/qscint/scintilla/src/XPM.cp +# ./usr/lib/ +# ./usr/lib/NotepadPlugin/ +# ./usr/lib/NotepadPlugin/libQSci.a +# ./usr/lib/cmake/ +# ./usr/lib/cmake/NotepadPlugin/ +# ./usr/lib/cmake/NotepadPlugin/NotepadPluginConfig.cmake +# ^ 以此文件目录位置开始,Linux/Windows中都相同,但不是写死路径 +# ../ 为 /usr/lib/cmake 目录 +# ../../ 为 /usr/lib 目录 +# ../../../ 为 /usr 目录 +# ../../../include 为 /usr/include 目录 +# ../../../lib 为 /usr/lib 目录 + +# ../../../include/NotepadPlugin # (/usr)头文件目录(NOTEPAD_PLUGIN_INCLUDEDIR) +# ../../NotepadPlugin # (/usr/lib)库文件目录(NOTEPAD_PLUGIN_LIBDIR) +# ../../cmake # (/usr/lib)cmake文件目录(无需关心) +set(NOTEPAD_PLUGIN_INCLUDEDIR + ${CMAKE_CURRENT_LIST_DIR}/../../../include/${NOTEPAD_PLUGIN} + ${CMAKE_CURRENT_LIST_DIR}/../../../include/${NOTEPAD_PLUGIN}/Qsci) +set(NOTEPAD_PLUGIN_LIBDIR + ${CMAKE_CURRENT_LIST_DIR}/../../${NOTEPAD_PLUGIN}) + +if(NOTEPAD_BUILD_BY_QT5) + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) + set(CMAKE_AUTORCC ON) + find_package(Qt5 COMPONENTS Core Widgets REQUIRED) +endif(NOTEPAD_BUILD_BY_QT5) + +if(NOTEPAD_BUILD_BY_QT6) + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) + set(CMAKE_AUTORCC ON) + find_package(Qt6 COMPONENTS Core Widgets REQUIRED) +endif(NOTEPAD_BUILD_BY_QT6) + +if(NOTEPAD_BUILD_BY_SHARED) + add_library(${NOTEPAD_PLUGIN} SHARED IMPORTED) + set_target_properties(${${NOTEPAD_PLUGIN}} PROPERTIES + IMPORTED_LOCATION + ${NOTEPAD_PLUGIN_LIBDIR}/${NOTEPAD_PLUGIN_CORELIB_NAME} + INCLUDE_DIRECTORIES + "${NOTEPAD_PLUGIN_INCLUDEDIR}" + ) +else() + add_library(${NOTEPAD_PLUGIN} STATIC IMPORTED) + set_target_properties(${${NOTEPAD_PLUGIN}} PROPERTIES + IMPORTED_LOCATION + ${NOTEPAD_PLUGIN_LIBDIR}/${NOTEPAD_PLUGIN_CORELIB_NAME} + INCLUDE_DIRECTORIES + "${NOTEPAD_PLUGIN_INCLUDEDIR}" + ) +endif() + +if(CMAKE_HOST_UNIX) + # 在 Linux 中开启 compile_commands.json 文件输出,增强 clangd 能力 + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +endif(CMAKE_HOST_UNIX) + +# add_notepad_plugin( [...]) +# 此宏定义了,基于源代码文件构建 Notepad-- 插件时所需要的一系列流程内容 +macro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) + # aux_source_directory(${PLUGIN_VAR}_SOURCES ${ARGN}) + add_library(${PLUGIN_VAR} SHARED ${PLUGIN_SRC} ${ARGN}) + + if(CMAKE_HOST_WIN32) + # Win32 已提供宏判断 + # target_compile_definitions(${PLUGIN_VAR} PUBLIC NDD_EXPORT=export) + endif(CMAKE_HOST_WIN32) + + if(CMAKE_HOST_UNIX) + target_compile_definitions(${PLUGIN_VAR} PUBLIC NDD_EXPORT=) + endif(CMAKE_HOST_UNIX) + + # ------------ 为在不同平台构建的插件定义输出名称(尾巴) ------------- # + # 平台: Windows/MacOS/Linux + # 架构: X86_64、AMD64、ARM64、.... + # 编译器:MinGW、Cygwin、MSVC、GNU、Clang、Intel.... + # Qt版本: + set(${PLUGIN_VAR}_OUTPUT_NAME ${PLUGIN_VAR}) + + # ------- 确定平台 Apple/Linux/Windows ------------------- # + if(APPLE) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_MacOS") + elseif(UNIX AND NOT APPLE AND NOT WIN32 AND NOT ANDROID) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Linux") + elseif(WIN32) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Win32") + endif() + + # ------- 确定架构 X86_64/AMD64/ARM64/... -------------- # + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_${CMAKE_HOST_SYSTEM_PROCESSOR}") + # if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) + # if(CMAKE_APPLE_SILICON_PROCESSOR) + # string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Silicon") + # endif(CMAKE_APPLE_SILICON_PROCESSOR) + # endif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) + + # ----- 确定编译器类型 + # string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_MinGW") + if(WIN32) + if(MINGW) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_MinGW") + elseif(CYGWIN) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Cygwin") + elseif(MSVC) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_MSVC") + else() # 如果不是 MinGW、 Cygwin 、MSVC + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "") + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Unknow") + else() # 如果不是 CMAKE_CXX_COMPILER_ID 不为空 + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_${CMAKE_CXX_COMPILER_ID}") + endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "") + endif() + else() + # 此处:如果不提前进行 MINGW 判断,MINGW 也将会是 GNU + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_${CMAKE_CXX_COMPILER_ID}") + endif() + + # 预留: GNU Compiler 系列并不清楚如何区分 + # if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + # string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_GCC") + # endif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + + # + # if(NOT "${Qt5_}" STREQUAL "") + # string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_${QT_VERSION}") + # endif(NOT "${QT_VERSION}" STREQUAL "") + if(NOTEPAD_BUILD_BY_QT5) + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Qt5") + else() + string(APPEND ${PLUGIN_VAR}_OUTPUT_NAME "_Qt6") + endif(NOTEPAD_BUILD_BY_QT5) + + + set_property(TARGET ${PLUGIN_VAR} + PROPERTY + OUTPUT_NAME "${${PLUGIN_VAR}_OUTPUT_NAME}") + # ------------ 为构建的插件配置尾巴 ------------- # + + # Notepad-- 插件开发时应该使用的 头文件安装目录、库文件安装目录 + target_include_directories(${PLUGIN_VAR} PUBLIC + ${NOTEPAD_PLUGIN_INCLUDEDIR}) + target_link_directories(${PLUGIN_VAR} PUBLIC + ${NOTEPAD_PLUGIN_LIBDIR}) + target_link_libraries(${PLUGIN_VAR} ${NOTEPAD_PLUGIN_CORELIB}) + + if(NOTEPAD_BUILD_BY_QT5) + target_link_libraries(${PLUGIN_VAR} Qt5::Core Qt5::Widgets) + endif(NOTEPAD_BUILD_BY_QT5) + + if(NOTEPAD_BUILD_BY_QT6) + target_link_libraries(${PLUGIN_VAR} Qt6::Core Qt6::Widgets) + endif(NOTEPAD_BUILD_BY_QT6) + + # 这是插件实现接口中增加的 NOTEPAD_PLUGIN_MANAGER 宏开关 + # 来处理减少 Notepad-- 在编译时不需要,但在插件编译时所需要的模板内容 + + if(WIN32 AND NOTEPAD_BUILD_BY_SHARED) + target_compile_definitions(${PLUGIN_VAR} + PUBLIC + NOTEPAD_PLUGIN_MANAGER + QSCINTILLA_DLL # 取消废弃,一些插件的构建中测试为需要明确显式声明此宏 + ) + else() + target_compile_definitions(${PLUGIN_VAR} + PUBLIC + NOTEPAD_PLUGIN_MANAGER) + endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED) + +endmacro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) + +# support git plugin +# add_notepad_plugin_with_git +# 该宏定义了从指定的 git 仓库中获取插件源代码,并进行简单的构建 +macro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) + execute_process(COMMAND git clone ${GIT_REPO_URL} ${PLUGIN_VAR}_git + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + aux_source_directory(${CMAKE_BINARY_DIR}/${PLUGIN_VAR}_git/${GIT_REPO_PLUGIN_PATH} ${PLUGIN_VAR}_RESOURCES) + add_notepad_plugin(${PLUGIN_VAR} ${${PLUGIN_VAR}_RESOURCES}) +endmacro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) + +message("- >>>>>>>>>>>>>>>>>> NotepadPlugin: <<<<<<<<<<<<<<<<<<") +message(" - ${CMAKE_CURRENT_LIST_FILE}") +message(" - ${NOTEPAD_PLUGIN_INCLUDEDIR}") +message(" - ${NOTEPAD_PLUGIN_LIBDIR}") +message(" - ${NOTEPAD_PLUGIN_CORELIB}") +message(" - ${NOTEPAD_PLUGIN_CORELIB_NAME}") +message("- >>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<") diff --git a/cmake/SparkAppimageConfig.cmake b/cmake/SparkAppimageConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7384b474700e861534ffb9280fba4e69be7d35f8 --- /dev/null +++ b/cmake/SparkAppimageConfig.cmake @@ -0,0 +1,192 @@ +# SparkAppimageConfig.cmake + +# 1. 在使用时通过准备默认的 icon 与 SparkDesktopConfig.cmake 在生成 desktop 文件 + # 时进行借用 desktop 文件中的基本描述完成 spark-appimage.dekstop 文件的生成, + # 并在使用 add_appimage 时完成所有逻辑判断与目标的定义 + # add_appimage_icon + # add_appimage_desktop + # add_appimage + +# 2. 在 add_appimage 中,我们判断了是否为 cmake 提供了 LINUXDEPLOYQT 宏, + # 并获取此工具的真实路径。并继续判断了 APPIMAGETOOL 宏与该工具的真实路径。 + # 然后,创建一个目录,用于即将进行的 Appimage 打包。 + + # 通过调用 target_linuxdeploy() 来完成 linuxdeploy 的目标创建 + # 通过调用 target_appimage() 来完成 appimage 的目标创建 + +# 3. 对于 linuxdeploy 目标,大致上就是通过执行 linuxdeployqt 命令与 -appimage + # 参数来创建可用于 Appimage 打包的内容结构,并且使用一些参数来处理相关库的依赖。 + # 其次就是,将 spark-appimage.desktop 复制为 default.desktop + # 另一个就是 spark-appimage.png 复制为 default.png + +# 4. 对于 appimage 目标,大致上就是通过执行 appimagetool 命令将准备好打包的目录 + # 结构进行打包为 Appimage 可执行文件,其中为了避免可能缺失的文件,重复了对 + # default.desktop 文件与 default.png 文件的生成。 + # 这是一个依赖的 copy-desktop-appimage 目标,并先行执行 + +# 要求: + # LINUXDEPLOYQT 提供的外部参数,一般指 linuxdeployqt 程序路径 + # APPIMAGETOOL 提供的外部参数,一般指 appimagetool 程序路径 + +option(USE_APPIMAGE_NEW_GLIBC "允许在打包过程中使用较新版本的 glibc 库" ON) + +set(APPIMAGE_OUTPUT "${CMAKE_BINARY_DIR}/appimage") +set(APPIMAGE_OUTPUT_ICON "${APPIMAGE_OUTPUT}/default.png") +set(APPIMAGE_OUTPUT_DESTKOP "${APPIMAGE_OUTPUT}/default.desktop") + +# 1. 添加一个可以用于 Appimage 使用的图标文件 +function(add_appimage_icon _icon) + if(CMAKE_VERSION VERSION_LESS 3.21) + message("> cmake version is less than 3.21") + configure_file(${_icon} ${APPIMAGE_OUTPUT_ICON} COPYONLY) + else() + file(MAKE_DIRECTORY ${APPIMAGE_OUTPUT}) + file(COPY_FILE ${_icon} ${APPIMAGE_OUTPUT_ICON}) + endif(CMAKE_VERSION VERSION_LESS 3.21) +endfunction(add_appimage_icon _icon) + +# 2. 基于 SparkDesktopMacros.cmake 提供的宏来定义 desktop 内容说明 + # 使用与自身的 desktop.in 模板进行生成 +function(add_appimage_desktop) + configure_file(cmake/spark-appimage.desktop.in.txt + ${APPIMAGE_OUTPUT_DESTKOP} @ONLY) +endfunction(add_appimage_desktop) + +function(target_linuxdeploy _target) + + if(USE_APPIMAGE_NEW_GLIBC) + message("Use New glibc") + add_custom_target(linuxdeploy pwd + BYPRODUCTS appimage + COMMAND "${LINUXDEPLOYQT}" $ -appimage -unsupported-allow-new-glibc -verbose=3 -no-strip || true + WORKING_DIRECTORY "${APPIMAGE_OUTPUT}") + else() + message("Un Use New glibc") + add_custom_target(linuxdeploy pwd + BYPRODUCTS appimage + COMMAND "${LINUXDEPLOYQT}" $ -appimage -verbose=3 -no-strip || true + WORKING_DIRECTORY "${APPIMAGE_OUTPUT}") + endif(USE_APPIMAGE_NEW_GLIBC) + +endfunction(target_linuxdeploy _target) + +function(target_appimage) + add_custom_target(appimage pwd + COMMAND ${APPIMAGETOOL} ${APPIMAGE_OUTPUT} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +endfunction(target_appimage) + +# 3. 添加对目标的 Appimage 构建,Appimage 在一个项目中只能构建一个目标 +function(add_appimage_target _target) + # check linuxdeploy + if(NOT DEFINED LINUXDEPLOYQT) + message("AppImage> Not Found LINUXDEPLOYQT Variable!") + return() + endif(NOT DEFINED LINUXDEPLOYQT) + if(CMAKE_VERSION VERSION_LESS 3.19) + message("> cmake version is less than 3.19") + if(CMAKE_VERSION VERSION_GREATER 3.4) + get_filename_component(LINUXDEPLOYQT_REAL_PATH ${LINUXDEPLOYQT} REALPATH) + else() + message("> cmake version is less than 3.4") + message(WARNING "!Relative paths are not supported!") + endif(CMAKE_VERSION VERSION_GREATER 3.4) + else() + file(REAL_PATH ${LINUXDEPLOYQT} LINUXDEPLOYQT_REAL_PATH) + endif(CMAKE_VERSION VERSION_LESS 3.19) + 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) + # execute_process(COMMAND realpath ${APPIMAGETOOL} OUTPUT_VARIABLE APPIMAGETOOL_REAL_PATH) + message("> cmake version is less than 3.19") + if(CMAKE_VERSION VERSION_GREATER 3.4) + get_filename_component(APPIMAGETOOL_REAL_PATH ${APPIMAGETOOL} REALPATH) + else() + message("> cmake version is less than 3.4") + message(WARNING "!Relative paths are not supported!") + endif(CMAKE_VERSION VERSION_GREATER 3.4) + else() + file(REAL_PATH ${APPIMAGETOOL} APPIMAGETOOL_REAL_PATH) + endif(CMAKE_VERSION VERSION_LESS 3.19) + message("AppImage> Found APPIMAGETOOL Variable: ${APPIMAGETOOL}") + + # do add_custome_target + make_directory(${APPIMAGE_OUTPUT}) + target_linuxdeploy(${_target}) + target_appimage() + + # 重设目标输出的目录 + set_target_properties(${_target} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APPIMAGE_OUTPUT}") + + # 为解决在不使用 -unsupported-allow-new-glibc 参数时, + # 可能不会生成 AppRun 软链接的问题 + if(NOT USE_APPIMAGE_NEW_GLIBC) + set_target_properties(${_target} + PROPERTIES + RUNTIME_OUTPUT_NAME "AppRun") + endif(NOT USE_APPIMAGE_NEW_GLIBC) + +endfunction(add_appimage_target _target) + + +# 如果 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 的使用 +# ./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_target(${PROJECT_NAME}) # 添加到 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 + + + +# NOTE: +# 如果使用的库不存在于系统路径,则需要配置 export LD_LIBRARY_PATH=<路径> 以便 linuxdeployqt 可搜索到库的位置 diff --git a/cmake/SparkBuildGraphviz.cmake b/cmake/SparkBuildGraphviz.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ce9dbc3149a1af3e257a26d300986d081f8c74f9 --- /dev/null +++ b/cmake/SparkBuildGraphviz.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.5.1) + +# 添加构建项目依赖图目标: make builddeps +add_custom_target(builddeps + COMMAND "${CMAKE_COMMAND}" "--graphviz=graphviz/builddeps.dot" . + COMMAND dot -Tpng graphviz/builddeps.dot -o builddeps.png + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" +) \ No newline at end of file diff --git a/cmake/SparkDebPackageConfig.cmake b/cmake/SparkDebPackageConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..fe275e149dc0f39b90ef36d8868f0f9718da48ff --- /dev/null +++ b/cmake/SparkDebPackageConfig.cmake @@ -0,0 +1,366 @@ +cmake_minimum_required(VERSION 3.0.0) + +# function(add_deb_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_MAINTAINER PACKAGE_EMAIL PACKAGE_SHORT_DESCRIPTION PACKAGE_LONG_DESCRIPTION) + +# endfunction(add_deb_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_MAINTAINER PACKAGE_EMAIL PACKAGE_SHORT_DESCRIPTION PACKAGE_LONG_DESCRIPTION) + +# if(add_deb_package VALUE) set(Package ${VALUE} PARENT_SCOPE) endif(add_deb_package VALUE) +# if(add_deb_version VALUE) set(Version ${VALUE} PARENT_SCOPE) endif(add_deb_version VALUE) +# if(add_deb_maintainer VALUE) set(Maintainer ${VALUE} PARENT_SCOPE) endif(add_deb_maintainer VALUE) +# if(add_deb_email VALUE) set(Email ${VALUE} PARENT_SCOPE) endif(add_deb_email VALUE) +# if(add_deb_descrition VALUE) set(Descrition ${VALUE} PARENT_SCOPE) endif(add_deb_descrition VALUE) +# if(add_deb_detail VALUE) set(Detail ${VALUE} PARENT_SCOPE) endif(add_deb_detail VALUE) + + +# set(Package "") +# set(Version "") +# set(Architecture "") +# set(Maintainer "") +# set(Email "") +# set(Descrition "") + +function(find_str _IN _SEP _OUT) + string(FIND "${_IN}" "${_SEP}" _TMP) + set(${_OUT} ${_TMP} PARENT_SCOPE) +endfunction(find_str _IN _SEP _OUT) + + +function(find_next _IN _OUT) + find_str("${_IN}" "\n" _TMP) + set(${_OUT} ${_TMP} PARENT_SCOPE) +endfunction(find_next _IN _OUT) + +function(sub_next _IN _INDEX _OUT __OUT) + find_next(${_IN} _NEXTINDEX) + string(SUBSTRING "${_IN}" ${_INDEX} ${_NEXTINDEX} _TMP) + math(EXPR _NEXTINDEX ${_NEXTINDEX}+1) + string(SUBSTRING "${_IN}" ${_NEXTINDEX} -1 __TMP) + set(${_OUT} ${_TMP} PARENT_SCOPE) + set(${__OUT} ${__TMP} PARENT_SCOPE) +endfunction(sub_next _IN _INDEX _OUT) + +function(trim_str _IN _OUT) + string(STRIP "${_IN}" _TMP) + set(${_OUT} ${_TMP} PARENT_SCOPE) +endfunction(trim_str _IN _OUT) + +function(split_str _IN _SEP _OUT) + string(FIND "${_IN}" "${_SEP}" _TMP_INDEX) + if(NOT _TMP_INDEX EQUAL -1) + string(SUBSTRING "${_IN}" 0 ${_TMP_INDEX} _TMP) + math(EXPR _TMP_INDEX ${_TMP_INDEX}+1) + string(SUBSTRING "${_IN}" ${_TMP_INDEX} -1 __TMP) + set(${_OUT} "${_TMP};${__TMP}" PARENT_SCOPE) + else() + set(${_OUT} ${_IN} PARENT_SCOPE) + endif(NOT _TMP_INDEX EQUAL -1) +endfunction(split_str _IN _SEP _OUT) + +function(split_str_p _IN _SEP _OUT __OUT) + split_str("${_IN}" "${_SEP}" _TMP) + list(GET _TMP 0 __TMP) + list(GET _TMP 1 ___TMP) + set(${_OUT} ${__TMP} PARENT_SCOPE) + set(${__OUT} ${___TMP} PARENT_SCOPE) +endfunction(split_str_p _IN _SEP _OUT __OUT) + +function(split_str_n _IN _SEP _OUT _N) + if(_N GREATER 1) + set(_C ${_N}) + set(_RET "") + set(_NEXT ${_IN}) + while(NOT _C EQUAL 0) + split_str("${_NEXT}" "${_SEP}" _TMP) + list(LENGTH _TMP _TMP_LEN) + if(_TMP_LEN EQUAL 2) + list(GET _TMP 0 __TMP) + list(GET _TMP 1 _NEXT) + list(APPEND _RET ${__TMP}) + else() + break() + endif(_TMP_LEN EQUAL 2) + math(EXPR _C "${_C}-1") + endwhile(NOT _C EQUAL 0) + list(APPEND _RET ${_NEXT}) + set(${_OUT} ${_RET} PARENT_SCOPE) + else() + split_str("${_IN}" "${_SEP}" _TMP) + set(${_OUT} ${_TMP} PARENT_SCOPE) + endif(_N GREATER 1) +endfunction(split_str_n _IN _SEP _OUT _N) + + +function(set_package_vars _IN_KEY _IN_VAL) + + # trim_str("${_IN_KEY}" _IN_KEY) + + find_str("${_IN_KEY}" "Type" _Type) + if(_Type EQUAL "0") + string(TOUPPER "${_IN_VAL}" _IN_VAL_UPPER) + string(TOLOWER "${_IN_VAL}" _IN_VAL_LOWER) + set(CPACK_GENERATOR "${_IN_VAL_UPPER}" PARENT_SCOPE) + message("--> 软件包类型: ${_IN_VAL_LOWER}") + endif(_Type EQUAL "0") + + find_str("${_IN_KEY}" "Package" _Package) + if(_Package EQUAL "0") + if(_IN_VAL STREQUAL "auto") + set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}" PARENT_SCOPE) + else() + set(CPACK_DEBIAN_PACKAGE_NAME "${_IN_VAL}" PARENT_SCOPE) + endif(_IN_VAL STREQUAL "auto") + message("--> 软件包名: ${_IN_VAL}") + endif(_Package EQUAL "0") + + find_str("${_IN_KEY}" "Version" _Version) + if(_Version EQUAL "0") + if(_IN_VAL STREQUAL "auto") + set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}" PARENT_SCOPE) + else() + set(CPACK_DEBIAN_PACKAGE_VERSION "${_IN_VAL}" PARENT_SCOPE) + endif(_IN_VAL STREQUAL "auto") + + message("--> 软件版本: ${_IN_VAL}") + endif(_Version EQUAL "0") + + find_str("${_IN_KEY}" "CalVer" _CalVer) + if(_CalVer EQUAL "0") + set(CalVer "${_IN_VAL}" PARENT_SCOPE) + message("--> 日历化版本: ${_IN_VAL}") + endif(_CalVer EQUAL "0") + + find_str("${_IN_KEY}" "OSD" _OSDVer) + if(_OSDVer EQUAL "0") + set(OSDVer "${_IN_VAL}" PARENT_SCOPE) + message("--> 声明发行版号: ${_IN_VAL}") + endif(_OSDVer EQUAL "0") + + find_str("${_IN_KEY}" "Architecture" _Architecture) + if(_Architecture EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_IN_VAL}" PARENT_SCOPE) + if(_IN_VAL STREQUAL "auto") + execute_process( + COMMAND dpkg --print-architecture + OUTPUT_VARIABLE _RETV + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_RETV}" PARENT_SCOPE) + endif(_IN_VAL STREQUAL "auto") + message("--> 软件架构: ${_IN_VAL}") + endif(_Architecture EQUAL "0") + + find_str("${_IN_KEY}" "Priority" _Priority) + if(_Priority EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_PRIORITY "${_IN_VAL}" PARENT_SCOPE) + message("--> 优先级: ${_IN_VAL}") + endif(_Priority EQUAL "0") + + find_str("${_IN_KEY}" "Depends" _Depends) + if(_Depends EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${_IN_VAL}" PARENT_SCOPE) + message("--> 软件依赖: ${_IN_VAL}") + endif(_Depends EQUAL "0") + + find_str("${_IN_KEY}" "Maintainer" _Maintainer) + if(_Maintainer EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${_IN_VAL}" PARENT_SCOPE) + message("--> 软件维护者: ${_IN_VAL}") + endif(_Maintainer EQUAL "0") + + find_str("${_IN_KEY}" "Homepage" _Homepage) + if(_Homepage EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${_IN_VAL}" PARENT_SCOPE) + message("--> 软件主页: ${_IN_VAL}") + endif(_Homepage EQUAL "0") + + find_str("${_IN_KEY}" "Recommends" _Recommends) + if(_Recommends EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "${_IN_VAL}" PARENT_SCOPE) + message("--> 软件建议: ${_IN_VAL}") + endif(_Recommends EQUAL "0") + + find_str("${_IN_KEY}" "Conflicts" _Conflicts) + if(_Conflicts EQUAL "0") + set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${_IN_VAL}" PARENT_SCOPE) + message("--> 软件冲突: ${_IN_VAL}") + endif(_Conflicts EQUAL "0") + +endfunction(set_package_vars _IN_KEY _IN_VAL) + +# 定义一个自定义(add_package_descript)函数 +# 用于按特定配置约定自动化构建软件包配置 +function(add_package_descript IN_DES) + set(PACKAGE_DES_PATH "${IN_DES}") + + if(EXISTS ${IN_DES}) + + elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES}") + set(PACKAGE_DES_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES}") + else() + message(FATAL_ERROR "!! Not Found Path: ${PACKAGE_DES_PATH}") + return() + endif(EXISTS ${IN_DES}) + + file(READ ${PACKAGE_DES_PATH} DES_CONTENT) + trim_str("${DES_CONTENT}" DES_CONTENT) + + ################## 解析 ################## + + sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) + set(PREV_DES "") + while(NOT DES_LINE STREQUAL "${PREV_DES}") + # 检查该描述行是否是 # 注释开头,是的话将跳过该行 + find_str("${DES_LINE}" "#" _COMMENT) + if(_COMMENT EQUAL "0") + message("--> !!!!!!! ${DES_LINE}") + sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) + continue() + endif(_COMMENT EQUAL "0") + + # 检查该描述行是否是 Descrition 开头,是的话说明描述结尾了 + find_str("${DES_LINE}" "Descrition" _DESCRIPTION) + if(_DESCRIPTION EQUAL "0") + break() + endif(_DESCRIPTION EQUAL "0") + + split_str_n("${DES_LINE}" ":" _TMP 1) + list(LENGTH _TMP _TMP_LEN) + + if(_TMP_LEN EQUAL 2) + split_str_p("${DES_LINE}" ":" _TMP __TMP) + trim_str("${__TMP}" __TMP) + string(LENGTH "${__TMP}" __TMP_LENGTH) + if(NOT __TMP_LENGTH EQUAL "0") + set_package_vars("${_TMP}" "${__TMP}") + endif(NOT __TMP_LENGTH EQUAL "0") + endif(_TMP_LEN EQUAL 2) + + # 记录当前行,获取下一行,可能是已经结尾了(将保持重复行) + set(PREV_DES "${DES_LINE}") + sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) + endwhile(NOT DES_LINE STREQUAL "${PREV_DES}") + + + # 再一次检查该描述行是否是 Descrition 开头,是的话将进行分析描述行 + find_str("${DES_LINE}" "Descrition" _DESCRIPTION) + if(_DESCRIPTION EQUAL "0") + split_str_p("${DES_LINE}" ":" _TMP __TMP) + trim_str("${__TMP}" __TMP) + set(Descrition ${__TMP}) + set(PREV_DES_LINE "") + while(NOT PREV_DES_LINE STREQUAL DES_LINE) + if(NOT PREV_DES_LINE STREQUAL "") + if ("${CMAKE_VERSION}" VERSION_LESS "3.15") + set(Descrition "${Descrition}\n${DES_LINE}") + else() + string(STRIP "${DES_LINE}" STRIP_DES_LINE) + set(Descrition "${Descrition}\n${STRIP_DES_LINE}") + endif("${CMAKE_VERSION}" VERSION_LESS "3.15") + endif(NOT PREV_DES_LINE STREQUAL "") + set(PREV_DES_LINE "${DES_LINE}") + sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) + endwhile(NOT PREV_DES_LINE STREQUAL DES_LINE) + # set(Descrition "${Descrition}") + message("--> 软件说明: ${Descrition}") + + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${Descrition}) + endif(_DESCRIPTION EQUAL "0") + + ##################### deb ##################### + # ARCHITECTURE + if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") + set(ARCHITECTURE "amd64") + elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64") + set(ARCHITECTURE "arm64") + endif() + + #################### Calendar Version ################### + if("${CalVer}" STREQUAL "true") + string(TIMESTAMP BUILD_TIME "%Y%m%d") + set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}-${BUILD_TIME}") + endif("${CalVer}" STREQUAL "true") + + + ####################### OS Release ###################### + if("${OSDVer}" STREQUAL "true") + exec_program(lsb_release ARGS -si + OUTPUT_VARIABLE _OSI + ) + exec_program(lsb_release ARGS -sr + OUTPUT_VARIABLE _OSR + ) + if(NOT "${_OSI}" STREQUAL "" AND NOT "${_OSR}" STREQUAL "") + set(PACKAGE_SUFFIX "${PACKAGE_SUFFIX}_${_OSI}${_OSR}") + endif(NOT "${_OSI}" STREQUAL "" AND NOT "${_OSR}" STREQUAL "") + endif("${OSDVer}" STREQUAL "true") + + + + ##################### deb file name ##################### + set(_Package "${CPACK_DEBIAN_PACKAGE_NAME}") + set(_Version "${CPACK_DEBIAN_PACKAGE_VERSION}") + set(_Architecture "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + + set(_DebFileName + "${_Package}_${_Version}_${_Architecture}${PACKAGE_SUFFIX}.deb" + ) + set(CPACK_DEBIAN_FILE_NAME ${_DebFileName}) + + # 标识: spark-deb-package + if(NOT "${PACKAGE_SUFFIX}" STREQUAL "") + # eg: remove '_' of '_Debian' + string(SUBSTRING "${PACKAGE_SUFFIX}" 1 -1 DISTRIBUTION) + if ("${CMAKE_VERSION}" VERSION_LESS "3.15") + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${Descrition}\n .\n Build for ${DISTRIBUTION} through spark-deb-build.") + else() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${Descrition} "\n.\nBuild for ${DISTRIBUTION} through spark-deb-build.") + endif("${CMAKE_VERSION}" VERSION_LESS "3.15") + + endif(NOT "${PACKAGE_SUFFIX}" STREQUAL "") + + # set(CPACK_DEBIAN_PACKAGE_NAME "${Package}") + # set(CPACK_DEBIAN_PACKAGE_VERSION "${Version}") + # set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${Architecture}") + # set(CPACK_DEBIAN_PACKAGE_DEPENDS "${Depends}") + # set(CPACK_DEBIAN_PACKAGE_PRIORITY "${Priority}") + # set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${Maintainer}") + # set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${Descrition}") + + # 设置即将使用的标准脚本 + # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + # "${CMAKE_SOURCE_DIR}/config/DEBIAN/preinst" + # "${CMAKE_SOURCE_DIR}/config/DEBIAN/postinst" + # "${CMAKE_SOURCE_DIR}/config/DEBIAN/prerm" + # "${CMAKE_SOURCE_DIR}/config/DEBIAN/postrm" + # ) + + # 设置为ON,以便使用 dpkg-shlibdeps 生成更好的包依赖列表。 + # set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) + # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") + + include(CPack) + +endfunction(add_package_descript IN_DES) + + +# TODO: +# CPACK_GENERATOR +# CPACK_DEBIAN_FILE_NAME - n +# CPACK_DEBIAN_PACKAGE_NAME - y +# CPACK_DEBIAN_PACKAGE_VERSION - y +# CPACK_DEBIAN_PACKAGE_ARCHITECTURE - y(auto) -> dpkg --print-architecture +# CPACK_DEBIAN_PACKAGE_DEPENDS - y +# CPACK_DEBIAN_PACKAGE_PRIORITY - y +# CPACK_DEBIAN_PACKAGE_MAINTAINER - y +# CPACK_DEBIAN_PACKAGE_DESCRIPTION - y + +# ARCHITECTURE +# if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") +# set(ARCHITECTURE "amd64") +# elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64") +# set(ARCHITECTURE "arm64") +# endif() + + +# string(TIMESTAMP BUILD_TIME "%Y%m%d") diff --git a/cmake/SparkDesktopMacros.cmake b/cmake/SparkDesktopMacros.cmake new file mode 100644 index 0000000000000000000000000000000000000000..bea9da8a0ac8add8a0ee2a7103eb141d61c87778 --- /dev/null +++ b/cmake/SparkDesktopMacros.cmake @@ -0,0 +1,50 @@ +# SparkDesktopMacros.cmake + +macro(spark_desktop_macros) + set(APP_NAME ${ARGV0}) + set(APP_NAME_ZH_CN ${ARGV1}) + set(APP_COMMENT ${ARGV2}) + set(APP_TYPE ${ARGV3}) + set(APP_EXECUTE_PATH ${ARGV4}) + set(APP_EXECUTE_ICON_PATH ${ARGV5}) + set(APP_CATEGORIES ${ARGV6}) + set(APP_MIME_TYPE ${ARGV7}) + configure_file(cmake/spark-desktop.desktop.in.txt + ${CMAKE_BINARY_DIR}/${ARGV0}.desktop + ) + set(SPARK_DESKTOP_FILE ${CMAKE_BINARY_DIR}/${ARGV0}.desktop) +endmacro(spark_desktop_macros) + +# include(cmake/SparkDesktopMacros.cmake) +# 内容默认应用名称: Name= 应与项目名称相同 +# spark_desktop_macros( + # 应用名称: Name= + # 应用名称: Name[zh_CN]= + # 应用说明: Comment= + # 应用类型: Type= + # 执行程序: Exec= + # 图标路径: Icon= + # 应用分类: Categories= + # MIME类型: MimeType= +# ) + +# TODO 安装位置:INSTALL(将自动实现 install 文件,如 /usr/share/applications) + +# install(FILES ${APP_NAME}.desktop +# DESTINATION /usr/share/applications +# ) + # 或者 +# install(FILES ${SPARK_DESKTOP_FILE} +# DESTINATION /usr/share/applications +# ) + +# 基于 configure_file 填充内容配置 +# configure_file( +# [NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS | +# FILE_PERMISSIONS ...] +# [COPYONLY] [ESCAPE_QUOTES] [@ONLY] +# [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) + +# install(FILES ${SPARK_DESKTOP_FILE}.desktop +# DESTINATION /usr/share/applications +# ) diff --git a/cmake/SparkEnvConfig.cmake b/cmake/SparkEnvConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cbc334cba0f7e57f426e73b6de2f220f0c9ceca9 --- /dev/null +++ b/cmake/SparkEnvConfig.cmake @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.5.1) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +# set(CMAKE_BUILD_TYPE "Debug") + +option(SPARK_DEBUG_MESSAGE "CMake Spark Module Debug Message." OFF) +set(SPAKK_DEBUG_LOGFILE "${CMAKE_BINARY_DIR}/spark_debug.log" CACHE STRING "Spark Build Debug logfile." FORCE) +file(WRITE ${SPAKK_DEBUG_LOGFILE}) + +macro(spark_debug_message) + if(SPARK_DEBUG_MESSAGE) + set(SPARK_ONECE_LOG ${ARGN}) + message("[SPARK_MESSAGE]: " ${SPARK_ONECE_LOG}) + file(APPEND ${SPAKK_DEBUG_LOGFILE} ${SPARK_ONECE_LOG} "\n") + unset(SPARK_ONECE_LOG) + endif(SPARK_DEBUG_MESSAGE) +endmacro(spark_debug_message) + diff --git a/cmake/SparkFindDtkConfig.cmake b/cmake/SparkFindDtkConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..278d0d11e01df64e87afd7620dcece0b846c31ec --- /dev/null +++ b/cmake/SparkFindDtkConfig.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.5.1) + +# include(SparkFindQt5Config.cmake) +find_package(Dtk COMPONENTS Core Widget Gui) + +function(target_link_dtk NAME) + target_link_libraries(${NAME} + ${DtkCore_LIBRARIES} + ${DtkWidget_LIBRARIES} + ${DtkGui_LIBRARIES}) +endfunction(target_link_dtk NAME) \ No newline at end of file diff --git a/cmake/SparkFindLibraries.cmake b/cmake/SparkFindLibraries.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a1b936c150cd82dd3f2eea521fa4f9020628378a --- /dev/null +++ b/cmake/SparkFindLibraries.cmake @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.5.1) + +# spark_find_library(notify libnotify) + +# function(target_link_${_prefix} TARGET) +# target_link_libraries(${TARGET} ${_prefix}) +# endfunction(target_link_${_prefix} TARGET) \ No newline at end of file diff --git a/cmake/SparkFindQt5Config.cmake b/cmake/SparkFindQt5Config.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6f021e6606d78dfca82a0363cc1c9b2dcfac3984 --- /dev/null +++ b/cmake/SparkFindQt5Config.cmake @@ -0,0 +1,153 @@ +cmake_minimum_required(VERSION 3.5.1) + +set(SPARK_FIND_QT5 TRUE) + +find_package(Qt5 COMPONENTS Core Widgets Network REQUIRED) + +# function(target_link_qt5 NAME) +# target_link_libraries(${NAME} +# Qt5::Core +# Qt5::Widgets +# Qt5::Network) +# endfunction(target_link_qt5 NAME) + +# 使用 spark_add_link 生成 target_link_qt5 以替代上面内容 +spark_add_link(qt5 Qt5::Core Qt5::Widgets Qt5::Network) + + +# spark_add_link_qt5 +# 自定义宏 spark_add_link_qt5 以扩展 target_link_qt5_ 结构 + # _IN_NAME: 此宏使用嵌套宏 spark_add_link 时追加 名称 + # 同等于 spark_add_link(qt_ ${ARGN}) +macro(spark_add_link_qt5 _IN_NAME) + spark_add_link(qt5_${_IN_NAME} ${ARGN}) +endmacro(spark_add_link_qt5 _IN_NAME) + +# 使用 spark_add_link_qt5 生成 target_link_qt5_ 的宏 +# spark_add_link_qt5(Concurrent Qt5::Concurrent) + +# 高级自定义 +# spark_add_links_qt5 +# 自定义宏 spark_add_links_qt5 以扩展 spark_add_link_qt5 宏配置组 + # 特点: 任意长度参数 + # qt5_item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) + # 例如: qt5_item 为 Core: + # spark_add_link_qt5(${qt5_item} Qt5::${qt5_item}) + # 展开为 spark_add_link_qt5(Core Qt5::Core) + # 展开为 spark_add_link(qt5_Core Qt5::Core) + # 展开为 spark_add_link(qt5_Core Qt5::Core) + # 特性: 增加 qt5_Core 转 qt5_core + # string(TOLOWER ) +macro(spark_add_links_qt5) + set(qt5_items ${ARGN}) + foreach(qt5_item IN LISTS qt5_items) + find_package(Qt5${qt5_item}) + spark_add_link_qt5(${qt5_item} Qt5::${qt5_item}) + + string(TOLOWER "${qt5_item}" qt5_lower_item) + spark_add_link_qt5(${qt5_lower_item} Qt5::${qt5_item}) + spark_debug_message("add_target_link_qt5_${qt5_item} or add_target_link_qt5_${qt5_lower_item}") + endforeach(qt5_item IN LISTS qt5_items) +endmacro(spark_add_links_qt5) + + +# Core 用于其它模块的核心非图形类。 +# GUI 图形用户界面 GUI 组件基类。包括 OpenGL。 +# Multimedia 音频 视频 无线电 摄像头功能类。 +# Multimedia Widgets 用于实现多媒体功能,基于 Widget 的类。 +# Network 使网络编程更容易和更可移植的类。 + +# QML QML 和 JavaScript 语言类。 +# Quick 以自定义用户界面 UI 构建高动态应用程序的声明性框架。 +# Quick Controls 为桌面、嵌入式及移动设备创建高性能用户界面提供轻量 QML 类型。这些类型运用简单样式化体系结构且非常高效。 +# Quick Dialogs 用于从 Qt Quick 应用程序创建系统对话框,并与之交互的类型。 +# Quick Layouts 布局是用于在用户界面中排列基于 Qt Quick 2 项的项。 +# Quick Test 用于 QML 应用程序的单元测试框架,其测试案例被编写成 JavaScript 函数。 + # 注意: 二进制保证不兼容 Qt Quick Test,但源代码仍兼容。 + +# Qt SQL 集成使用 SQL 数据库的类。 +# Qt Test 单元测试 Qt 应用程序和库的类。 + # 注意: 二进制保证不兼容 Qt Test,但源代码仍兼容。 +# Qt Widgets 以 C++ 小部件扩展 Qt GUI 的类。 + + + +# 找出所有 Qt5 模板 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 + +# 掐头去尾,洗一次 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' + +# 排序 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 + +spark_add_links_qt5( + # AccessibilitySupport + # AttributionsScannerTools + Concurrent + # Core + # DBus + # Designer + # DesignerComponents + # DeviceDiscoverySupport + # DocTools + # EdidSupport + # EglFSDeviceIntegration + # EglFsKmsSupport + # EglSupport + # EventDispatcherSupport + # FbSupport + # FontDatabaseSupport + # GlxSupport + Gui + # Help + # InputSupport + # KmsSupport + # LinguistTools + # LinuxAccessibilitySupport + # Network + # OpenGL + # OpenGLExtensions + # PacketProtocol + # PlatformCompositorSupport + # Positioning + # PositioningQuick + PrintSupport + # Qml + # QmlDebug + # QmlDevTools + # QmlImportScanner + # QmlModels + # QmlWorkerScript + # Quick + # QuickCompiler + # QuickControls2 + # QuickParticles + # QuickShapes + # QuickTemplates2 + # QuickTest + # QuickWidgets + # SerialBus + # SerialPort + # ServiceSupport + # Sql + # Svg + # Test + # ThemeSupport + # UiPlugin + # UiTools + # VulkanSupport + # WebChannel + # WebEngine + # WebEngineCore + # WebEngineWidgets + # WebKit + # WebKitWidgets + # WebSockets + # Widgets + # X11Extras + # XcbQpa + # XkbCommonSupport + # Xml + XmlPatterns +) \ No newline at end of file diff --git a/cmake/SparkFindQt6Config.cmake b/cmake/SparkFindQt6Config.cmake new file mode 100644 index 0000000000000000000000000000000000000000..95ba2bd066d1121e157fbc57afabc0ce0690b67d --- /dev/null +++ b/cmake/SparkFindQt6Config.cmake @@ -0,0 +1,130 @@ +cmake_minimum_required(VERSION 3.5.1) + +set(SPARK_FIND_QT6 TRUE) + +find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) + +# function(target_link_qt6 NAME) +# target_link_libraries(${NAME} +# Qt6::Core +# Qt6::Widgets +# Qt6::Network) +# endfunction(target_link_qt6 NAME) + +# 使用 spark_add_link 生成 target_link_qt6 以替代上面内容 +spark_add_link(qt6 Qt6::Core Qt6::Widgets Qt6::Network) + + +# spark_add_link_qt6 +# 自定义宏 spark_add_link_qt6 以扩展 target_link_qt6_ 结构 + # _IN_NAME: 此宏使用嵌套宏 spark_add_link 时追加 名称 + # 同等于 spark_add_link(qt_ ${ARGN}) +macro(spark_add_link_qt6 _IN_NAME) + spark_add_link(qt6_${_IN_NAME} ${ARGN}) +endmacro(spark_add_link_qt6 _IN_NAME) + +# 使用 spark_add_link_qt6 生成 target_link_qt6_ 的宏 +# spark_add_link_qt5(Concurrent Qt6::Concurrent) + +# 高级自定义 +# spark_add_links_qt6 +# 自定义宏 spark_add_links_qt6 以扩展 spark_add_link_qt6 宏配置组 + # 特点: 任意长度参数 + # qt6_item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) + # 例如: qt6_item 为 Core: + # spark_add_link_qt6(${qt6_item} Qt6::${qt6_item}) + # 展开为 spark_add_link_qt6(Core Qt6::Core) + # 展开为 spark_add_link(qt6_Core Qt6::Core) + # 展开为 spark_add_link(qt6_Core Qt6::Core) + # 特性: 增加 qt6_Core 转 qt6_core + # string(TOLOWER ) +macro(spark_add_links_qt6) + set(qt6_items ${ARGN}) + foreach(qt6_item IN LISTS qt6_items) + find_package(Qt6${qt6_item}) + spark_add_link_qt6(${qt6_item} Qt6::${qt6_item}) + + string(TOLOWER "${qt6_item}" qt6_lower_item) + spark_add_link_qt6(${qt6_lower_item} Qt6::${qt6_item}) + spark_debug_message("add_target_link_qt6_${qt6_item} or add_target_link_qt6_${qt6_lower_item}") + endforeach(qt6_item IN LISTS qt6_items) +endmacro(spark_add_links_qt6) + +# 找出所有 Qt6 模板 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt6@Qt6@;' | grep ^Qt6 + +# 掐头去尾,洗一次 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' + +# 排序 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 +# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt6@Qt6@;' | grep ^Qt6 | sed 's@^Qt6@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 + +spark_add_links_qt6( + # BuildInternals + # BuildInternals/StandaloneTests/Qt5CompatTests + # BuildInternals/StandaloneTests/QtBaseTests + Concurrent + # Core + Core5Compat + # CoreTools + # DBus + # DBusTools + # DeviceDiscoverySupportPrivate + # EglFSDeviceIntegrationPrivate + # EglFsKmsGbmSupportPrivate + # EglFsKmsSupportPrivate + # FbSupportPrivate + # Gui + # GuiTools + # HostInfo + # InputSupportPrivate + # KmsSupportPrivate + # Network + # OpenGL + # OpenGLWidgets + PrintSupport + # QComposePlatformInputContextPlugin + # QCupsPrinterSupportPlugin + # QEglFSEmulatorIntegrationPlugin + # QEglFSIntegrationPlugin + # QEglFSKmsEglDeviceIntegrationPlugin + # QEglFSKmsGbmIntegrationPlugin + # QEglFSX11IntegrationPlugin + # QEvdevKeyboardPlugin + # QEvdevMousePlugin + # QEvdevTabletPlugin + # QEvdevTouchScreenPlugin + # QGifPlugin + # QGtk3ThemePlugin + # QIBaseDriverPlugin + # QIbusPlatformInputContextPlugin + # QICOPlugin + # QJpegPlugin + # QLibInputPlugin + # QLinuxFbIntegrationPlugin + # QMinimalEglIntegrationPlugin + # QMinimalIntegrationPlugin + # QMYSQLDriverPlugin + # QNetworkManagerNetworkInformationPlugin + # QODBCDriverPlugin + # QOffscreenIntegrationPlugin + # QPSQLDriverPlugin + # QSQLiteDriverPlugin + # QTlsBackendCertOnlyPlugin + # QTlsBackendOpenSSLPlugin + # QTsLibPlugin + # QTuioTouchPlugin + # QVkKhrDisplayIntegrationPlugin + # QVncIntegrationPlugin + # QXcbEglIntegrationPlugin + # QXcbGlxIntegrationPlugin + # QXcbIntegrationPlugin + # QXdgDesktopPortalThemePlugin + # Sql + # Test + # Widgets + # WidgetsTools + # XcbQpaPrivate + # Xml +) \ No newline at end of file diff --git a/cmake/SparkInstallMacrosConfig.cmake b/cmake/SparkInstallMacrosConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..204d16ae83919b0ebad3507945e5e782a64eaa6d --- /dev/null +++ b/cmake/SparkInstallMacrosConfig.cmake @@ -0,0 +1,132 @@ + +# spark_install_target +# 基于传入的路径/目标进行安装 +# 可接受的值为: 安装路径 目标A +# 可接受的值为: 安装路径 目标A 目标B 目标C... +macro(spark_install_target INSTALL_TARGET_DIR INSTALL_TARGETS) + install(TARGETS + ${INSTALL_TARGETS} ${ARGN} + DESTINATION ${INSTALL_TARGET_DIR}) +endmacro(spark_install_target INSTALL_TARGET_DIR INSTALL_TARGETS) + +# spark_install_file +# 基于传入的路径/文件进行安装 +# 可接受的值为: 安装路径 文件A +# 可接受的值为: 安装路径 文件A 文件B 文件C... +macro(spark_install_file INSTALL_FILE_DIR INSTALL_FILE) + install(FILES + ${INSTALL_FILE} ${ARGN} + DESTINATION ${INSTALL_FILE_DIR}) +endmacro(spark_install_file INSTALL_FILE_DIR INSTALL_FILE) + +# spark_install_program +# 基于传入的路径/文件进行安装,并自动为其添加可执行权限 +# 可接受的值为: 安装路径 文件A +# 可接受的值为: 安装路径 文件A 文件B 文件C... +macro(spark_install_program INSTALL_PROGRAM_DIR INSTALL_PROGRAM) + install(PROGRAMS + ${INSTALL_PROGRAM} ${ARGN} + DESTINATION ${INSTALL_PROGRAM_DIR}) +endmacro(spark_install_program INSTALL_PROGRAM_DIR INSTALL_PROGRAM) + + +# spark_install_directory +# 基于传入的路径/目录进行安装 +# 可接受的值为: 安装路径 路径A +# 可接受的值为: 安装路径 路径A/* 为安装路径A下所有内容 +macro(spark_install_directory INSTALL_DIRECTORY_DIR INSTALL_DIRECOTRY) + # INSTALL_DIRECOTRY 可能包含 * ? + # 1. 找到 '*', 截取,列出目录下所有文件,安装 + # 2. 是文件的直接使用 spark_install_file 安装 + # 2. 是目录的直接使用 spark_install_directory 安装 + # message(FATAL_ERROR "${INSTALL_DIRECTORY_DIR}") + # string(FIND [REVERSE]) + string(FIND "${INSTALL_DIRECOTRY}" "*" INSTALL_DIRECTORY_FIND_INDEX) + # message(FATAL_ERROR "${INSTALL_DIRECTORY_FIND_INDEX}: ${INSTALL_DIRECTORY_DIR}") + + # file(GLOB + # [LIST_DIRECTORIES true|false] [RELATIVE ] [CONFIGURE_DEPENDS] + # [...]) + + if (NOT INSTALL_DIRECTORY_FIND_INDEX EQUAL -1) + # string(SUBSTRING ) + string(SUBSTRING "${INSTALL_DIRECOTRY}" 0 ${INSTALL_DIRECTORY_FIND_INDEX} INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING) + # message(FATAL_ERROR "directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING}") + + # file(GLOB + # [LIST_DIRECTORIES true|false] [RELATIVE ] [CONFIGURE_DEPENDS] + # [...]) + + file(GLOB INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING}/*) + list(LENGTH INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST_LENGTH) + foreach(item IN LISTS INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST) + # message("-> ${item}") + if(IS_DIRECTORY ${item}) + message("-> ${item} IS_DIRECTORY") + # spark_install_directory(${INSTALL_DIRECTORY_DIR} ${item}) + install(DIRECTORY + ${item} + DESTINATION ${INSTALL_DIRECTORY_DIR} + USE_SOURCE_PERMISSIONS) + else() + message("-> ${item} NOT IS_DIRECTORY") + spark_install_program(${INSTALL_DIRECTORY_DIR} ${item}) + # spark_install_file(${INSTALL_DIRECTORY_DIR} ${item}) + endif(IS_DIRECTORY ${item}) + endforeach(item IN LISTS INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST) + + # message(FATAL_ERROR " directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST}") + # message(FATAL_ERROR " directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST_LENGTH}") + + else() + # ISSUES: You Must check here + # message(FATAL_ERROR "install: ${INSTALL_DIRECTORY_DIR}") + + install(DIRECTORY + ${INSTALL_DIRECOTRY} ${ARGN} + DESTINATION ${INSTALL_DIRECTORY_DIR}) + endif(NOT INSTALL_DIRECTORY_FIND_INDEX EQUAL -1) + +endmacro(spark_install_directory INSTALL_DIRECTORY_DIR INSTALL_DIRECOTRY) + + + +macro(spark_install_changelog CHANGE_LOG_FILE) + set(SOURCE_CHANGE_LOG_FILE ${CHANGE_LOG_FILE}) + if (EXISTS ${SOURCE_CHANGE_LOG_FILE}) + + execute_process(COMMAND test -f ${SOURCE_CHANGE_LOG_FILE} + RESULT_VARIABLE changelog_test + ) + execute_process(COMMAND which gzip + RESULT_VARIABLE gzip_test + ) + if (NOT changelog_test EQUAL 0) + message(FATAL_ERROR "NOTE: 不是常规文件: ${SOURCE_CHANGE_LOG_FILE}") + endif(NOT changelog_test EQUAL 0) + + if (NOT gzip_test EQUAL 0) + message(FATAL_ERROR "NOTE: 未安装 gzip, 无法压缩 changelog") + endif(NOT gzip_test EQUAL 0) + + # 压缩与安装日志文件 + add_custom_command( + OUTPUT "${CMAKE_BINARY_DIR}/changelog.gz" + COMMAND gzip -cn9 "${SOURCE_CHANGE_LOG_FILE}" > "${CMAKE_BINARY_DIR}/changelog.gz" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Compressing changelog" + ) + add_custom_target(changelog ALL DEPENDS "${CMAKE_BINARY_DIR}/changelog.gz") + + # include(GNUInstallDirs) + set(SPARK_INSTALL_CHANGE_LOG_DIR "/usr/share/doc/${PROJECT_NAME}/") + install(FILES + ${CMAKE_BINARY_DIR}/changelog.gz + debian/copyright + + DESTINATION ${SPARK_INSTALL_CHANGE_LOG_DIR} + ) + else() + message(FATAL_ERROR "未找到: ${SOURCE_CHANGE_LOG_FILE}") + endif(EXISTS ${SOURCE_CHANGE_LOG_FILE}) +endmacro(spark_install_changelog CHANGE_LOG_FILE) diff --git a/cmake/SparkMacrosConfig.cmake b/cmake/SparkMacrosConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7a353ca69de9b76a0dbc1b3736ced854bc9eb311 --- /dev/null +++ b/cmake/SparkMacrosConfig.cmake @@ -0,0 +1,360 @@ +cmake_minimum_required(VERSION 3.5.1) + +# 定义一些 macro 用于自动生成构建结构 + +# spark_aux_source_directory outvar invar [skip] +# 获取目录下的所有源代码 +macro(spark_aux_source_directory OUTVAR INVAR) + # iv: internal_variable + set(iv_args ${ARGN}) + list(LENGTH iv_args iv_arglen) + + file(GLOB iv_SOURCE_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${INVAR}/*.c ${INVAR}/*.cpp) + file(GLOB iv_HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${INVAR}/*.h ${INVAR}/*.hpp) + file(GLOB iv_QT_UI_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${INVAR}/*.ui ${INVAR}/*.qrc) + + if(iv_arglen EQUAL 1) + list(APPEND ${OUTVAR} ${iv_SOURCE_LIST} ${iv_HEADER_LIST} ${iv_QT_UI_LIST}) + else() + set(${OUTVAR} ${iv_SOURCE_LIST} ${iv_HEADER_LIST} ${iv_QT_UI_LIST}) + endif(iv_arglen EQUAL 1) + + unset(iv_args) + unset(iv_arglen) + unset(iv_SOURCE_LIST) + unset(iv_HEADER_LIST) + unset(iv_QT_UI_LIST) + +endmacro(spark_aux_source_directory OUTVAR INVAR) + +# spark_aux_source_directories outvar invar [...] +# 获取目录列表下的所有源代码 + # spark_aux_source_directory 的扩展,支持多个 invar 与追加参数 +macro(spark_aux_source_directories OUTVAR INVAR) + set(iv_aux_directories ${ARGN}) + + spark_aux_source_directory(${OUTVAR} ${INVAR}) + + foreach(iv_directory IN LISTS iv_aux_directories) + spark_aux_source_directory(${OUTVAR} ${iv_directory} SKIP) + endforeach(iv_directory IN LISTS iv_aux_directories) + + unset(iv_aux_directories) + +endmacro(spark_aux_source_directories OUTVAR INVAR) + + +# spark_add_library [files]... +# 构建一个库,基于指定的源文件 + # 并根据库名生成 target_link_ 函数 +macro(spark_add_library _lib_name) + spark_debug_message("================ ${_lib_name} Library ================") + add_library(${_lib_name} ${ARGN}) + + set(SRCS ${ARGN}) + foreach(item IN LISTS SRCS) + spark_debug_message(" -> ${item}") + endforeach(item IN LISTS SRCS) + + function(target_link_${_lib_name} TARGET) + spark_debug_message("${_lib_name}") + target_link_libraries(${TARGET} ${_lib_name}) + endfunction(target_link_${_lib_name} TARGET) + +endmacro(spark_add_library _lib_name) + +# spark_add_library_path +# 构建一个库,基于指定的路径 + # 并根据库名生成 target_link_ 函数 + # 函数内增加以 头文件搜索路径 +macro(spark_add_library_path _lib_name _lib_path) + + # 0. 建立初始变量体系 + set(${_lib_name}_TYPE) + set(${_lib_name}_TYPE_MESSAGE "STATIC(Default)") + set(${_lib_name}_ARGN ${ARGN}) + + # 1. 判断 _lib_path 是否是 SHARED 或 STATIC + if(${_lib_path} STREQUAL SHARED OR ${_lib_path} STREQUAL STATIC) + set(${_lib_name}_TYPE ${_lib_path}) + set(${_lib_name}_TYPE_MESSAGE ${${_lib_name}_TYPE}) + + if(${ARGC} LESS 3) + message(FATAL_ERROR "Missing parameter, library path not specified.") + endif(${ARGC} LESS 3) + else() + # 如没有则将 _lib_path 加入到 ARGN + list(APPEND ${_lib_name}_ARGN ${_lib_path}) + endif(${_lib_path} STREQUAL SHARED OR ${_lib_path} STREQUAL STATIC) + + # 1. 处理由 spark_add_library_realpaths 构建转本构建时的清洗机制 + spark_debug_message("> Building: ${_lib_name}, type: ${${_lib_name}_TYPE_MESSAGE}") + set(${_lib_name}_ARGN_REF ${${_lib_name}_ARGN}) + unset(${_lib_name}_ARGN) + foreach(_old IN LISTS ${_lib_name}_ARGN_REF) + set(_new ${_old}) + string(FIND "${_old}" "+" _plus_index) + if(${_plus_index} GREATER 0) + string(SUBSTRING "${_old}" 0 ${_plus_index} _new) + spark_debug_message(" [CONVERT] ${_new} <- ${_old}") + endif(${_plus_index} GREATER 0) + list(APPEND ${_lib_name}_ARGN ${_new}) + endforeach(_old IN LISTS ${_lib_name}_ARGN_REF) + + + # 2.目标参数项分析出子项 + # 拆分出源代码、路径、未知项等 + set(${_lib_name}_ARGN_SOURCES) + set(${_lib_name}_ARGN_APPEND_PATHS) + set(${_lib_name}_ARGN_UNKNOW) + foreach(item IN LISTS ${_lib_name}_ARGN) + spark_debug_message(" [ARGN] check:" ${item}) + if(NOT EXISTS ${item}) + set(item ${CMAKE_CURRENT_LIST_DIR}/${item}) + endif() + if(EXISTS ${item}) + # spark_debug_message(" exists: true") + file(REAL_PATH ${item} ${_lib_name}_ARGN_item) + if(IS_DIRECTORY ${${_lib_name}_ARGN_item}) + list(APPEND ${_lib_name}_ARGN_APPEND_PATHS ${item}) + else() + list(APPEND ${_lib_name}_ARGN_SOURCES ${item}) + endif(IS_DIRECTORY ${${_lib_name}_ARGN_item}) + else() + list(APPEND ${_lib_name}_ARGN_UNKNOW ${item}) + spark_debug_message(" exists: false") + endif() + endforeach() + + list(LENGTH ${_lib_name}_ARGN_SOURCES ${_lib_name}_ARGN_SOURCES_LENGTH) + list(LENGTH ${_lib_name}_ARGN_APPEND_PATHS ${_lib_name}_ARGN_APPEND_PATHS_LENGTH) + list(LENGTH ${_lib_name}_ARGN_UNKNOW ${_lib_name}_ARGN_UNKNOW_LENGTH) + spark_debug_message(" result: files(${${_lib_name}_ARGN_SOURCES_LENGTH}), paths(${${_lib_name}_ARGN_APPEND_PATHS_LENGTH}), unknow(${${_lib_name}_ARGN_UNKNOW_LENGTH})" ${item}) + + # 3. 获取所以源代码为 any_files + spark_debug_message(" files:") + set(any_files ${${_lib_name}_ARGN_SOURCES}) + foreach(item IN LISTS ${_lib_name}_ARGN_APPEND_PATHS) + spark_aux_source_directory(item_files ${item}) + list(APPEND any_files ${item_files}) + foreach(item_file IN LISTS item_files) + spark_debug_message(" ${item_file}") + endforeach(item_file IN LISTS item_files) + endforeach(item IN LISTS ${_lib_name}_ARGN_APPEND_PATHS) + + # 4. 构建目标库 + add_library(${_lib_name} ${${_lib_name}_TYPE} + ${${_lib_name}_ARGN_SOURCES} + ${any_files}) + + # 5. 建立引用点 + # target_link_<_lib_name> 函数 + # target_include_<_lib_name> 函数 + + # target_<_lib_name>_include 函数 + # target_<_lib_name>_link 函数 + + function(target_${_lib_name}_include _include) + spark_debug_message("添加引用: ${_lib_name} <- ${_include} ${${_lib_name}_INCLUDE_ARGN}") + target_include_directories(${_lib_name} PRIVATE ${_include}) + endfunction(target_${_lib_name}_include _include) + + function(target_${_lib_name}_link _library) + spark_debug_message("添加链接: ${_lib_name} <- ${_library} ${${_lib_name}_LINK_ARGN}") + target_link_libraries(${_lib_name} ${_library}) + endfunction(target_${_lib_name}_link _library) + + function(target_link_${_lib_name} TARGET) + spark_debug_message("链接引用: ${TARGET} <- ${_lib_name}") + target_include_directories(${TARGET} PRIVATE + "${${_lib_name}_SOURCE_PATH}" ${${_lib_name}_ARGN_APPEND_PATHS}) + target_link_libraries(${TARGET} ${_lib_name}) + endfunction(target_link_${_lib_name} TARGET) + + function(target_include_${_lib_name} TARGET) + spark_debug_message("引入引用: ${TARGET} <- ${_lib_name}") + target_include_directories(${TARGET} PUBLIC + "${${_lib_name}_SOURCE_PATH}" ${${_lib_name}_ARGN_APPEND_PATHS}) + endfunction(target_include_${_lib_name} TARGET) + + + target_include_directories(${_lib_name} PRIVATE + "${${_lib_name}_ARGN_APPEND_PATHS}") + + # 输出 includes + spark_debug_message(" ${_lib_name}_ARGN_APPEND_PATHS: ") + foreach(item IN LISTS ${_lib_name}_ARGN_APPEND_PATHS) + string(REPLACE "${CMAKE_SOURCE_DIR}/" "" item_var "${item}") + spark_debug_message(" ${item_var}") + endforeach(item IN LISTS ${_lib_name}_ARGN_APPEND_PATHS) + + # 如果想用以下操作手动实现 target_link_include_directories + # 请注意对 LIST 类型使用 "" 进行包围 + # target_link_include_directories 的 PUBLIC 将会填充(追加)目标的 INCLUDE_DIRECTORIES 属性 + # target_link_include_directories 支持 cmake 生成大表达式,更容易操作,手动将无法实现此类能力 + # target_link_include_directories 支持相对路径和绝对路径参数 + # 手动操作将必须使用绝对路径,这是不好的地方 + # get_target_property(_lib_include_directories ${_lib_name} INCLUDE_DIRECTORIES) + # list(APPEND _lib_include_directories "${CMAKE_CURRENT_LIST_DIR}/${${_lib_name}_SOURCE_PATH}") + # spark_debug_message("----> ${CMAKE_CURRENT_LIST_DIR}/${${_lib_name}_SOURCE_PATH}") + # spark_debug_message("----> ${_lib_include_directories}") + # set_target_properties(${_lib_name} PROPERTIES + # INCLUDE_DIRECTORIES "${_lib_include_directories}" + # INTERFACE_INCLUDE_DIRECTORIES "${_lib_include_directories}" + # ) + +endmacro(spark_add_library_path _lib_name _lib_path) + +# spark_add_executable [files]... +# 构建一个可执行文件,基于指定的源文件 + # Qt编译时源文件包括很多类型,需要指定 *.h/*.cpp/*.qrc/*.qm/... 等 +macro(spark_add_executable _exec_name) + + set(${_exec_name}_TYPE_MESSAGE "可执行程序") + spark_debug_message("> Building: ${_exec_name}, type: ${${_exec_name}_TYPE_MESSAGE}") + + add_executable(${_exec_name} ${ARGN}) + +endmacro(spark_add_executable _exec_name) + +# spark_add_executable_path [files ... paths] +# 构建一个可执行程序,基于指定的路径 +macro(spark_add_executable_path _exec_name _exec_path) + spark_add_executable(${_exec_name}) + + # 0. 建立初始变量体系 + # set(${_exec_name}_TYPE) + # set(${_exec_name}_TYPE_MESSAGE "可执行程序") + set(${_exec_name}_ARGN ${ARGN}) + + # 1. 处理由 spark_add_executable_realpaths 构建转本构建时的清洗机制 + # spark_debug_message("> Building: ${_exec_name}, type: ${${_exec_name}_TYPE_MESSAGE}") + set(${_exec_name}_ARGN_REF ${${_exec_name}_ARGN}) + unset(${_exec_name}_ARGN) + foreach(_old IN LISTS ${_exec_name}_ARGN_REF) + set(_new ${_old}) + string(FIND "${_old}" "+" _plus_index) + if(${_plus_index} GREATER 0) + string(SUBSTRING "${_old}" 0 ${_plus_index} _new) + spark_debug_message(" [CONVERT] ${_new} <- ${_old}") + endif(${_plus_index} GREATER 0) + list(APPEND ${_exec_name}_ARGN ${_new}) + endforeach(_old IN LISTS ${_exec_name}_ARGN_REF) + + # 1.目标参数项分析出子项 + # 拆分出源代码、路径、未知项等 + # spark_debug_message("> Building: ${_exec_name}, type: ${${_exec_name}_TYPE_MESSAGE}") + set(${_exec_name}_ARGN_SOURCES) + set(${_exec_name}_ARGN_APPEND_PATHS ${_exec_path}) + set(${_exec_name}_ARGN_UNKNOW) + foreach(item IN LISTS ${_exec_name}_ARGN) + spark_debug_message(" [ARGN] check:" ${item}) + if(NOT EXISTS ${item}) + set(item ${CMAKE_CURRENT_LIST_DIR}/${item}) + endif() + if(EXISTS ${item}) + # spark_debug_message(" exists: true") + file(REAL_PATH ${item} ${_exec_name}_ARGN_item) + if(IS_DIRECTORY ${${_exec_name}_ARGN_item}) + list(APPEND ${_exec_name}_ARGN_APPEND_PATHS ${item}) + else() + list(APPEND ${_exec_name}_ARGN_SOURCES ${item}) + endif(IS_DIRECTORY ${${_exec_name}_ARGN_item}) + else() + list(APPEND ${_exec_name}_ARGN_UNKNOW ${item}) + spark_debug_message(" exists: false") + endif() + endforeach() + + list(LENGTH ${_exec_name}_ARGN_SOURCES ${_exec_name}_ARGN_SOURCES_LENGTH) + list(LENGTH ${_exec_name}_ARGN_APPEND_PATHS ${_exec_name}_ARGN_APPEND_PATHS_LENGTH) + list(LENGTH ${_exec_name}_ARGN_UNKNOW ${_exec_name}_ARGN_UNKNOW_LENGTH) + spark_debug_message(" result: files(${${_exec_name}_ARGN_SOURCES_LENGTH}), paths(${${_exec_name}_ARGN_APPEND_PATHS_LENGTH}), unknow(${${_exec_name}_ARGN_UNKNOW_LENGTH})" ${item}) + + + # 2. 获取所以源代码为 any_files + spark_debug_message(" files:") + set(any_files ${${_exec_name}_ARGN_SOURCES}) + foreach(item IN LISTS ${_exec_name}_ARGN_APPEND_PATHS) + spark_aux_source_directory(item_files ${item}) + list(APPEND any_files ${item_files}) + foreach(item_file IN LISTS item_files) + spark_debug_message(" ${item_file}") + endforeach(item_file IN LISTS item_files) + endforeach(item IN LISTS ${_exec_name}_ARGN_APPEND_PATHS) + + # 3. 构建可执行目标所需要的文件 + # add_executable(${_exec_name} + # ${${_exec_name}_ARGN_SOURCES} + # ${any_files}) + + target_sources(${_exec_name} PRIVATE + ${${_exec_name}_ARGN_SOURCES} + ${any_files}) + + # 4. 建立引用点 + # target_<_exec_name>_include 函数 + # target_<_exec_name>_link 函数 + function(target_${_exec_name}_include _include) + spark_debug_message("添加引用: ${_exec_name} <- ${_include} ${${_exec_name}_INCLUDE_ARGN}") + target_include_directories(${_exec_name} PRIVATE ${_include}) + endfunction(target_${_exec_name}_include _include) + + function(target_${_exec_name}_link _library) + spark_debug_message("添加链接: ${_exec_name} <- ${_library} ${${_exec_name}_LINK_ARGN}") + target_link_libraries(${_exec_name} ${_library}) + endfunction(target_${_exec_name}_link _library) + + target_include_directories(${_exec_name} PRIVATE + ${_exec_path}) + spark_debug_message(" include: ${_exec_path}\n") + +endmacro(spark_add_executable_path _exec_name _exec_path) + +# spark_find_library +# 搜索一个库,基于指定的库名,调用 pkg-config 搜索库 + # 并根据库名生成一个 target_link_ 函数 +macro(spark_find_library _prefix) + find_package(PkgConfig REQUIRED) + + # libnotify + pkg_check_modules(${_prefix} ${ARGN}) + function(target_link_${_prefix} TARGET) + target_include_directories(${TARGET} PUBLIC + ${${_prefix}_INCLUDE_DIRS}) + target_link_libraries(${TARGET} + ${${_prefix}_LIBRARIES}) + endfunction(target_link_${_prefix} TARGET) + +endmacro(spark_find_library _prefix) + + +# spark_add_executable_paths +# 自定义构建宏,基于指定的前缀名称,处理后续参数为子目录 + # item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) + # file: 为在目录中不以递归(GLOB_RECURSE)方式寻找 qrc 文件,需要将其参与编译才能被 rcc + # 并根据 prefix- 生成构建目标, +macro(spark_add_executable_paths _prefix_path) + set(PATHS ${ARGN}) + foreach(item IN LISTS PATHS) + file(GLOB QRCS "${item}/*.qrc") + spark_debug_message(">>> add_executable: " "${_prefix_path}-${item} ${item} + ${QRCS}") + spark_add_executable_path(${_prefix_path}-${item} ${item} ${QRCS}) + target_link_qt5(${_prefix_path}-${item}) + endforeach(item IN LISTS PATHS) +endmacro(spark_add_executable_paths _prefix_path) + +# spark_add_link +# 自定义宏以代替当前使用 fucntion 定义 target_link_ 结构 + # _IN_NAME: 此宏生成 target_link_ 的要求参数 + # ARGN: 此宏剩余的参数列表 + # 在使用 target_link_ 时 + # _NAME: 用于此 fucntion 中的要求参数: <_NAME>目标将要连接此库 +macro(spark_add_link _name) + function(target_link_${_name} _link) + spark_debug_message("> Linking: ${_link}") + spark_debug_message(" <- ${ARGN}\n") + target_link_libraries(${_link} + ${ARGN}) + endfunction(target_link_${_name} _link) +endmacro(spark_add_link _name) diff --git a/cmake/SparkMacrosExtendConfig.cmake b/cmake/SparkMacrosExtendConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6426cefc9eb60d6e4bb70968e7bd877fd2e2ca73 --- /dev/null +++ b/cmake/SparkMacrosExtendConfig.cmake @@ -0,0 +1,335 @@ + +# find_plus +# 寻找 INVAl 传入的字符串,如果存在 + 字符将写入位置到 OUTVAL +function(find_plus INVAL OUTVAL) + string(FIND "${INVAL}" "+" plus_index) + set(${OUTVAL} ${plus_index} PARENT_SCOPE) +endfunction(find_plus INVAL OUTVAL) + +function(find_plus_v INVAL OUTVAL) + string(FIND "${${INVAL}}" "+" plus_index) + set(${OUTVAL} ${plus_index} PARENT_SCOPE) +endfunction(find_plus_v INVAL OUTVAL) + +function(find_colon INVAL OUTVAL) + string(FIND "${INVAL}" ":" colon_index) + set(${OUTVAL} ${colon_index} PARENT_SCOPE) +endfunction(find_colon INVAL OUTVAL) + +function(find_colon_v INVAL OUTVAL) + string(FIND "${${INVAL}}" ":" colon_index) + set(${OUTVAL} ${colon_index} PARENT_SCOPE) +endfunction(find_colon_v INVAL OUTVAL) + +function(find_dir INVAL OUTVAL) + string(FIND "${INVAL}" "/" _STR ${ARGN}) + set(${OUTVAL} ${_STR} PARENT_SCOPE) +endfunction(find_dir INVAL OUTVAL) + +function(find_dir_v INVAL OUTVAL) + string(FIND "${${INVAL}}" "/" _STR ${ARGN}) + set(${OUTVAL} ${_STR} PARENT_SCOPE) +endfunction(find_dir_v INVAL OUTVAL) + +# +function(str_left INVAL INDEX OUTVAL) + set(LEFT_INDEX ${INDEX}) + string(SUBSTRING "${INVAL}" 0 ${LEFT_INDEX} _LEFT_V) + set(${OUTVAL} ${_LEFT_V} PARENT_SCOPE) +endfunction(str_left INVAL INDEX OUTVAL) + +function(str_right INVAL INDEX OUTVAL) + math(EXPR RIGHT_INDEX ${INDEX}+1) + string(SUBSTRING "${INVAL}" ${RIGHT_INDEX} -1 _RIGHT_V) + set(${OUTVAL} ${_RIGHT_V} PARENT_SCOPE) +endfunction(str_right INVAL INDEX OUTVAL) + +function(str_left_v INVAL INDEX OUTVAL) + set(LEFT_INDEX ${${INDEX}}) + string(SUBSTRING "${${INVAL}}" 0 ${LEFT_INDEX} _LEFT_V) + set(${OUTVAL} ${_LEFT_V} PARENT_SCOPE) +endfunction(str_left_v INVAL INDEX OUTVAL) + +function(str_right_v INVAL INDEX OUTVAL) + math(EXPR RIGHT_INDEX ${${INDEX}}+1) + string(SUBSTRING "${${INVAL}}" ${RIGHT_INDEX} -1 _RIGHT_V) + set(${OUTVAL} ${_RIGHT_V} PARENT_SCOPE) +endfunction(str_right_v INVAL INDEX OUTVAL) + +# +function(find_colon_plus INVAL OUTVAL) + find_colon(${INVAL} COLON_INDEX) + str_right(${INVAL} ${COLON_INDEX} COLON_RIGHT) + find_plus_v(COLON_RIGHT PLUS_INDEX) + str_left_v(COLON_RIGHT PLUS_INDEX COLON_RIGHT_LEFT_PLUS) + + set(${OUTVAL} ${COLON_RIGHT_LEFT_PLUS} PARENT_SCOPE) +endfunction(find_colon_plus INVAL OUTVAL) + +function(find_colon_plus_v INVAL OUTVAL) + find_colon_v(${INVAL} COLON_INDEX) + str_right_v(${INVAL} COLON_INDEX COLON_RIGHT) + find_plus_v(COLON_RIGHT PLUS_INDEX) + str_left_v(COLON_RIGHT PLUS_INDEX COLON_RIGHT_LEFT_PLUS) + + set(${OUTVAL} ${COLON_RIGHT_LEFT_PLUS} PARENT_SCOPE) +endfunction(find_colon_plus_v INVAL OUTVAL) + +function(find_dir_plus INVAL OUTVAL) + # t:*/*+d + # ^ + find_dir("${INVAL}" SLASH_INDEX REVERSE) + str_right("${INVAL}" ${SLASH_INDEX} SLASH_RIGHT) + find_plus_v(SLASH_RIGHT PLUS_INDEX) + str_left_v(SLASH_RIGHT PLUS_INDEX SLASH_RIGHT_LEFT_PLUS) + + set(${OUTVAL} ${SLASH_RIGHT_LEFT_PLUS} PARENT_SCOPE) +endfunction(find_dir_plus INVAL OUTVAL) + +function(find_dir_plus_v INVAL OUTVAL) + # t:*/*+d + # ^ + find_dir("${${INVAL}}" SLASH_INDEX REVERSE) + str_right("${${INVAL}}" ${SLASH_INDEX} SLASH_RIGHT) + find_plus_v(SLASH_RIGHT PLUS_INDEX) + str_left_v(SLASH_RIGHT PLUS_INDEX SLASH_RIGHT_LEFT_PLUS) + + set(${OUTVAL} ${SLASH_RIGHT_LEFT_PLUS} PARENT_SCOPE) +endfunction(find_dir_plus_v INVAL OUTVAL) + + +# spark_add_library_source ... +# 扩展 一行一可执行目标 的构建的扩展宏 +# 在构建时将会另外加入这些资源 +macro(spark_add_library_source target) + set(${target}_ADD_SOURCE ${ARGN}) +endmacro(spark_add_library_source target) + +# 冗余的 target_link_qt5 或 qt6 的处理逻辑 +macro(_handle_spark_target_link_qt_macro _target) + if(SPARK_FIND_QT5) + target_link_qt5(${_target}) + endif(SPARK_FIND_QT5) + + if(SPARK_FIND_QT6) + target_link_qt6(${_target}) + endif(SPARK_FIND_QT6) +endmacro(_handle_spark_target_link_qt_macro _target) + +# spark_add_library_realpaths +# 基于传入的项进行构建 +# 可接受的值为: 路径列表 +# 可接受的值为: 路径列表+依赖库A+依赖库B +macro(spark_add_library_realpaths) + + set(REALPATHS ${ARGN}) + foreach(REALPATH IN LISTS REALPATHS) + + # # 找 : 号下标,这是找:号的函数 + # find_colon(${REALPATH} COLON_INDEX) + # 找 / 号下标,这是找/号的函数 + find_dir_v(REALPATH SLASH_INDEX REVERSE) + # 找 + 号下标,这是找+号的函数 + find_plus_v(REALPATH PLUS_INDEX) + + # + + if(PLUS_INDEX LESS 0) + # 完全没有 + 的情况下,它就是一个基于目录的构建 + set(dir ${REALPATH}) + str_right_v(REALPATH SLASH_INDEX target) + + spark_add_library_path(${target} + ${dir} + ${${target}_ADD_SOURCE} + ) + # 使用 spark_add_library_realpaths 构建的依赖将允许直接引用库头文件 + target_include_directories(${target} PUBLIC ${dir}) + _handle_spark_target_link_qt_macro(${target}) + else() + # 有 + 的情况下,获取 + 号下标右侧所有内容为 target_depends_str 并转为列表 + str_right_v(REALPATH PLUS_INDEX target_depends_str) + string(REPLACE "+" ";" target_depends "${target_depends_str}") + + find_dir_plus_v(REALPATH target) + str_left_v(REALPATH PLUS_INDEX dir) + + spark_add_library_path(${target} + ${dir} + ${${target}_ADD_SOURCE} + ) + spark_debug_message(" [INCLUDE_DIRS]: ${dir} ${dir}/.. \n") + target_include_directories(${target} PUBLIC ${dir} ${dir}/..) + target_link_libraries(${target} ${target_depends}) + endif(PLUS_INDEX LESS 0) + + endforeach(REALPATH IN LISTS REALPATHS) + +endmacro(spark_add_library_realpaths) + + +# spark_aux_source_paths +# 将指定路径中的文件变成可用的AUX源文件列表 +macro(spark_aux_source_paths AUX_VAR) + set(${AUX_VAR} "") + set(${AUX_VAR}_PATHS ${ARGN}) + + foreach(aux_path IN LISTS ${AUX_VAR}_PATHS) + # spark_debug_message("aux_path: ${aux_path}") + aux_source_directory(${aux_path} ${AUX_VAR}) + endforeach(aux_path IN LISTS ${AUX_VAR}_PATHS) + +endmacro(spark_aux_source_paths AUX_VAR) + +# spark_file_glob +# 使用用 file(GLOB) 的匹配规则,并一次可匹配多个规则 +# +macro(spark_file_glob FGLOB_VAR) + set(${FGLOB_VAR} "") + set(${FGLOB_VAR}_PATHS ${ARGN}) + + foreach(fglob_path IN LISTS ${FGLOB_VAR}_PATHS) + + file(GLOB FGLOB_PATH_SRCS ${fglob_path}) + foreach(fglob_path_src IN LISTS FGLOB_PATH_SRCS) + # spark_debug_message(" -> ${item}") + list(APPEND ${FGLOB_VAR} ${fglob_path_src}) + endforeach(fglob_path_src IN LISTS FGLOB_PATH_SRCS) + + endforeach(fglob_path IN LISTS ${FGLOB_VAR}_PATHS) + +endmacro(spark_file_glob FGLOB_VAR) + + +# spark_add_source_paths +# 将指定路径中的文件变成可用的源文件列表 +# +macro(spark_add_source_paths SOURCE_VAR) + set(${SOURCE_VAR} "") + set(${SOURCE_VAR}_PATHS ${ARGN}) + + spark_aux_source_paths(${SOURCE_VAR} ${ARGN}) + foreach(source_path IN LISTS ${SOURCE_VAR}_PATHS) + # list(APPEND ${SOURCE_VAR}_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_PATH}) + # aux_source_directory(${SOURCE_PATH} _SOURCES) + # foreach(item IN LISTS _SOURCES) + # # spark_debug_message(" -> ${item}") + # list(APPEND ${SOURCE_VAR} ${item}) + # endforeach(item IN LISTS _SOURCES) + + # file(GLOB HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_PATH}/*.h) + # foreach(item IN LISTS HEADER_LIST) + # # spark_debug_message(" -> ${item}") + # list(APPEND ${SOURCE_VAR} ${item}) + # endforeach(item IN LISTS HEADER_LIST) + + file(GLOB UI_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${source_path}/*.ui) + foreach(ui_src IN LISTS UI_SRCS) + # spark_debug_message(" -> ${item}") + list(APPEND ${SOURCE_VAR} ${ui_src}) + endforeach(ui_src IN LISTS UI_SRCS) + endforeach(source_path IN LISTS ${SOURCE_VAR}_PATHS) +endmacro(spark_add_source_paths SOURCE_VAR) + + +# spark_add_library_file_glob + # +macro(spark_add_library_file_glob _lib_name) + spark_file_glob(${_lib_name}_SOURCES ${ARGN}) + spark_add_library(${_lib_name} ${${_lib_name}_SOURCES}) +endmacro(spark_add_library_file_glob _lib_name) + + + +# spark_add_executable_source ... +# 扩展 一行一可执行目标 的构建的扩展宏 +# 在构建时将会另外加入这些资源 +macro(spark_add_executable_source target) + set(${target}_ADD_SOURCE ${ARGN}) +endmacro(spark_add_executable_source target) + +# 冗余的 spark_add_executable_realpaths 的 dir 处理逻辑 +macro(_handle_spark_add_executable_realpaths_if_dir_empty_macro) + if("${dir}" STREQUAL "") + spark_add_executable(${target} + ${${target}_ADD_SOURCE} + ) + else() + spark_add_executable_path(${target} + ${dir} + ${${target}_ADD_SOURCE} + ) + endif("${dir}" STREQUAL "") +endmacro(_handle_spark_add_executable_realpaths_if_dir_empty_macro) + +# spark_add_executable_realpaths +# 基于传入的项进行构建 +# 可接受的值为: 可执行目标:路径列表 +# 可接受的值为: 可执行目标:路径列表+依赖库A+依赖库B +macro(spark_add_executable_realpaths) + + set(REALPATHS ${ARGN}) + foreach(REALPATH IN LISTS REALPATHS) + + # 找 : 号下标,这是找:号的函数 + find_colon(${REALPATH} COLON_INDEX) + + if(COLON_INDEX LESS 0) + # do not anything + else() + # 找到 : 号,将截取 target 名称 + # string(SUBSTRING "${REALPATH}" 0 ${COLON_INDEX} REALTARGET) + find_colon_v(REALPATH COLON_INDEX) + str_left_v(REALPATH COLON_INDEX target) + str_right_v(REALPATH COLON_INDEX COLON_REMAIN) + # message(FATAL_ERROR "构建一个: ${target}") # 已验证 + + endif(COLON_INDEX LESS 0) + + # 找 + 号下标,这是找+号的函数 + find_plus_v(REALPATH PLUS_INDEX) + + if(PLUS_INDEX LESS 0) + # 完全没有 + 的情况下,它就是一个基于目录的构建 + set(dir ${COLON_REMAIN}) + # spark_add_executable_path(${target} + # ${dir} + # ${${target}_ADD_SOURCE} + # ) + _handle_spark_add_executable_realpaths_if_dir_empty_macro() + _handle_spark_target_link_qt_macro(${target}) + else() + # 有 + 的情况下,获取 + 号下标右侧所有内容为 target_depends_str 并转为列表 + str_right_v(REALPATH PLUS_INDEX target_depends_str) + string(REPLACE "+" ";" target_depends "${target_depends_str}") + + # 再从主要内容中获取 dir ,以及 + find_colon_plus_v(REALPATH dir) + # spark_add_executable_path(${target} + # ${dir} + # ${${target}_ADD_SOURCE} + # ) + _handle_spark_add_executable_realpaths_if_dir_empty_macro() + target_include_directories(${target} PUBLIC ${dir} ${dir}/..) + target_link_libraries(${target} ${target_depends}) + endif(PLUS_INDEX LESS 0) + endforeach(REALPATH IN LISTS REALPATHS) + +endmacro(spark_add_executable_realpaths) + + +# 一行一库概念构建 +# 1.构建一个库,基于指定的目录路径进行构建 +# src/widgets/DocTypeListView +# ^目录将被用于制作的目标名称 +# 目录下的所有文件将被用于制作此库的源代码文件 +# +# 2.构建一个库,基于指定的目录路径进行构建,并依赖其后面所列出的依赖项 +# src/widgets/MaintainerInfoView+DocTypeListView+... +# ^此库将被用于 MaintainerInfoView 库的依赖 +# ^此符号'+'将被视为依赖项列表的分隔符 + +# 一行一可执行目标概念 +# 1.构建一个可执行目标,基于指定的目录路径进行构建(行不通,可执行目标很少为一个目录) +# 2.构建一个可执行目标,基于指定的文件路径进行构建(也许可以) +# 3.构建一个可执行目标,基于指定的文件名称进行构建() +# 4.构建一个可执行目标,基于指定命名规则(target:dir:dir+depend+depend...) diff --git a/cmake/SparkTranslatorConfig.cmake b/cmake/SparkTranslatorConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..33eec6f92261bf1cd378dffedd39b92060a65899 --- /dev/null +++ b/cmake/SparkTranslatorConfig.cmake @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.5.1) + +# translator_qt5 _qmvar [... *.ts] +macro(translator_qt5 _qmvar) + # set(SPARK_TRANSLATIONS_ARGN ${ARGN}) + # file(GLOB SPARK_TRANSLATIONS ${SPARK_TRANSLATIONS_ARGN}) + # qt5_add_translation(SPARK_QM_TRANSLATIONS + # ${SPARK_TRANSLATIONS}) + + set(${_qmvar}_ARNG ${ARGN}) + file(GLOB ${_qmvar}_TS_FILES ${${_qmvar}_ARNG}) + find_package(Qt5LinguistTools) + + qt5_add_translation(${_qmvar} + ${${_qmvar}_TS_FILES}) + + set(SPARK_QM_TRANSLATIONS ${_qmvar}) + + # 注意,必须将 SPARK_QM_TRANSLATIONS 或 ${_qmvar} 加入到 add_executable 参数中才能在编译时生成只有原文的ts文件 + + # qt5_create_translation + # ts文件会在 make clean 或重新编译的时候一并被删除,再编译的时候生成全新的ts(原有的翻译会丢失,万分注意!!) + + # qt5_add_translation + # 此宏比较稳定 +endmacro(translator_qt5 _qmvar) + + +# translator_qt6 _qmvar [... *.ts] +macro(translator_qt6 _qmvar) + # todo +endmacro(translator_qt6 _qmvar) + +# 冗余的 translator_qt5 或 qt6 的处理逻辑 +macro(_handle_spark_translator_qt_macro _outvar) + if(SPARK_FIND_QT5) + translator_qt5(${_outvar} ${ARGN}) + endif(SPARK_FIND_QT5) + + if(SPARK_FIND_QT6) + translator_qt6(${_outvar} ${ARGN}) + endif(SPARK_FIND_QT6) +endmacro(_handle_spark_translator_qt_macro _outvar) + +# translator_qt _qmvar [... *.ts | match] +macro(translator_qt) + _handle_spark_translator_qt_macro(${ARGN}) +endmacro(translator_qt) diff --git a/how_build/cmake/deb_package_config.cmake b/cmake/deb_package_config.cmake similarity index 100% rename from how_build/cmake/deb_package_config.cmake rename to cmake/deb_package_config.cmake diff --git a/cmake/linuxdeployqt-help b/cmake/linuxdeployqt-help new file mode 100644 index 0000000000000000000000000000000000000000..1b72fda9a437f50fd97e892ffe216681bc42b275 --- /dev/null +++ b/cmake/linuxdeployqt-help @@ -0,0 +1,48 @@ +linuxdeployqt (commit 5fa79fa), build 36 built on 2022-08-21 12:36:03 UTC +WARNING: Not checking glibc on the host system. + The resulting AppDir or AppImage may not run on older systems. + This mode is unsupported and discouraged. + For more information, please see + https://github.com/probonopd/linuxdeployqt/issues/340 + +Usage: linuxdeployqt [options] + +Options: + -always-overwrite : Copy files even if the target file exists. + -appimage : Create an AppImage (implies -bundle-non-qt-libs). + -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries. + -exclude-libs= : List of libraries which should be excluded, + separated by comma. + -ignore-glob= : Glob pattern relative to appdir to ignore when + searching for libraries. + -executable= : Let the given executable use the deployed libraries + too + -extra-plugins= : List of extra plugins which should be deployed, + separated by comma. + -no-copy-copyright-files : Skip deployment of copyright files. + -no-plugins : Skip plugin deployment. + -no-strip : Don't run 'strip' on the binaries. + -no-translations : Skip deployment of translations. + -qmake= : The qmake executable to use. + -qmldir= : Scan for QML imports in the given path. + -qmlimport= : Add the given path to QML module search locations. + -show-exclude-libs : Print exclude libraries list. + -verbose=<0-3> : 0 = no output, 1 = error/warning (default), + 2 = normal, 3 = debug. + -updateinformation= : Embed update information STRING; if zsyncmake is installed, generate zsync file + -qtlibinfix= : Adapt the .so search if your Qt distribution has infix. + -version : Print version statement and exit. + +linuxdeployqt takes an application as input and makes it +self-contained by copying in the Qt libraries and plugins that +the application uses. + +By default it deploys the Qt instance that qmake on the $PATH points to. +The '-qmake' option can be used to point to the qmake executable +to be used instead. + +Plugins related to a Qt library are copied in with the library. + +See the "Deploying Applications on Linux" topic in the +documentation for more information about deployment on Linux. +zinface@zinface-PC:/tmp/tmp.5gmZKUqn9s$ \ No newline at end of file diff --git a/cmake/make-batch-powershell/README.md b/cmake/make-batch-powershell/README.md new file mode 100644 index 0000000000000000000000000000000000000000..027b34faa6471c7d2e15cb41e117ae3968e828ad --- /dev/null +++ b/cmake/make-batch-powershell/README.md @@ -0,0 +1,49 @@ +# 此处提供 Makefile/Batch/PowerShell 配置模板 - 由使用者自定义环境 + +> 使用者将模板拷贝到项目根目录并进行修改。\ +> 由于 .gitignore 中配置了对根目录的 mk 文件过滤,如果需要 git add 添加到暂存,请使用 -f 参数。 + +- 有关此处结构的内容说明 + ``` + make + ├── alternative + │ ├── windows-mingw.mk + │ ├── windows.mk + │ ├── windows-msvc.mk + │ └── windows-universal.mk + ├── history + │ ├── win.bat + │ ├── windows.bat + │ ├── win-mingw-make-msbuild.mk + │ └── win.mk + ├── powershell-msvc-msbuild.mk + ├── README.md + └── windows-msvc-ninja.bat + + 2 directories, 11 files + ``` + +- 来源于 alternative 目录的说明 + + ```batch + :: 被用于保留的构建模板,在无法验证时保留其变化,除非被确定可用 + ``` + +- 来源于 history 目录的说明 + + ```batch + :: 由 fork 用户提供的一系列构建模板,但一般情况下并不可通用 + ``` + +- 来源于 windows-msvc-ninja.bat 文件的说明 + + ```batch + :: 用于直接在 Windows 的 cmd 与 PowerShell 中使用的基于批处理构建的模板 + :: 将此文件复制到源代码根目录,并进行定制,而 .gitignore 已将其忽略,不再进入源代码树 + ``` + +- 来源于 powershell-msvc.mk 文件的说明(暂时保留,无法确认可行) + + ```shell + # 用于直接在 PowerShell 中使用 mingw32-make.exe 的模板 + ``` diff --git a/cmake/make-batch-powershell/alternative/windows-mingw.mk b/cmake/make-batch-powershell/alternative/windows-mingw.mk new file mode 100644 index 0000000000000000000000000000000000000000..1fe2f086facaca14374132022e78a25e3cbecdbb --- /dev/null +++ b/cmake/make-batch-powershell/alternative/windows-mingw.mk @@ -0,0 +1,34 @@ +# windows-mingw.mk +# Windows MinGW - 通用 Windows 平台 MinGW 构建方案 + +builddir := build/windows-mingw +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_WINDOWS_MINGW=ON +CMAKE_MINGW_DIR := -DCMAKE_PREFIX_PATH="" +CMAKE_GENERATER := -G"CodeBlocks - MinGW Makefiles" +CMAKE_MINGW_QT := $(CMAKE_OPTIONS) -DWINDOWS_DEPLOY_QT=ON +CMAKE_MINGW_QT5 := $(CMAKE_MINGW_QT) -DWINDOWS_DEPLOY_QT5=ON +CMAKE_MINGW_QT6 := $(CMAKE_MINGW_QT) -DWINDOWS_DEPLOY_QT6=ON + +JOBS=$(shell nproc) + +# mingw32-make.exe +QT_MINGW_PREFIX_DIR := "-DCMAKE_PREFIX_PATH=C:\Qt\Qt5.14.2\5.14.2\mingw73_64" + +windows-mingw: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_DEBUG) $(CMAKE_OPTIONS) $(CMAKE_MINGW_DIR) + $(MAKE) -C $(builddir) -j$(JOBS) + +windows-mingw-release: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_OPTIONS) $(CMAKE_MINGW_DIR) + $(MAKE) -C $(builddir) -j$(JOBS) + +windows-mingw-release-qt5: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MINGW_QT5) $(CMAKE_MINGW_DIR) + $(MAKE) -C $(builddir) -j$(JOBS) + +windows-mingw-release-qt6: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MINGW_QT6) $(CMAKE_MINGW_DIR) + $(MAKE) -C $(builddir) -j$(JOBS) \ No newline at end of file diff --git a/cmake/make-batch-powershell/alternative/windows-msvc.mk b/cmake/make-batch-powershell/alternative/windows-msvc.mk new file mode 100644 index 0000000000000000000000000000000000000000..b1e1185ee283b2dcd613fb5c4382e798acdf3c5c --- /dev/null +++ b/cmake/make-batch-powershell/alternative/windows-msvc.mk @@ -0,0 +1,45 @@ +# windows-msvc.mk +# Windows MSVC - 通用 Windows 平台 MSVC 构建方案 + +# 设定指向用于构建时引用的 MSVC Qt 库位置 +QT_MSVC_PREFIX_DIR := C:\Qt\Qt5.14.2\5.14.2\msvc2017_64 + +CPUS:=$(shell powershell "(Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors") + +builddir := build/windows-msvc +installdir:= $(builddir)/install +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_CXX_FLAGS := -DCMAKE_CXX_FLAGS="/MP$(CPUS)" +CMAKE_OPTIONS := $(CMAKE_CXX_FLAGS) -DUSE_WINDOWS_MSVC=ON +CMAKE_MSVC_DIR := -DCMAKE_PREFIX_PATH=$(QT_MSVC_PREFIX_DIR) +CMAKE_GENERATER := "" +CMAKE_MSVC_QT := $(CMAKE_OPTIONS) -DWINDOWS_DEPLOY_QT=ON +CMAKE_MSVC_QT5 := $(CMAKE_MSVC_QT) -DWINDOWS_DEPLOY_QT5=ON +CMAKE_MSVC_QT6 := $(CMAKE_MSVC_QT) -DWINDOWS_DEPLOY_QT6=ON + + +windows-msvc: + cmake -B$(builddir) $(CMAKE_DEBUG) $(CMAKE_OPTIONS) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) + +windows-msvc-release: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_OPTIONS) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt5: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MSVC_QT5) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt6: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MSVC_QT6) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt5-install: windows-msvc-release-qt5 + cmake --install $(installdir) + cmake --build $(builddir) --target windows-deployqt + +windows-msvc-release-qt6-install: windows-msvc-release-qt6 + cmake --install $(installdir) + cmake --build $(builddir) --target windows-deployqt \ No newline at end of file diff --git a/cmake/make-batch-powershell/alternative/windows-universal.mk b/cmake/make-batch-powershell/alternative/windows-universal.mk new file mode 100644 index 0000000000000000000000000000000000000000..2de806ef2126f2ca7ac5905d4a563fd60c4e6753 --- /dev/null +++ b/cmake/make-batch-powershell/alternative/windows-universal.mk @@ -0,0 +1,31 @@ +# windows-universal.mk +# Windows Universal - 通用 Windows 平台构建方案 + +builddir := build +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_WINDOWS_UNIVERSAL=ON +CMAKE_GENERATER := "" +CMAKE_UNIVERSAL_QT := $(CMAKE_OPTIONS) -DWINDOWS_DEPLOY_QT=ON +CMAKE_UNIVERSAL_QT5 := $(CMAKE_UNIVERSAL_QT) -DWINDOWS_DEPLOY_QT5=ON +CMAKE_UNIVERSAL_QT6 := $(CMAKE_UNIVERSAL_QT) -DWINDOWS_DEPLOY_QT6=ON + +JOBS=$(shell nproc) + + +windows-universal: + cmake -B$(builddir) $(CMAKE_DEBUG) $(CMAKE_GENERATER) $(CMAKE_OPTIONS) + cmake --build $(builddir) -- -j$(JOBS) + +windows-universal-release: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_GENERATER) $(CMAKE_OPTIONS) + cmake --build $(builddir) -- -j$(JOBS) + +windows-universal-release-qt5: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_UNIVERSAL_QT5) + cmake --build $(builddir) -- -j$(JOBS) + +windows-universal-release-qt6: + cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_UNIVERSAL_QT6) + cmake --build $(builddir) -- -j$(JOBS) \ No newline at end of file diff --git a/cmake/make-batch-powershell/alternative/windows.bat b/cmake/make-batch-powershell/alternative/windows.bat new file mode 100644 index 0000000000000000000000000000000000000000..dea65e11a04612bc53f2790f47c27ff308ff4980 --- /dev/null +++ b/cmake/make-batch-powershell/alternative/windows.bat @@ -0,0 +1,11 @@ +set Msg='Build with the following configuration:' +set One='1. mingw-make32.exe -f windows-universal.mk' +set Two='2. mingw-make32.exe -f windows-mingw.mk' +set Three='3. mingw-make32.exe -f windows-msvc.mk' + + +@echo %Msg% +@echo %One% "\n\tThe default Universal Windows platform build" +@echo %Two% "\n\tThe default Universal Windows Platform MinGW build." +@echo %Three% "\n\tThe default Universal Windows Platform MSVC build." + diff --git a/cmake/make-batch-powershell/alternative/windows.mk b/cmake/make-batch-powershell/alternative/windows.mk new file mode 100644 index 0000000000000000000000000000000000000000..4ba821cda9d6c0bf88c5692a925d42f4c6dcd551 --- /dev/null +++ b/cmake/make-batch-powershell/alternative/windows.mk @@ -0,0 +1,11 @@ +Msg := 'Build with the following configuration:' +One := '1. mingw-make32.exe -f windows-universal.mk' +Two := '2. mingw-make32.exe -f windows-mingw.mk' +Three := '3. mingw-make32.exe -f windows-msvc.mk' + +all: + @echo -e $(Msg) + @echo -e $(One) "\n\tThe default Universal Windows platform build" + @echo -e $(Two) "\n\tThe default Universal Windows Platform MinGW build." + @echo -e $(Three) "\n\tThe default Universal Windows Platform MSVC build." + diff --git a/cmake/make-batch-powershell/history/win-mingw-make-msbuild.mk b/cmake/make-batch-powershell/history/win-mingw-make-msbuild.mk new file mode 100644 index 0000000000000000000000000000000000000000..f67c67c576b4ae4c67177337d9624c2d2cb32fc4 --- /dev/null +++ b/cmake/make-batch-powershell/history/win-mingw-make-msbuild.mk @@ -0,0 +1,37 @@ + +# 基于 powershell 环境编写 +# windows 下mingw32-make.exe cmake.exe msbuild.exe cl.exe工具链编译 +# 使用方式 mingw32-make -f win-mingw-make-msbuild.mk + +# 填入cmake程序完整路径 +CMAKE_TOOL:=D:\Soft\mingw64\bin\cmake.exe +# 填入cpack程序完整路径 +CPACK_TOOL:=D:\Soft\mingw64\bin\cpack.exe +# 填入MSVC工具链路径 +# 填入msbuild程序完整路径 +MSBUILD_TOOL:=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe +# 填入cl程序完整路径 +CL_COMPILER:=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe + +# 填入Qt的msvc相关工具安装路径 +# 填入MSVC Qt库查找路径 +Qt_MSVC_PREFIX_PATH:=d:\Soft\Qt\5.15.2\msvc2019_64 + +NUM_LOGICAL_PROCESSOR=$(shell powershell (Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors) + +ifneq ($(shell powershell Test-Path build\bin\plugin), True) + MKDIR:=mkdir -p build\bin\plugin +endif + +all:msvc + +msvc: + ${CMAKE_TOOL} -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} . + ${CMAKE_TOOL} --build ./build --config=Release -j${NUM_LOGICAL_PROCESSOR} + $(shell powershell New-Item -ErrorAction SilentlyContinue -Type Directory build\bin\plugin) + $(shell powershell cp -Force build\Release\NotePad--.exe build\bin\) + cd build/bin && ${Qt_MSVC_PREFIX_PATH}\bin\windeployqt.exe --qmldir=${Qt_MSVC_PREFIX_PATH}\bin\qml NotePad--.exe + $(shell powershell cp -r -Force build\src\*\*\Release\*.dll build\bin\plugin) + $(shell powershell cp -r -Force build\src\*\Release\*.lib build\bin\plugin) + cd build && ${CPACK_TOOL} --config CPackConfig.cmake + diff --git a/how_build/win.bat b/cmake/make-batch-powershell/history/win.bat similarity index 100% rename from how_build/win.bat rename to cmake/make-batch-powershell/history/win.bat diff --git a/how_build/win.mk b/cmake/make-batch-powershell/history/win.mk similarity index 100% rename from how_build/win.mk rename to cmake/make-batch-powershell/history/win.mk diff --git a/cmake/make-batch-powershell/history/windows.bat b/cmake/make-batch-powershell/history/windows.bat new file mode 100644 index 0000000000000000000000000000000000000000..4ae3d0b323a942c6d07a30d3741f820a95183275 --- /dev/null +++ b/cmake/make-batch-powershell/history/windows.bat @@ -0,0 +1,73 @@ +@echo off + +set build_dir=build +set source_dir=. +set generator=-G Ninja +set build_type_debug=Debug +set build_type_release=Relase +set build_type=%build_type_debug% +set universal=ON +set qt=ON +set qt5=ON +set qt6=OFF + + + +echo finding vcvars64.bat... +set vcvars= +for %%i in (C: D: E: F: G: H:) do ( + if exist %%i ( + pushd %%i\ + for /r %%j in (*vcvars64.bat) do ( + set vcvars=%%j + popd + goto :find_vcvars + ) + popd + ) +) + +:find_vcvars +if not "%vcvars%"=="" ( + call "%vcvars%" + echo config MSVC environment... +)else ( + echo error: could not find vcvars64.bat MSVC ENV config file. + goto :out +) + +echo finding qt msvc path... +set qt_msvc= +for %%i in (D: D: E: F: G: H:) do ( + if exist %%i ( + pushd %%i\ + for /d /r %%j in (*msvc20*) do ( + echo %%j + if exist %%j\bin ( + if exist %%j\bin\windeployqt.exe ( + if exist %%j\bin\Qt5Core.dll ( + set qt_msvc=%%j + popd + goto :find_qt_msvc + ) + ) + ) + ) + popd + ) +) + +:find_qt_msvc +if not "%qt_msvc%"=="" ( + echo config qt msvc path... +) else ( + echo error: could not find qt msvc path. + goto :out +) + +cmake -B%build_dir% CMAKE_BUILD_TYPE=%build_type% %generator% -DUSE_WINDOWS_UNIVERSAL=%universal% -DWINDOWS_DEPLOY_QT=%qt% -DWINDOWS_DEPLOY_QT5=%qt5% -DWINDOWS_DEPLOY_QT6=%qt6% -DCMAKE_PREFIX_PATH=%qt_msvc% %source_dir% +cmake --build %build_dir% -- +xcopy %build_dir%\windows-deployqt\Notepad--.app\bin\ %build_dir%\bin\ /e + +:out +pause \ No newline at end of file diff --git a/cmake/make-batch-powershell/powershell-msvc-msbuild.mk b/cmake/make-batch-powershell/powershell-msvc-msbuild.mk new file mode 100644 index 0000000000000000000000000000000000000000..a7de66d5098f2a2ddd0e4b66cb6aa15fde5d7d98 --- /dev/null +++ b/cmake/make-batch-powershell/powershell-msvc-msbuild.mk @@ -0,0 +1,44 @@ +# windows-msvc.mk +# Windows MSVC - 通用 Windows 平台 MSVC 构建方案 + +# 设定指向用于构建时引用的 MSVC Qt 库位置 +QT_MSVC_PREFIX_DIR := C:\Qt\Qt5.14.2\5.14.2\msvc2017_64 + +CPUS:=$(shell powershell "(Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors") + +builddir := build/windows-msvc +installdir:= $(builddir)/install +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_CXX_FLAGS := -DCMAKE_CXX_FLAGS="/MP$(CPUS)" +CMAKE_OPTIONS := $(CMAKE_CXX_FLAGS) -DUSE_WINDOWS_MSVC=ON +CMAKE_MSVC_DIR := -DCMAKE_PREFIX_PATH=$(QT_MSVC_PREFIX_DIR) +CMAKE_GENERATER := "" +CMAKE_MSVC_QT := $(CMAKE_OPTIONS) -DWINDOWS_DEPLOY_QT=ON +CMAKE_MSVC_QT5 := $(CMAKE_MSVC_QT) -DWINDOWS_DEPLOY_QT5=ON +CMAKE_MSVC_QT6 := $(CMAKE_MSVC_QT) -DWINDOWS_DEPLOY_QT6=ON + +windows-msvc: + cmake -B$(builddir) $(CMAKE_DEBUG) $(CMAKE_OPTIONS) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) + +windows-msvc-release: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_OPTIONS) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt5: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MSVC_QT5) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt6: + cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_MSVC_QT6) $(CMAKE_MSVC_DIR) + cmake --build $(builddir) --config Release + +windows-msvc-release-qt5-install: windows-msvc-release-qt5 + cmake --install $(installdir) + cmake --build $(builddir) --target windows-deployqt + +windows-msvc-release-qt6-install: windows-msvc-release-qt6 + cmake --install $(installdir) + cmake --build $(builddir) --target windows-deployqt \ No newline at end of file diff --git a/cmake/make-batch-powershell/windows-msvc-ninja.bat b/cmake/make-batch-powershell/windows-msvc-ninja.bat new file mode 100644 index 0000000000000000000000000000000000000000..94907289068b076bf48493388988cc9329c19a96 --- /dev/null +++ b/cmake/make-batch-powershell/windows-msvc-ninja.bat @@ -0,0 +1,146 @@ +:: windows-msvc-ninja.bat + +:: Windows MSVC - ͨ Windows ƽ̨ MSVC +:: ļ GBK 棬 PowerShell + +@echo off + +:: Ԥ̻ +set builddir=build/windows-universal +set installdir=%builddir%/install + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: !!! : ָڹʱõ MSVC Qt λ!!! :: +set QT_MSVC_PREFIX_DIR=C:\Qt\Qt5.14.2\5.14.2\msvc2017_64 +:: set QT_MSVC_PREFIX_DIR=C:\Qt\Qt6.4.2\6.4.2\msvc2019_64 +:: :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + +:: ѡԤ +set CMAKE_OPTIONS= +set CMAKE_OPTIONS=%CMAKE_OPTIONS% -G Ninja +set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_PREFIX_PATH=%QT_MSVC_PREFIX_DIR% +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Debug +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DUSE_WINDOWS_UNIVERSAL=ON +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT=ON +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT5=ON +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT6=ON +@REM set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DUSE_QT6=ON + +:: ʱ installdir ʾҪװ· +set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_INSTALL_PREFIX=%installdir% + + +:: --------------------------------------------------- :: +:: ýղ +if "%1" == "run" ( + :: ˴ \ / ෴ + build\windows-universal\windows-deployqt\Notepad--.app\bin\Notepad--.exe + goto :finish +) +:: --------------------------------------------------- :: + +@echo ---- Notepad-- Ŀ ---- + +:: 1. ѯʹ +@echo 1. Debug(Ĭ), 2. Release +set /p chose=": " + +if "%chose%" == "2" ( + set CMAKE_BUILD_TYPE=Relase + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Relase +) else ( + set CMAKE_BUILD_TYPE=Debug + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Debug +) + +:: 2. ѯ QSci +@echo ---- Ƿָ QScint Ϊ̬? Ĭ(OFF) ---- +set /p useshare=(on): + +if "%useshare%" == "on" ( + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DNOTEPAD_BUILD_BY_SHARED=ON +) + +:: 3. ѯ USE_WINDOWS_UNIVERSAL +@echo ---- Ƿ USE_WINDOWS_UNIVERSAL? Ĭ(ON) ---- +set /p universal=(n): + +if not "%universal%" == "n" ( + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DUSE_WINDOWS_UNIVERSAL=ON +) + +:: 4. ѯ WINDOWS_DEPLOY_QT +@echo ---- Ƿ WINDOWS_DEPLOY_QT? Ĭ(ON) ---- +set /p deployqt=(n): + +if not "%deployqt%" == "n" ( + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT=ON +) + +:: 5. ѯ WINDOWS_DEPLOY_QT5 WINDOWS_DEPLOY_QT6 USE_QT6 +@echo ---- Ƿ WINDOWS_DEPLOY_QT5 汾? Ĭ(5,ѡ6) ---- +set /p deployqt5=(6): + +if not "%deployqt5%" == "6" ( + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT5=ON +) else ( + set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DWINDOWS_DEPLOY_QT6=ON -DUSE_QT6=ON +) + +:: ------------------------------------------------------------------- :: +@echo ----------------------- ǰԤ --------------------------- +@echo "cmake -B%builddir% %CMAKE_OPTIONS% ." +@echo "cmake --build %builddir% --config %CMAKE_BUILD_TYPE%" +@echo "cmake --install %builddir% --prefix %installdir%" +@echo "cmake --build %builddir% --target windows-deployqt" +:: ------------------------------------------------------------------- :: + + +:: ǰ - ѰӲе msvc +@echo ---- ѰӲе msvc ---- + +set vcvars= +for %%d in (C: D: E: F: G: H:) do ( + if exist %%d ( + @echo ڲӲ %%d е VC û... + pushd %%d\ + for /r %%p in (*vcvars64.bat) do ( + @echo ļ: %%p + set vcvars=%%p + popd + goto :set_vcvars + ) + popd + ) +) + +:set_vcvars +if "%vcvars%" == "" ( + @echo "could not found vcvars64.bat file" + goto :finish +) else ( + @echo "config MSVC environment..." + call "%vcvars%" amd64 +) + + +:: ʽĿáװ +@echo ------------ ׼ ------------ +cmake -B%builddir% %CMAKE_OPTIONS% . +cmake --build %builddir% --config %CMAKE_BUILD_TYPE% +cmake --install %builddir% --prefix %installdir% +:: ʹõIJ֣ install Զõ windeployqt Ѿ +@REM cmake --build %builddir% --target windows-deployqt +goto :finish + + +:: 쳣˳Ķλ +:finish +pause + +:: ģ cmd Powershell +:: ģ帴ƵĿĿ¼ƣ Windows ˫ +:: ÿ \ No newline at end of file diff --git a/cmake/modules/Notepad--.cmake b/cmake/modules/Notepad--.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d0d14550116c37eb839fe36041ffa34fe2f61721 --- /dev/null +++ b/cmake/modules/Notepad--.cmake @@ -0,0 +1,68 @@ +# Notepad--.cmake + +# Notepad-- 核心构建 +# 在模块化构建中,这个部分代表着构建 Notepad-- +# 1. 默认构建时产出的目标为 Notepad-- +# 2. 在此处可对 Notepad-- 目标进行详细的构建计划 + +if(TRUE) + # 准备构建 Notepad-- 主程序 + set(QRC_SOURCES src/RealCompare.qrc) + spark_add_executable_path(${PROJECT_NAME} + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/cceditor + ${QRC_SOURCES}) + + target_include_directories(${PROJECT_NAME} PRIVATE + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/cceditor + + ${PROJECT_SOURCE_DIR}/src/qscint/src + ${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex + ) + # target_link_libraries(${PROJECT_NAME} QSci) + target_link_QSci(${PROJECT_NAME}) + if(USE_QT6) + target_link_qt6_Core5Compat(${PROJECT_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分 + target_link_qt6_PrintSupport(${PROJECT_NAME}) + # target_link_qt6_XmlPatterns(${PROJECT_NAME}) # Bug 初期配置时无此依赖要求 + else() + target_link_qt5_PrintSupport(${PROJECT_NAME}) + target_link_qt5_XmlPatterns(${PROJECT_NAME}) + endif(USE_QT6) +endif(TRUE) + +# ----------------- Notepad-- 插件支持相关 ----------------- # +if(TRUE) + # 开启插件支持 - 此处废弃,并由构建宏支持部分处理 + # target_compile_definitions(${PROJECT_NAME} PUBLIC NO_PLUGIN) + # 其它有关插件的部分处理... +endif(TRUE) + + +# Notepad-- 目标在构建时依赖了一些其它内容,像先前构建的 QSci 目标、Qt5::XmlPatterns +# Notepad-- 程序构建...配置 + +# ----------------- Notepad-- 构建宏支持相关 ----------------- # + +if(WIN32) + # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译 + target_compile_definitions(${PROJECT_NAME} + PRIVATE + NO_PLUGIN # 开启插件支持 + QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT + # 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT + ) +endif(WIN32) + +if(UNIX) + # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译 + target_compile_definitions(${PROJECT_NAME} + PRIVATE + NO_PLUGIN # 开启插件支持 + ) +endif(UNIX) diff --git a/cmake/modules/QScint.cmake b/cmake/modules/QScint.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6bca66f7b495de5742e0c5714d6402c2b6a500d6 --- /dev/null +++ b/cmake/modules/QScint.cmake @@ -0,0 +1,85 @@ +# QScint.cmake + +# 在模块化构建中,这个部分代表着构建 Qscintilla +# 1. 静态化构建库时产出的目标为 libQSci.a +# 2. 在此处可对 QSci 目标进行详细的构建计划 + +option(NOTEPAD_BUILD_BY_SHARED "指定 Notepad 将构建为动态库" OFF) + +if(TRUE) + # add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) + # file(GLOB MOC_HEADER src/qscint/src/Qsci/*.h) + spark_file_glob(MOC_HEADER "src/qscint/src/Qsci/*.h") + + spark_add_source_paths(QSciSources + src/qscint/src + src/qscint/scintilla/lexers + src/qscint/scintilla/lexlib + src/qscint/scintilla/src + src/qscint/scintilla/boostregex + + # src/qscint/src/Qsci + # FAIL: only *.ui will spark_file_glob(MOC_HEADER ...) + ) + if(NOTEPAD_BUILD_BY_SHARED) + spark_add_library(QSci SHARED ${QSciSources} ${MOC_HEADER}) + else() + spark_add_library(QSci STATIC ${QSciSources} ${MOC_HEADER}) + endif(NOTEPAD_BUILD_BY_SHARED) + target_include_directories(QSci PRIVATE + src/qscint/scintilla/boostregex + src/qscint/scintilla/lexlib) + target_include_directories(QSci PUBLIC + src/qscint/src + src/qscint/src/Qsci + src/qscint/scintilla/src + src/qscint/scintilla/include) + if(USE_QT6) + target_link_qt6(QSci) + target_link_qt6_Core5Compat(QSci) + target_link_qt6_PrintSupport(QSci) + target_link_qt6_Concurrent(QSci) + if(APPLE) + # Is there anything missing? + # MacExtras? + endif(APPLE) + else() + target_link_qt5(QSci) + target_link_qt5_PrintSupport(QSci) + target_link_qt5_Concurrent(QSci) + if(APPLE) + find_package(Qt5 COMPONENTS MacExtras) + target_link_libraries(QSci Qt5::MacExtras) + endif(APPLE) + endif(USE_QT6) +endif(TRUE) + + +# QSci 库构建时依赖了一些其它内容,像 PrintSupport,Concurrent 等 +# QSci 库构建...配置 + +if(WIN32) + # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译 + target_compile_definitions(QSci + PRIVATE + SCINTILLA_QT # + SCI_LEXER # + INCLUDE_DEPRECATED_FEATURES # + QSCINTILLA_MAKE_DLL # 在 Windows 中构建此库时应该采用 Q_DECL_EXPORT + # 并且在 Windows 中使用此库时应该采用 Q_DECL_IMPORT + # 控制 QSCINTILLA_EXPORT 符号应为: + # 构建时(导出),由外部使用时(导入) + ) +endif(WIN32) + +if(UNIX) + # 在 Linux 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译 + target_compile_definitions(QSci + PRIVATE + SCINTILLA_QT # + SCI_LEXER # + INCLUDE_DEPRECATED_FEATURES # + # QSCINTILLA_MAKE_DLL # 在 Linux 未使用 Q_DECL_EXPORT 、 Q_DECL_IMPORT + # 控制 QSCINTILLA_EXPORT 符号应为留空 + ) +endif(UNIX) diff --git a/how_build/cmake/nsis_package_config.cmake b/cmake/nsis_package_config.cmake similarity index 100% rename from how_build/cmake/nsis_package_config.cmake rename to cmake/nsis_package_config.cmake diff --git a/cmake/platforms/linux-appimage.cmake b/cmake/platforms/linux-appimage.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f3b2d1469d9b4dff51947aa2d67856216caf283f --- /dev/null +++ b/cmake/platforms/linux-appimage.cmake @@ -0,0 +1,48 @@ +# linux-appimage.cmake + +# 此构建表示,在 Linux 中以通用平台的构建方式进行 Appimage 打包 + +# 1. SparkAppimageConfig.cmake 依赖于 SparkDesktopMacros.cmake 构建的 desktop +# 2. 为可执行程序进行部署一个 linuxdeployqt 操作,并生成为 Appimage 可用于打包的目录结构 +# 3. 使用 Appimagetool 对已生成的 Appimage 标准目录进行打包 +# 4. 将会生成一个 Notepad--.X86_64.Appimage + +# 参看 Appimagetool 相关的内容: + # https://doc.appimage.cn/docs/appimagetool-usage/ + +option(LINUX_DEPLOY_QT "为 Linux 中构建的应用进程 linuxdeployqt" OFF) +if(LINUX_DEPLOY_QT) + # ... 已由 Appimage 自动化构建组件完成 +endif(LINUX_DEPLOY_QT) + +option(USE_LINUX_APPIMAGE "为 Linux 生成 Appimage 可执行程序" OFF) + +if(USE_LINUX_APPIMAGE) + + include(cmake/SparkDesktopMacros.cmake) + # 内容默认应用名称: Name= 应与项目名称相同 + spark_desktop_macros( + # 应用名称: Name= + ${PROJECT_NAME} + # 应用名称: Name[zh_CN]= + "Notepad--" + # 应用说明: Comment= + "Notepad-- 是一个国产跨平台、简单的文本编辑器。" + # 应用类型: Type= + "Application" + # 执行程序: Exec= + # 有关此 %F 参数可查看: https://gitee.com/zinface/z-tools/blob/desktop-dev/src/DesktopGenerater/desktopexecparamdialog.cpp + "notepad-- %F" + # 图标路径: Icon= + "/usr/share/notepad--/icons/spark.png" + # 应用分类: Category= + "Development" + ) + + # 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_target(${PROJECT_NAME}) # 应用对 Appimage 的构建 + +endif(USE_LINUX_APPIMAGE) diff --git a/cmake/platforms/linux-debian.cmake b/cmake/platforms/linux-debian.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9e0848f9faf3ebd9227e42d23a671b47b7ef37df --- /dev/null +++ b/cmake/platforms/linux-debian.cmake @@ -0,0 +1,18 @@ +# linux-debian.cmake + +# 此构建表示,在 Linux 中以通用平台的构建方式进行 Debian 打包 + +# 1. 在 cmake/package-deb.descript 中提供标准软件包描述信息 +# 2. 在 DebPackageConfig.cmake 构建模块中分析与自动化配置 + +option(USE_LINUX_DEBIAN "为 Linux 生成 deb 软件包" OFF) + +if(USE_LINUX_DEBIAN) + + find_package(SparkDebPackage PATHS ${CMAKE_SOURCE_DIR}) + add_package_descript(cmake/spark-deb-package.descript) + +endif(USE_LINUX_DEBIAN) + + + diff --git a/cmake/platforms/linux-universal.cmake b/cmake/platforms/linux-universal.cmake new file mode 100644 index 0000000000000000000000000000000000000000..598eddd3acb6e1354778cc9130b23da421e0652b --- /dev/null +++ b/cmake/platforms/linux-universal.cmake @@ -0,0 +1,122 @@ +# linux-universal.cmake + +# 此构建表示,在 Linux 中以通用平台的构建方式进行构建此内容 +# +# /usr/bin/ 在 Linux 中标准的程序位置 +# Notepad-- +# +# /usr/inculde/ 在 Linux 中提供一系列可提供插件开发的头文件 +# NotepadPlugin/ +# pluginGl.h +# QSci/ +# qscint/scintilla/ +# +# /usr/lib/ 在 Linux 中提供一个用于插件开发的核心依赖文件 +# NotepadPlugin/ +# libQSci.so +# +# /usr/lib/cmake/ 在 Linux 中提供一个用于插件开发的核心开发配置 +# NotepadPlugin/ +# NotepadPluginConfig.cmake +# +# /usr/share/Notepad--/ 在 Linux 中提供一个用于随带资源文件的目录 +# plugin/ +# themes/ +# + + +# 可能需要变更为 CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" ?? +# 并使用 Linux.cmake 维护? +if(CMAKE_HOST_UNIX) + include(cmake/SparkInstallMacrosConfig.cmake) + + # 当使用 Linux 构建应用时,可执行程序的资源文件应该存放在此处 + set(LINUX_APPLICATION_DIR /usr/share/${PROJECT_NAME}) + + # 通用的 Linux 资源文件 + spark_install_directory(/usr cmake/platforms/linux/universal/usr/*) + + # 如何安装 themes ? 安装到该程序的资源目录/themes + # 如何准备 plugin ? 安装到该程序的资源目录/plugin + spark_install_directory(${LINUX_APPLICATION_DIR} src/themes) + + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + include(CMakePackageConfigHelpers) + include(GNUInstallDirs) + + # 定义插件配置安装位置 + set(CMAKE_INSTALL_PREFIX "/usr") + set(NOTEPAD_PLUGIN NotepadPlugin) + + # 定义开发插件时的配置目录与 CMake 模块文件名称 + set(NOTEPAD_PLUGIN_CONFIG ${NOTEPAD_PLUGIN}Config.cmake) + # 定义一些扩展内容,主要是提供给 CMake 模块文件填充 + set(NOTEPAD_PLUGIN_CORELIB QSci) # QSci 为构建的 QScintllia 库 + + # 将当前平台构建的目标转为平台下的库名称 + include(cmake/platforms/utils.cmake) + get_current_platform_lib_name(NOTEPAD_PLUGIN_CORELIB_NAME + ${NOTEPAD_BUILD_BY_SHARED} + QSci) + + # 定义在插件开发的 CMake 模块中,Notepad-- 是否是基于 QT5 实现 + # 并自动为插件开发层自动开启相关 Qt 依赖组件 + # 此部分逻辑将自动提供给 add_notepad_plugin 自行处理 + set(NOTEPAD_BUILD_BY_QT5 TRUE) + set(NOTEPAD_BUILD_BY_QT6 FALSE) + + if(USE_QT6) + set(NOTEPAD_BUILD_BY_QT5 FALSE) + set(NOTEPAD_BUILD_BY_QT6 TRUE) + endif(USE_QT6) + + # 定义在平台中插件应该安装的位置(待确定) + # 定义在插件开发的 CMake 模块中,Notepad-- 是否将提供 "插件安装目录(位置)" + set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY "") + + # 这些是在此部分安装时使用,但不被用于填充 NotepadPlugin.cmake.in 的内容 + set(NOTEPAD_PLUGIN_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${NOTEPAD_PLUGIN}) + set(NOTEPAD_PLUGIN_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NOTEPAD_PLUGIN}) + + + # 将 NOTEPAD_PLUGIN_INCLUDEDIR NOTEPAD_PLUGIN_LIBDIR 填充到 cmake 文件 + configure_package_config_file(cmake/NotepadPluginConfig.cmake.in + ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG} + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN}) + # 安装 cmake 文件 + spark_install_file(${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN} + ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG}) + # 安装头插件接口文件 + spark_install_file(${NOTEPAD_PLUGIN_INCLUDEDIR} + src/include/pluginGl.h) + # 安装插件所需要的Qsci文件 + spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR} + src/qscint/src/Qsci) + # 安装开发插件高级功能所需要的内容 + spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR}/qscint + src/qscint/scintilla) + + # 导出 QSci 的头文件(从插件实现层面来看,目前是使用*.h 与 pluginGl.h + # 但从 Qsci 层面来看,*.h 使用的是 #include ,所以此部分不被使用) + # spark_file_glob(QSci_HEADERS src/qscint/src/Qsci/*.h src/include/pluginGl.h) + # set_target_properties(QSci PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") + + # 导出 Notepad-- 的接口文件(从逻辑层面来看,目前已经在前面安装了接口文件,所以此部分不被使用) + # spark_file_glob(Notepad_HEADERS src/include/pluginGl.h) + # set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") + + # 安装项目文件与 QSci 文件 + install(TARGETS ${PROJECT_NAME} QSci + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} + ARCHIVE DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} + PUBLIC_HEADER DESTINATION ${NOTEPAD_PLUGIN_INCLUDEDIR} + ) + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + +endif(CMAKE_HOST_UNIX) + diff --git a/cmake/platforms/linux-uos.cmake b/cmake/platforms/linux-uos.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e1603d695b54b0e5d64f8dfdfb6e2d5856a67793 --- /dev/null +++ b/cmake/platforms/linux-uos.cmake @@ -0,0 +1,72 @@ +# linux-uos.cmake + +# 此构建表示,在独立于 Linux 的 Uos 或 Deepin 平台,以此方式构建内容 +# 1. 主要用于规范化构建,并使用项目中准备好的目录结构进行构建 +# 2. 安装内容 + # 1. 起始路径要求: /opt/apps// + # 2. 系统路径要求: entries + # 1. icon、applications、metadata 等位于 entries + # 3. 文件部分要求: files + # 1. Notepad-- 位于 files + # 2. themes 位于 files + # 3. plugin 位于 files + +# /. +# /opt +# /opt/apps +# /opt/apps/com.hmja.notepad +# /opt/apps/com.hmja.notepad/entries +# /opt/apps/com.hmja.notepad/entries/applications +# /opt/apps/com.hmja.notepad/entries/applications/com.hmja.notepad.desktop +# /opt/apps/com.hmja.notepad/entries/icons +# /opt/apps/com.hmja.notepad/entries/icons/hicolor +# /opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable +# /opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps +# /opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps/ndd.svg +# /opt/apps/com.hmja.notepad/files +# /opt/apps/com.hmja.notepad/files/Notepad-- +# /opt/apps/com.hmja.notepad/files/themes +# /opt/apps/com.hmja.notepad/files/themes/.... +# /opt/apps/com.hmja.notepad/info + +option(USE_LINUX_UOS "为 Linux Uos 生成规范的软件包" OFF) + +if(USE_LINUX_UOS) + + # 一些相关的信息,用标准结构定义 + set(UOS_APP_ID "com.hmja.notepad") + set(UOS_APP_HOME_DIR "/opt/apps/${UOS_APP_ID}") + set(UOS_APP_HOME_ENTRY_DIR "${UOS_APP_HOME_DIR}/entries") + set(UOS_APP_HOME_FILES_DIR "${UOS_APP_HOME_DIR}/files") + set(UOS_APP_HOME_INFO_FILE "${UOS_APP_HOME_DIR}/info") + + # 当使用 Linux 构建应用时,可执行程序的资源文件应该存放在此处 + set(LINUX_UOS_APP_HOME_DIR ${UOS_APP_HOME_DIR}) + + include(cmake/SparkInstallMacrosConfig.cmake) + + # ------------------ 部署应用目录结构 ------------------ # + # 1. 将项目内准备的 Uos 应用目录安装到 /opt/apps/ 中 + spark_install_directory(/opt/apps/ + cmake/platforms/linux/uos/${UOS_APP_HOME_DIR} + ) + + # ------------------ 构建与资源文件安装 ------------------ # + # 1. 安装可执行文件到 files 目录 + spark_install_target(${UOS_APP_HOME_FILES_DIR} + ${PROJECT_NAME} + ) + # 2. 安装 themes 目录到 files 目录 + spark_install_directory(${UOS_APP_HOME_FILES_DIR} + src/themes + ) + + # ------------------ 最终打包 deb 部分 ------------------ # + # 1. 为即将构建的 Uos 增加 Uos 后缀 + # set(PACKAGE_SUFFIX "_onlyUos") + + # 2. 使用同样来自 debian 系列的 deb 构建能力 + find_package(SparkDebPackage PATHS ${CMAKE_SOURCE_DIR}) + add_package_descript(cmake/spark-deb-package.descript) + +endif(USE_LINUX_UOS) diff --git a/cmake/platforms/linux/universal/usr/share/applications/io.gitee.cxasm.notepad--.desktop b/cmake/platforms/linux/universal/usr/share/applications/io.gitee.cxasm.notepad--.desktop new file mode 100644 index 0000000000000000000000000000000000000000..8a1d5894f7a53fabc9494b47a63057f2bd1d32cf --- /dev/null +++ b/cmake/platforms/linux/universal/usr/share/applications/io.gitee.cxasm.notepad--.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Name=Notepad-- +Name[zh_CN]=Notepad-- +Comment=Notepad-- 是一个国产跨平台、简单的文本编辑器。 +Type=Application +Exec=Notepad-- %F +Icon=notepad-- +Categories=Development;Office; +Terminal=false +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; + +# Generated from the DesktopGenerater component of the z-Tools toolkit diff --git a/cmake/platforms/linux/universal/usr/share/icons/hicolor/128x128/apps/notepad--.png b/cmake/platforms/linux/universal/usr/share/icons/hicolor/128x128/apps/notepad--.png new file mode 100644 index 0000000000000000000000000000000000000000..8df364d4e3ac4b5c81bfdd704be06edec736240d Binary files /dev/null and b/cmake/platforms/linux/universal/usr/share/icons/hicolor/128x128/apps/notepad--.png differ diff --git a/cmake/platforms/linux/universal/usr/share/icons/hicolor/32x32/apps/notepad--.png b/cmake/platforms/linux/universal/usr/share/icons/hicolor/32x32/apps/notepad--.png new file mode 100644 index 0000000000000000000000000000000000000000..fa547b6c787bc9256b9c5bfeb27d6d064478a2c6 Binary files /dev/null and b/cmake/platforms/linux/universal/usr/share/icons/hicolor/32x32/apps/notepad--.png differ diff --git a/cmake/platforms/linux/universal/usr/share/icons/hicolor/64x64/apps/notepad--.png b/cmake/platforms/linux/universal/usr/share/icons/hicolor/64x64/apps/notepad--.png new file mode 100644 index 0000000000000000000000000000000000000000..8d3f055968d51a2be8cd305ef26af608cc09a190 Binary files /dev/null and b/cmake/platforms/linux/universal/usr/share/icons/hicolor/64x64/apps/notepad--.png differ diff --git a/cmake/platforms/linux/universal/usr/share/licenses/notepad--/LICENSE b/cmake/platforms/linux/universal/usr/share/licenses/notepad--/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..818433ecc0e094a4db1023c68b33f24344643ad8 --- /dev/null +++ b/cmake/platforms/linux/universal/usr/share/licenses/notepad--/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/cmake/platforms/linux/universal/usr/share/metainfo/io.gitee.cxasm.notepad--.metainfo.xml b/cmake/platforms/linux/universal/usr/share/metainfo/io.gitee.cxasm.notepad--.metainfo.xml new file mode 100644 index 0000000000000000000000000000000000000000..8b337d185543ff1a71778ebd9b062ad2f7a3e01e --- /dev/null +++ b/cmake/platforms/linux/universal/usr/share/metainfo/io.gitee.cxasm.notepad--.metainfo.xml @@ -0,0 +1,18 @@ + + + io.gitee.cxasm.notepad-- + + Notepad-- + Notepad-- + + MIT + GPL-2.0-or-later + + +

+ notepad--是一个国产跨平台、简单的文本编辑器,是替换notepad++的一种选择。其内置强大的代码对比功能,让你丢掉付费的beyond compare。 +

+
+ + io.gitee.cxasm.notepad--.desktop +
diff --git a/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/applications/io.gitee.cxasm.notepad--.desktop b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/applications/io.gitee.cxasm.notepad--.desktop new file mode 100644 index 0000000000000000000000000000000000000000..9d14570bef566af321a679c155e62b91eca621a8 --- /dev/null +++ b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/applications/io.gitee.cxasm.notepad--.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Version=1.0 +Name=Notepad-- +Name[zh_CN]=Notepad-- +Comment=Notepad-- 是一个国产跨平台、简单的文本编辑器。 +Type=Application +Exec=/opt/apps/com.hmja.notepad/files/Notepad-- %U +Icon=/opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps/ndd.svg +Categories=TextEditor; +Encoding=UTF-8 +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; +StartupNotify=true +Terminal=false +TryExec=/opt/apps/com.hmja.notepad/files/Notepad-- +X-DDE-FileManager-MenuTypes=SingleFile + +# Generated from the DesktopGenerater component of the z-Tools toolkit diff --git a/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps/ndd.svg b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps/ndd.svg new file mode 100644 index 0000000000000000000000000000000000000000..8c25acdb77fec767656d8bd1e7d7d9db84488b79 --- /dev/null +++ b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/icons/hicolor/scalable/apps/ndd.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/licenses/notepad--/LICENSE b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/licenses/notepad--/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..818433ecc0e094a4db1023c68b33f24344643ad8 --- /dev/null +++ b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/licenses/notepad--/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/metainfo/io.gitee.cxasm.notepad--.metainfo.xml b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/metainfo/io.gitee.cxasm.notepad--.metainfo.xml new file mode 100644 index 0000000000000000000000000000000000000000..8b337d185543ff1a71778ebd9b062ad2f7a3e01e --- /dev/null +++ b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/entries/metainfo/io.gitee.cxasm.notepad--.metainfo.xml @@ -0,0 +1,18 @@ + + + io.gitee.cxasm.notepad-- + + Notepad-- + Notepad-- + + MIT + GPL-2.0-or-later + + +

+ notepad--是一个国产跨平台、简单的文本编辑器,是替换notepad++的一种选择。其内置强大的代码对比功能,让你丢掉付费的beyond compare。 +

+
+ + io.gitee.cxasm.notepad--.desktop +
diff --git a/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/info b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/info new file mode 100644 index 0000000000000000000000000000000000000000..c2f0b44f57ddbf4ce390558feaec010100a372bf --- /dev/null +++ b/cmake/platforms/linux/uos/opt/apps/com.hmja.notepad/info @@ -0,0 +1,18 @@ +{ + "appid": "com.hmja.notepad", + "name": "Notepad--", + "version": "1.22.1.0", + "arch": ["amd64"], + "permissions": { + "autostart": false, + "notification": false, + "trayicon": false, + "clipboard": true, + "account": false, + "bluetooth": false, + "camera": false, + "audio_record": false, + "installed_apps": false + } +} + diff --git a/cmake/platforms/macos-deployqt.cmake b/cmake/platforms/macos-deployqt.cmake new file mode 100644 index 0000000000000000000000000000000000000000..eb43d760e246a6790233de23dd7662a13bcdb8d9 --- /dev/null +++ b/cmake/platforms/macos-deployqt.cmake @@ -0,0 +1,78 @@ +# macos-deployqt.cmake + +# NOTE: 未提供可用性判断 + +# option(MACOSX_DEPLOY_QT "为 MacOS 中构建的应用进行 macdeployqt" OFF) +# option(MACOSX_DEPLOY_QT5 "为 MacOS 中构建的 QT5 应用进行 macdeployqt" OFF) +# option(MACOSX_DEPLOY_QT6 "为 MacOS 中构建的 QT6 应用进行 macdeployqt" OFF) + +# if(USE_MACOSX_DEPLOY_QT) +# if(MACOSX_DEPLOY_QT5) +# # 当使用 MACOSX_DEPLOY_QT5 配方时,将使用来源于 Qt5 中提供的路径 +# set(MACOSX_QT_DIR "${Qt5_DIR}") +# elseif(MACOSX_DEPLOY_QT6) +# # 当使用 MACOSX_DEPLOY_QT6 配方时,将使用来源于 Qt6 中提供的路径 +# set(MACOSX_QT_DIR "${Qt6_DIR}") +# endif() + +# if (MACOSX_DEPLOY_QT5 OR MACOSX_DEPLOY_QT6) + +# if(USE_QT6) +# set(MACOSX_QT_DIR "${Qt6_DIR}") +# endif(USE_QT6) + +# #/opt/homebrew/Cellar/qt@5/5.15.10_1/bin/macdeployqt +# set(MACOS_APPLICATION_DEPLOY_PATH +# ${CMAKE_BINARY_DIR}/macos-deployqt) + +# set(MACOS_APPLICATION_BUNDLE_PATH +# ${MACOS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.app) + +# # set_target_properties(${PROJECT_NAME} +# # PROPERTIES +# # 可执行文件生成目录 +# # MACOSX_BUNDLE TRUE +# # RUNTIME_OUTPUT_DIRECTORY ${MACOS_APPLICATION_DEPLOY_PATH}) +# # RUNTIME_OUTPUT_DIRECTORY ${MACOS_APPLICATION_DEPLOY_PATH}/Contents/MacOS) + +# message("MACOS_QT_DIR: ${MACOS_QT_DIR}") + + +# # install(FILES src/mac.icns +# # DESTINATION +# # ${MACOS_APPLICATION_DEPLOY_PATH}/Contents/Resources) + +# # add_custom_command(TARGET ${PROJECT_NAME} +# # # 在构建之后计划进行执行以下命令 +# # POST_BUILD +# # # 即将在构建目录中 +# # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +# # # COMMAND ${CMAKE_COMMAND} -E make_directory +# # # ${MACOS_APPLICATION_BUNDLE_PATH}/Contents/Resources/ +# # # COMMAND ${CMAKE_COMMAND} -E copy +# # # ${CMAKE_SOURCE_DIR}/src/mac.icns +# # # ${MACOS_APPLICATION_BUNDLE_PATH}/Contents/Resources/ +# # # 执行以下命令进行 windeployqt +# # COMMAND ${MACOS_QT_DIR}/../../../bin/macdeployqt +# # # +# # ${MACOS_APPLICATION_BUNDLE_PATH} + +# # # 扫描QML-从目录开始导入。 +# # #--qmlimport=${MACOS_QT_DIR}/../../../qml +# # # 部署编译器运行时(仅限桌面)。 +# # #--compiler-runtime +# # # 详细级别(0-2) +# # #--verbose=2 +# # # 部署运行时使用指定的目录 +# # # --dir ${MACOS_APPLICATION_DEPLOY_PATH} +# # ) + +# if(USE_MAC_DEPLOYQT) +# include(cmake/platforms/utils.cmake) +# macdeployqt_install(${PROJECT_NAME}) +# endif(USE_MAC_DEPLOYQT) + +# include(CPack) + +# endif(MACOSX_DEPLOY_QT5 OR MACOSX_DEPLOY_QT6) +# endif(USE_MACOSX_DEPLOY_QT) diff --git a/cmake/platforms/macos-universal.cmake b/cmake/platforms/macos-universal.cmake new file mode 100644 index 0000000000000000000000000000000000000000..bb6a24acc34a8c1087f4ca7ff46071211359e811 --- /dev/null +++ b/cmake/platforms/macos-universal.cmake @@ -0,0 +1,25 @@ +# macos-universal.cmake + +# 此构建表示,在 MacOSX 中以通用平台的构建方式进行构建此内容 +# 为 Notepad-- 通用构建的设计安装结构 +# +# Contents/ 在 MacOSX 中标准的包目录 +# MacOS/ +# Notepad-- 在 MacOSX 中标准的程序位置 +# +# Resources/ +# ... + +if(CMAKE_HOST_APPLE) + + set(CPACK_GENERATOR "Bundle") + set(CPACK_BUNDLE_NAME ${PROJECT_NAME}) + set(CPACK_BUNDLE_ICON ${CMAKE_SOURCE_DIR}/src/mac.icns) + set(CPACK_BUNDLE_PLIST ${CMAKE_SOURCE_DIR}/cmake/platforms/macos/cpack/Info.plist) + + # 程序安装位置 + install(TARGETS ${PROJECT_NAME} DESTINATION ../MacOS) + # 安装 themes + install(DIRECTORY src/themes DESTINATION ../MacOS) + +endif(CMAKE_HOST_APPLE) diff --git a/cmake/platforms/macos/cpack/Info.plist b/cmake/platforms/macos/cpack/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..433737b1a6d2e179d1b0ea25b86c8ec891e2b0d1 --- /dev/null +++ b/cmake/platforms/macos/cpack/Info.plist @@ -0,0 +1,161 @@ + + + + + CFBundleExecutable + Notepad-- + CFBundleGetInfoString + Created by zuoweiyin + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + txt + + CFBundleTypeIconFile + txt.png + CFBundleTypeName + abc file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + cpp + + CFBundleTypeIconFile + cpp.png + CFBundleTypeName + cpp file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + xml + + + CFBundleTypeExtensions + + c + + CFBundleTypeIconFile + c.png + CFBundleTypeName + c file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + xml + + + CFBundleTypeExtensions + + h + + CFBundleTypeIconFile + h.png + CFBundleTypeName + h file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + html + + CFBundleTypeIconFile + html.png + CFBundleTypeName + html file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + ini + go + java + js + json + xml + pro + pri + php + asp + bat + asm + html + yml + js + sh + log + csv + json + + CFBundleTypeIconFile + *.png + CFBundleTypeName + * file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + html + + CFBundleTypeIconFile + html.png + CFBundleTypeName + html file + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleIconFile + Notepad--.icns + CFBundleIdentifier + www.itdp.cn.Notepad-- + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSMinimumSystemVersion + 14.1 + NOTE + This file was generated by Qt/QMake. + NSPrincipalClass + NSApplication + NSSupportsAutomaticGraphicsSwitching + + NSRequiresAquaSystemAppearance + + + diff --git a/cmake/platforms/utils.cmake b/cmake/platforms/utils.cmake new file mode 100644 index 0000000000000000000000000000000000000000..829e147d360169a7896a2e96a3e3b3e2a764a0f3 --- /dev/null +++ b/cmake/platforms/utils.cmake @@ -0,0 +1,137 @@ +# utils.cmake + # 定义一些其它工具函数 + +# get_current_platform_lib_name <_VAR> <_IS_IS_SHREAD> <_LIB> + # _VAR 用于存储内容的变量 + # _IS_IS_SHREAD 是否为共享库 + # _LIB 目标名称 + function(get_current_platform_lib_name _VAR _IS_SHREAD _LIB) + set(_LIB_NAME "") + if(WIN32) + set(_LIB_NAME ${_LIB}.lib) + elseif(UNIX AND NOT APPLE) + if(${_IS_SHREAD}) + set(_LIB_NAME lib${_LIB}.so) + else() + set(_LIB_NAME lib${_LIB}.a) + endif(${_IS_SHREAD}) + elseif(APPLE) + if(${_IS_SHREAD}) + set(_LIB_NAME lib${_LIB}.dylib) + else() + set(_LIB_NAME lib${_LIB}.a) + endif(${_IS_SHREAD}) + else() + message("ERROR: Unknow current platform") + set(_LIB_NAME ${_LIB}) + endif() + message("[utils.cmake] get_current_platform_lib_name: ${_LIB}(${_LIB_NAME}) ") + set(${_VAR} ${_LIB_NAME} PARENT_SCOPE) +endfunction(get_current_platform_lib_name _VAR _IS_SHREAD _LIB) +# 获取当前平台的 lib 名称 +# 在 Windows 中 + # 用于编译的静态库与动态库后缀相同: .lib + # 并且不是 lib 开头 +# 在 Linux 中 + # 用于编译的静态库与动态库后缀分别是:.a 与 .so + # 文件名称由 lib 开头 +# 在 MacOS 中 + # 用于编译的静态库与动态库后缀分别是:.a 与 .dylib + # 文件名称由 lib 开头 + +# qt5_qt6_compatible_check + # Qt5/6 兼容性构建检查方案,如果文件中存在 true 将认为可兼容构建 + # _CHECK_FILE Qt5/Qt6 兼容性检查文件 + # _VAR 检查结果 +function(qt5_qt6_compatible_check _CHECK_FILE _VAR) + set(${_VAR} true PARENT_SCOPE) + file(READ ${_CHECK_FILE} file_content) + string(FIND ${file_content} "true" _index) + if(_index LESS 0) + # -1: It is not checked and passed + set(${_VAR} false PARENT_SCOPE) + endif(_index LESS 0) +endfunction(qt5_qt6_compatible_check _CHECK_FILE _VAR) + + +# windeployqt_install + # Windows 在 install 目标时进行 windeployqt 的自动化 + # 根据 + # https://blog.nathanosman.com/2017/11/24/using-windeployqt-with-cpack.html +function(windeployqt_install TARGET) + # string(TOLOWER "${ALIAS}_file" _file) + # string(TOLOWER "${ALIAS}_output" _output) + + set(WINDEPLOYQT_EXECUTABLE "${WINDOWS_QT_DIR}/../../../bin/windeployqt") + # + file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/${TARGET}_PATH" + CONTENT "$" + ) + install(CODE + " + file(READ \"${CMAKE_BINARY_DIR}/${TARGET}_PATH\" _file) + execute_process( + COMMAND \"${WINDEPLOYQT_EXECUTABLE}\" + # 虚假的运行 windeployqt 而不复制任何内容 + --dry-run + # 扫描QML-从目录开始导入。 + --qmlimport ${WINDOWS_QT_DIR}/../../../qml + # 部署编译器运行时(仅限桌面)。 + --compiler-runtime + # 以源 目标的输出形成映射关系,以便用于解析内容 + --list mapping + \${_file} + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # 将内容转为一个列表,使用 WINDOWS_COMMAND 类型的处理方式 + separate_arguments(_files WINDOWS_COMMAND \${_output}) + + while(_files) + list(GET _files 0 _src) + list(GET _files 1 _dest) + execute_process( + COMMAND \"\${CMAKE_COMMAND}\" -E + copy_if_different \${_src} \"\${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\" + ) + message(\"COPY \${_src} \${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\") + list(REMOVE_AT _files 0 1) + endwhile(_files) + " + ) +endfunction(windeployqt_install TARGET) + +# +# [UnTested]macdeployqt_install + # MacOSX 在 install 目标时进行 macdeployqt 的自动化 + # 由于 +function(macdeployqt_install _target) + set(MACDEPLOYQT_EXECUTABLE "${MACOS_QT_DIR}/../../../bin/macdeployqt") + # + file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/${_target}_PATH" + # CONTENT "$" + CONTENT "${CMAKE_BINARY_DIR}/_CPack_Packages/Darwin/Bundle/${_target}-${PROJECT_VERSION}-Darwin/${_target}.app" + ) + install(CODE + " + file(READ \"${CMAKE_BINARY_DIR}/${_target}_PATH\" _file) + execute_process( + COMMAND \"${MACDEPLOYQT_EXECUTABLE}\" + # 虚假的运行 macdeployqt 而不复制任何内容 + --dry-run + # 扫描QML-从目录开始导入。 + #--qmlimport=${MACOS_QT_DIR}/../../../qml + # 部署编译器运行时(仅限桌面)。 + #--compiler-runtime + # 以源 目标的输出形成映射关系,以便用于解析内容 + #--list mapping + #-no-plugins + #-timestamp + \${_file} + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + " + ) +endfunction(macdeployqt_install _target) diff --git a/cmake/platforms/windows-deployqt.cmake b/cmake/platforms/windows-deployqt.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4594e89c8d0106e3ec8a2b3fb7a2804c8baae29d --- /dev/null +++ b/cmake/platforms/windows-deployqt.cmake @@ -0,0 +1,146 @@ +# windows-deployqt.cmake + +# Windows 平台 windeployqt 自动化模块 +# 在对项目进行构建时,是否需要配置 deployqt 来为项目进行构建部署设计 + +# 1. 如果需要进行 windeployqt,需要提供此 WINDOWS_DEPLOY_QT 开关 +# 2. 默认应用构建的内容将随附在此处 +# 3. 预先设置一个默认的 Windows Qt 目录变量 +set(WINDOWS_QT_DIR "") + +option(WINDOWS_DEPLOY_QT "为 Windows 中构建的应用进行 windeployqt" OFF) +option(WINDOWS_DEPLOY_QT5 "为 Windows 中构建的 QT5 应用进行 windeployqt" OFF) +option(WINDOWS_DEPLOY_QT6 "为 Windows 中构建的 QT6 应用进行 windeployqt" OFF) + +if(WINDOWS_DEPLOY_QT) + + if(WINDOWS_DEPLOY_QT5) + # 当使用 WINDOWS_DEPLOY_QT5 配方时,将使用来源于 Qt5 中提供的路径 + set(WINDOWS_QT_DIR "${Qt5_DIR}") + elseif(WINDOWS_DEPLOY_QT6) + # 当使用 WINDOWS_DEPLOY_QT6 配方时,将使用来源于 Qt6 中提供的路径 + set(WINDOWS_QT_DIR "${Qt6_DIR}") + endif() + + if (WINDOWS_DEPLOY_QT5 OR WINDOWS_DEPLOY_QT6) + + if(USE_QT6) + set(WINDOWS_QT_DIR "${Qt6_DIR}") + endif(USE_QT6) + + message("[windows-deployqt.cmake]: find windployqt tool") + message(" ${WINDOWS_QT_DIR}/../../../bin/windeployqt") + + # install(TARGETS ${PROJECT_NAME} + # DESTINATION ${CMAKE_BINARY_DIR}/windows-deployqt) + + + # 配置一个自动运行 windeployqt 配方的位置 + # 当使用 Windows Deploy Qt 时,可执行程序与即将部署的应用运行时将在此处出现 + set(WINDOWS_APPLICATION_DEPLOY_PATH + ${CMAKE_BINARY_DIR}/windows-deployqt/${PROJECT_NAME}.app/bin) + + # 在开启支持 windeployqt 配方后,这部分将会改变默认构建的目标的一些行为 + # 这是 windeployqt,所以,它应该是一个 WIN32 程序 + # 它的输出目录将定义为 + set_target_properties(${PROJECT_NAME} + PROPERTIES + # 这是一个 WIN32 程序,即可执行文件不再出现黑窗口,转而使用 WinMain(某种 Windows 内部特性) + WIN32_EXECUTABLE $<$:FALSE>$<$:TRUE> + # 静态库生成目录 + # ARCHIVE_OUTPUT_DIRECTORY "" + # 动态库生成目录 + # LIBRARY_OUTPUT_DIRECTORY "" + # 可执行文件生成目录 + RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_APPLICATION_DEPLOY_PATH}) + + # 自动化构建 Windows Deploy Qt Application + # 参考: windeployqt --qmldir + add_custom_command(TARGET ${PROJECT_NAME} + # 在构建之后计划进行执行以下命令 + POST_BUILD + # 即将在构建目录中 + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + # 执行以下命令进行 windeployqt + COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt + # + ${WINDOWS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.exe + + # 扫描QML-从目录开始导入。 + --qmlimport ${WINDOWS_QT_DIR}/../../../qml + # 部署编译器运行时(仅限桌面)。 + --compiler-runtime + # 详细级别(0-2) + --verbose 2 + # 部署运行时使用指定的目录 + --dir ${WINDOWS_APPLICATION_DEPLOY_PATH} + ) + + # 此部分为创建一个 windows-deployqt 的虚拟目标,用于对执行安装后的应用进行 windeployqt + # 手动化构建 Windows Deploy Qt Application + # 参考: windeployqt --qmldir + # add_custom_target(windows-deployqt + # COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt + # # + # ${WINDOWS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.exe + + # # 扫描QML-从目录开始导入。 + # --qmlimport ${WINDOWS_QT_DIR}/../../../qml + # # 部署编译器运行时(仅限桌面)。 + # --compiler-runtime + # # 详细级别(0-2) + # --verbose 2 + # # 部署运行时使用指定的目录 + # --dir ${CMAKE_INSTALL_PREFIX}/bin + # ) + # 以上为被废除的内容,不再定义 windows-deployqt 为安装后的目标进行配置 windeployqt + # 并转为以下部分处理 + + + # ---------- Windeployqt With Install Target ---------- # + include(cmake/platforms/utils.cmake) + windeployqt_install(${PROJECT_NAME}) + + # ---------------------------------- QSci ---------------------------------- # + + # 当 QSci 需要构建为动态库时,就已经开始导致了关联性错误,这个与原始分支上的预期的方案不符 + # 1. 需要处理运行时生成位置,将运行时与 Notepad-- 保持在一个目录下 + # 2. 处理此动态库的依赖问题,将依赖进行导出,由于 windeployqt 未解析出 Notepad-- 间接的动态库依赖 + # 需要以 QSci 为主体进行部署生成缺失的部分 + # 3. 在安装时,依然需要将动态库生成部署生成,这是一个非常让构建者烦恼的问题 + + if(NOTEPAD_BUILD_BY_SHARED) + # 如果 QSci 构建为动态库,那么它生成的位置也应该是与 Notepad-- 输出到同一个位置 + # 用于支撑 Notepad-- 的 Debug 运行时, 以及安装的续接操作 + set_target_properties(QSci + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_APPLICATION_DEPLOY_PATH}) + + add_custom_command(TARGET QSci + # 在构建之后计划进行执行以下命令 + POST_BUILD + # 即将在构建目录中 + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + # 执行以下命令进行 windeployqt + COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt + # + ${WINDOWS_APPLICATION_DEPLOY_PATH}/QSci.dll + + # 扫描QML-从目录开始导入。 + --qmlimport ${WINDOWS_QT_DIR}/../../../qml + # 部署编译器运行时(仅限桌面)。 + --compiler-runtime + # 详细级别(0-2) + --verbose 2 + # 部署运行时使用指定的目录 + --dir ${WINDOWS_APPLICATION_DEPLOY_PATH} + ) + + # ---------- Windeployqt With Install Target ---------- # + windeployqt_install(QSci) + + endif(NOTEPAD_BUILD_BY_SHARED) + + endif (WINDOWS_DEPLOY_QT5 OR WINDOWS_DEPLOY_QT6) + +endif(WINDOWS_DEPLOY_QT) \ No newline at end of file diff --git a/cmake/platforms/windows-universal.cmake b/cmake/platforms/windows-universal.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4032091e5dceeb6c13201f95543fe5eff621f8d8 --- /dev/null +++ b/cmake/platforms/windows-universal.cmake @@ -0,0 +1,107 @@ +# windows-universal.cmake + +# 此构建表示,在 Windows 中以通用平台构建方式进行构建此内容 +# 为 Notepad-- 通用构建的设计安装结构 +# +# /bin 在 Windows 中标准的程序位置 +# Notepad--.exe +# plugin/ +# themes +# +# /include/ 在 Windows 中提供一系列可提供插件开发的头文件 +# NotepadPlugin/ +# pluginGl.h +# QSci/ +# qscint/scintilla/ +# +# /lib/ 在 Windows 中提供一个用于插件开发的核心依赖文件 +# cmake/ +# NotepadPlugin/ +# NotepadPluginConfig.cmake +# NotepadPlugin/ +# QSci.lib +# + + +if(CMAKE_HOST_WIN32) + include(cmake/SparkInstallMacrosConfig.cmake) + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + include(CMakePackageConfigHelpers) + include(GNUInstallDirs) + + # 定义插件配置安装位置 + # set(CMAKE_INSTALL_PREFIX "/usr") # 仅限 Linux ,Windows 中不使用 + set(NOTEPAD_PLUGIN NotepadPlugin) + + # 定义开发插件时的配置目录与 CMake 模块文件名称 + set(NOTEPAD_PLUGIN_CONFIG ${NOTEPAD_PLUGIN}Config.cmake) + # 定义一些扩展内容,主要是提供给 CMake 模块文件填充 + set(NOTEPAD_PLUGIN_CORELIB QSci) # QSci 为构建的 QScintllia 库 + + # 将当前平台构建的目标转为平台下的库名称 + include(cmake/platforms/utils.cmake) + get_current_platform_lib_name(NOTEPAD_PLUGIN_CORELIB_NAME + ${NOTEPAD_BUILD_BY_SHARED} + QSci) + + # 定义在插件开发的 CMake 模块中,Notepad-- 是否是基于 QT5 实现 + # 并自动为插件开发层自动开启相关 Qt 依赖组件 + # 此部分逻辑将自动提供给 add_notepad_plugin 自行处理 + set(NOTEPAD_BUILD_BY_QT5 TRUE) + set(NOTEPAD_BUILD_BY_QT6 FALSE) + + if(USE_QT6) + set(NOTEPAD_BUILD_BY_QT5 FALSE) + set(NOTEPAD_BUILD_BY_QT6 TRUE) + endif(USE_QT6) + + # 定义在平台中插件应该安装的位置(待确定) + # 定义在插件开发的 CMake 模块中,Notepad-- 是否将提供 "插件安装目录(位置)" + set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY "") + + # 这些是在此部分安装时使用,但不被用于填充 NotepadPlugin.cmake.in 的内容 + set(NOTEPAD_PLUGIN_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/${NOTEPAD_PLUGIN}) + set(NOTEPAD_PLUGIN_LIBDIR ${CMAKE_INSTALL_LIBDIR}/${NOTEPAD_PLUGIN}) + + + # 将 NOTEPAD_PLUGIN_INCLUDEDIR NOTEPAD_PLUGIN_LIBDIR 填充到 cmake 文件 + configure_package_config_file(cmake/NotepadPluginConfig.cmake.in + ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG} + INSTALL_DESTINATION ${NOTEPAD_PLUGIN_LIBDIR}/cmake/${NOTEPAD_PLUGIN}) + # 安装 cmake 文件 + spark_install_file(${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN} + ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG}) + # 安装头插件接口文件 + spark_install_file(${NOTEPAD_PLUGIN_INCLUDEDIR} + src/include/pluginGl.h) + # 安装插件所需要的Qsci文件 + spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR} + src/qscint/src/Qsci) + # 安装开发插件高级功能所需要的内容 + spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR}/qscint + src/qscint/scintilla) + + # 导出 QSci 的头文件(从插件实现层面来看,目前是使用*.h 与 pluginGl.h + # 但从 Qsci 层面来看,*.h 使用的是 #include ,所以此部分不被使用) + # spark_file_glob(QSci_HEADERS src/qscint/src/Qsci/*.h src/include/pluginGl.h) + # set_target_properties(QSci PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") + + # 导出 Notepad-- 的接口文件(从逻辑层面来看,目前已经在前面安装了接口文件,所以此部分不被使用) + # spark_file_glob(Notepad_HEADERS src/include/pluginGl.h) + # set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") + + # 安装项目文件与 QSci 文件 + install(TARGETS ${PROJECT_NAME} QSci + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} + ARCHIVE DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} + PUBLIC_HEADER DESTINATION ${NOTEPAD_PLUGIN_INCLUDEDIR} + ) + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + +endif(CMAKE_HOST_WIN32) + diff --git a/cmake/qt5_qt6_compatible_check b/cmake/qt5_qt6_compatible_check new file mode 100644 index 0000000000000000000000000000000000000000..02e4a84d62c4b0fe9cca60bba7b9799f78f1f7ed --- /dev/null +++ b/cmake/qt5_qt6_compatible_check @@ -0,0 +1 @@ +false \ No newline at end of file diff --git a/cmake/spark-appimage.desktop.in b/cmake/spark-appimage.desktop.in new file mode 100644 index 0000000000000000000000000000000000000000..70fc6b90311fb5fede7eef4d00a047943c6bb3bd --- /dev/null +++ b/cmake/spark-appimage.desktop.in @@ -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/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; diff --git a/cmake/spark-appimage.desktop.in.txt b/cmake/spark-appimage.desktop.in.txt new file mode 100644 index 0000000000000000000000000000000000000000..491716de005256a849673d7a10e78575e9703ccc --- /dev/null +++ b/cmake/spark-appimage.desktop.in.txt @@ -0,0 +1,9 @@ +[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@; \ No newline at end of file diff --git a/cmake/spark-deb-package.descript b/cmake/spark-deb-package.descript new file mode 100644 index 0000000000000000000000000000000000000000..e7bc6afa2a4d96ef8407f522b74c81de684cabbe --- /dev/null +++ b/cmake/spark-deb-package.descript @@ -0,0 +1,49 @@ +# 注释行(使用方式) +# find_package(SparkDebPackage PATHS ${CMAKE_SOURCE_DIR}) +# add_package_descript(cmake/spark-deb-package.descript) + +# 打包后的文件名称 +# FileName: 待定 +# 配置 PACKAGE_SUFFIX 变量可添加尾巴名称 +# 如在 Makefile 中硬编码方式 +# OSID=$(shell lsb_release -si) +# OSRELEASE=$(shell lsb_release -sr) +# -DPACKAGE_SUFFIX="_$(OSID)$(OSRELEASE)" + +# deb 安装包的安装时脚本 +# 1.安装[前|后]执行脚本(preinst,postinst), +# 2.卸载[前|后]执行脚本(prerm,postrm) +# ControlExtra: 未定义(暂不支持) +# 如需指定请修改 DebPackageConfig.cmake 模板(第252行) +# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 变量 + +# 打包类型,暂支持 deb, 未来支持 tgz(tar.gz) +Type: deb +# 软件包名称(自动, 使用 PROJECT_NAME 变量值) +Package: com.hmja.notepad +# 软件包版本(自动, 使用 PROJECT_VERSION 变量值) +Version: auto +# 日历化尾部版本 +CalVer: true +# 声明发行版号(类似于 Debian11,Debian为OS标志,11为发行版号) +OSD: true +# 软件包架构(自动) +Architecture: auto +# 软件包属于的系统部分[admin|cli-mono|comm|database|debug|devel|doc|editors|education|electronics|embedded|fonts|games|gnome|gnu-r|gnustep|graphics|hamradio|haskell|httpd|interpreters|introspection|java|javascript|kde|kernel|libdevel|libs|lisp|localization|mail|math|metapackages|misc|net|news|ocaml|oldlibs|otherosfs|perl|php|python|ruby|rust|science|shells|sound|tasks|tex|text|utils|vcs|video|web|x11|xfce|zope] +Section: editors +# 软件包优先级[required|important|stantard|optional|extra] +Priority: optional +# 软件包依赖 +Depends: +# 软件包维护者(组织或个人) +Maintainer: Ndd开源组织 <757210198@qq.com> +# 软件包主页 +Homepage: https://gitee.com/cxasm/notepad-- +# 软件包建议 +Recommends: +# 软件冲突 +Conflicts: +# 软件包描述信息 +Descrition: Notepad--是一个国产跨平台、简单的文本编辑器。 + Notepad--是一个国产跨平台、简单的文本编辑器,是替换notepad++的一种选择。 + 其内置强大的代码对比功能,让你丢掉付费的beyond compare。 diff --git a/cmake/spark-desktop.desktop.in.txt b/cmake/spark-desktop.desktop.in.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eb46c3d017b6ed83e0aeb7c356cb0e4b23952a7 --- /dev/null +++ b/cmake/spark-desktop.desktop.in.txt @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Name=@APP_NAME@ +Name[zh_CN]=@APP_NAME_ZH_CN@ +Comment=@APP_COMMENT@ +Type=@APP_TYPE@ +Exec=@APP_EXECUTE_PATH@ +Icon=@APP_EXECUTE_ICON_PATH@ +Categories=@APP_CATEGORIES@ +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; + +# Generated from the DesktopGenerater component of the z-Tools toolkit + diff --git a/cmake/visualstudio/CMakeSettings.json b/cmake/visualstudio/CMakeSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..74a3181c6a306b26432e284c575a5d49b74674ac --- /dev/null +++ b/cmake/visualstudio/CMakeSettings.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\Debug\\${name}", + "installRoot": "${projectDir}\\out\\install\\Debug\\${name}", + "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64 -DUSE_WINDOWS_UNIVERSAL=ON -DWINDOWS_DEPLOY_QT=ON -DWINDOWS_DEPLOY_QT5=ON", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "Release", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\Release\\${name}", + "installRoot": "${projectDir}\\out\\install\\Release\\${name}", + "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64 -DUSE_WINDOWS_UNIVERSAL=ON -DWINDOWS_DEPLOY_QT=ON -DWINDOWS_DEPLOY_QT5=ON", + "buildCommandArgs": "", + "ctestCommandArgs": "" + } + ] +} \ No newline at end of file diff --git a/cmake/vscode/README.md b/cmake/vscode/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c83d021d54725e7dcdb22297ad40eec437637107 --- /dev/null +++ b/cmake/vscode/README.md @@ -0,0 +1,25 @@ +# 此处提供 vscode 工作区配置模板 + +> 根据提供的有限配置模板、进行修改可完成在 VSCode 中构建 Notepad-- 的工作 + +- windows-vs-2022-cmake-ninja.json + > 基于 Vistual Studio 2022 生成器安装的 CMake 组件 + + - 适用工具链: + 1. `Visual Studio 生成工具 2022 Release - amd64` + 2. `Visual Studio Community 2022 Release - amd64` + 3. ... + + - 注意: + 1. 工具链架构选择可能与 `msvc2017`、`msvc2017_64` 等路径有关 + +- windows-vs-2022-cmake-ninja-qt6.json + > 基于 Vistual Studio 2022 生成器安装的 CMake 组件 + + - 适用工具链: + 1. `Visual Studio 生成工具 2022 Release - amd64` + 2. `Visual Studio Community 2022 Release - amd64` + 3. ... + + - 注意: + 1. 工具链架构应该为 Qt6 所支持 msvc 构建的 `msvc2019`, `msvc2019_64` diff --git a/cmake/vscode/windows-vs-2022-cmake-ninja-qt6.json b/cmake/vscode/windows-vs-2022-cmake-ninja-qt6.json new file mode 100644 index 0000000000000000000000000000000000000000..d8dbd660568782b839eba1603d20e44a4a58268c --- /dev/null +++ b/cmake/vscode/windows-vs-2022-cmake-ninja-qt6.json @@ -0,0 +1,33 @@ +{ + // 指定使用 Visual Studio Community 安装的 CMake 组件 + "cmake.cmakePath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe", + + // 配置生成器为 Nijia + "cmake.generator": "Ninja", + + // 要在配置时传递给 CMake 的参数 + "cmake.configureArgs": [ + // 为 CMake 指定生成器后使用的构建程序,来源于 CMake 组件 + "-DCMAKE_MAKE_PROGRAM='C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe'", + // 为 CMake 指定查找 MSVC 构建支持的 Qt 库路径 + // "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64", + "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt6.4.2\\6.4.2\\msvc2019_64", + // 使用 Windows 通用构建配方 + "-DUSE_WINDOWS_UNIVERSAL=ON", + // 使用 Qt5 自动化 windeployqt + "-DWINDOWS_DEPLOY_QT=ON", + "-DWINDOWS_DEPLOY_QT5=ON", + // 明确指定为构建 QT6 版本的 Notepad-- + "-DUSE_QT6=ON" + ], + // 要在生成时传递给 CMake 的参数 + "cmake.buildArgs": [ + "-j20" + ], + // 要在生成时传递给基础生成工具的其他参数 + "cmake.buildToolArgs": [ + + ], + // 使用 install 时,安装到 build/install 目录 + "cmake.installPrefix": "${workspaceFolder}/build/install" +} \ No newline at end of file diff --git a/cmake/vscode/windows-vs-2022-cmake-ninja.json b/cmake/vscode/windows-vs-2022-cmake-ninja.json new file mode 100644 index 0000000000000000000000000000000000000000..29cc81a925828071329358f89dbf0ad40eda9dbe --- /dev/null +++ b/cmake/vscode/windows-vs-2022-cmake-ninja.json @@ -0,0 +1,30 @@ +{ + // 指定使用 Visual Studio Community 安装的 CMake 组件 + "cmake.cmakePath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe", + + // 配置生成器为 Nijia + "cmake.generator": "Ninja", + + // 要在配置时传递给 CMake 的参数 + "cmake.configureArgs": [ + // 为 CMake 指定生成器后使用的构建程序,来源于 CMake 组件 + "-DCMAKE_MAKE_PROGRAM='C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe'", + // 为 CMake 指定查找 MSVC 构建支持的 Qt 库路径 + "-DCMAKE_PREFIX_PATH=C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64", + // 使用 Windows 通用构建配方 + "-DUSE_WINDOWS_UNIVERSAL=ON", + // 使用 Qt5 自动化 windeployqt + "-DWINDOWS_DEPLOY_QT=ON", + "-DWINDOWS_DEPLOY_QT5=ON", + ], + // 要在生成时传递给 CMake 的参数 + "cmake.buildArgs": [ + "-j20" + ], + // 要在生成时传递给基础生成工具的其他参数 + "cmake.buildToolArgs": [ + + ], + // 使用 install 时,安装到 build/install 目录 + "cmake.installPrefix": "${workspaceFolder}/build/install" +} \ No newline at end of file diff --git a/how_build/CMakeLists.txt b/how_build/CMakeLists.txt deleted file mode 100644 index 43888dd98dfa06ffe419569fbf78476367c97d7f..0000000000000000000000000000000000000000 --- a/how_build/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(NotePad-- VERSION 1.22.0) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTORCC ON) - -find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) - -# qscint 关键依赖库 -add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) - -# 插件库包含 -# helloworld 动态插件库 -add_subdirectory(${PROJECT_SOURCE_DIR}/src/plugin/helloworld) - -# win下需要开启UNICODE进行支持TCHAR -if(CMAKE_HOST_WIN32) - add_definitions(-D_UNICODE -DUNICODE) -endif() - - -if(${PLUGIN_EN}) - if(${PLUGIN_EN} STREQUAL on) - add_definitions(-DNO_PLUGIN=1) - endif(${PLUGIN_EN}) -endif() - - - -file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui) -set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui) -aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) -aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC) - - -if(CMAKE_HOST_WIN32) -# 添加 WIN32 保证主程序启动没有命令行 - list(APPEND WIN_RCS ${PROJECT_SOURCE_DIR}/src/RealCompareToMinGw.rc) - add_executable(${PROJECT_NAME} WIN32 ${WIN_RCS} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) -else() - add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) -endif() - -target_include_directories(${PROJECT_NAME} PRIVATE -${PROJECT_SOURCE_DIR}/src -${PROJECT_SOURCE_DIR}/src/cceditor - -${PROJECT_SOURCE_DIR}/src/qscint/src -${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci -${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src -${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include -${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib -${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex -) - -target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) - -# set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin") -# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) - -if(CMAKE_HOST_UNIX) - install( - TARGETS ${PROJECT_NAME} - DESTINATION "bin" - ) - - install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr - DESTINATION "/") - - include(${PROJECT_SOURCE_DIR}/cmake/deb_package_config.cmake) - include(CPack) -elseif(CMAKE_HOST_WIN32) - install(TARGETS ${PROJECT_NAME} - DESTINATION "/") - - install(DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin/ - DESTINATION "/") - # 设置软件版本 - set(CPACK_PACKAGE_NAME "NotePad--") - set(CPACK_PACKAGE_DESCRIPTION "NotePad--") - set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2023") - set(CPACK_PACKAGE_VERSION "1.22.0") - set(CPACK_PACKAGE_VERSION_MAJOR "1") - set(CPACK_PACKAGE_VERSION_MINOR "22") - set(CPACK_PACKAGE_VERSION_PATCH "0") - - include(${PROJECT_SOURCE_DIR}/cmake/nsis_package_config.cmake) - include(CPack) -endif() diff --git a/how_build/linux.mk b/how_build/linux.mk deleted file mode 100644 index 43f4a79e18d17f29917c568bcf5714073ebe88c1..0000000000000000000000000000000000000000 --- a/how_build/linux.mk +++ /dev/null @@ -1,42 +0,0 @@ -CPUS=$(shell nproc) -CALENDAR=$(shell date '+%Y%m%d') -OSID=$(shell lsb_release -si) -OSRELEASE=$(shell lsb_release -sr) -SUFFIX= -ifneq ("$(OSID)", "") -SUFFIX=_$(OSID)$(OSRELEASE) -endif - -PROJECT_NAME=notepad-- -PACKAGE_NAME=com.hmja.notepad - -all: - mkdir -p build - cd build && cmake .. - cd build && make -j$(CPUS) - -run: all - exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME)) - -debug: - mkdir -p build - cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. - cd build && make -j$(CPUS) - -release: - mkdir -p build - cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=off -DPACKAGE_SUFFIX="$(SUFFIX)" .. - cd build && make -j$(CPUS) - -package: release - cd build && make package - tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-* -# dpkg-deb --contents build/$(PROJECT_NAME)$(SUFFIX).deb - -builddeps: - cd build && make builddeps - -cpus: - @echo "CPU数量: $(CPUS)" - - diff --git "a/how_build/linux\345\274\200\346\272\220\347\274\226\350\257\221\345\217\212\344\270\213\350\275\275\350\257\264\346\230\216.txt" "b/how_build/linux\345\274\200\346\272\220\347\274\226\350\257\221\345\217\212\344\270\213\350\275\275\350\257\264\346\230\216.txt" deleted file mode 100755 index d8951a2c387bac9d486a19289e1257e45aab216b..0000000000000000000000000000000000000000 --- "a/how_build/linux\345\274\200\346\272\220\347\274\226\350\257\221\345\217\212\344\270\213\350\275\275\350\257\264\346\230\216.txt" +++ /dev/null @@ -1,36 +0,0 @@ -编译 -CMake工具链编译说明: - -Ubuntu/Debian -安装编译环境 sudo apt-get install g++ make cmake -安装qt工具和库 sudo apt-get install qtbase5-dev qt5-qmake qtbase5-dev-tools libqt5printsupport5 libqt5xmlpatterns5-dev -配置 cmake -B build -DCMAKE_BUILD_TYPE=Release -编译 cd build && make -j -打包 cpack -ArchLinux -安装编译环境 sudo pacman -S gcc cmake make ninja -安装 qt 工具和库 sudo pacman -S qt5-tools qt5-base qt5-xmlpatterns -配置 cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -W no-dev -编译 ninja -C build && ninja -C build install -打包: 使用 AUR/notepad---git yay -S notepad---git -安装: -预编译包添加 ArchLinuxCN/notepad---git 镜像 yay -S archlinuxcn/notepad---git -预编译包 Debuginfod/notepad---git-debug 包 yay -S archlinuxcn/notepad---git-debug -openSUSE Tumbleweed -安装编译环境和Qt工具库 sudo zypper in -t pattern devel_C_C++ devel_basis devel_qt5 -配置 cmake -B build -DCMAKE_BUILD_TYPE=Release -编译 cd build && make -j -打包使用 OBS (Open Build Service) -Qt工程编译说明: - -1)使用qtcreator 或 vs 先打开qscint/src/qscintilla.pro 。先编译出这个qscintlla的依赖库。 - -2)再打开RealCompare.pro 加载后编译。 - -3)由于编译的平台较多,涉及windows/linux/mac,有任何编译问题,还请加qq群 959439826 。欢迎广大网友实现新功能后提交代码给我们。 - -代码上线不久,删除了商业的对比功能和注册功能(这部分有商业原因,请理解),除此以外,所有功能全部保留。 - -4)Arch Linux 及其衍生版可以通过 AUR 仓库安装:notepad---git - -yay -S notepad---git \ No newline at end of file diff --git a/linux-appimage.mk b/linux-appimage.mk new file mode 100644 index 0000000000000000000000000000000000000000..108b9d455bad407d536345eab9a6d60762b86783 --- /dev/null +++ b/linux-appimage.mk @@ -0,0 +1,47 @@ +# Linux Appimage - 通用 Linux 平台 Appimage 构建方案 + +include linux-universal.mk + +CPUS=$(shell nproc) + +builddir := build/linux-appimage +# sourcedir := . +# CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +# CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_LINUX_APPIMAGE=ON $(CMAKE_OPTIONS) + + +# -------------------------------- Appimage Build Tools -------------------------------- # +# 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)/$(builddir)/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" + +# 追加 Appimagetool、linuxdeployqt 构建配置 +CMAKE_OPTIONS := -DLINUXDEPLOYQT=$(LINUXDEPLOYQT) -DAPPIMAGETOOL=$(APPIMAGETOOL) $(CMAKE_OPTIONS) + +linuxdeploy: download-bundle-linuxdeploytools + cmake -B$(builddir) $(CMAKE_OPTIONS) + cmake --build $(builddir) -- linuxdeploy + +genrate-appimage: + cmake -B$(builddir) $(CMAKE_OPTIONS) + cmake --build $(builddir) -- appimage + + +package: linux-universal-release linuxdeploy genrate-appimage + +linux-build-options: + @echo $(CMAKE_OPTIONS) + +# 此配置为构建 linux Appimage 通用版本构建 \ No newline at end of file diff --git a/linux-debian.mk b/linux-debian.mk new file mode 100644 index 0000000000000000000000000000000000000000..081973f2add7104f31a115c74d16f241d0e57d7d --- /dev/null +++ b/linux-debian.mk @@ -0,0 +1,19 @@ +# Linux Debian - 通用 Linux 平台 Debian 构建方案 + +include linux-universal.mk + +CPUS=$(shell nproc) + +builddir := build/linux-debian +# sourcedir := . +# CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +# CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_LINUX_DEBIAN=ON $(CMAKE_OPTIONS) + +package: linux-universal-release + make -C $(builddir) package + +linux-build-options: + @echo $(CMAKE_OPTIONS) + +# 此配置为构建 linux debian 通用版本构建 \ No newline at end of file diff --git a/linux-universal.mk b/linux-universal.mk new file mode 100644 index 0000000000000000000000000000000000000000..f69314b3484918229afc57ad4bebf5f65f9f6661 --- /dev/null +++ b/linux-universal.mk @@ -0,0 +1,21 @@ +# Linux Universal - 通用 Linux 平台 构建方案 + +CPUS=$(shell nproc) + +builddir := build/linux-universal +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_LINUX_UNIVERSAL=ON + + +linux-universal: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_DEBUG) + cmake --build $(builddir) -- -j$(CPUS) + + +linux-universal-release: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_RELEASE) + cmake --build $(builddir) -- -j$(CPUS) + +# 此配置为构建 linux 通用版本构建 \ No newline at end of file diff --git a/linux-uos.mk b/linux-uos.mk new file mode 100644 index 0000000000000000000000000000000000000000..0fef21713fbf77038000ac7ded74cb91c7bdc366 --- /dev/null +++ b/linux-uos.mk @@ -0,0 +1,51 @@ +# 独立 Linux 平台的 Uos 构建 + +include linux-universal.mk + +# 覆盖 linux-universal.mk 中定义的部分 +linux-universal: + @echo "此目标不应该由 UOS 配方构建" +linux-universal-release: + @echo "此目标不应该由 UOS 配方构建" + + +CPUS=$(shell nproc) + +builddir := build/linux-uos +# sourcedir := . +# CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +# CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_LINUX_UOS=ON + + +linux-uos: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_DEBUG) + cmake --build build -- -j$(CPUS) + +linux-uos-release: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_RELEASE) + cmake --build build -- -j$(CPUS) + +package: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_RELEASE) + cmake --build $(builddir) -- -j$(CPUS) package + +package-contents: + -cd $(builddir)/_CPack_Packages/Linux/DEB/ && find + +package-contents-tree: + -tree $(builddir)/_CPack_Packages/Linux/DEB/ + +# 此配置为构建 linux 通用版本构建 + +# 一次系统检察 +UOS_OS_ID=$(shell lsb_release -si) +ifneq ($(UOS_OS_ID),Uos) +linux-uos: + @echo "此目标不应该由 $(UOS_OS_ID) 来构建 Uos 配方, 否则实际 Uos 系统可能由于 Qt 版本过低将无法使用." +linux-uos-release: + @echo "此目标不应该由 $(UOS_OS_ID) 来构建 Uos 配方, 否则实际 Uos 系统可能由于 Qt 版本过低将无法使用." +package: + @echo "此目标不应该由 $(UOS_OS_ID) 来构建 Uos 配方, 否则实际 Uos 系统可能由于 Qt 版本过低将无法使用." +endif +# repo: 要求使用 Uos 平台来进行独立 Linux 平台的 Uos 构建 \ No newline at end of file diff --git a/linux.mk b/linux.mk new file mode 100644 index 0000000000000000000000000000000000000000..c16e9f5ac8057bf280e5b22c2187db2842d22527 --- /dev/null +++ b/linux.mk @@ -0,0 +1,14 @@ +Msg := 'Build with the following configuration:' +One := '1. make -f linux-universal.mk' +Two := '2. make -f linux-debian.mk package' +Three := '3. make -f linux-appimage.mk package' +Four := '4. make -f linux-uos.mk package' + + +all: + @echo $(Msg) + @echo $(One) "\n\t默认的通用 Linux 平台构建." + @echo $(Two) "\n\t通用 Linux 平台的 Debian deb 构建." + @echo $(Three) "\n\t通用 Linux 平台的 Appimage 构建." + @echo $(Four) "\n\t独立 Linux 平台的 Uos 构建." + diff --git a/macos.mk b/macos.mk new file mode 100644 index 0000000000000000000000000000000000000000..8d7fbc424cbd2739cfc0adcf57e94598dc0c71c0 --- /dev/null +++ b/macos.mk @@ -0,0 +1,30 @@ +Msg := 'Build with the following configuration:' +One := '1. make macosx-universal' +Two := '2. make macosx-universal-release' +Three := '3. make package' + +all: + @echo $(Msg) + @echo $(One) "\n\t通用 MacOSX 平台构建(Debug)." + @echo $(Two) "\n\t通用 MacOSX 平台构建(Release)." + @echo $(Three) "\n\t通用 MacOSX 平台构建 CPack 打包." + +builddir := build/macosx-universal +sourcedir := . +CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug +CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release +CMAKE_OPTIONS := -DUSE_MACOSX_UNIVERSAL=ON + +CPUS=8 + +macosx-universal: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_DEBUG) + cmake --build $(builddir) -- -j$(CPUS) + +macosx-universal-release: + cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_RELEASE) + cmake --build $(builddir) -- -j$(CPUS) + + +package: macosx-universal-release + make -C $(builddir) package \ No newline at end of file diff --git a/patchs/README.md b/patchs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..701870cdb07cac7d106fff4a6b5bb5f30f7953d7 --- /dev/null +++ b/patchs/README.md @@ -0,0 +1,56 @@ +# 补丁操作说明 + +> 用于 patchs/coconil-cmake-spark-deb-appimage.patch 补丁化构建方式 + +- 如何使用此补丁(测试本补丁) + + > 注:此补丁仅可基于 master 分支进行构建 + + 1. 在项目中使用此补丁? + ```shell + git am --whitespace=fix < patchs/coconil-cmake-spark-deb-appimage.patch + ``` + 2. 使用在线的方式直接使用补丁文件,并对纯净的 ndd 项目进行打补丁 + ``` + # 克隆 notepad-- 项目 + git clone https://gitee.com/cxasm/notepad-- + cd notepad-- + + # 打在线补丁 + curl -s https://gitee.com/zinface/coconil-notepad--/raw/cmake-patchs/patchs/coconil-cmake-spark-deb-appimage.patch | git am --whitespace=fix + + make package # 构建 release 模式的 deb 包 + make linuxdeploy # 构建出相关文件与自动组织 appimage 的结构目录 + make genrate-appimage # 基于已 linuxdeploy 的结构目录进行打包为 Appimage + ``` + + +- 在应用补丁时,并对补丁进行的更新操作 + + ```shell + # 切换到一个新的分支,即可开始进行补丁内的更新提交 + git checkout -b coconil-cmake-spark-deb-appimage + + # origin/dev 表示本仓库的 dev 开发分支 + # 在应用过补丁,并产生了新的提交,即可在当前所在补丁更新分支内 + # 相对基于 origin/master 为参考,目前所包含的所有最新提交内容将生成为一个补丁文件(其中尾部为增量更新) + git format-patch --stdout origin/master > patchs/coconil-cmake-spark-deb-appimage.patch + + # 最后,回到你的原 master 分支,将被改变的补丁文件进行提交 + # 在推送完成后,即可放弃你在 coconil-cmake-spark-deb-appimage 分支中所有产生的内容(因为都已经进入补丁) + ``` + +- 一些注意事项 + + ```shell + # 在不了解补丁时,你需要认识一下补丁,但补丁与补丁之间有着不同的用法 + # 本 patchs/coconil-cmake-spark-deb-appimage.patch 补丁为支持 Appimage 构建 + + # 关于补丁的一些方面 + # 1. 首先你需要了解 git 是什么,以及简单的使用 + # 2. 你需要了解补丁是什么,以及简单的使用(应用补丁) + # 3. 你需要了解如何创建一个补丁,最基本的就是相对于旧目标分支,将本分区新增的提交进行导出为补丁 + # 4. 你可能只会将单个提交、或多个提交导出为补丁,但这还不够,你需要具有绝对的对于补丁的理解 + # 5. 对于不同的目的补丁,应该是多个 patch 文件存在的形式 + # 6. 最后,不管在什么时候,你在应用补丁前,你应该考虑是否应用到当前分支?为什么不切换到一个新的分支呢? + ``` \ No newline at end of file diff --git a/patchs/base-4c8661d74aa78ea504a9a2f8b06139d571caed3d-linux-qt6.patch b/patchs/base-4c8661d74aa78ea504a9a2f8b06139d571caed3d-linux-qt6.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2ea5c7c1861abe730b7b02a666fe56cf143da4e --- /dev/null +++ b/patchs/base-4c8661d74aa78ea504a9a2f8b06139d571caed3d-linux-qt6.patch @@ -0,0 +1,890 @@ +From 34d458cf82810609bee2c85f1eb772bbef40a152 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 16:40:36 +0800 +Subject: [PATCH] =?UTF-8?q?linux-qt6:=20=E6=B7=BB=E5=8A=A0=E7=94=A8?= + =?UTF-8?q?=E4=BA=8E=20Qt6=20=E7=BC=96=E8=AF=91=E7=9A=84=E7=9B=B8=E5=85=B3?= + =?UTF-8?q?=E5=8F=98=E6=9B=B4?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + src/CmpareMode.cpp | 4 +- + src/Encode.cpp | 2 +- + src/RealCompare.pro | 44 ++++++++++---------- + src/batchfindreplace.cpp | 6 +-- + src/cceditor/ccnotepad.cpp | 64 ++++++++++++++-------------- + src/columnedit.cpp | 4 +- + src/ctipwin.cpp | 2 +- + src/draglineedit.cpp | 1 + + src/encodeconvert.cpp | 2 +- + src/findresultwin.cpp | 26 +++++++----- + src/findwin.cpp | 4 +- + src/langstyledefine.cpp | 8 ++-- + src/nddsetting.cpp | 2 +- + src/qscint/src/qscilexer.cpp | 4 +- + src/qscint/src/qscintilla.pro | 18 ++------ + src/qtlangset.cpp | 78 +++++++++++++++++------------------ + src/scintillaeditview.cpp | 8 ++-- + src/userlexdef.cpp | 6 +-- + 18 files changed, 139 insertions(+), 144 deletions(-) + +diff --git a/src/CmpareMode.cpp b/src/CmpareMode.cpp +index b8fb335..1245275 100755 +--- a/src/CmpareMode.cpp ++++ b/src/CmpareMode.cpp +@@ -181,7 +181,7 @@ quint32 CmpareMode::readLineFromFileWithUnicodeLe(uchar* m_fileFpr, const int fi + else if (mode == 2) + { + QString temp = lineInfo.unicodeStr; +- md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8()); ++ md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8()); + } + }; + +@@ -429,7 +429,7 @@ CODE_ID CmpareMode::readLineFromFile(uchar* m_fileFpr, const int fileLength, con + else if (mode == 2) + { + QString temp = lineInfo.unicodeStr; +- md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8()); ++ md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8()); + } + }; + +diff --git a/src/Encode.cpp b/src/Encode.cpp +index 2164880..9fd8af1 100755 +--- a/src/Encode.cpp ++++ b/src/Encode.cpp +@@ -1,6 +1,6 @@ + #include "Encode.h" + #include +-#include ++#include + + /* 检查字符串编码的类。看了大量文献,结论如下: + *如果是UTF BOM格式,或者UNICODE格式,其文件头部前几个字节(2-3)有一定的标识。由此标识直接按对应编码处理。 +diff --git a/src/RealCompare.pro b/src/RealCompare.pro +index 1035414..0da717e 100755 +--- a/src/RealCompare.pro ++++ b/src/RealCompare.pro +@@ -3,9 +3,9 @@ LANGUAGE = C++ + + TARGET = Notepad-- + +-CONFIG += qt warn_on Debug ++CONFIG += qt warn_on + +-QT += core gui widgets concurrent network xmlpatterns ++QT += core gui widgets concurrent network core5compat + + + HEADERS += *.h \ +@@ -33,47 +33,47 @@ INCLUDEPATH += cceditor + + TRANSLATIONS += realcompare_zh.ts + +- if(contains(QMAKE_HOST.arch, x86_64)){ +- CONFIG(Debug, Debug|Release){ ++ if(contains(QMAKE_HOST.arch, x86_64|loongarch64)){ ++ CONFIG(debug, debug|release){ + DESTDIR = x64/Debug +- LIBS += -Lx64/Debug +- LIBS += -lqmyedit_qt5d ++ LIBS += -Lx64/Debug ++ LIBS += -lqmyedit_qt6d + }else{ + DESTDIR = x64/Release + LIBS += -Lx64/Release +- LIBS += -lqmyedit_qt5 ++ LIBS += -lqmyedit_qt6 + #QMAKE_CXXFLAGS += /openmp + } +- } ++} ++ + unix{ +-if(CONFIG(debug, Debug|Release)){ +- LIBS += -L/home/yzw/build/CCNotePad/x64/Debug -lqmyedit_qt5 ++ if(CONFIG(debug, debug|release)){ ++ LIBS += -L/home/yzw/build/CCNotePad/x64/Debug -lqmyedit_qt6 + +-QMAKE_CXXFLAGS += -fopenmp +-LIBS += -lgomp -lpthread ++ QMAKE_CXXFLAGS += -fopenmp ++ LIBS += -lgomp -lpthread + }else{ +- LIBS += -L/home/yzw/build/CCNotePad/x64/Release -lqmyedit_qt5 ++ LIBS += -L/home/yzw/build/CCNotePad/x64/Release -lqmyedit_qt6 + DESTDIR = x64/Release + + QMAKE_CXXFLAGS += -fopenmp -O2 + LIBS += -lgomp -lpthread + } +- } +- ++} + + RC_FILE += RealCompare.rc ++ + unix + { +- +-INCLUDEPATH += $$PWD/. +-DEPENDPATH += $$PWD/. ++ INCLUDEPATH += $$PWD/. ++ DEPENDPATH += $$PWD/. + + +-unix:!macx: LIBS += -L$$PWD/x64/Release/ -lqmyedit_qt5 ++ unix:!macx: LIBS += -L$$PWD/x64/Release/ -lqmyedit_qt6 + +-INCLUDEPATH += $$PWD/x64/Release +-DEPENDPATH += $$PWD/x64/Release ++ INCLUDEPATH += $$PWD/x64/Release ++ DEPENDPATH += $$PWD/x64/Release + +-unix:!macx: PRE_TARGETDEPS += $$PWD/x64/Release/libqmyedit_qt5.a ++ unix:!macx: PRE_TARGETDEPS += $$PWD/x64/Release/libqmyedit_qt6.a + } + +diff --git a/src/batchfindreplace.cpp b/src/batchfindreplace.cpp +index cb071c3..2602e3c 100755 +--- a/src/batchfindreplace.cpp ++++ b/src/batchfindreplace.cpp +@@ -89,7 +89,7 @@ void BatchFindReplace::appendToFindReplaceTable(QStringList& findKeyword) + bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outputKeyWordList) + { + //ѿհַո\t \r\n ַ滻Ϊո +- QRegExp re("\\s"); ++ QRegularExpression re("\\s"); + findKeyWord.replace(re, QString(" ")); + + //ٽпոָ +@@ -257,7 +257,7 @@ void BatchFindReplace::on_export() + if (!fileName.isEmpty()) + { + QSettings setting(fileName, QSettings::IniFormat); +- setting.setIniCodec("UTF-8"); ++// setting.setIniCodec("UTF-8"); + + int rowNums = ui.findReplaceTable->rowCount(); + +@@ -303,7 +303,7 @@ void BatchFindReplace::on_import() + QFileInfo fi(fileNameList[0]); + + QSettings setting(fi.filePath(), QSettings::IniFormat); +- setting.setIniCodec("UTF-8"); ++// setting.setIniCodec("UTF-8"); + + ui.findKeywordEdit->setPlainText(setting.value("find").toStringList().join(" ")); + ui.replaceKeywordEdit->setPlainText(setting.value("replace").toStringList().join(" ")); +diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp +index 1f04879..5efe091 100755 +--- a/src/cceditor/ccnotepad.cpp ++++ b/src/cceditor/ccnotepad.cpp +@@ -507,7 +507,7 @@ void initFileTypeLangMap() + //把新语言tagName,和关联ext单独存放起来ext_tag.ini。只读取一个文件就能获取所有,避免遍历慢 + QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + QStringList keys = qs.allKeys(); + //LangType lexId = L_USER_TXT; +@@ -3981,7 +3981,7 @@ void CCNotePad::initFileListDockWin() + } + }); + m_dockFileListWin->setAttribute(Qt::WA_DeleteOnClose); +- m_dockFileListWin->layout()->setMargin(0); ++ m_dockFileListWin->layout()->setContentsMargins(0, 0, 0, 0); + m_dockFileListWin->layout()->setSpacing(0); + + //暂时不提供关闭,因为关闭后需要同步菜单的check状态 +@@ -4312,7 +4312,7 @@ void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) + if (pEdit != nullptr) + { + //如果是新建的文件,则弹出保存对话框,进行保存 +- if (pEdit->property(Edit_File_New) >= 0) ++ if (pEdit->property(Edit_File_New).toString().length() >= 0) + { + QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)"); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QString(), filter); +@@ -4472,7 +4472,7 @@ void CCNotePad::slot_actionSaveAsFile_toggle(bool /*checked*/) + if (pEdit != nullptr) + { + //如果是新建的文件,则弹出保存对话框,进行保存 +- if (pEdit->property(Edit_File_New) >= 0) ++ if (pEdit->property(Edit_File_New).toString().length() >= 0) + { + QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)"); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As ..."),QString(), filter); +@@ -4763,7 +4763,7 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) + return; + } + +- QVariant v = pEdit->property(Edit_Text_Change); ++ QVariant v = pEdit->property(Edit_Text_Change); + bool isDirty = v.toBool(); + + //不脏则不需要保存,直接跳过。不脏的文件,只记录1个名称,下次打开时恢复 +@@ -4773,7 +4773,7 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) + //把文件记录到qs中去 + //index一定不能重复。n表示新建 + //如果是新建的文件 +- if (pEdit->property(Edit_File_New) >= 0) ++ if (pEdit->property(Edit_File_New).toInt() >= 0) + { + qs.setValue(QString("%1").arg(index), QString("%1|1").arg(fileName)); + } +@@ -4792,7 +4792,7 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) + } + + //如果是新建的文件 +- if (pEdit->property(Edit_File_New) >= 0) ++ if (pEdit->property(Edit_File_New).toInt() >= 0) + { + QString qsSavePath = qs.fileName(); + +@@ -4963,7 +4963,7 @@ void CCNotePad::closeAllFileStatic() + { + QString tempFileList = QString("notepad/temp/list"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + qs.clear(); + + //从尾部开始依次调用保存所有文件。没修改的不需要保存 +@@ -5047,7 +5047,7 @@ void CCNotePad::closeEvent(QCloseEvent * event) + #else + if ((s_restoreLastFile == 1) && m_isMainWindows) + { +- closeAllFileStatic(); ++ closeAllFileStatic(); + m_isQuitCancel = false; + } + else +@@ -5094,9 +5094,9 @@ void CCNotePad::closeEvent(QCloseEvent * event) + { + c->showNormal(); + } +- qlonglong winId = (qlonglong)c->effectiveWinId(); +- m_shareMem->lock(); +- memcpy(m_shareMem->data(), &winId, sizeof(qlonglong)); ++ qlonglong winId = (qlonglong)c->effectiveWinId(); ++ m_shareMem->lock(); ++ memcpy(m_shareMem->data(), &winId, sizeof(qlonglong)); + m_shareMem->unlock(); + c->m_isMainWindows = true; + } +@@ -5480,7 +5480,7 @@ void CCNotePad::initFindWindow() + //从历史查找记录文件中加载 + QString searchHistory = QString("notepad/searchHistory");//历史查找记录 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + if (qs.contains("keys")) + { +@@ -5545,7 +5545,7 @@ void CCNotePad::slot_saveSearchHistory() + //从历史查找记录文件中加载 + QString searchHistory = QString("notepad/searchHistory");//历史查找记录 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + if (s_findHistroy.count() > 15) + { +@@ -5772,7 +5772,7 @@ void CCNotePad::initFindResultDockWin() + m_dockSelectTreeWin = new QDockWidget(tr("Find result"), this); + connect(m_dockSelectTreeWin, &QDockWidget::dockLocationChanged, this, &CCNotePad::slot_findResultPosChangeed); + +- m_dockSelectTreeWin->layout()->setMargin(0); ++ m_dockSelectTreeWin->layout()->setContentsMargins(0, 0, 0, 0); + m_dockSelectTreeWin->layout()->setSpacing(0); + + //暂时不提供关闭,因为关闭后需要同步菜单的check状态 +@@ -6573,7 +6573,7 @@ bool CCNotePad::eventFilter(QObject * watched, QEvent * event) + } + return false; + } +- ++ + + #ifdef Q_OS_WIN + static const ULONG_PTR CUSTOM_TYPE = 10000; +@@ -6581,16 +6581,16 @@ static const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001; + + bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * result) + { +- MSG *param = static_cast(message); +- +- switch (param->message) +- { +- case WM_COPYDATA: +- { +- COPYDATASTRUCT *cds = reinterpret_cast(param->lParam); +- if (cds->dwData == CUSTOM_TYPE) +- { +- QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); ++ MSG *param = static_cast(message); ++ ++ switch (param->message) ++ { ++ case WM_COPYDATA: ++ { ++ COPYDATASTRUCT *cds = reinterpret_cast(param->lParam); ++ if (cds->dwData == CUSTOM_TYPE) ++ { ++ QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); + + int retIndex = findFileIsOpenAtPad(openFilePath); + if (-1 == retIndex) +@@ -6622,9 +6622,9 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * + + + this->activateWindow(); +- *result = 1; +- return true; +- } ++ *result = 1; ++ return true; ++ } + else if (cds->dwData == OPEN_NOTEPAD_TYPE) + { + activateWindow(); +@@ -6632,8 +6632,8 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * + + *result = 1; + return true; +- } +- } ++ } ++ } + } + + return QWidget::nativeEvent(eventType, message, result); +@@ -7124,7 +7124,7 @@ int CCNotePad::restoreLastFiles() + + QString tempFileList = QString("notepad/temp/list"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + QStringList fileList = qs.allKeys(); + //从小到大排序一下 +diff --git a/src/columnedit.cpp b/src/columnedit.cpp +index 50fd9ae..aaf93f1 100755 +--- a/src/columnedit.cpp ++++ b/src/columnedit.cpp +@@ -216,13 +216,13 @@ void ColumnEdit::slot_ok() + { + QByteArray s_space(cursorCol - lineEndCol, ' '); + lineData.append(s_space); +- lineData.append(text); ++ lineData.append(text.toLatin1()); + } + else + { + int posAbs2Start = pEdit->execute(SCI_FINDCOLUMN, i, cursorCol); + int posRelative2Start = posAbs2Start - lineBegin; +- lineData.insert(posRelative2Start, text); ++ lineData.insert(posRelative2Start, text.toLatin1()); + } + + pEdit->SendScintilla(SCI_SETTARGETRANGE, lineBegin, lineEnd); +diff --git a/src/ctipwin.cpp b/src/ctipwin.cpp +index 9412777..5bf16a9 100755 +--- a/src/ctipwin.cpp ++++ b/src/ctipwin.cpp +@@ -9,7 +9,7 @@ CTipWin::CTipWin(QWidget *parent) + this->setWindowFlags(Qt::ToolTip); + + QPalette palette(this->palette()); +- palette.setColor(QPalette::Background, QColor(0xfff29d)); ++ palette.setColor(QPalette::Window, QColor(0xfff29d)); + this->setPalette(palette); + } + +diff --git a/src/draglineedit.cpp b/src/draglineedit.cpp +index c21f3de..d8a8513 100755 +--- a/src/draglineedit.cpp ++++ b/src/draglineedit.cpp +@@ -1,4 +1,5 @@ + #include "draglineedit.h" ++#include + + DragLineEdit::DragLineEdit(QWidget *parent) + : QLineEdit(parent) +diff --git a/src/encodeconvert.cpp b/src/encodeconvert.cpp +index c17022e..7bbcfc5 100755 +--- a/src/encodeconvert.cpp ++++ b/src/encodeconvert.cpp +@@ -11,7 +11,7 @@ + #include + #include + #include +- ++#include + + const int ITEM_CODE = Qt::UserRole + 1; + +diff --git a/src/findresultwin.cpp b/src/findresultwin.cpp +index 7d86701..ad01b46 100755 +--- a/src/findresultwin.cpp ++++ b/src/findresultwin.cpp +@@ -5,7 +5,7 @@ + #include + #include + #include +-#include ++#include > + #include + #include + #include +@@ -151,8 +151,8 @@ void FindResultWin::slot_selectAll() + QModelIndex pMi = curSelItem.parent(); + if (pMi.isValid()) + { +- curSelItem = pMi; +-} ++ curSelItem = pMi; ++ } + else + { + break; +@@ -176,12 +176,13 @@ void FindResultWin::slot_selectAll() + //遍历下面的子节点 + int i = 0; + QModelIndex childMi; +- childMi = sectionItem.child(i, 0); ++ const QAbstractItemModel *const sectionItemModel = sectionItem.model(); ++ childMi = sectionItemModel->index(i, 0); + while (childMi.isValid()) + { + ++i; + ui.resultTreeView->selectionModel()->select(childMi, QItemSelectionModel::Select); +- childMi = sectionItem.child(i, 0); ++ childMi = sectionItemModel->index(i, 0); + } + return i+1; + }; +@@ -189,17 +190,20 @@ void FindResultWin::slot_selectAll() + QModelIndex rootItem = firstRootItem; + int j = 0; + int selectCount = 0; ++ const QAbstractItemModel *const rootItemModel = rootItem.model(); ++ const QAbstractItemModel *const firstRootItemModel = firstRootItem.model(); ++ + while (rootItem.isValid()) + { + //遍历根节点下面每一个section + { + int i = 0; +- QModelIndex section = rootItem.child(i, 0); ++ QModelIndex section = rootItemModel->index(i, 0); + while (section.isValid() && !section.data(ResultItemEditor).isNull()) + { + ++i; + selectCount += selectSection(section); +- section = firstRootItem.child(i, 0); ++ section = firstRootItemModel->index(i, 0); + } + } + +@@ -223,12 +227,12 @@ void FindResultWin::slot_selectSection() + //遍历下面的子节点 + int i = 0; + QModelIndex childMi; +- childMi = sectionItem.child(i, 0); ++ childMi = sectionItem.model()->index(i, 0); + while (childMi.isValid()) + { + ++i; + ui.resultTreeView->selectionModel()->select(childMi, QItemSelectionModel::Select); +- childMi = sectionItem.child(i, 0); ++ childMi = sectionItem.model()->index(i, 0); + } + return i+1; + }; +@@ -420,7 +424,7 @@ QString FindResultWin::highlightFindText(FindRecord& record) + } + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + tail = QString(utf8bytes.mid(tailStart)); +- if (tail > MAX_TAIL_LENGTH) ++ if (tail.size() > MAX_TAIL_LENGTH) + { + tail = (tail.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped(); + } +@@ -454,7 +458,7 @@ QString FindResultWin::highlightFindText(FindRecord& record) + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + + QString tailContens = QString(utf8bytes.mid(tailStart)); +- if (tailContens > MAX_TAIL_LENGTH) ++ if (tailContens.size() > MAX_TAIL_LENGTH) + { + tailContens = (tailContens.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped(); + } +diff --git a/src/findwin.cpp b/src/findwin.cpp +index 7a55059..8fe891e 100755 +--- a/src/findwin.cpp ++++ b/src/findwin.cpp +@@ -559,8 +559,8 @@ bool readBase(const QChar * str, int * value, int base, int size) + current = str[i]; + if (current >= 'A') + { +- current = current.digitValue() & 0xdf; +- current = current.digitValue() - ('A' - '0' - 10); ++ current = static_cast(current.digitValue() & 0xdf); ++ current = static_cast(current.digitValue() - ('A' - '0' - 10)); + } + else if (current > '9') + return false; +diff --git a/src/langstyledefine.cpp b/src/langstyledefine.cpp +index 2df3a4f..f667f09 100755 +--- a/src/langstyledefine.cpp ++++ b/src/langstyledefine.cpp +@@ -30,7 +30,7 @@ bool LangStyleDefine::readLangSetFile(QString langName, bool isLoadToUI) + { + QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + qDebug() << qs.fileName(); + + if (!qs.contains("mz")) +@@ -160,7 +160,7 @@ void LangStyleDefine::slot_save() + //把新语言tagName,和关联ext单独存放起来。后面只读取一个文件就能获取所有,避免遍历慢 + QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + QStringList extList = ui.extNameLe->text().trimmed().split(" "); + extList.append(QString::number(motherLangs)); //最后一个是mother lexer +@@ -201,7 +201,7 @@ void LangStyleDefine::slot_delete() + { + QString userLangFile = QString("notepad/userlang/%1").arg(name);//自定义语言中不能有.字符,否则可能有错,后续要检查 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + //删除userlang下面的tag.ini + QFile::remove(qs.fileName()); +@@ -211,7 +211,7 @@ void LangStyleDefine::slot_delete() + //把新语言在ext_tag中的关联文件记录也删除 + QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + QStringList extList = qs.value(name).toStringList(); + //更新当前ExtLexerManager::getInstance()。如果不更新,就要重启软件才能生效 +diff --git a/src/nddsetting.cpp b/src/nddsetting.cpp +index ed20f73..7e2070a 100755 +--- a/src/nddsetting.cpp ++++ b/src/nddsetting.cpp +@@ -50,7 +50,7 @@ void NddSetting::init() + QString qsSetPath = qs.fileName(); + + s_nddSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir); +- s_nddSet->setIniCodec("UTF-8"); ++// s_nddSet->setIniCodec("UTF-8"); + bool initOk = true; + + auto initNddSet = []() { +diff --git a/src/qscint/src/qscilexer.cpp b/src/qscint/src/qscilexer.cpp +index b49fdc5..f21fff8 100755 +--- a/src/qscint/src/qscilexer.cpp ++++ b/src/qscint/src/qscilexer.cpp +@@ -896,7 +896,7 @@ const char* QsciLexer::getUserDefineKeywords() + + QString userLangFile = QString("notepad/userlang/%1").arg(m_tagName);//自定义语言中不能有.字符,否则可能有错,后续要检查 + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + if (!qs.contains("mz")) + { +@@ -948,4 +948,4 @@ void QsciLexer::setCommentEnd(QByteArray commentEnd) + void QsciLexer::setCurThemes(int themesId) + { + m_themesId = themesId; +-} +\ No newline at end of file ++} +diff --git a/src/qscint/src/qscintilla.pro b/src/qscint/src/qscintilla.pro +index 2704d72..9ef4520 100755 +--- a/src/qscint/src/qscintilla.pro ++++ b/src/qscint/src/qscintilla.pro +@@ -21,24 +21,14 @@ + !win32:VERSION = 15.1.0 + + TEMPLATE = lib +-CONFIG += qt warn_off thread exceptions hide_symbols debug staticlib ++CONFIG += qt warn_off thread exceptions hide_symbols staticlib + + CONFIG(debug, debug|release) { +- mac: { +- TARGET = qmyedit_qt$${QT_MAJOR_VERSION}_debug +- } else { +- win32: { +- TARGET = qmyedit_qt$${QT_MAJOR_VERSION}d +- } else { +- TARGET = qmyedit_qt$${QT_MAJOR_VERSION} +- } +- } +- +- DESTDIR = ../../x64/Debug ++ TARGET = qmyedit_qt$${QT_MAJOR_VERSION} ++ DESTDIR = ../../x64/Debug + } else { + TARGET = qmyedit_qt$${QT_MAJOR_VERSION} +- +- DESTDIR = ../../x64/Release ++ DESTDIR = ../../x64/Release + } + + macx:!CONFIG(staticlib) { +diff --git a/src/qtlangset.cpp b/src/qtlangset.cpp +index e88d132..99b6258 100755 +--- a/src/qtlangset.cpp ++++ b/src/qtlangset.cpp +@@ -36,8 +36,8 @@ enum LangType { + // Don't use L_JS, use L_JAVASCRIPT instead + // The end of enumated language type, so it should be always at the end + L_EXTERNAL = 100, L_USER_DEFINE = 200 +-}; +-#endif ++}; ++#endif + + //static const QColor blackColor(Qt::black); + //static const QColor lightColor(0xdedede); +@@ -421,14 +421,14 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + QsciLexer *pLexer = ScintillaEditView::createLexer(index); + if (nullptr != pLexer) + { +- ++ + switch (flag) + { + case GLOBAL_FONT: + { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) + { + oldfont = pLexer->font(i); + oldfont.setFamily(m_curStyleData.font.family()); +@@ -439,9 +439,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + break; + case GLOBAL_FONT_SIZE: + { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) + { + oldfont = pLexer->font(i); + oldfont.setPointSize(m_curStyleData.font.pointSize()); +@@ -452,9 +452,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + break; + case GLOBAL_FONT_BOLD: + { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) + { + oldfont = pLexer->font(i); + oldfont.setBold(m_curStyleData.font.bold()); +@@ -465,9 +465,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + break; + case GLOBAL_FONT_UNDERLINE: + { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) + { + oldfont = pLexer->font(i); + oldfont.setUnderline(m_curStyleData.font.underline()); +@@ -478,9 +478,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + break; + case GLOBAL_FONT_ITALIC: + { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) + { + oldfont = pLexer->font(i); + oldfont.setItalic(m_curStyleData.font.italic()); +@@ -503,10 +503,10 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) + break; + default: + break; +- } ++ } + + saveLangeSet(pLexer); +- } ++ } + delete pLexer; + } + } +@@ -537,7 +537,7 @@ void QtLangSet::restoreOriginLangAllStyle() + { + QFile::remove(qs.fileName()); + } +- ++ + delete pLexer; + pLexer = nullptr; + } +@@ -578,12 +578,12 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) + QsciLexer *pLexer = ScintillaEditView::createLexer(index); + QsciLexer *pOriginLexer = ScintillaEditView::createLexer(index,"",true); + if (nullptr != pLexer) +- { +- for (int i = 0; i <= 255; ++i) +- { +- if (!pLexer->description(i).isEmpty()) +- { +- ++ { ++ for (int i = 0; i <= 255; ++i) ++ { ++ if (!pLexer->description(i).isEmpty()) ++ { ++ + switch (flag) + { + case GLOBAL_FONT: +@@ -649,11 +649,11 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) + break; + default: + break; +- } +- } ++ } ++ } + } + saveLangeSet(pLexer); +- } ++ } + delete pLexer; + delete pOriginLexer; + } +@@ -795,7 +795,7 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth + { + QString userLangFile = QString("notepad/userlang/%1").arg(langName);//Զв.ַдҪ + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + //qDebug() << qs.fileName(); + + if (!qs.contains("mz")) +@@ -917,15 +917,15 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) + ui.keywordTe->setPlainText(keyword); + ui.motherLangCb->setCurrentIndex(0); + +- for (int i = 0; i <= 255; ++i) +- { +- QString desc = pLexer->description(i); +- if (!desc.isEmpty()) +- { ++ for (int i = 0; i <= 255; ++i) ++ { ++ QString desc = pLexer->description(i); ++ if (!desc.isEmpty()) ++ { + QListWidgetItem *itemtemp = new QListWidgetItem(desc); +- itemtemp->setData(Qt::UserRole, i); +- ui.styleListWidget->addItem(itemtemp); +- } ++ itemtemp->setData(Qt::UserRole, i); ++ ui.styleListWidget->addItem(itemtemp); ++ } + } + } + +diff --git a/src/scintillaeditview.cpp b/src/scintillaeditview.cpp +index 60181dd..fac3648 100755 +--- a/src/scintillaeditview.cpp ++++ b/src/scintillaeditview.cpp +@@ -2155,7 +2155,7 @@ void ScintillaEditView::changeCase(const TextCaseType & caseToConvert, QString& + else if (caseToConvert == TITLECASE_FORCE) + strToConvert[i] = strToConvert[i].toLower(); + //An exception +- if ((i < 2) ? false : (strToConvert[i - 1] == L'\'' && (strToConvert[i - 2].isLetter()))) ++ if ((i < 2) ? false : (strToConvert[i - 1] == QChar(L'\'') && (strToConvert[i - 2].isLetter()))) + strToConvert[i] = strToConvert[i].toLower(); + } + } +@@ -2183,11 +2183,11 @@ void ScintillaEditView::changeCase(const TextCaseType & caseToConvert, QString& + wasEolR = false; + wasEolN = false; + //An exception +- if (strToConvert[i] == L'i' && ++ if (strToConvert[i] == static_cast(L'i') && + ((i < 1) ? false : (strToConvert[i - 1].isSpace() || strToConvert[i - 1] == '(' || strToConvert[i - 1] == '"')) && \ + ((i + 1 == nbChars) ? false : (strToConvert[i + 1].isSpace() || strToConvert[i + 1] == '\''))) + { +- strToConvert[i] = L'I'; ++ strToConvert[i] = static_cast(L'I'); + } + } + else if (strToConvert[i] == '.' || strToConvert[i] == '!' || strToConvert[i] == '?') +@@ -2856,7 +2856,7 @@ bool isUrlQueryDelimiter(QChar const c) + void scanToUrlEnd(QString & text, int textLen, int start, int* distance) + { + int p = start; +- QChar q = 0; ++ QChar q; + enum { sHostAndPath, sQuery, sQueryAfterDelimiter, sQueryQuotes, sQueryAfterQuotes, sFragment } s = sHostAndPath; + while (p < textLen) + { +diff --git a/src/userlexdef.cpp b/src/userlexdef.cpp +index 6b8c7d2..86e238b 100755 +--- a/src/userlexdef.cpp ++++ b/src/userlexdef.cpp +@@ -24,7 +24,7 @@ bool UserLexDef::readUserSettings(QString langTagName) + + QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + + if (!qs.contains(QString("mz"))) + { +@@ -93,13 +93,13 @@ bool UserLexDef::writeUserSettings(QString langTagName) + + QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +- qs.setIniCodec("UTF-8"); ++// qs.setIniCodec("UTF-8"); + qs.clear(); + + qs.setValue("mz", langTagName); + qs.setValue("mother", m_motherLang); + qs.setValue("ext", m_extTypes); +- qs.setValue("keyword", m_keyword.data()); ++ qs.setValue("keyword", m_keyword.toStdString().c_str()); + + return true; + } +-- +2.20.1 + diff --git a/patchs/coconil-cmake-spark-deb-appimage.patch b/patchs/coconil-cmake-spark-deb-appimage.patch new file mode 100644 index 0000000000000000000000000000000000000000..b077d64c79dfdfa12b848e150e639b439a311edf --- /dev/null +++ b/patchs/coconil-cmake-spark-deb-appimage.patch @@ -0,0 +1,2759 @@ +From cc06baf3b21851b8addc0f691a31541ca436d395 Mon Sep 17 00:00:00 2001 +From: coconil +Date: Tue, 31 Jan 2023 22:17:32 +0800 +Subject: [PATCH 01/13] add cmake support + +--- + CMakeLists.txt | 2 ++ + src/qscint/CMakeLists.txt | 6 +++--- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f1d6eea..f1c6d25 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -53,3 +53,5 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr + + include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) + include(CPack) ++ ++target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) +\ No newline at end of file +diff --git a/src/qscint/CMakeLists.txt b/src/qscint/CMakeLists.txt +index b114614..f132dc6 100644 +--- a/src/qscint/CMakeLists.txt ++++ b/src/qscint/CMakeLists.txt +@@ -1,5 +1,5 @@ +-cmake_minimum_required(VERSION 3.16) +-project(qscintilla2_qt5 CXX) ++cmake_minimum_required(VERSION 3.24) ++project(qscint CXX) + + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) +@@ -28,7 +28,7 @@ ${PROJECT_SOURCE_DIR}/scintilla/boostregex + + target_include_directories(${PROJECT_NAME} PUBLIC + ${PROJECT_SOURCE_DIR}/src +-${PROJECT_SOURCE_DIR}/src/Qsci ++${PROJECT_SOURCE_DIR}/src/Qsci + ${PROJECT_SOURCE_DIR}/scintilla/src + ${PROJECT_SOURCE_DIR}/scintilla/include) + +-- +2.20.1 + + +From 7466475538da85ba7eb24024e34b5fde8babe5f9 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Wed, 1 Feb 2023 20:04:05 +0800 +Subject: [PATCH 02/13] =?UTF-8?q?repo:=20=E5=BC=95=E5=85=A5=20Spark=20?= + =?UTF-8?q?=E6=9E=84=E5=BB=BA=EF=BC=8C=E6=94=AF=E6=8C=81=E6=9E=84=E5=BB=BA?= + =?UTF-8?q?=20deb?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + .gitignore | 54 ++++- + CMakeLists.txt | 36 ++- + Makefile | 61 +++++ + assets/spark.png | Bin 0 -> 4959 bytes + cmake/DebPackageConfig.cmake | 323 +++++++++++++++++++++++++++ + cmake/SparkDesktopMacros.cmake | 35 +++ + cmake/SparkInstallMacrosConfig.cmake | 131 +++++++++++ + cmake/package-deb.descript | 45 ++++ + cmake/spark-desktop.desktop.in | 12 + + 9 files changed, 682 insertions(+), 15 deletions(-) + create mode 100644 Makefile + create mode 100644 assets/spark.png + create mode 100644 cmake/DebPackageConfig.cmake + create mode 100644 cmake/SparkDesktopMacros.cmake + create mode 100644 cmake/SparkInstallMacrosConfig.cmake + create mode 100644 cmake/package-deb.descript + create mode 100644 cmake/spark-desktop.desktop.in + +diff --git a/.gitignore b/.gitignore +index 8d723bc..72fb977 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -384,15 +384,45 @@ FodyWeavers.xsd + !.vscode/extensions.json + *.code-workspace + +-# Local History for Visual Studio Code +-.history/ +- +-# Windows Installer files from build outputs +-*.cab +-*.msi +-*.msix +-*.msm +-*.msp +- +-# JetBrains Rider +-*.sln.iml ++# Local History for Visual Studio Code ++.history/ ++ ++# Windows Installer files from build outputs ++*.cab ++*.msi ++*.msix ++*.msm ++*.msp ++ ++# JetBrains Rider ++*.sln.iml ++ ++ ++ ++# Ignore the build directory generated by the vsocde cmake extension ++build/ ++# Ignore the build directory generated by the vsocde clangd extension ++.cache ++ ++# Created by https://www.toptal.com/developers/gitignore/api/cmake ++# Edit at https://www.toptal.com/developers/gitignore?templates=cmake ++ ++### CMake ### ++CMakeLists.txt.user ++CMakeCache.txt ++CMakeFiles ++CMakeScripts ++Testing ++Makefile ++cmake_install.cmake ++install_manifest.txt ++compile_commands.json ++CTestTestfile.cmake ++_deps ++ ++### CMake Patch ### ++# External projects ++*-prefix/ ++ ++# End of https://www.toptal.com/developers/gitignore/api/cmake ++!/Makefile +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f1c6d25..666fbdb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ +-cmake_minimum_required(VERSION 3.16) +-project(notepad--) ++cmake_minimum_required(VERSION 3.24) ++project(notepad-- VERSION 1.22.0) + + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) +@@ -54,4 +54,34 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr + include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) + include(CPack) + +-target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) +\ No newline at end of file ++target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) ++ ++if(CMAKE_HOST_UNIX) ++ include(cmake/SparkInstallMacrosConfig.cmake) ++ include(cmake/SparkDesktopMacros.cmake) ++ # 内容默认应用名称: Name= 应与项目名称相同 ++ spark_desktop_macros( ++ # 应用名称: Name= ++ ${PROJECT_NAME} ++ # 应用名称: Name[zh_CN]= ++ "Notepad--" ++ # 应用说明: Comment= ++ "Notepad-- 是一个国产跨平台、简单的文本编辑器。" ++ # 应用类型: Type= ++ "Application" ++ # 执行程序: Exec= ++ "notepad--" ++ # 图标路径: Icon= ++ "/usr/share/notepad--/icons/spark.png" ++ # 应用分类: Category= ++ "Development" ++ ) ++ spark_install_file(/usr/share/applications/ ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop) ++ spark_install_file(/usr/share/notepad--/icons/ assets/spark.png) ++ spark_install_target(/usr/bin/ ${PROJECT_NAME}) ++ ++ # 注释行(使用方式) ++ find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR}) ++ add_package_descript(cmake/package-deb.descript) ++ ++endif(CMAKE_HOST_UNIX) +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..43e849f +--- /dev/null ++++ b/Makefile +@@ -0,0 +1,61 @@ ++CPUS=$(shell nproc) ++CALENDAR=$(shell date '+%Y%m%d') ++OSID=$(shell lsb_release -si) ++OSRELEASE=$(shell lsb_release -sr) ++SUFFIX= ++ifneq ("$(OSID)", "") ++SUFFIX=_$(OSID)$(OSRELEASE) ++endif ++ ++PROJECT_NAME=notepad-- ++PACKAGE_NAME=com.hmja.notepad ++ ++all: ++ mkdir -p build ++ cd build && cmake .. ++ cd build && make -j$(CPUS) ++ ++run: all ++ exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME)) ++ ++debug: ++ mkdir -p build ++ cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. ++ cd build && make -j$(CPUS) ++ ++release: ++ mkdir -p build ++ cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPACKAGE_SUFFIX="$(SUFFIX)" .. ++ cd build && make -j$(CPUS) ++ ++package: release ++ cd build && make package ++ tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-* ++ dpkg-deb --contents build/$(PACKAGE_NAME)_*$(CALENDAR)*$(SUFFIX).deb ++ # cd build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)_*$(CALENDAR)*$(SUFFIX).deb && find . ++ ++builddeps: ++ cd build && make builddeps ++ ++cpus: ++ @echo "CPU数量: $(CPUS)" ++ ++copytosource:package ++ cp build/$(PACKAGE_NAME)_*$(CALENDAR)*.deb . ++ ++# 进入 qdebug 模式,在 deepin 中默认被禁用,可 env | grep QT 查看,并在 /etc/X11/Xsession.d/00deepin-dde-env 配置中已定义 ++# 1. 禁止 qt 的 debug 打印: qt.*.debug=false ++# qt.qpa.input.events ++# qt.qpa.events ++# 2. 禁止 dtk 的 debug 打印: dtk.*.debug=false ++# dtk.dpluginloader ++# 3. 禁止 qtcreator 本身的 debug 打印 ++# qtc.autotest.testcodeparser ++# qtc.clangbackend.server ++# ... ++# 4. 关闭其它的太麻烦了,直接只启用本地 debug ++# .debug=true ++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 +diff --git a/assets/spark.png b/assets/spark.png +new file mode 100644 +index 0000000000000000000000000000000000000000..544e2c7cff5f70894e27a7a717d4a62120630b7a +GIT binary patch +literal 4959 +zcmZ9Qc|26n`^T?!hOvx&4Pz%{EZLPYvTq^E5@pRcGGvX$AW~VT?0YC8CHu}WL)I*j +zCA+d^OJw_v@Avn|@AZ4V?z!iAo%_7*bMCpH^W6J>;>=8R>1nxX0RW)a*F)YU^_YtW +zrY4=^DWIpMj{2UVE)p04)_~)Bx;9qQ2n|Z_wm$&K2wgO?prUJmq(Kl`-&hB=G~+P>c2E7|m)F7F$6%61XMsolUg0zXycp@v@GZ1K>rt9xd?C!>%*+W7 +z%C&esu?1QvJQKjm(&8q^?oTJ)%8V0?)|OjY&d?Gr6jy6+xCM5i6!*6NB4P1KRCNm^ +zm+NR*M%4c-!-n9r0lIJ!D)W+&T9oD)Dem^7SRik@V(WfPQ@fFKyaf2lH?CLvA5uka +za&warZ&7cj6r);vpGc6CZ?~=95k;2K+aF*1m@^PTnvH2@U9bunlhI3nmsfK^BZU;4=_*3}V}PoZ +zEP*COH$^QdyIwzO=Shp{b@@LAC7u=@nYJ8)oEoIduWITqMn>MScBnM|V;V8ajW%>c +z2|9_!;}u5SRyWpkQzR8giy|l$Ivq`@U%TZM4}hv^OUIk_s0z#=s!u~04W3Iv&C;FbL%51jwmUPHQ@0l~qZwrDUlHbTaRh}I7O +zg75zlU9YVkytJ~+#_*>+av3b*ZLbM`=lrm(GyKlhzDKd&-~YS-XuB{i6aEdZrmT8V +z5=&CIeIGmv+apvfRY7`h1Zf4_L_-7KYf+zDaL#{K)Hw61>q|2q>%TNiMk|sXtmY*1 +z`E77tq7vBO#3uo(t!jj^QMa-dh___m=cxM&AL^ +zdT&14OSgK$%!-|9_M)?`i4B)w7eegd!IoH)mWyyhiqc1~EPAqoCCYEgl(hFM{^Ftj +z%GS_$^uT6K)$jtUK69tc1oS-cV3H( +zyzVwJW(p>4KWuO@dx-z65M|t#j~xmYkY<&V$cV9IcL@+9-%Akb(9C^=$km21|8lq_ +za=b^e+n~SA!s?z86LD4&0RU2Vl|bwCrvOB*uG>-oaP+AaCy?IW;MZ7A&oS_=puC#x +zTSjKS2X}HZv)}oKicKX7<~q>8hy|~*HpzV*Y^DRSBNNv-=R$KtX-5a5FE!_Wj#!o0njA +z8JkG4+{e@({dOMVP51|1y`CGI?{rMiLdMQTV)8ojeNwqrgP)*5q}hq9`jG=rE*1L0 +z=0gY)xu5I$L0nYIwuM<@k7MqNbid7Ko1mz?Wtyzjo`jUhJJU|J`Jq_(fZ+l%ogp5Y +zIDI`mBjycCE3h-oAO06y%KHv_U0fWu7`0F)$u5yL6u~KnhuEC++z(})gQ{w9X}O1^ +ziig+EPJfUA4&ecpZ?0Sc06XsoNMjeO3Wcj3%MW32I2nYaNKiwF#jknm8fO-R8aEHO +zS;P_Zcdx7H>7UoVjHFijGh;WVUGy??)C=6c|6BJ?%amgTP(}HCU2Z0Y^Sx|AO%6>B +z7k8KD-1)Kga0b7Xt>)Jmz><_Svi*-IB6_0ky0@X$d%1Z$EAcD*>w~VW$*SRrQOa6E +z)cKJdzv;DO-USxsZnV8sfR>g0;TF*eXKlHEv~kBDQlVHocet}SvAsdI1E^G1doNa$er}pksd?U1pF|_rB +zSIJIEOQLI~-J9cO}P)Oz~yJ4z~jwPCIW7GR>tKG}oJGSkdoz};#7?(Sg>_x?Y_Q?4k +zZ$BO!ta2Sdt}R&N@%WDQoxFGNn8p;VW$7qF|8D7og^|0?JUW*}Y|jx!#LUqPlwg=m +zRt9aEBD1%*_tO_~T=|(R%DbCN?p_VFK+vzERN1}RWAZ6OAYYD(J}CcnVj9+as%G)o +z;NJXAE1<2%q6D=&D&c&^K7J$1uCL+uS>u|xgNGNU%c~o5r72Q`D?M*NaI@;bFQ#CT +zV0IV|1Ll4vb*8mCG70}W_>J!pbL`q(Mk#Luq5Ho-?sljN6JfW)-Tyt?3`DZ%L +z>1cfFaA%b9aDM4sjzPiuCSI52j;PmRFq03dvd{@)=@Z9{wG$dz~4@#t3rj;1m%CZ{=~k9~XcBC6v7NckqV@1WVYQ<43f3{9(XPWS>EN{EO~*-CK*bt;ZS;!OLuY +z87ft)RVyp(Cw{BC?#*W-X}?E8n+mG`{Ikbd@Mf3BkFQ_T3aIyS+g0*qIBMqV83`?o +zX*3SoyLQT=V65w9M3)n><3cpp4wMiSNQ6I0WTSfL@yq6O5RJ^;rpPEzOSf?<#OEal +z#JE8?_%;i?y7A-hXB(+R7p{hi!m)9NPT7A;G|icpHm~wS^k`I({`l+|qO9g~*i~G*9imYv^HH~-3PeB-S_xwv+Y2l=g6>lXZk|B1v+dn| +zeA>r~Z}f3>@rByy3Q&w80&#K>pvR%5geJnqq +z#YL_Lw5jl$vkg7ZRPvcNku1Nz{`lM2`2I+BH-`3Ba?R1ny-~VYe +z9l%0>oH`pOV?m#)LN)yxXMS#M>?$?Ja6PLFE);UCNl#M06nrh>lc`K1PMyM&Ka>tI +zyKVLSSwJ-z2RXNRh*UcPO%t2{i@X_0uuwJ6@h;-=Qef3g6X8cFUHPoCZIv{}R78rZ%99agCe;SpR +z2&R5q?E=vp9E`14e_L9iWfefrys(&*EXOenhi}(uR8D%;1^v32tF*i$meYY6!3~@Q +zv5OSB5c`O2eYdLw^yThU*z33iu!U)sm(UUi!Yh5@S`weCs{BaFFDP7dWAap2{nG=s +zg+-P;PwqQ+?wHvS{X^xRx~)ampA>1zW`P2@zwfa|>{ +z(Zt?9q>hUSNyY-w8WjF3)S{^{Y;7-zeNdEWXCYNlYE#WdCdLmAQQa{ib}eB{46!Vm +zo13!fMtVj@*A05r-xRqe1O+nR=OyKWG>u1mlD&rJ7WUEOHCORSf`H4G9m&D*U>eu{ +zLp6o#gU{59h79h}@mqyQxAYnwjZ3|e)+cm~c9C*PmcN-nJ13-pb9}j+aMZB3eWbuU +z(aP`J@@Js(3eo*K%?H@(M#W~b(~+qW`F;+iobQ&M*W>{=WjBNNZqtpbh4N5N(I2dG +z-RX`fI|JPp?}OI)XaR2iVs;j=E!yAobeUouDw>}0b0z1W+MTAGY0eJ{GDB$rxn+Jx +zijgtNgG}Ip-xgzR(6Yw>ce#I{RXF)m?YpDnSx1P +z-qxP|)1Pe80-2Yo{|kjzD-b|ra*a%GbQ-JEf +zY4Ef^R`Uo`;5%GzqsAjSR8OWeT$^xkT*!`awX@U|_Abd2Kni%MHCjtQr!HimpSd78 +zqrPOZv^3?zweIu9Gt!GTOD19I)$#R&XHcKG{N6t4Uzm)% +z_&ik-;lla8ao5f-XCXafQiDpVG*V0{N!aCZPn=1CN`%)rVO5b3-l1<&5Rm>dgqG6& +zi6I?9NDN#D1uh~vl;mU=49d2IlV^tnzNl6O2YpihPema^^jse;K;WdUa}|$oaghqg +z(6Awt@Duo-@b4d^62bJ31eGM@W)0Qd@X!Ndd;7ddj(j^*YY2nz}q(w%?j=RPLP@eEF|B$PQ2KtCtcE0TG0n}qx$Q0g;>#Q +zXb4R~mYm3CJ1RdzfK4TCyeNO)4km{6`QK7Rtf74G7sV*O8|HzS0B>>4yF}W2o(lp* +zM{UWrv+Ba@vnVNI88u6!KF%=Wbx&cqT*am6q30wD#F98KVc5!5oJkm|LweHam10~r +zX@~3#%zVK@yDeBv6!qOETx37pSa`UBTxI#cHI-Sl3=?)E1K4yNsZ5YEKwM8qGV1Vn +zk8qYSbHYB+UTkQmS +t;Jjx^&~6n@&egfT2m_h_UkqA5Co_+SJESY3=}2`iKwrlMS%GlG{15vgE&>1m + +literal 0 +HcmV?d00001 + +diff --git a/cmake/DebPackageConfig.cmake b/cmake/DebPackageConfig.cmake +new file mode 100644 +index 0000000..cfba051 +--- /dev/null ++++ b/cmake/DebPackageConfig.cmake +@@ -0,0 +1,323 @@ ++cmake_minimum_required(VERSION 3.0.0) ++ ++# function(add_deb_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_MAINTAINER PACKAGE_EMAIL PACKAGE_SHORT_DESCRIPTION PACKAGE_LONG_DESCRIPTION) ++ ++# endfunction(add_deb_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_MAINTAINER PACKAGE_EMAIL PACKAGE_SHORT_DESCRIPTION PACKAGE_LONG_DESCRIPTION) ++ ++# if(add_deb_package VALUE) set(Package ${VALUE} PARENT_SCOPE) endif(add_deb_package VALUE) ++# if(add_deb_version VALUE) set(Version ${VALUE} PARENT_SCOPE) endif(add_deb_version VALUE) ++# if(add_deb_maintainer VALUE) set(Maintainer ${VALUE} PARENT_SCOPE) endif(add_deb_maintainer VALUE) ++# if(add_deb_email VALUE) set(Email ${VALUE} PARENT_SCOPE) endif(add_deb_email VALUE) ++# if(add_deb_descrition VALUE) set(Descrition ${VALUE} PARENT_SCOPE) endif(add_deb_descrition VALUE) ++# if(add_deb_detail VALUE) set(Detail ${VALUE} PARENT_SCOPE) endif(add_deb_detail VALUE) ++ ++ ++# set(Package "") ++# set(Version "") ++# set(Architecture "") ++# set(Maintainer "") ++# set(Email "") ++# set(Descrition "") ++ ++function(find_str _IN _SEP _OUT) ++ string(FIND "${_IN}" "${_SEP}" _TMP) ++ set(${_OUT} ${_TMP} PARENT_SCOPE) ++endfunction(find_str _IN _SEP _OUT) ++ ++ ++function(find_next _IN _OUT) ++ find_str("${_IN}" "\n" _TMP) ++ set(${_OUT} ${_TMP} PARENT_SCOPE) ++endfunction(find_next _IN _OUT) ++ ++function(sub_next _IN _INDEX _OUT __OUT) ++ find_next(${_IN} _NEXTINDEX) ++ string(SUBSTRING "${_IN}" ${_INDEX} ${_NEXTINDEX} _TMP) ++ math(EXPR _NEXTINDEX ${_NEXTINDEX}+1) ++ string(SUBSTRING "${_IN}" ${_NEXTINDEX} -1 __TMP) ++ set(${_OUT} ${_TMP} PARENT_SCOPE) ++ set(${__OUT} ${__TMP} PARENT_SCOPE) ++endfunction(sub_next _IN _INDEX _OUT) ++ ++function(trim_str _IN _OUT) ++ string(STRIP "${_IN}" _TMP) ++ set(${_OUT} ${_TMP} PARENT_SCOPE) ++endfunction(trim_str _IN _OUT) ++ ++function(split_str _IN _SEP _OUT) ++ string(FIND "${_IN}" "${_SEP}" _TMP_INDEX) ++ if(NOT _TMP_INDEX EQUAL -1) ++ string(SUBSTRING "${_IN}" 0 ${_TMP_INDEX} _TMP) ++ math(EXPR _TMP_INDEX ${_TMP_INDEX}+1) ++ string(SUBSTRING "${_IN}" ${_TMP_INDEX} -1 __TMP) ++ set(${_OUT} "${_TMP};${__TMP}" PARENT_SCOPE) ++ else() ++ set(${_OUT} ${_IN} PARENT_SCOPE) ++ endif(NOT _TMP_INDEX EQUAL -1) ++endfunction(split_str _IN _SEP _OUT) ++ ++function(split_str_p _IN _SEP _OUT __OUT) ++ split_str("${_IN}" "${_SEP}" _TMP) ++ list(GET _TMP 0 __TMP) ++ list(GET _TMP 1 ___TMP) ++ set(${_OUT} ${__TMP} PARENT_SCOPE) ++ set(${__OUT} ${___TMP} PARENT_SCOPE) ++endfunction(split_str_p _IN _SEP _OUT __OUT) ++ ++function(split_str_n _IN _SEP _OUT _N) ++ if(_N GREATER 1) ++ set(_C ${_N}) ++ set(_RET "") ++ set(_NEXT ${_IN}) ++ while(NOT _C EQUAL 0) ++ split_str("${_NEXT}" "${_SEP}" _TMP) ++ list(LENGTH _TMP _TMP_LEN) ++ if(_TMP_LEN EQUAL 2) ++ list(GET _TMP 0 __TMP) ++ list(GET _TMP 1 _NEXT) ++ list(APPEND _RET ${__TMP}) ++ else() ++ break() ++ endif(_TMP_LEN EQUAL 2) ++ math(EXPR _C "${_C}-1") ++ endwhile(NOT _C EQUAL 0) ++ list(APPEND _RET ${_NEXT}) ++ set(${_OUT} ${_RET} PARENT_SCOPE) ++ else() ++ split_str("${_IN}" "${_SEP}" _TMP) ++ set(${_OUT} ${_TMP} PARENT_SCOPE) ++ endif(_N GREATER 1) ++endfunction(split_str_n _IN _SEP _OUT _N) ++ ++ ++function(set_package_vars _IN_KEY _IN_VAL) ++ ++ # trim_str("${_IN_KEY}" _IN_KEY) ++ ++ find_str("${_IN_KEY}" "Type" _Type) ++ if(_Type EQUAL "0") ++ string(TOUPPER "${_IN_VAL}" _IN_VAL_UPPER) ++ string(TOLOWER "${_IN_VAL}" _IN_VAL_LOWER) ++ set(CPACK_GENERATOR "${_IN_VAL_UPPER}" PARENT_SCOPE) ++ message("--> 软件包类型: ${_IN_VAL_LOWER}") ++ endif(_Type EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Package" _Package) ++ if(_Package EQUAL "0") ++ if(_IN_VAL STREQUAL "auto") ++ set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}" PARENT_SCOPE) ++ else() ++ set(CPACK_DEBIAN_PACKAGE_NAME "${_IN_VAL}" PARENT_SCOPE) ++ endif(_IN_VAL STREQUAL "auto") ++ message("--> 软件包名: ${_IN_VAL}") ++ endif(_Package EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Version" _Version) ++ if(_Version EQUAL "0") ++ if(_IN_VAL STREQUAL "auto") ++ set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}" PARENT_SCOPE) ++ else() ++ set(CPACK_DEBIAN_PACKAGE_VERSION "${_IN_VAL}" PARENT_SCOPE) ++ endif(_IN_VAL STREQUAL "auto") ++ ++ message("--> 软件版本: ${_IN_VAL}") ++ endif(_Version EQUAL "0") ++ ++ find_str("${_IN_KEY}" "CalVer" _CalVer) ++ if(_CalVer EQUAL "0") ++ set(CalVer "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 日历化版本: ${_IN_VAL}") ++ endif(_CalVer EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Architecture" _Architecture) ++ if(_Architecture EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_IN_VAL}" PARENT_SCOPE) ++ if(_IN_VAL STREQUAL "auto") ++ execute_process( ++ COMMAND dpkg --print-architecture ++ OUTPUT_VARIABLE _RETV ++ OUTPUT_STRIP_TRAILING_WHITESPACE ++ ) ++ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_RETV}" PARENT_SCOPE) ++ endif(_IN_VAL STREQUAL "auto") ++ message("--> 软件架构: ${_IN_VAL}") ++ endif(_Architecture EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Priority" _Priority) ++ if(_Priority EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_PRIORITY "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 优先级: ${_IN_VAL}") ++ endif(_Priority EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Depends" _Depends) ++ if(_Depends EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_DEPENDS "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 软件依赖: ${_IN_VAL}") ++ endif(_Depends EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Maintainer" _Maintainer) ++ if(_Maintainer EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 软件维护者: ${_IN_VAL}") ++ endif(_Maintainer EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Homepage" _Homepage) ++ if(_Homepage EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 软件主页: ${_IN_VAL}") ++ endif(_Homepage EQUAL "0") ++ ++ find_str("${_IN_KEY}" "Recommends" _Recommends) ++ if(_Recommends EQUAL "0") ++ set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "${_IN_VAL}" PARENT_SCOPE) ++ message("--> 软件建议: ${_IN_VAL}") ++ endif(_Recommends EQUAL "0") ++ ++endfunction(set_package_vars _IN_KEY _IN_VAL) ++ ++# 定义一个自定义(add_package_descript)函数 ++# 用于按特定配置约定自动化构建软件包配置 ++function(add_package_descript IN_DES) ++ set(PACKAGE_DES_PATH "${IN_DES}") ++ ++ if(EXISTS ${IN_DES}) ++ ++ elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES}") ++ set(PACKAGE_DES_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES}") ++ else() ++ message(FATAL_ERROR "!! Not Found Path: ${PACKAGE_DES_PATH}") ++ return() ++ endif(EXISTS ${IN_DES}) ++ ++ file(READ ${PACKAGE_DES_PATH} DES_CONTENT) ++ trim_str("${DES_CONTENT}" DES_CONTENT) ++ ++ ################## 解析 ################## ++ ++ sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) ++ set(PREV_DES "") ++ while(NOT DES_LINE STREQUAL "${PREV_DES}") ++ # 检查该描述行是否是 # 注释开头,是的话将跳过该行 ++ find_str("${DES_LINE}" "#" _COMMENT) ++ if(_COMMENT EQUAL "0") ++ message("--> !!!!!!! ${DES_LINE}") ++ sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) ++ continue() ++ endif(_COMMENT EQUAL "0") ++ ++ # 检查该描述行是否是 Descrition 开头,是的话说明描述结尾了 ++ find_str("${DES_LINE}" "Descrition" _DESCRIPTION) ++ if(_DESCRIPTION EQUAL "0") ++ break() ++ endif(_DESCRIPTION EQUAL "0") ++ ++ split_str_n("${DES_LINE}" ":" _TMP 1) ++ list(LENGTH _TMP _TMP_LEN) ++ ++ if(_TMP_LEN EQUAL 2) ++ split_str_p("${DES_LINE}" ":" _TMP __TMP) ++ trim_str("${__TMP}" __TMP) ++ string(LENGTH "${__TMP}" __TMP_LENGTH) ++ if(NOT __TMP_LENGTH EQUAL "0") ++ set_package_vars("${_TMP}" "${__TMP}") ++ endif(NOT __TMP_LENGTH EQUAL "0") ++ endif(_TMP_LEN EQUAL 2) ++ ++ # 记录当前行,获取下一行,可能是已经结尾了(将保持重复行) ++ set(PREV_DES "${DES_LINE}") ++ sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) ++ endwhile(NOT DES_LINE STREQUAL "${PREV_DES}") ++ ++ ++ # 再一次检查该描述行是否是 Descrition 开头,是的话将进行分析描述行 ++ find_str("${DES_LINE}" "Descrition" _DESCRIPTION) ++ if(_DESCRIPTION EQUAL "0") ++ split_str_p("${DES_LINE}" ":" _TMP __TMP) ++ trim_str("${__TMP}" __TMP) ++ set(Descrition ${__TMP}) ++ set(PREV_DES_LINE "") ++ while(NOT PREV_DES_LINE STREQUAL DES_LINE) ++ if(NOT PREV_DES_LINE STREQUAL "") ++ set(Descrition "${Descrition}\n${DES_LINE}") ++ endif(NOT PREV_DES_LINE STREQUAL "") ++ set(PREV_DES_LINE "${DES_LINE}") ++ sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT) ++ endwhile(NOT PREV_DES_LINE STREQUAL DES_LINE) ++ # set(Descrition "${Descrition}") ++ message("--> 软件说明: ${Descrition}") ++ ++ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${Descrition}) ++ endif(_DESCRIPTION EQUAL "0") ++ ++ ##################### deb ##################### ++ # ARCHITECTURE ++ if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") ++ set(ARCHITECTURE "amd64") ++ elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64") ++ set(ARCHITECTURE "arm64") ++ endif() ++ ++ #################### Calendar Version ################### ++ if("${CalVer}" STREQUAL "true") ++ string(TIMESTAMP BUILD_TIME "%Y%m%d") ++ set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}-${BUILD_TIME}") ++ endif("${CalVer}" STREQUAL "true") ++ ++ ++ ++ ##################### deb file name ##################### ++ set(_Package "${CPACK_DEBIAN_PACKAGE_NAME}") ++ set(_Version "${CPACK_DEBIAN_PACKAGE_VERSION}") ++ set(_Architecture "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") ++ ++ set(_DebFileName ++ "${_Package}_${_Version}_${_Architecture}${PACKAGE_SUFFIX}.deb" ++ ) ++ set(CPACK_DEBIAN_FILE_NAME ${_DebFileName}) ++ ++ ++ # set(CPACK_DEBIAN_PACKAGE_NAME "${Package}") ++ # set(CPACK_DEBIAN_PACKAGE_VERSION "${Version}") ++ # set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${Architecture}") ++ # set(CPACK_DEBIAN_PACKAGE_DEPENDS "${Depends}") ++ # set(CPACK_DEBIAN_PACKAGE_PRIORITY "${Priority}") ++ # set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${Maintainer}") ++ # set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${Descrition}") ++ ++ # 设置即将使用的标准脚本 ++ # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ++ # "${CMAKE_SOURCE_DIR}/config/DEBIAN/preinst" ++ # "${CMAKE_SOURCE_DIR}/config/DEBIAN/postinst" ++ # "${CMAKE_SOURCE_DIR}/config/DEBIAN/prerm" ++ # "${CMAKE_SOURCE_DIR}/config/DEBIAN/postrm" ++ # ) ++ ++ # 设置为ON,以便使用 dpkg-shlibdeps 生成更好的包依赖列表。 ++ # set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) ++ # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) ++ # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") ++ ++ include(CPack) ++ ++endfunction(add_package_descript IN_DES) ++ ++ ++# TODO: ++# CPACK_GENERATOR ++# CPACK_DEBIAN_FILE_NAME - n ++# CPACK_DEBIAN_PACKAGE_NAME - y ++# CPACK_DEBIAN_PACKAGE_VERSION - y ++# CPACK_DEBIAN_PACKAGE_ARCHITECTURE - y(auto) ++# CPACK_DEBIAN_PACKAGE_DEPENDS - y ++# CPACK_DEBIAN_PACKAGE_PRIORITY - y ++# CPACK_DEBIAN_PACKAGE_MAINTAINER - y ++# CPACK_DEBIAN_PACKAGE_DESCRIPTION - y ++ ++# ARCHITECTURE ++# if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") ++# set(ARCHITECTURE "amd64") ++# elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64") ++# set(ARCHITECTURE "arm64") ++# endif() ++ ++# string(TIMESTAMP BUILD_TIME "%Y%m%d") +diff --git a/cmake/SparkDesktopMacros.cmake b/cmake/SparkDesktopMacros.cmake +new file mode 100644 +index 0000000..223ac6b +--- /dev/null ++++ b/cmake/SparkDesktopMacros.cmake +@@ -0,0 +1,35 @@ ++ ++macro(spark_desktop_macros _APP_NAME _APP_NAME_ZH_CN _APP_COMMENT _APP_TYPE _APP_EXECUTE_PATH _APP_EXECUTE_ICON_PATH _APP_CATEGORIES) ++ set(APP_NAME ${_APP_NAME}) ++ set(APP_NAME_ZH_CN ${_APP_NAME_ZH_CN}) ++ set(APP_COMMENT ${_APP_COMMENT}) ++ set(APP_TYPE ${_APP_TYPE}) ++ set(APP_EXECUTE_PATH ${_APP_EXECUTE_PATH}) ++ set(APP_EXECUTE_ICON_PATH ${_APP_EXECUTE_ICON_PATH}) ++ set(APP_CATEGORIES ${_APP_CATEGORIES}) ++ configure_file(cmake/spark-desktop.desktop.in ++ ${CMAKE_BINARY_DIR}/${_APP_NAME}.desktop ++ ) ++endmacro(spark_desktop_macros _APP_NAME _APP_NAME_ZH_CN _APP_COMMENT _APP_TYPE _APP_EXECUTE_PATH _APP_EXECUTE_ICON_PATH _APP_CATEGORIES) ++ ++# include(cmake/SparkDesktopMacros.cmake) ++# 内容默认应用名称: Name= 应与项目名称相同 ++# spark_desktop_macros( ++ # 应用名称: Name= ++ # 应用名称: Name[zh_CN]= ++ # 应用说明: Comment= ++ # 应用类型: Type= ++ # 执行程序: Exec= ++ # 图标路径: Icon= ++ # 应用分类: Category= ++# ) ++ ++# configure_file( ++# [NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS | ++# FILE_PERMISSIONS ...] ++# [COPYONLY] [ESCAPE_QUOTES] [@ONLY] ++# [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) ++ ++# install(FILES ${APP_NAME}.desktop ++# DESTINATION /usr/share/applications ++# ) +\ No newline at end of file +diff --git a/cmake/SparkInstallMacrosConfig.cmake b/cmake/SparkInstallMacrosConfig.cmake +new file mode 100644 +index 0000000..1f8939b +--- /dev/null ++++ b/cmake/SparkInstallMacrosConfig.cmake +@@ -0,0 +1,131 @@ ++ ++# spark_install_target ++# 基于传入的路径/目标进行安装 ++# 可接受的值为: 安装路径 目标A ++# 可接受的值为: 安装路径 目标A 目标B 目标C... ++macro(spark_install_target INSTALL_TARGET_DIR INSTALL_TARGETS) ++ install(TARGETS ++ ${INSTALL_TARGETS} ${ARGN} ++ DESTINATION ${INSTALL_TARGET_DIR}) ++endmacro(spark_install_target INSTALL_TARGET_DIR INSTALL_TARGETS) ++ ++# spark_install_file ++# 基于传入的路径/文件进行安装 ++# 可接受的值为: 安装路径 文件A ++# 可接受的值为: 安装路径 文件A 文件B 文件C... ++macro(spark_install_file INSTALL_FILE_DIR INSTALL_FILE) ++ install(FILES ++ ${INSTALL_FILE} ${ARGN} ++ DESTINATION ${INSTALL_FILE_DIR}) ++endmacro(spark_install_file INSTALL_FILE_DIR INSTALL_FILE) ++ ++# spark_install_program ++# 基于传入的路径/文件进行安装,并自动为其添加可执行权限 ++# 可接受的值为: 安装路径 文件A ++# 可接受的值为: 安装路径 文件A 文件B 文件C... ++macro(spark_install_program INSTALL_PROGRAM_DIR INSTALL_PROGRAM) ++ install(PROGRAMS ++ ${INSTALL_PROGRAM} ${ARGN} ++ DESTINATION ${INSTALL_PROGRAM_DIR}) ++endmacro(spark_install_program INSTALL_PROGRAM_DIR INSTALL_PROGRAM) ++ ++ ++# spark_install_directory ++# 基于传入的路径/目录进行安装 ++# 可接受的值为: 安装路径 路径A ++# 可接受的值为: 安装路径 路径A/* 为安装路径A下所有内容 ++macro(spark_install_directory INSTALL_DIRECTORY_DIR INSTALL_DIRECOTRY) ++ # INSTALL_DIRECOTRY 可能包含 * ? ++ # 1. 找到 '*', 截取,列出目录下所有文件,安装 ++ # 2. 是文件的直接使用 spark_install_file 安装 ++ # 2. 是目录的直接使用 spark_install_directory 安装 ++ # message(FATAL_ERROR "${INSTALL_DIRECTORY_DIR}") ++ # string(FIND [REVERSE]) ++ string(FIND "${INSTALL_DIRECOTRY}" "*" INSTALL_DIRECTORY_FIND_INDEX) ++ # message(FATAL_ERROR "${INSTALL_DIRECTORY_FIND_INDEX}: ${INSTALL_DIRECTORY_DIR}") ++ ++ # file(GLOB ++ # [LIST_DIRECTORIES true|false] [RELATIVE ] [CONFIGURE_DEPENDS] ++ # [...]) ++ ++ if (NOT INSTALL_DIRECTORY_FIND_INDEX EQUAL -1) ++ # string(SUBSTRING ) ++ string(SUBSTRING "${INSTALL_DIRECOTRY}" 0 ${INSTALL_DIRECTORY_FIND_INDEX} INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING) ++ # message(FATAL_ERROR "directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING}") ++ ++ # file(GLOB ++ # [LIST_DIRECTORIES true|false] [RELATIVE ] [CONFIGURE_DEPENDS] ++ # [...]) ++ ++ file(GLOB INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING}/*) ++ list(LENGTH INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST_LENGTH) ++ foreach(item IN LISTS INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST) ++ # message("-> ${item}") ++ if(IS_DIRECTORY ${item}) ++ message("-> ${item} IS_DIRECTORY") ++ # spark_install_directory(${INSTALL_DIRECTORY_DIR} ${item}) ++ install(DIRECTORY ++ ${item} ++ DESTINATION ${INSTALL_DIRECTORY_DIR} ++ USE_SOURCE_PERMISSIONS) ++ else() ++ message("-> ${item} NOT IS_DIRECTORY") ++ spark_install_program(${INSTALL_DIRECTORY_DIR} ${item}) ++ # spark_install_file(${INSTALL_DIRECTORY_DIR} ${item}) ++ endif(IS_DIRECTORY ${item}) ++ endforeach(item IN LISTS INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST) ++ ++ # message(FATAL_ERROR " directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST}") ++ # message(FATAL_ERROR " directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST_LENGTH}") ++ ++ else() ++ message(FATAL_ERROR "install: ${INSTALL_DIRECTORY_DIR}") ++ ++ install(DIRECTORY ++ ${INSTALL_DIRECOTRY} ${ARGN} ++ DESTINATION ${INSTALL_DIRECTORY_DIR}) ++ endif(NOT INSTALL_DIRECTORY_FIND_INDEX EQUAL -1) ++ ++endmacro(spark_install_directory INSTALL_DIRECTORY_DIR INSTALL_DIRECOTRY) ++ ++ ++ ++macro(spark_install_changelog CHANGE_LOG_FILE) ++ set(SOURCE_CHANGE_LOG_FILE ${CHANGE_LOG_FILE}) ++ if (EXISTS ${SOURCE_CHANGE_LOG_FILE}) ++ ++ execute_process(COMMAND test -f ${SOURCE_CHANGE_LOG_FILE} ++ RESULT_VARIABLE changelog_test ++ ) ++ execute_process(COMMAND which gzip ++ RESULT_VARIABLE gzip_test ++ ) ++ if (NOT changelog_test EQUAL 0) ++ message(FATAL_ERROR "NOTE: 不是常规文件: ${SOURCE_CHANGE_LOG_FILE}") ++ endif(NOT changelog_test EQUAL 0) ++ ++ if (NOT gzip_test EQUAL 0) ++ message(FATAL_ERROR "NOTE: 未安装 gzip, 无法压缩 changelog") ++ endif(NOT gzip_test EQUAL 0) ++ ++ # 压缩与安装日志文件 ++ add_custom_command( ++ OUTPUT "${CMAKE_BINARY_DIR}/changelog.gz" ++ COMMAND gzip -cn9 "${SOURCE_CHANGE_LOG_FILE}" > "${CMAKE_BINARY_DIR}/changelog.gz" ++ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ++ COMMENT "Compressing changelog" ++ ) ++ add_custom_target(changelog ALL DEPENDS "${CMAKE_BINARY_DIR}/changelog.gz") ++ ++ # include(GNUInstallDirs) ++ set(SPARK_INSTALL_CHANGE_LOG_DIR "/usr/share/doc/${PROJECT_NAME}/") ++ install(FILES ++ ${CMAKE_BINARY_DIR}/changelog.gz ++ debian/copyright ++ ++ DESTINATION ${SPARK_INSTALL_CHANGE_LOG_DIR} ++ ) ++ else() ++ message(FATAL_ERROR "未找到: ${SOURCE_CHANGE_LOG_FILE}") ++ endif(EXISTS ${SOURCE_CHANGE_LOG_FILE}) ++endmacro(spark_install_changelog CHANGE_LOG_FILE) +diff --git a/cmake/package-deb.descript b/cmake/package-deb.descript +new file mode 100644 +index 0000000..be0fa83 +--- /dev/null ++++ b/cmake/package-deb.descript +@@ -0,0 +1,45 @@ ++# 注释行(使用方式) ++# find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR}) ++# add_package_descript(cmake/package-deb.descript) ++ ++# 打包后的文件名称 ++# FileName: 待定 ++# 配置 PACKAGE_SUFFIX 变量可添加尾巴名称 ++# 如在 Makefile 中硬编码方式 ++# OSID=$(shell lsb_release -si) ++# OSRELEASE=$(shell lsb_release -sr) ++# -DPACKAGE_SUFFIX="_$(OSID)$(OSRELEASE)" ++ ++# deb 安装包的安装时脚本 ++# 1.安装[前|后]执行脚本(preinst,postinst), ++# 2.卸载[前|后]执行脚本(prerm,postrm) ++# ControlExtra: 未定义(暂不支持) ++# 如需指定请修改 DebPackageConfig.cmake 模板(第252行) ++# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 变量 ++ ++# 打包类型,暂支持 deb, 未来支持 tgz(tar.gz) ++Type: deb ++# 软件包名称(自动, 使用 PROJECT_NAME 变量值) ++Package: com.hmja.notepad ++# 软件包版本(自动, 使用 PROJECT_VERSION 变量值) ++Version: auto ++# 日历化尾部版本 ++CalVer: true ++# 软件包架构(自动) ++Architecture: auto ++# 软件包属于的系统部分[admin|cli-mono|comm|database|debug|devel|doc|editors|education|electronics|embedded|fonts|games|gnome|gnu-r|gnustep|graphics|hamradio|haskell|httpd|interpreters|introspection|java|javascript|kde|kernel|libdevel|libs|lisp|localization|mail|math|metapackages|misc|net|news|ocaml|oldlibs|otherosfs|perl|php|python|ruby|rust|science|shells|sound|tasks|tex|text|utils|vcs|video|web|x11|xfce|zope] ++Section: editors ++# 软件包优先级[required|important|stantard|optional|extra] ++Priority: optional ++# 软件包依赖 ++Depends: ++# 软件包维护者(组织或个人) ++Maintainer: 尹作为 <757210198@qq.com> ++# 软件包主页 ++Homepage: https://gitee.com/cxasm/notepad-- ++# 软件包建议 ++Recommends: ++# 软件包描述信息 ++Descrition: Notepad--是一个国产跨平台、简单的文本编辑器。 ++ Notepad--是一个国产跨平台、简单的文本编辑器,是替换notepad++的一种选择。 ++ 其内置强大的代码对比功能,让你丢掉付费的beyond compare。 +diff --git a/cmake/spark-desktop.desktop.in b/cmake/spark-desktop.desktop.in +new file mode 100644 +index 0000000..e7c3b18 +--- /dev/null ++++ b/cmake/spark-desktop.desktop.in +@@ -0,0 +1,12 @@ ++[Desktop Entry] ++Version=1.0 ++Name=@APP_NAME@ ++Name[zh_CN]=@APP_NAME_ZH_CN@ ++Comment=@APP_COMMENT@ ++Type=@APP_TYPE@ ++Exec=@APP_EXECUTE_PATH@ ++Icon=@APP_EXECUTE_ICON_PATH@ ++Categories=@APP_CATEGORIES@ ++MimeType=text/plain ++ ++# Generated from the DesktopGenerater component of the z-Tools toolkit +\ No newline at end of file +-- +2.20.1 + + +From 684ced155e1c749b06e76449177c95db9392c0fc Mon Sep 17 00:00:00 2001 +From: zinface +Date: Wed, 1 Feb 2023 20:09:49 +0800 +Subject: [PATCH 03/13] =?UTF-8?q?repo:=20=E5=BC=95=E5=85=A5=20Spark=20?= + =?UTF-8?q?=E6=9E=84=E5=BB=BA=EF=BC=8C=E6=94=AF=E6=8C=81=E6=9E=84=E5=BB=BA?= + =?UTF-8?q?=20Appimage?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 8 ++ + Makefile | 23 ++++++ + cmake/SparkAppimageConfig.cmake | 139 ++++++++++++++++++++++++++++++++ + cmake/spark-appimage.desktop.in | 10 +++ + 4 files changed, 180 insertions(+) + create mode 100644 cmake/SparkAppimageConfig.cmake + create mode 100644 cmake/spark-appimage.desktop.in + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 666fbdb..a8f27aa 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -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) +diff --git a/Makefile b/Makefile +index 43e849f..b71b27f 100644 +--- a/Makefile ++++ b/Makefile +@@ -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 +diff --git a/cmake/SparkAppimageConfig.cmake b/cmake/SparkAppimageConfig.cmake +new file mode 100644 +index 0000000..7463a48 +--- /dev/null ++++ b/cmake/SparkAppimageConfig.cmake +@@ -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 +diff --git a/cmake/spark-appimage.desktop.in b/cmake/spark-appimage.desktop.in +new file mode 100644 +index 0000000..0ca2577 +--- /dev/null ++++ b/cmake/spark-appimage.desktop.in +@@ -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 +-- +2.20.1 + + +From c241f19bbcec29d7a1ed8fe8e1f0d6e36a957b69 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Thu, 2 Feb 2023 13:58:29 +0800 +Subject: [PATCH 04/13] =?UTF-8?q?desktop:=20=E4=B8=BA=20desktop=20?= + =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC=E6=96=87=E4=BB=B6=E7=9A=84?= + =?UTF-8?q?=E7=9B=B8=E5=85=B3=20MimeType?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + cmake/spark-appimage.desktop.in | 2 +- + cmake/spark-desktop.desktop.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cmake/spark-appimage.desktop.in b/cmake/spark-appimage.desktop.in +index 0ca2577..70fc6b9 100644 +--- a/cmake/spark-appimage.desktop.in ++++ b/cmake/spark-appimage.desktop.in +@@ -7,4 +7,4 @@ Comment=@APP_COMMENT@ + Terminal=true + Type=Application + Categories=@APP_CATEGORIES@ +-MimeType=text/plain ++MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; +diff --git a/cmake/spark-desktop.desktop.in b/cmake/spark-desktop.desktop.in +index e7c3b18..e33c74e 100644 +--- a/cmake/spark-desktop.desktop.in ++++ b/cmake/spark-desktop.desktop.in +@@ -7,6 +7,6 @@ Type=@APP_TYPE@ + Exec=@APP_EXECUTE_PATH@ + Icon=@APP_EXECUTE_ICON_PATH@ + Categories=@APP_CATEGORIES@ +-MimeType=text/plain ++MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-patch;text/x-adasrc;text/x-chdr;text/x-csrc;text/css;application/x-desktop;text/x-patch;text/x-fortran;text/html;text/x-java;text/x-tex;text/x-makefile;text/x-objcsrc;text/x-pascal;application/x-perl;application/x-perl;application/x-php;text/vnd.wap.wml;text/x-python;application/x-ruby;text/sgml;application/xml;model/vrml;image/svg+xml;application/json; + + # Generated from the DesktopGenerater component of the z-Tools toolkit +\ No newline at end of file +-- +2.20.1 + + +From 4a74a60af053dfa4680918ceac8a78974d481d53 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Thu, 2 Feb 2023 14:00:54 +0800 +Subject: [PATCH 05/13] =?UTF-8?q?repo:=20=E5=AF=B9=20desktop=20=E6=96=87?= + =?UTF-8?q?=E4=BB=B6=E6=B7=BB=E5=8A=A0=20%F=20=E5=8F=82=E6=95=B0=EF=BC=8C?= + =?UTF-8?q?=E4=BB=A5=E4=BF=9D=E8=AF=81=E5=8F=AF=E6=AD=A3=E7=A1=AE=E4=BC=A0?= + =?UTF-8?q?=E5=85=A5=E5=8F=82=E6=95=B0?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a8f27aa..63e878c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,7 +70,8 @@ if(CMAKE_HOST_UNIX) + # 应用类型: Type= + "Application" + # 执行程序: Exec= +- "notepad--" ++ # 有关此 %F 参数可查看: https://gitee.com/zinface/z-tools/blob/desktop-dev/src/DesktopGenerater/desktopexecparamdialog.cpp ++ "notepad-- %F" + # 图标路径: Icon= + "/usr/share/notepad--/icons/spark.png" + # 应用分类: Category= +-- +2.20.1 + + +From b7f8abc6c6631ea598216c3606d0f61a9b653474 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Thu, 2 Feb 2023 14:47:56 +0800 +Subject: [PATCH 06/13] =?UTF-8?q?cmake-version:=20=E5=B0=86=E7=89=88?= + =?UTF-8?q?=E6=9C=AC=E9=99=8D=E5=88=B0=203.22=20=E4=BB=A5=E9=80=82?= + =?UTF-8?q?=E7=94=A8=E4=BA=8E=20cmake=20=E6=9E=84=E5=BB=BA?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 2 +- + src/qscint/CMakeLists.txt | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 63e878c..60e9171 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.24) ++cmake_minimum_required(VERSION 3.22) + project(notepad-- VERSION 1.22.0) + + set(CMAKE_AUTOMOC ON) +diff --git a/src/qscint/CMakeLists.txt b/src/qscint/CMakeLists.txt +index f132dc6..77f02f2 100644 +--- a/src/qscint/CMakeLists.txt ++++ b/src/qscint/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.24) ++cmake_minimum_required(VERSION 3.22) + project(qscint CXX) + + set(CMAKE_AUTOMOC ON) +-- +2.20.1 + + +From 8661b20c61ad6f70f645e69e89da46e2b945bf7d Mon Sep 17 00:00:00 2001 +From: zinface +Date: Sun, 5 Feb 2023 12:55:38 +0800 +Subject: [PATCH 07/13] =?UTF-8?q?repo:=20=E5=BC=95=E5=85=A5=20Spark=20?= + =?UTF-8?q?=E7=8E=B0=E6=9C=89=E5=AE=8C=E6=95=B4=E6=9E=84=E5=BB=BA=E6=A8=A1?= + =?UTF-8?q?=E5=9D=97?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + cmake/SparkEnvConfig.cmake | 8 + + cmake/SparkFindQt5Config.cmake | 153 ++++++++++++++++++ + cmake/SparkFindQt6Config.cmake | 130 +++++++++++++++ + cmake/SparkMacrosConfig.cmake | 161 +++++++++++++++++++ + cmake/SparkMacrosExtendConfig.cmake | 237 ++++++++++++++++++++++++++++ + 5 files changed, 689 insertions(+) + create mode 100644 cmake/SparkEnvConfig.cmake + create mode 100644 cmake/SparkFindQt5Config.cmake + create mode 100644 cmake/SparkFindQt6Config.cmake + create mode 100644 cmake/SparkMacrosConfig.cmake + create mode 100644 cmake/SparkMacrosExtendConfig.cmake + +diff --git a/cmake/SparkEnvConfig.cmake b/cmake/SparkEnvConfig.cmake +new file mode 100644 +index 0000000..3690f1a +--- /dev/null ++++ b/cmake/SparkEnvConfig.cmake +@@ -0,0 +1,8 @@ ++cmake_minimum_required(VERSION 3.5.1) ++ ++set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ++# set(CMAKE_INCLUDE_CURRENT_DIR ON) ++set(CMAKE_AUTOMOC ON) ++set(CMAKE_AUTOUIC ON) ++set(CMAKE_AUTORCC ON) ++# set(CMAKE_BUILD_TYPE "Debug") +\ No newline at end of file +diff --git a/cmake/SparkFindQt5Config.cmake b/cmake/SparkFindQt5Config.cmake +new file mode 100644 +index 0000000..ad2db4c +--- /dev/null ++++ b/cmake/SparkFindQt5Config.cmake +@@ -0,0 +1,153 @@ ++cmake_minimum_required(VERSION 3.5.1) ++ ++set(SPARK_FIND_QT5 TRUE) ++ ++find_package(Qt5 COMPONENTS Core Widgets Network REQUIRED) ++ ++# function(target_link_qt5 NAME) ++# target_link_libraries(${NAME} ++# Qt5::Core ++# Qt5::Widgets ++# Qt5::Network) ++# endfunction(target_link_qt5 NAME) ++ ++# 使用 spark_add_link 生成 target_link_qt5 以替代上面内容 ++spark_add_link(qt5 Qt5::Core Qt5::Widgets Qt5::Network) ++ ++ ++# spark_add_link_qt5 ++# 自定义宏 spark_add_link_qt5 以扩展 target_link_qt5_ 结构 ++ # _IN_NAME: 此宏使用嵌套宏 spark_add_link 时追加 名称 ++ # 同等于 spark_add_link(qt_ ${ARGN}) ++macro(spark_add_link_qt5 _IN_NAME) ++ spark_add_link(qt5_${_IN_NAME} ${ARGN}) ++endmacro(spark_add_link_qt5 _IN_NAME) ++ ++# 使用 spark_add_link_qt5 生成 target_link_qt5_ 的宏 ++# spark_add_link_qt5(Concurrent Qt5::Concurrent) ++ ++# 高级自定义 ++# spark_add_links_qt5 ++# 自定义宏 spark_add_links_qt5 以扩展 spark_add_link_qt5 宏配置组 ++ # 特点: 任意长度参数 ++ # qt5_item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) ++ # 例如: qt5_item 为 Core: ++ # spark_add_link_qt5(${qt5_item} Qt5::${qt5_item}) ++ # 展开为 spark_add_link_qt5(Core Qt5::Core) ++ # 展开为 spark_add_link(qt5_Core Qt5::Core) ++ # 展开为 spark_add_link(qt5_Core Qt5::Core) ++ # 特性: 增加 qt5_Core 转 qt5_core ++ # string(TOLOWER ) ++macro(spark_add_links_qt5) ++ set(qt5_items ${ARGN}) ++ foreach(qt5_item IN LISTS qt5_items) ++ find_package(Qt5${qt5_item}) ++ spark_add_link_qt5(${qt5_item} Qt5::${qt5_item}) ++ ++ string(TOLOWER "${qt5_item}" qt5_lower_item) ++ spark_add_link_qt5(${qt5_lower_item} Qt5::${qt5_item}) ++ message("add_target_link_qt5_${qt5_item} or add_target_link_qt5_${qt5_lower_item}") ++ endforeach(qt5_item IN LISTS qt5_items) ++endmacro(spark_add_links_qt5) ++ ++ ++# Core 用于其它模块的核心非图形类。 ++# GUI 图形用户界面 GUI 组件基类。包括 OpenGL。 ++# Multimedia 音频 视频 无线电 摄像头功能类。 ++# Multimedia Widgets 用于实现多媒体功能,基于 Widget 的类。 ++# Network 使网络编程更容易和更可移植的类。 ++ ++# QML QML 和 JavaScript 语言类。 ++# Quick 以自定义用户界面 UI 构建高动态应用程序的声明性框架。 ++# Quick Controls 为桌面、嵌入式及移动设备创建高性能用户界面提供轻量 QML 类型。这些类型运用简单样式化体系结构且非常高效。 ++# Quick Dialogs 用于从 Qt Quick 应用程序创建系统对话框,并与之交互的类型。 ++# Quick Layouts 布局是用于在用户界面中排列基于 Qt Quick 2 项的项。 ++# Quick Test 用于 QML 应用程序的单元测试框架,其测试案例被编写成 JavaScript 函数。 ++ # 注意: 二进制保证不兼容 Qt Quick Test,但源代码仍兼容。 ++ ++# Qt SQL 集成使用 SQL 数据库的类。 ++# Qt Test 单元测试 Qt 应用程序和库的类。 ++ # 注意: 二进制保证不兼容 Qt Test,但源代码仍兼容。 ++# Qt Widgets 以 C++ 小部件扩展 Qt GUI 的类。 ++ ++ ++ ++# 找出所有 Qt5 模板 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 ++ ++# 掐头去尾,洗一次 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' ++ ++# 排序 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 ++ ++spark_add_links_qt5( ++ # AccessibilitySupport ++ # AttributionsScannerTools ++ Concurrent ++ # Core ++ # DBus ++ # Designer ++ # DesignerComponents ++ # DeviceDiscoverySupport ++ # DocTools ++ # EdidSupport ++ # EglFSDeviceIntegration ++ # EglFsKmsSupport ++ # EglSupport ++ # EventDispatcherSupport ++ # FbSupport ++ # FontDatabaseSupport ++ # GlxSupport ++ Gui ++ # Help ++ # InputSupport ++ # KmsSupport ++ # LinguistTools ++ # LinuxAccessibilitySupport ++ # Network ++ # OpenGL ++ # OpenGLExtensions ++ # PacketProtocol ++ # PlatformCompositorSupport ++ # Positioning ++ # PositioningQuick ++ PrintSupport ++ # Qml ++ # QmlDebug ++ # QmlDevTools ++ # QmlImportScanner ++ # QmlModels ++ # QmlWorkerScript ++ # Quick ++ # QuickCompiler ++ # QuickControls2 ++ # QuickParticles ++ # QuickShapes ++ # QuickTemplates2 ++ # QuickTest ++ # QuickWidgets ++ # SerialBus ++ # SerialPort ++ # ServiceSupport ++ # Sql ++ # Svg ++ # Test ++ # ThemeSupport ++ # UiPlugin ++ # UiTools ++ # VulkanSupport ++ # WebChannel ++ # WebEngine ++ # WebEngineCore ++ # WebEngineWidgets ++ # WebKit ++ # WebKitWidgets ++ # WebSockets ++ # Widgets ++ # X11Extras ++ # XcbQpa ++ # XkbCommonSupport ++ # Xml ++ XmlPatterns ++) +\ No newline at end of file +diff --git a/cmake/SparkFindQt6Config.cmake b/cmake/SparkFindQt6Config.cmake +new file mode 100644 +index 0000000..fb2d741 +--- /dev/null ++++ b/cmake/SparkFindQt6Config.cmake +@@ -0,0 +1,130 @@ ++cmake_minimum_required(VERSION 3.5.1) ++ ++set(SPARK_FIND_QT6 TRUE) ++ ++find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++ ++# function(target_link_qt6 NAME) ++# target_link_libraries(${NAME} ++# Qt6::Core ++# Qt6::Widgets ++# Qt6::Network) ++# endfunction(target_link_qt6 NAME) ++ ++# 使用 spark_add_link 生成 target_link_qt6 以替代上面内容 ++spark_add_link(qt6 Qt6::Core Qt6::Widgets Qt6::Network) ++ ++ ++# spark_add_link_qt6 ++# 自定义宏 spark_add_link_qt6 以扩展 target_link_qt6_ 结构 ++ # _IN_NAME: 此宏使用嵌套宏 spark_add_link 时追加 名称 ++ # 同等于 spark_add_link(qt_ ${ARGN}) ++macro(spark_add_link_qt6 _IN_NAME) ++ spark_add_link(qt6_${_IN_NAME} ${ARGN}) ++endmacro(spark_add_link_qt6 _IN_NAME) ++ ++# 使用 spark_add_link_qt6 生成 target_link_qt6_ 的宏 ++# spark_add_link_qt5(Concurrent Qt6::Concurrent) ++ ++# 高级自定义 ++# spark_add_links_qt6 ++# 自定义宏 spark_add_links_qt6 以扩展 spark_add_link_qt6 宏配置组 ++ # 特点: 任意长度参数 ++ # qt6_item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) ++ # 例如: qt6_item 为 Core: ++ # spark_add_link_qt6(${qt6_item} Qt6::${qt6_item}) ++ # 展开为 spark_add_link_qt6(Core Qt6::Core) ++ # 展开为 spark_add_link(qt6_Core Qt6::Core) ++ # 展开为 spark_add_link(qt6_Core Qt6::Core) ++ # 特性: 增加 qt6_Core 转 qt6_core ++ # string(TOLOWER ) ++macro(spark_add_links_qt6) ++ set(qt6_items ${ARGN}) ++ foreach(qt6_item IN LISTS qt6_items) ++ find_package(Qt6${qt6_item}) ++ spark_add_link_qt6(${qt6_item} Qt6::${qt6_item}) ++ ++ string(TOLOWER "${qt6_item}" qt6_lower_item) ++ spark_add_link_qt6(${qt6_lower_item} Qt6::${qt6_item}) ++ message("add_target_link_qt6_${qt6_item} or add_target_link_qt6_${qt6_lower_item}") ++ endforeach(qt6_item IN LISTS qt6_items) ++endmacro(spark_add_links_qt6) ++ ++# 找出所有 Qt6 模板 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt6@Qt6@;' | grep ^Qt6 ++ ++# 掐头去尾,洗一次 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' ++ ++# 排序 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt5@Qt5@;' | grep ^Qt5 | sed 's@^Qt5@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 ++# find /usr/lib/x86_64-linux-gnu/cmake/ -name "*Config.cmake" | sed 's@^.*/Qt6@Qt6@;' | grep ^Qt6 | sed 's@^Qt6@@; s@Config.cmake$@@; /^\s*$/d' | sort | pr -t -3 ++ ++spark_add_links_qt6( ++ # BuildInternals ++ # BuildInternals/StandaloneTests/Qt5CompatTests ++ # BuildInternals/StandaloneTests/QtBaseTests ++ Concurrent ++ # Core ++ Core5Compat ++ # CoreTools ++ # DBus ++ # DBusTools ++ # DeviceDiscoverySupportPrivate ++ # EglFSDeviceIntegrationPrivate ++ # EglFsKmsGbmSupportPrivate ++ # EglFsKmsSupportPrivate ++ # FbSupportPrivate ++ # Gui ++ # GuiTools ++ # HostInfo ++ # InputSupportPrivate ++ # KmsSupportPrivate ++ # Network ++ # OpenGL ++ # OpenGLWidgets ++ PrintSupport ++ # QComposePlatformInputContextPlugin ++ # QCupsPrinterSupportPlugin ++ # QEglFSEmulatorIntegrationPlugin ++ # QEglFSIntegrationPlugin ++ # QEglFSKmsEglDeviceIntegrationPlugin ++ # QEglFSKmsGbmIntegrationPlugin ++ # QEglFSX11IntegrationPlugin ++ # QEvdevKeyboardPlugin ++ # QEvdevMousePlugin ++ # QEvdevTabletPlugin ++ # QEvdevTouchScreenPlugin ++ # QGifPlugin ++ # QGtk3ThemePlugin ++ # QIBaseDriverPlugin ++ # QIbusPlatformInputContextPlugin ++ # QICOPlugin ++ # QJpegPlugin ++ # QLibInputPlugin ++ # QLinuxFbIntegrationPlugin ++ # QMinimalEglIntegrationPlugin ++ # QMinimalIntegrationPlugin ++ # QMYSQLDriverPlugin ++ # QNetworkManagerNetworkInformationPlugin ++ # QODBCDriverPlugin ++ # QOffscreenIntegrationPlugin ++ # QPSQLDriverPlugin ++ # QSQLiteDriverPlugin ++ # QTlsBackendCertOnlyPlugin ++ # QTlsBackendOpenSSLPlugin ++ # QTsLibPlugin ++ # QTuioTouchPlugin ++ # QVkKhrDisplayIntegrationPlugin ++ # QVncIntegrationPlugin ++ # QXcbEglIntegrationPlugin ++ # QXcbGlxIntegrationPlugin ++ # QXcbIntegrationPlugin ++ # QXdgDesktopPortalThemePlugin ++ # Sql ++ # Test ++ # Widgets ++ # WidgetsTools ++ # XcbQpaPrivate ++ # Xml ++) +\ No newline at end of file +diff --git a/cmake/SparkMacrosConfig.cmake b/cmake/SparkMacrosConfig.cmake +new file mode 100644 +index 0000000..4f68ce1 +--- /dev/null ++++ b/cmake/SparkMacrosConfig.cmake +@@ -0,0 +1,161 @@ ++cmake_minimum_required(VERSION 3.5.1) ++ ++# 定义一些 macro 用于自动生成构建结构 ++ ++# spark_add_library [files]... ++# 构建一个库,基于指定的源文件 ++ # 并根据库名生成 target_link_ 函数 ++macro(spark_add_library _lib_name) ++ message("================ ${_lib_name} Library ================") ++ add_library(${_lib_name} ${ARGN}) ++ ++ set(SRCS ${ARGN}) ++ foreach(item IN LISTS SRCS) ++ message(" -> ${item}") ++ endforeach(item IN LISTS SRCS) ++ ++ function(target_link_${_lib_name} TARGET) ++ message("${_lib_name}") ++ target_link_libraries(${TARGET} ${_lib_name}) ++ endfunction(target_link_${_lib_name} TARGET) ++ ++endmacro(spark_add_library _lib_name) ++ ++# spark_add_library_path ++# 构建一个库,基于指定的路径 ++ # 并根据库名生成 target_link_ 函数 ++ # 函数内增加以 头文件搜索路径 ++macro(spark_add_library_path _lib_name _lib_path) ++ ++ set(${_lib_name}_SOURCE_PATH ${_lib_path}) ++ set(${_lib_name}_TYPE) ++ if(${${_lib_name}_SOURCE_PATH} STREQUAL SHARED OR ${${_lib_name}_SOURCE_PATH} STREQUAL STATIC) ++ set(${_lib_name}_SOURCE_PATH ${ARGV2}) ++ set(${_lib_name}_TYPE ${_lib_path}) ++ message("_lib_path: ${${_lib_name}_SOURCE_PATH}(${ARGV2})[${${_lib_name}_TYPE}]") ++ ++ if(${ARGC} LESS 3) ++ message(FATAL_ERROR "Missing parameter, library path not specified.") ++ endif(${ARGC} LESS 3) ++ endif(${${_lib_name}_SOURCE_PATH} STREQUAL SHARED OR ${${_lib_name}_SOURCE_PATH} STREQUAL STATIC) ++ ++ aux_source_directory(${${_lib_name}_SOURCE_PATH} ${_lib_name}_SOURCES) ++ ++ message("================ spark_add_library_path: ${_lib_name} ================") ++ file(GLOB UI_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${${_lib_name}_SOURCE_PATH}/*.ui) ++ add_library(${_lib_name} ${${_lib_name}_TYPE} ${${_lib_name}_SOURCES} ${UI_LIST}) ++ message("${_lib_name}_SOURCES: ${${_lib_name}_SOURCES}, ${${_lib_name}_SOURCE_PATH}") ++ foreach(item IN LISTS ${_lib_name}_SOURCES) ++ message(" -> ${item}") ++ endforeach(item IN LISTS ${_lib_name}_SOURCES) ++ ++ function(target_link_${_lib_name} TARGET) ++ # message("target_link_${_lib_name}") ++ message(" -> (include): ${${_lib_name}_SOURCE_PATH}") ++ target_include_directories(${TARGET} PUBLIC "${${_lib_name}_SOURCE_PATH}") ++ target_link_libraries(${TARGET} ${_lib_name}) ++ endfunction(target_link_${_lib_name} TARGET) ++ ++ function(target_include_${_lib_name} TARGET) ++ # message("target_link_${_lib_name}") ++ message(" -> (include): ${${_lib_name}_SOURCE_PATH}") ++ target_include_directories(${TARGET} PUBLIC "${${_lib_name}_SOURCE_PATH}") ++ # target_link_libraries(${TARGET} ${_lib_name}) ++ endfunction(target_include_${_lib_name} TARGET) ++ ++ # file(GLOB HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${${_lib_name}_SOURCE_PATH}/*.h) ++ target_include_directories(${_lib_name} PUBLIC "${${_lib_name}_SOURCE_PATH}") ++ ++ # 如果想用以下操作手动实现 target_link_include_directories ++ # 请注意对 LIST 类型使用 "" 进行包围 ++ # target_link_include_directories 的 PUBLIC 将会填充(追加)目标的 INCLUDE_DIRECTORIES 属性 ++ # target_link_include_directories 支持 cmake 生成大表达式,更容易操作,手动将无法实现此类能力 ++ # target_link_include_directories 支持相对路径和绝对路径参数 ++ # 手动操作将必须使用绝对路径,这是不好的地方 ++ # get_target_property(_lib_include_directories ${_lib_name} INCLUDE_DIRECTORIES) ++ # list(APPEND _lib_include_directories "${CMAKE_CURRENT_LIST_DIR}/${${_lib_name}_SOURCE_PATH}") ++ # message("----> ${CMAKE_CURRENT_LIST_DIR}/${${_lib_name}_SOURCE_PATH}") ++ # message("----> ${_lib_include_directories}") ++ # set_target_properties(${_lib_name} PROPERTIES ++ # INCLUDE_DIRECTORIES "${_lib_include_directories}" ++ # INTERFACE_INCLUDE_DIRECTORIES "${_lib_include_directories}" ++ # ) ++ ++endmacro(spark_add_library_path _lib_name _lib_path) ++ ++# spark_add_executable [files]... ++# 构建一个可执行文件,基于指定的源文件 ++ # Qt编译时源文件包括很多类型,需要指定 *.h/*.cpp/*.qrc/*.qm/... 等 ++macro(spark_add_executable _exec_name) ++ ++ message("================ ${_exec_name} Executable ================") ++ add_executable(${_exec_name} ${ARGN}) ++ ++endmacro(spark_add_executable _exec_name) ++ ++macro(spark_add_executable_path _exec_name _exec_path) ++ aux_source_directory(${_exec_path} ${_exec_name}_SOURCES) ++ ++ message("================ ${_exec_name} Executable ================") ++ file(GLOB UI_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${_exec_path}/*.ui) ++ add_executable(${_exec_name} ${${_exec_name}_SOURCES} ${ARGN} ${UI_LIST}) ++ foreach(item IN LISTS ${_exec_name}_SOURCES) ++ message(" -> ${item}") ++ endforeach(item IN LISTS ${_exec_name}_SOURCES) ++ ++ # function(target_link_${_exec_name} TARGET) ++ # message("target_link_${_lib_name}") ++ message(" -> (include): ${_exec_path}") ++ target_include_directories(${_exec_name} PUBLIC "${_exec_path}") ++ # target_link_libraries(${TARGET} ${_lib_name}) ++ # endfunction(target_link_${_exec_name} TARGET) ++ # target_link_${_exec_name}(${_exec_name}) ++ ++endmacro(spark_add_executable_path _exec_name _exec_path) ++ ++# spark_find_library ++# 搜索一个库,基于指定的库名,调用 pkg-config 搜索库 ++ # 并根据库名生成一个 target_link_ 函数 ++macro(spark_find_library _prefix) ++ find_package(PkgConfig REQUIRED) ++ ++ # libnotify ++ pkg_check_modules(${_prefix} ${ARGN}) ++ function(target_link_${_prefix} TARGET) ++ target_include_directories(${TARGET} PUBLIC ++ ${${_prefix}_INCLUDE_DIRS}) ++ target_link_libraries(${TARGET} ++ ${${_prefix}_LIBRARIES}) ++ endfunction(target_link_${_prefix} TARGET) ++ ++endmacro(spark_find_library _prefix) ++ ++ ++# spark_add_executable_paths ++# 自定义构建宏,基于指定的前缀名称,处理后续参数为子目录 ++ # item: 为进行遍历后的单项,类似于 python3 中的 (for item in items:) ++ # file: 为在目录中不以递归(GLOB_RECURSE)方式寻找 qrc 文件,需要将其参与编译才能被 rcc ++ # 并根据 prefix- 生成构建目标, ++macro(spark_add_executable_paths _prefix_path) ++ set(PATHS ${ARGN}) ++ foreach(item IN LISTS PATHS) ++ file(GLOB QRCS "${item}/*.qrc") ++ message(">>> add_executable: " "${_prefix_path}-${item} ${item} + ${QRCS}") ++ spark_add_executable_path(${_prefix_path}-${item} ${item} ${QRCS}) ++ target_link_qt5(${_prefix_path}-${item}) ++ endforeach(item IN LISTS PATHS) ++endmacro(spark_add_executable_paths _prefix_path) ++ ++# spark_add_link ++# 自定义宏以代替当前使用 fucntion 定义 target_link_ 结构 ++ # _IN_NAME: 此宏生成 target_link_ 的要求参数 ++ # ARGN: 此宏剩余的参数列表 ++ # 在使用 target_link_ 时 ++ # _NAME: 用于此 fucntion 中的要求参数: <_NAME>目标将要连接此库 ++macro(spark_add_link _IN_NAME) ++ function(target_link_${_IN_NAME} _NAME) ++ message("LINK ${_NAME} ${ARGN}") ++ target_link_libraries(${_NAME} ++ ${ARGN}) ++ endfunction(target_link_${_IN_NAME} _NAME) ++endmacro(spark_add_link _IN_NAME) +diff --git a/cmake/SparkMacrosExtendConfig.cmake b/cmake/SparkMacrosExtendConfig.cmake +new file mode 100644 +index 0000000..bd15f0d +--- /dev/null ++++ b/cmake/SparkMacrosExtendConfig.cmake +@@ -0,0 +1,237 @@ ++ ++# find_plus ++# 寻找 INVAl 传入的字符串,如果存在 + 字符将写入位置到 OUTVAL ++function(find_plus INVAL OUTVAL) ++ string(FIND "${INVAL}" "+" plus_index) ++ set(${OUTVAL} ${plus_index} PARENT_SCOPE) ++ # if(plus_index LESS 0) ++ # set(${OUTVAL} -1 PARENT_SCOPE) ++ # else() ++ # set(${OUTVAL} ${plus_index} PARENT_SCOPE) ++ # endif(plus_index LESS 0) ++endfunction(find_plus INVAL OUTVAL) ++ ++# find_plus("FF" FFFF) ++# message("--> FFFF ${FFFF}") # --> FFFF -1 ++# find_plus("F+F" FFFF) ++# message("--> FFFF ${FFFF}") # --> FFFF 1 ++# find_plus("+F+F" FFFF) ++# message("--> FFFF ${FFFF}") # --> FFFF 0 ++ ++# set(FFF) ++# list(APPEND FFFF ) ++# list(APPEND FFFF "F") ++# list(APPEND FFFF "FA") ++# message("--> FFFF: ${FFFF}") # --> FFFF: F;FA ++ ++# set(FFFFS "") ++# list(APPEND FFFFS ${FFFF}) ++# message("--> FFFFS: ${FFFFS}") # --> FFFFS: F;FA ++ ++# set(FFFF "+AA+BB+CC+DD") ++# string(REPLACE "+" ";" FFFFL "${FFFF}") ++# list(LENGTH FFFFL FFFFLEN) ++# message("--> FFFFL: ${FFFFL} --> ${FFFFLEN}") # --> FFFFL: F; ++ ++# plus_list ++# 将传入的 "+AAA+BBB+CCC" 类型数据变成一个 列表(list) ++# 适用于不使用 string 进行替换 + 为 ";" 的情况下使用直接变成 list ++function(plus_list INVAL OUTVAL OUTVALLEN) ++ # set(${OUTVAL} "..." PARENT_SCOPE) ++ # set(${OUTVALLEN} 0 PARENT_SCOPE) ++ ++ set(_tmps "") # 设置为空的 ++ ++ # 寻找下一个 + 位置 ++ find_plus(${INVAL} RIGHT_PLUS) ++ ++ string(LENGTH "${INVAL}" INVALLEN) ++ message("--> 传入的 INVAL: --> 内容: ${INVAL}") ++ message("--> 传入的 INVAL: --> 长度: ${INVALLEN}") ++ message("--> 传入的 INVAL: --> +位置: ${RIGHT_PLUS}") ++ ++ # 判断是否有右侧 + 号 ++ if(RIGHT_PLUS LESS 0) ++ message("--> 传入的 INVAL: --> 无需计算新的+位置") ++ # message("--> 计算新的 + 位置: ${_PLUSINDEX}") ++ list(APPEND _tmps ${INVAL}) ++ else() ++ math(EXPR _PLUSINDEX "${RIGHT_PLUS}+1") ++ message("--> 传入的 INVAL: --> 需计算+位置 --> 右移: ${_PLUSINDEX}") ++ ++ string(SUBSTRING "${INVAL}" ${_PLUSINDEX} ${INVALLEN} NewVal) ++ message("--> 传入的 INVAL: --> 需计算+位置 --> 右移: ${_PLUSINDEX} -> 内容: ${NewVal}") ++ # string(REPLACE "+" ";" _tmps "${NewVal}") ++ # list(LENGTH FFFFL FFFFLEN) ++ ++ # message("--> 计算新的 + 位置: ${_PLUSINDEX} --> 后面的 NewVal: ${NewVal}") ++ ++ # find_plus(${NewVal} _NextPlus) ++ # if(_NextPlus LESS 0) ++ # list(APPEND _tmps ${NewVal}) ++ # message("--> 追加新的 + 位置: ${_PLUSINDEX} --> 后面的") ++ # else() ++ # message("--> 追加新的 + 位置: ${_PLUSINDEX} --> 后面的") ++ # # 重新 ++ # # plus_list(${NewVal} NewValS ) ++ # # foreach(item) ++ # # list(APPEND _tmps ${item}) ++ # # endforeach(item) ++ # endif(_NextPlus LESS 0) ++ endif(RIGHT_PLUS LESS 0) ++ ++ set(${OUTVAL} ${_tmps} PARENT_SCOPE) ++ list(LENGTH _tmps _tmps_len) ++ set(${OUTVALLEN} ${_tmps_len} PARENT_SCOPE) ++ ++endfunction(plus_list INVAL OUTVAL OUTVALLEN) ++ ++# plus_list("+AAA+BBB+CCC+DDD" FFF FFLEN) ++# message("--------> ${FFF}: -> ${FFLEN}") ++ ++# spark_add_library_realpaths ++# 基于传入的项进行构建 ++# 可接受的值为: 路径列表 ++# 可接受的值为: 路径列表+依赖库A+依赖库B ++macro(spark_add_library_realpaths) ++ message("---> 基于传入的项进行构建 <---") ++ # message("--> src/unclassified/ItemDelegates/NdStyledItemDelegate") ++ # string(FIND [REVERSE]) ++ # string(SUBSTRING ) ++ # math(EXPR value "100 * 0xA" OUTPUT_FORMAT DECIMAL) # value is set to "1000" ++ ++ set(REALPATHS ${ARGN}) ++ foreach(REALPATH IN LISTS REALPATHS) ++ message("---> 传入路径: ${REALPATH} <--- ") ++ string(LENGTH "${REALPATH}" REALPATH_LENGTH) ++ message("---> 计算传入路径长度: --> 长度: ${REALPATH_LENGTH}") ++ ++ string(FIND "${REALPATH}" "/" LASTINDEX REVERSE) ++ message("---> 计算传入路径末尾/位置: --> 长度: ${LASTINDEX}") ++ math(EXPR LASTINDEX "${LASTINDEX}+1") ++ message("---> 计算传入路径末尾/右移: --> 长度: ${LASTINDEX}") ++ string(SUBSTRING "${REALPATH}" ${LASTINDEX} ${REALPATH_LENGTH} REALNAME_Dependency) ++ ++ # 找 + 号下标,这是找+号的函数 ++ find_plus(${REALPATH} RIGHT_PLUS) ++ ++ # 判断是否有找到 + 号下标,值为 -1 或 正整数 ++ if(RIGHT_PLUS LESS 0) # 小于0: 不存在 + 号 ++ set(REALNAME "${REALNAME_Dependency}") ++ message("---> 传入路径末尾/右移部分: --> ${REALNAME} <-- 无依赖+") ++ ++ message("---> 构建 ${REALNAME} -> ${REALNAME} ${REALPATH} ") ++ ++ spark_add_library_path(${REALNAME} ${REALPATH}) ++ ++ if(SPARK_FIND_QT5) ++ target_link_qt5(${REALNAME}) ++ endif(SPARK_FIND_QT5) ++ ++ if(SPARK_FIND_QT6) ++ target_link_qt6(${REALNAME}) ++ endif(SPARK_FIND_QT6) ++ ++ else() ++ message("---> 传入路径末尾/右移部分: --> ${REALNAME_Dependency} <-- 依赖+") ++ ++ # 存在+号,将截取从 / 到 + 号之间的内容作为目标名称 ++ # 例如 src/unclassified/widgets/DocTypeListView+JsonDeploy ++ # ^(LASTINDEX) ^(RIGHT_PLUS) ++ # 将 RIGHT_PLUS - LASTINDEX 计算出 DocTypeListView 字符长度 ++ math(EXPR REALNAME_LENGTH "${RIGHT_PLUS}-${LASTINDEX}") ++ ++ message("---> 计算传入路径末尾/右移部分: --> 位置: ${RIGHT_PLUS}") ++ # message("---> 计算传入路径末尾/右移部分: --> 长度: ${REALNAME_Dependency}") ++ ++ # 目标名称为 DocTypeListView ++ # 依赖为 JsonDeploy ++ # set(REALNAME "") ++ string(SUBSTRING "${REALPATH}" 0 ${RIGHT_PLUS} _REALPATH_DIR) ++ string(SUBSTRING "${REALPATH}" ${LASTINDEX} ${REALNAME_LENGTH} REALNAME) ++ ++ message("---> 计算传入路径末尾/右移部分: --> 库名: ${REALNAME}") ++ ++ string(SUBSTRING "${REALPATH}" ${RIGHT_PLUS} ${REALPATH_LENGTH} Dependency) ++ message("---> 计算传入路径末尾/右移部分: --> 库名: ${REALNAME} --> +部分: ${Dependency}") ++ ++ # plus_list(${Dependency} dependencies dependencies_len) ++ string(REPLACE "+" ";" dependencies "${Dependency}") ++ message("---> 计算传入路径末尾/右移部分: --> 库名: ${REALNAME} --> +部分: ${Dependency} --> 列表: ${dependencies} <-- ") ++ ++ ++ message("---> 构建 ${REALNAME} -> ${REALNAME} ${_REALPATH_DIR}") ++ ++ spark_add_library_path(${REALNAME} ${_REALPATH_DIR}) ++ # target_link_qt5(${REALNAME}) # 使用依赖的依赖或许也不错 ++ ++ target_include_directories(${REALNAME} PUBLIC ${_REALPATH_DIR}) ++ target_link_libraries(${REALNAME} ${dependencies}) ++ ++ endif(RIGHT_PLUS LESS 0) ++ endforeach(REALPATH IN LISTS REALPATHS) ++ ++endmacro(spark_add_library_realpaths) ++ ++ ++# spark_aux_source_paths ++# 将指定路径中的文件变成可用的AUX源文件列表 ++macro(spark_aux_source_paths AUX_VAR) ++ set(${AUX_VAR} "") ++ set(${AUX_VAR}_PATHS ${ARGN}) ++ ++ foreach(aux_path IN LISTS ${AUX_VAR}_PATHS) ++ # message("aux_path: ${aux_path}") ++ aux_source_directory(${aux_path} ${AUX_VAR}) ++ endforeach(aux_path IN LISTS ${AUX_VAR}_PATHS) ++ ++endmacro(spark_aux_source_paths AUX_VAR) ++ ++# spark_file_glob ++# ++macro(spark_file_glob FGLOB_VAR) ++ set(${FGLOB_VAR} "") ++ set(${FGLOB_VAR}_PATHS ${ARGN}) ++ ++ foreach(fglob_path IN LISTS ${FGLOB_VAR}_PATHS) ++ ++ file(GLOB FGLOB_PATH_SRCS ${fglob_path}) ++ foreach(fglob_path_src IN LISTS FGLOB_PATH_SRCS) ++ # message(" -> ${item}") ++ list(APPEND ${FGLOB_VAR} ${fglob_path_src}) ++ endforeach(fglob_path_src IN LISTS FGLOB_PATH_SRCS) ++ ++ endforeach(fglob_path IN LISTS ${FGLOB_VAR}_PATHS) ++ ++endmacro(spark_file_glob FGLOB_VAR) ++ ++ ++# spark_add_source_paths ++# 将指定路径中的文件变成可用的源文件列表 ++# ++macro(spark_add_source_paths SOURCE_VAR) ++ set(${SOURCE_VAR} "") ++ set(${SOURCE_VAR}_PATHS ${ARGN}) ++ ++ spark_aux_source_paths(${SOURCE_VAR} ${ARGN}) ++ foreach(source_path IN LISTS ${SOURCE_VAR}_PATHS) ++ # list(APPEND ${SOURCE_VAR}_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_PATH}) ++ # aux_source_directory(${SOURCE_PATH} _SOURCES) ++ # foreach(item IN LISTS _SOURCES) ++ # # message(" -> ${item}") ++ # list(APPEND ${SOURCE_VAR} ${item}) ++ # endforeach(item IN LISTS _SOURCES) ++ ++ # file(GLOB HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_PATH}/*.h) ++ # foreach(item IN LISTS HEADER_LIST) ++ # # message(" -> ${item}") ++ # list(APPEND ${SOURCE_VAR} ${item}) ++ # endforeach(item IN LISTS HEADER_LIST) ++ ++ file(GLOB UI_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${source_path}/*.ui) ++ foreach(ui_src IN LISTS UI_SRCS) ++ # message(" -> ${item}") ++ list(APPEND ${SOURCE_VAR} ${ui_src}) ++ endforeach(ui_src IN LISTS UI_SRCS) ++ endforeach(source_path IN LISTS ${SOURCE_VAR}_PATHS) ++endmacro(spark_add_source_paths SOURCE_VAR) +-- +2.20.1 + + +From ba6310f45bd803ed6ac60b9851cecc14445cc942 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Sun, 5 Feb 2023 13:00:22 +0800 +Subject: [PATCH 08/13] =?UTF-8?q?repo:=20=E5=B0=86=E7=8E=B0=E6=9C=89?= + =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=BD=AC=E4=B8=BA=20spark=20=E5=8C=96?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 120 +++++++++++++++++++++++++++---------------------- + 1 file changed, 66 insertions(+), 54 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 60e9171..d990b1d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,60 +1,72 @@ + cmake_minimum_required(VERSION 3.22) ++ + project(notepad-- VERSION 1.22.0) + +-set(CMAKE_AUTOMOC ON) +-set(CMAKE_AUTOUIC ON) +-set(CMAKE_AUTORCC ON) +- +-find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) +- +-# TODO: use system provided libraries to build +-# current status: some header can not be found,for example: Scintilla.h +-find_library(QSCINTILLA_LIB_PATH qscintilla2_qt5) +-find_path(QSCINTILLA_INC_PATH qsciscintilla.h PATHS /usr/include/) +-find_path(SCINTILLA_INC_PATH Scintilla.h PATHS /usr/include/) +-if((${QSCINTILLA_LIB_PATH} STREQUAL "QSCINTILLA_LIB_PATH-NOTFOUND") OR +- (${QSCINTILLA_INC_PATH} STREQUAL "QSCINTILLA_INC_PATH-NOTFOUND") OR +- (${SCINTILLA_INC_PATH} STREQUAL "SCINTILLA_INC_PATH-NOTFOUND") ) +-set(NOTEPAD_USE_SYS_LIB OFF) +-message("system libraries or header not found,build from local") +-add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) +-else() +-set(NOTEPAD_USE_SYS_LIB ON) +-message("use system libraries") +-message("QSCINTILLA_LIB_PATH:" ${QSCINTILLA_LIB_PATH}) +-message("QSCINTILLA_INC_PATH:" ${QSCINTILLA_INC_PATH}) +-message("SCINTILLA_INC_PATH:" ${SCINTILLA_INC_PATH}) +-endif() +- +-file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui) +-set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui) +-aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) +-aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC) +- +-add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) +-target_include_directories(${PROJECT_NAME} PRIVATE +-${PROJECT_SOURCE_DIR}/src +-${PROJECT_SOURCE_DIR}/src/cceditor +-) +- +-if(NOTEPAD_USE_SYS_LIB) +-target_include_directories(${PROJECT_NAME} PRIVATE ${QSCINTILLA_INC_PATH} ${SCINTILLA_INC_PATH}) +-endif() +- +-target_link_libraries(${PROJECT_NAME} qscintilla2_qt5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) +- +-install( +- TARGETS ${PROJECT_NAME} +- DESTINATION "bin" +-) +- +-install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr +- DESTINATION "/") +- +-include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) +-include(CPack) +- +-target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) ++include(cmake/SparkEnvConfig.cmake) ++include(cmake/SparkMacrosConfig.cmake) ++include(cmake/SparkFindQt5Config.cmake) ++# include(cmake/SparkFindQt6Config.cmake) ++include(cmake/SparkMacrosExtendConfig.cmake) ++ ++# ----------------- Build QScint ----------------- # ++if(TRUE) ++ # add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) ++ # file(GLOB MOC_HEADER src/qscint/src/Qsci/*.h) ++ spark_file_glob(MOC_HEADER "src/qscint/src/Qsci/*.h") ++ ++ spark_add_source_paths(QSciSources ++ src/qscint/src ++ src/qscint/scintilla/lexers ++ src/qscint/scintilla/lexlib ++ src/qscint/scintilla/src ++ src/qscint/scintilla/boostregex ++ ++ # src/qscint/src/Qsci ++ # FAIL: only *.ui will spark_file_glob(MOC_HEADER ...) ++ ) ++ spark_add_library(QSci STATIC ${QSciSources} ${MOC_HEADER}) ++ target_compile_definitions(QSci PRIVATE SCINTILLA_QT SCI_LEXER INCLUDE_DEPRECATED_FEATURES) ++ target_include_directories(QSci PRIVATE ++ src/qscint/scintilla/boostregex ++ src/qscint/scintilla/lexlib) ++ target_include_directories(QSci PUBLIC ++ src/qscint/src ++ src/qscint/src/Qsci ++ src/qscint/scintilla/src ++ src/qscint/scintilla/include) ++ target_link_qt5(QSci) ++ target_link_qt5_PrintSupport(QSci) ++ target_link_qt5_Concurrent(QSci) ++endif(TRUE) ++ ++ ++# ----------------- Build CCEditor ----------------- # ++if(TRUE) ++ ++ # 准备构建 CCEditor ++ set(QRC_SOURCES src/RealCompare.qrc) ++ spark_aux_source_paths(CCEditorSources ++ src ++ src/cceditor ++ ) ++ spark_add_executable(${PROJECT_NAME} ${CCEditorSources} ${QRC_SOURCES}) ++ target_include_directories(${PROJECT_NAME} PRIVATE ++ ${PROJECT_SOURCE_DIR}/src ++ ${PROJECT_SOURCE_DIR}/src/cceditor ++ ++ ${PROJECT_SOURCE_DIR}/src/qscint/src ++ ${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci ++ ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src ++ ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include ++ ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib ++ ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex ++ ) ++ # target_link_libraries(${PROJECT_NAME} QSci) ++ target_link_QSci(${PROJECT_NAME}) ++ target_link_qt5_XmlPatterns(${PROJECT_NAME}) ++ ++endif(TRUE) ++ + + if(CMAKE_HOST_UNIX) + include(cmake/SparkInstallMacrosConfig.cmake) +-- +2.20.1 + + +From 28e63cf37d6e4b41b4a0720ee7a321d484487eb5 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Sun, 5 Feb 2023 16:58:53 +0800 +Subject: [PATCH 09/13] =?UTF-8?q?repo:=20=E9=A2=84=E7=95=99=E9=85=8D?= + =?UTF-8?q?=E7=BD=AE=E4=B8=BA=E6=8F=92=E4=BB=B6=E7=9B=B8=E5=85=B3=E6=94=AF?= + =?UTF-8?q?=E6=8C=81=E9=83=A8=E5=88=86?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d990b1d..c18417f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -67,6 +67,16 @@ if(TRUE) + + endif(TRUE) + ++# ----------------- CCEditor Plugin Support or Other ----------------- # ++if(TRUE) ++ ++ # 开启插件支持 ++ # target_compile_definitions(${PROJECT_NAME} PUBLIC NO_PLUGIN=0) ++ ++ # 其它有关插件的部分处理... ++ ++endif(TRUE) ++ + + if(CMAKE_HOST_UNIX) + include(cmake/SparkInstallMacrosConfig.cmake) +-- +2.20.1 + + +From 481a7f7b39fe4b67bec6a3cab24e59a4e06b39f0 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 01:10:42 +0800 +Subject: [PATCH 10/13] =?UTF-8?q?linux/plugin-support:=20=E6=B7=BB?= + =?UTF-8?q?=E5=8A=A0=20Notepad--=20=E6=8F=92=E4=BB=B6=E6=9E=84=E5=BB=BA?= + =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=94=AF=E6=8C=81?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 71 +++++++++++++++++++- + cmake/NotepadPluginConfig.cmake.in | 96 ++++++++++++++++++++++++++++ + cmake/SparkInstallMacrosConfig.cmake | 3 +- + 3 files changed, 167 insertions(+), 3 deletions(-) + create mode 100644 cmake/NotepadPluginConfig.cmake.in + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c18417f..28b3007 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -71,13 +71,14 @@ endif(TRUE) + if(TRUE) + + # 开启插件支持 +- # target_compile_definitions(${PROJECT_NAME} PUBLIC NO_PLUGIN=0) ++ target_compile_definitions(${PROJECT_NAME} PUBLIC NO_PLUGIN=0) + + # 其它有关插件的部分处理... + + endif(TRUE) + +- ++# 可能需要变更为 CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" ?? ++# 并使用 Linux.cmake 维护? + if(CMAKE_HOST_UNIX) + include(cmake/SparkInstallMacrosConfig.cmake) + include(cmake/SparkDesktopMacros.cmake) +@@ -103,6 +104,72 @@ if(CMAKE_HOST_UNIX) + spark_install_file(/usr/share/notepad--/icons/ assets/spark.png) + spark_install_target(/usr/bin/ ${PROJECT_NAME}) + ++ # TODO:如果主线已经将 linux/destkop 的PR合入,即可移除此部分以上部分,而使用以下部分 ++ # spark_install_directory(/usr src/linux/usr/*) # 完整的 Linux 资源文件 ++ ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ include(CMakePackageConfigHelpers) ++ include(GNUInstallDirs) ++ ++ # 定义插件配置安装位置 ++ set(CMAKE_INSTALL_PREFIX "/usr") ++ set(NOTEPAD_PLUGIN NotepadPlugin) ++ ++ # 定义开发插件时的配置目录与 CMake 模块文件名称 ++ set(NOTEPAD_PLUGIN_CONFIG ${NOTEPAD_PLUGIN}Config.cmake) ++ set(NOTEPAD_PLUGIN_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${NOTEPAD_PLUGIN}) ++ set(NOTEPAD_PLUGIN_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NOTEPAD_PLUGIN}) ++ ++ # 定义一些扩展内容,主要是提供给 CMake 模块文件填充 ++ set(NOTEPAD_PLUGIN_CORELIB QSci) ++ set(NOTEPAD_PLUGIN_EXTERNAL_INCLUDES ++ ${NOTEPAD_PLUGIN_INCLUDEDIR}/Qsci) ++ ++ # 定义在插件开发的 CMake 模块中,Notepad-- 是否是基于 QT5 实现 ++ # 并自动为插件开发层自动开启相关 Qt 依赖组件 ++ # 此部分逻辑将自动提供给 add_notepad_plugin 自行处理 ++ set(NOTEPAD_BUILD_BY_QT5 TRUE) ++ set(NOTEPAD_BUILD_BY_QT6 FALSE) ++ ++ # 定义在插件开发的 CMake 模块中,Notepad-- 是否将提供 "插件安装目录(位置)" ++ set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY "") ++ ++ # 将 NOTEPAD_PLUGIN_INCLUDEDIR NOTEPAD_PLUGIN_LIBDIR 填充到 cmake 文件 ++ configure_package_config_file(cmake/NotepadPluginConfig.cmake.in ++ ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG} ++ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN}) ++ # 安装 cmake 文件 ++ spark_install_file(${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN} ++ ${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG}) ++ # 安装头插件接口文件 ++ spark_install_file(${NOTEPAD_PLUGIN_INCLUDEDIR} ++ src/include/pluginGl.h) ++ # 安装插件所需要的Qsci文件 ++ spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR} ++ src/qscint/src/Qsci) ++ ++ # 导出 QSci 的头文件(从插件实现层面来看,目前是使用*.h 与 pluginGl.h ++ # 但从 Qsci 层面来看,*.h 使用的是 #include ,所以此部分不被使用) ++ # spark_file_glob(QSci_HEADERS src/qscint/src/Qsci/*.h src/include/pluginGl.h) ++ # set_target_properties(QSci PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") ++ ++ # 导出 Notepad-- 的接口文件(从逻辑层面来看,目前已经在前面安装了接口文件,所以此部分不被使用) ++ # spark_file_glob(Notepad_HEADERS src/include/pluginGl.h) ++ # set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}") ++ ++ # 安装项目文件与 QSci 文件 ++ install(TARGETS ${PROJECT_NAME} QSci ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} ++ ARCHIVE DESTINATION ${NOTEPAD_PLUGIN_LIBDIR} ++ PUBLIC_HEADER DESTINATION ${NOTEPAD_PLUGIN_INCLUDEDIR} ++ ) ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ # ------------------ INSTALL PLUGIN CONFIG ------------------ # ++ + + # 1. 在顶层构建中导入 Appimage 的构建 + include(cmake/SparkAppimageConfig.cmake) # 导入来自 Spark 构建的 Appimage 构建 +diff --git a/cmake/NotepadPluginConfig.cmake.in b/cmake/NotepadPluginConfig.cmake.in +new file mode 100644 +index 0000000..58e0bd7 +--- /dev/null ++++ b/cmake/NotepadPluginConfig.cmake.in +@@ -0,0 +1,96 @@ ++# NotepadPluginConfig.cmake ++# 用于 Notepad-- 插件实现的 CMake 模块初级定义 ++ ++# 在 Linux 中,它的布局应该如下: ++# /usr/lib/x86_64-linux-gnu/cmake/NotepadPlugin/NotepadPluginConfig.cmake ++ ++# 在 插件开发层中,它的使用如下: ++ # 1. 查找 NotepadPlugin 模块 ++ # find_package(NotepadPlugin) ++ # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) ++ # add_notepad_plugin( ...) ++ ++# 一些无关紧要的部分,如果需要实现插件安装操作时,即可进行使用 ++# include(CMakePackageConfigHelpers) ++# include(GNUInstallDirs) ++ ++# ++set(NOTEPAD_PLUGIN @NOTEPAD_PLUGIN@) ++set(NOTEPAD_PLUGIN_INCLUDEDIR @NOTEPAD_PLUGIN_INCLUDEDIR@) ++set(NOTEPAD_PLUGIN_LIBDIR @NOTEPAD_PLUGIN_LIBDIR@) ++set(NOTEPAD_PLUGIN_CORELIB @NOTEPAD_PLUGIN_CORELIB@) ++ ++# 一些扩展内容,主要是 CMake 模块文件的填充 ++set(NOTEPAD_PLUGIN_EXTERNAL_INCLUDES ++ @NOTEPAD_PLUGIN_EXTERNAL_INCLUDES@) ++ ++# 由插件开发者进行参考的 "Notepad 提供的插件安装目录(位置)" ++set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY @NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_DIRECTORY@) ++ ++set(NOTEPAD_BUILD_BY_QT5 @NOTEPAD_BUILD_BY_QT5@) ++set(NOTEPAD_BUILD_BY_QT6 @NOTEPAD_BUILD_BY_QT6@) ++ ++if(NOTEPAD_PLUGIN_BY_QT5) ++ set(CMAKE_AUTOMOC ON) ++ set(CMAKE_AUTOUIC ON) ++ find_package(Qt5 COMPONENTS Core Widgets REQUIRED) ++endif(NOTEPAD_PLUGIN_BY_QT5) ++ ++if(NOTEPAD_BUILD_BY_QT6) ++ set(CMAKE_AUTOMOC ON) ++ set(CMAKE_AUTOUIC ON) ++ find_package(Qt6 COMPONENTS Core Widgets REQUIRED) ++endif(NOTEPAD_BUILD_BY_QT6) ++ ++ ++ ++add_library(${NOTEPAD_PLUGIN} SHARED IMPORTED) ++set_target_properties(${${NOTEPAD_PLUGIN}} PROPERTIES ++ IMPORTED_LOCATION ++ ${NOTEPAD_PLUGIN_LIBDIR}/lib${NOTEPAD_PLUGIN_CORELIB}.so ++ ++ INCLUDE_DIRECTORIES ++ "${NOTEPAD_PLUGIN_INCLUDEDIR};${NOTEPAD_PLUGIN_EXTERNAL_INCLUDES}" ++) ++ ++# add_notepad_plugin( [...]) ++# ++macro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) ++ # aux_source_directory(${PLUGIN_VAR}_SOURCES ${ARGN}) ++ add_library(${PLUGIN_VAR} SHARED ${PLUGIN_SRC} ${ARGN}) ++ if(CMAKE_HOST_WIN32) ++ # Win32 已提供宏判断 ++ # target_compile_definitions(${PLUGIN_VAR} PUBLIC NDD_EXPORT=export) ++ endif(CMAKE_HOST_WIN32) ++ ++ if(CMAKE_HOST_UNIX) ++ target_compile_definitions(${PLUGIN_VAR} PUBLIC NDD_EXPORT=export) ++ endif(CMAKE_HOST_UNIX) ++ target_include_directories(${PLUGIN_VAR} PUBLIC ${NOTEPAD_PLUGIN_INCLUDEDIR} ${NOTEPAD_PLUGIN_EXTERNAL_INCLUDES}) ++ target_link_directories(${PLUGIN_VAR} PUBLIC ${NOTEPAD_PLUGIN_LIBDIR}) ++ target_link_libraries(${PLUGIN_VAR} ${NOTEPAD_PLUGIN_CORELIB}) ++ if(NOTEPAD_PLUGIN_QT5) ++ target_link_libraries(${PLUGIN_VAR} Qt5::Core Qt5::Widgets) ++ endif(NOTEPAD_PLUGIN_QT5) ++ ++ if(NOTEPAD_PLUGIN_QT5) ++ target_link_libraries(${PLUGIN_VAR} Qt6::Core Qt6::Widgets) ++ endif(NOTEPAD_PLUGIN_QT5) ++ ++endmacro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) ++ ++# support git plugin ++macro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) ++ execute_process(COMMAND git clone ${GIT_REPO_URL} ${PLUGIN_VAR}_git ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ ERROR_QUIET) ++ aux_source_directory(${CMAKE_BINARY_DIR}/$${PLUGIN_VAR}_git/${GIT_REPO_PLUGIN_PATH} ${PLUGIN_VAR}_RESOURCES) ++ add_notepad_plugin(${PLUGIN_VAR} ${${PLUGIN_VAR}_RESOURCES}) ++endmacro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) ++ ++message("- >>>>>>>>>>>>>>>>>> NotepadPlugin: <<<<<<<<<<<<<<<<<<") ++message(" - ${CMAKE_CURRENT_LIST_FILE}") ++message(" - ${NOTEPAD_PLUGIN_INCLUDEDIR}") ++message(" - ${NOTEPAD_PLUGIN_LIBDIR}") ++message(" - ${NOTEPAD_PLUGIN_CORELIB}") ++message("- >>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<") +\ No newline at end of file +diff --git a/cmake/SparkInstallMacrosConfig.cmake b/cmake/SparkInstallMacrosConfig.cmake +index 1f8939b..204d16a 100644 +--- a/cmake/SparkInstallMacrosConfig.cmake ++++ b/cmake/SparkInstallMacrosConfig.cmake +@@ -79,7 +79,8 @@ macro(spark_install_directory INSTALL_DIRECTORY_DIR INSTALL_DIRECOTRY) + # message(FATAL_ERROR " directory: ${INSTALL_DIRECTORY_FIND_INDEX_SUBSTRING_FILE_GLOB_LIST_LENGTH}") + + else() +- message(FATAL_ERROR "install: ${INSTALL_DIRECTORY_DIR}") ++ # ISSUES: You Must check here ++ # message(FATAL_ERROR "install: ${INSTALL_DIRECTORY_DIR}") + + install(DIRECTORY + ${INSTALL_DIRECOTRY} ${ARGN} +-- +2.20.1 + + +From 7e215f5fe65a9962bf29588a0e566d239b734d25 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 01:11:26 +0800 +Subject: [PATCH 11/13] =?UTF-8?q?linux/plugin-doc:=20=E6=B7=BB=E5=8A=A0=20?= + =?UTF-8?q?Notepad--=20=E6=8F=92=E4=BB=B6=E6=9E=84=E5=BB=BA=E6=8F=8F?= + =?UTF-8?q?=E8=BF=B0=E6=96=87=E6=A1=A3?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + cmake/NoteadPlugin-Linux-Development.md | 164 ++++++++++++++++++++++++ + 1 file changed, 164 insertions(+) + create mode 100644 cmake/NoteadPlugin-Linux-Development.md + +diff --git a/cmake/NoteadPlugin-Linux-Development.md b/cmake/NoteadPlugin-Linux-Development.md +new file mode 100644 +index 0000000..c642fc7 +--- /dev/null ++++ b/cmake/NoteadPlugin-Linux-Development.md +@@ -0,0 +1,164 @@ ++# NotepadPlugin 开发说明 ++ ++> 当前插件实现的提供 Linux 层开发说明 ++ ++- 引用 NotepadPluginConfig.cmake 中的说明 ++ ++ ```cmake ++ # NotepadPluginConfig.cmake ++ # 用于 Notepad-- 插件实现的 CMake 模块初级定义 ++ ++ # 在 Linux 中,它的布局应该如下: ++ # /usr/lib/x86_64-linux-gnu/cmake/NotepadPlugin/NotepadPluginConfig.cmake ++ ++ # 在 插件开发层中,它的使用如下: ++ # 1. 查找 NotepadPlugin 模块 ++ # find_package(NotepadPlugin) ++ # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) ++ # add_notepad_plugin( ...) ++ ``` ++ ++- 着手进行实现插件 ++ ++ > 将项目中的 src/plugin/helloworld 复制为单个项目,并使用 CMake 进行构建 ++ ++ ```cmake ++ cmake_minimum_required(VERSION 3.5.1) ++ ++ project(template LANGUAGES CXX VERSION 0.0.1) ++ ++ # 1. 查找 NotepadPlugin 模块 ++ find_package(NotepadPlugin REQUIRED) ++ ++ # 2. 使用 add_notepad_plugin(<模块名称> <源代码、资源文件> [...]) ++ add_notepad_plugin(Helloworld ++ helloworld/helloworldexport.cpp ++ helloworld/qttestclass.cpp ++ helloworld/qttestclass.h ++ helloworld/qttestclass.ui ++ ) ++ ++ # 以上将会构建出一个名叫 libHelloworld.so 的插件扩展 ++ ``` ++ ++- 一些 NotepadPluginConfig.cmake 中的变量声明 ++ ++ ```cmake ++ ++ # NOTEPAD_PLUGIN [不重要]CMake 模块名称 ++ # NOTEPAD_PLUGIN_CONFIG [不重要]CMake 模块文件名名称 ++ # NOTEPAD_PLUGIN_INCLUDEDIR [插件 头文件目录]插件开发者可自行使用 ++ # NOTEPAD_PLUGIN_LIBDIR [插件 库存放目录]插件开发者可自行使用 ++ # NOTEPAD_PLUGIN_CORELIB [插件 核心库名称]插件开发者可自行使用 ++ # NOTEPAD_PLUGIN_EXTERNAL_INCLUDES [插件 扩展的头文件目录]插件开发者可自行使用 ++ # NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY [插件 扩展插件安装目录(位置)]插件开发者可自行使用 ++ ++ # NOTEPAD_BUILD_BY_QT5 ++ # NOTEPAD_BUILD_BY_QT6 ++ [NOTEPAD_BUILD_BY_约定]如果在构建 Notepad-- 时开启了此项,将会向 CMake 构建系统询问相关模块 ++ ++ 例如: ++ 询问 Qt5 基本模块: 将会在 find_package(NotepadPlugin REQUIRED) 时自动加入 ++ set(CMAKE_AUTOMOC ON) ++ set(CMAKE_AUTOUIC ON) ++ find_package(Qt5 COMPONENTS Core Widgets REQUIRED) ++ ++ 为开发者自动添加 Qt5 模块依赖: 将会在 add_notepad_plugin 时自动加入 ++ if(NOTEPAD_PLUGIN_QT5) ++ target_link_libraries(${PLUGIN_VAR} Qt5::Core Qt5::Widgets) ++ endif(NOTEPAD_PLUGIN_QT5) ++ ++ ``` ++ ++- 当前提供插件的 Linux 目录结构 ++ ++ ``` ++ build/_CPack_Packages/Linux/DEB/notepad---1.22.0-Linux ++ ├── control ++ ├── control.tar.gz ++ ├── data.tar.gz ++ ├── debian-binary ++ ├── md5sums ++ └── usr ++ ├── bin ++ │   └── notepad-- ++ ├── include ++ │   └── NotepadPlugin ++ │   ├── pluginGl.h ++ │   └── Qsci ++ │   ├── qsciabstractapis.h ++ │   ├── qsciapis.h ++ │   ├── qscicommand.h ++ │   ├── qscicommandset.h ++ │   ├── qscidocument.h ++ │   ├── qsciglobal.h ++ │   ├── qscilexerasm.h ++ │   ├── qscilexeravs.h ++ │   ├── qscilexerbash.h ++ │   ├── qscilexerbatch.h ++ │   ├── qscilexercmake.h ++ │   ├── qscilexercoffeescript.h ++ │   ├── qscilexercpp.h ++ │   ├── qscilexercsharp.h ++ │   ├── qscilexercss.h ++ │   ├── qscilexercustom.h ++ │   ├── qscilexerd.h ++ │   ├── qscilexerdiff.h ++ │   ├── qscilexeredifact.h ++ │   ├── qscilexerfortran77.h ++ │   ├── qscilexerfortran.h ++ │   ├── qscilexerglobal.h ++ │   ├── qscilexergo.h ++ │   ├── qscilexer.h ++ │   ├── qscilexerhtml.h ++ │   ├── qscilexeridl.h ++ │   ├── qscilexerjava.h ++ │   ├── qscilexerjavascript.h ++ │   ├── qscilexerjson.h ++ │   ├── qscilexerlua.h ++ │   ├── qscilexermakefile.h ++ │   ├── qscilexermarkdown.h ++ │   ├── qscilexermatlab.h ++ │   ├── qscilexernsis.h ++ │   ├── qscilexeroctave.h ++ │   ├── qscilexerpascal.h ++ │   ├── qscilexerperl.h ++ │   ├── qscilexerpo.h ++ │   ├── qscilexerpostscript.h ++ │   ├── qscilexerpov.h ++ │   ├── qscilexerproperties.h ++ │   ├── qscilexerpython.h ++ │   ├── qscilexerruby.h ++ │   ├── qscilexerrust.h ++ │   ├── qscilexerspice.h ++ │   ├── qscilexersql.h ++ │   ├── qscilexertcl.h ++ │   ├── qscilexertex.h ++ │   ├── qscilexertext.h ++ │   ├── qscilexervb.h ++ │   ├── qscilexerverilog.h ++ │   ├── qscilexervhdl.h ++ │   ├── qscilexerxml.h ++ │   ├── qscilexeryaml.h ++ │   ├── qscimacro.h ++ │   ├── qsciprinter.h ++ │   ├── qsciscintillabase.h ++ │   ├── qsciscintilla.h ++ │   ├── qscistyledtext.h ++ │   └── qscistyle.h ++ ├── lib ++ │   ├── cmake ++ │   │   └── NotepadPlugin ++ │   │   └── NotepadPluginConfig.cmake ++ │   └── NotepadPlugin ++ │   └── libQSci.a ++ └── share ++ ├── applications ++ │   └── notepad--.desktop ++ └── notepad-- ++ └── icons ++ └── spark.png ++ ++ 13 directories, 71 files ++ ++ ``` +\ No newline at end of file +-- +2.20.1 + + +From 8c582a774e8cb0a3c347de5a574ecfd91f7522d2 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 01:37:46 +0800 +Subject: [PATCH 12/13] =?UTF-8?q?fix-plugin-cmake:=20=E4=BF=AE=E5=A4=8D?= + =?UTF-8?q?=E6=8F=92=E4=BB=B6=20CMake=20=E9=83=A8=E5=88=86=E5=AE=9A?= + =?UTF-8?q?=E4=B9=89=E7=9A=84=E9=94=99=E8=AF=AF?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + cmake/NotepadPluginConfig.cmake.in | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +diff --git a/cmake/NotepadPluginConfig.cmake.in b/cmake/NotepadPluginConfig.cmake.in +index 58e0bd7..37ad692 100644 +--- a/cmake/NotepadPluginConfig.cmake.in ++++ b/cmake/NotepadPluginConfig.cmake.in +@@ -30,11 +30,11 @@ set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY @NOTEPAD_PLUGIN_EXTERNAL_PL + set(NOTEPAD_BUILD_BY_QT5 @NOTEPAD_BUILD_BY_QT5@) + set(NOTEPAD_BUILD_BY_QT6 @NOTEPAD_BUILD_BY_QT6@) + +-if(NOTEPAD_PLUGIN_BY_QT5) ++if(NOTEPAD_BUILD_BY_QT5) + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOUIC ON) + find_package(Qt5 COMPONENTS Core Widgets REQUIRED) +-endif(NOTEPAD_PLUGIN_BY_QT5) ++endif(NOTEPAD_BUILD_BY_QT5) + + if(NOTEPAD_BUILD_BY_QT6) + set(CMAKE_AUTOMOC ON) +@@ -42,8 +42,6 @@ if(NOTEPAD_BUILD_BY_QT6) + find_package(Qt6 COMPONENTS Core Widgets REQUIRED) + endif(NOTEPAD_BUILD_BY_QT6) + +- +- + add_library(${NOTEPAD_PLUGIN} SHARED IMPORTED) + set_target_properties(${${NOTEPAD_PLUGIN}} PROPERTIES + IMPORTED_LOCATION +@@ -69,13 +67,13 @@ macro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) + target_include_directories(${PLUGIN_VAR} PUBLIC ${NOTEPAD_PLUGIN_INCLUDEDIR} ${NOTEPAD_PLUGIN_EXTERNAL_INCLUDES}) + target_link_directories(${PLUGIN_VAR} PUBLIC ${NOTEPAD_PLUGIN_LIBDIR}) + target_link_libraries(${PLUGIN_VAR} ${NOTEPAD_PLUGIN_CORELIB}) +- if(NOTEPAD_PLUGIN_QT5) ++ if(NOTEPAD_BUILD_BY_QT5) + target_link_libraries(${PLUGIN_VAR} Qt5::Core Qt5::Widgets) +- endif(NOTEPAD_PLUGIN_QT5) ++ endif(NOTEPAD_BUILD_BY_QT5) + +- if(NOTEPAD_PLUGIN_QT5) ++ if(NOTEPAD_BUILD_BY_QT6) + target_link_libraries(${PLUGIN_VAR} Qt6::Core Qt6::Widgets) +- endif(NOTEPAD_PLUGIN_QT5) ++ endif(NOTEPAD_BUILD_BY_QT6) + + endmacro(add_notepad_plugin PLUGIN_VAR PLUGIN_SRC) + +@@ -84,7 +82,7 @@ macro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) + execute_process(COMMAND git clone ${GIT_REPO_URL} ${PLUGIN_VAR}_git + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ERROR_QUIET) +- aux_source_directory(${CMAKE_BINARY_DIR}/$${PLUGIN_VAR}_git/${GIT_REPO_PLUGIN_PATH} ${PLUGIN_VAR}_RESOURCES) ++ aux_source_directory(${CMAKE_BINARY_DIR}/${PLUGIN_VAR}_git/${GIT_REPO_PLUGIN_PATH} ${PLUGIN_VAR}_RESOURCES) + add_notepad_plugin(${PLUGIN_VAR} ${${PLUGIN_VAR}_RESOURCES}) + endmacro(add_notepad_plugin_with_git PLUGIN_VAR GIT_REPO_URL GIT_REPO_PLUGIN_PATH) + +-- +2.20.1 + + +From e9fed613d3f0fe2593f2d163df3d611bf3cd3c2a Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 10:31:30 +0800 +Subject: [PATCH 13/13] =?UTF-8?q?repo:=20=E9=87=87=E7=94=A8=E9=A1=B9?= + =?UTF-8?q?=E7=9B=AE=E4=B8=AD=E5=AE=8C=E6=95=B4=E7=9A=84=20Linux=20?= + =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E5=AE=89=E8=A3=85?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 28b3007..b8f5fa7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -100,12 +100,14 @@ if(CMAKE_HOST_UNIX) + # 应用分类: Category= + "Development" + ) +- spark_install_file(/usr/share/applications/ ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop) +- spark_install_file(/usr/share/notepad--/icons/ assets/spark.png) +- spark_install_target(/usr/bin/ ${PROJECT_NAME}) +- +- # TODO:如果主线已经将 linux/destkop 的PR合入,即可移除此部分以上部分,而使用以下部分 +- # spark_install_directory(/usr src/linux/usr/*) # 完整的 Linux 资源文件 ++ # spark_install_file(/usr/share/applications/ ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop) ++ # spark_install_file(/usr/share/notepad--/icons/ assets/spark.png) ++ # spark_install_target(/usr/bin/ ${PROJECT_NAME}) ++ ++ # 完成:如果主线已经将 linux/destkop 的PR合入,即可移除此部分以上部分,而使用以下部分 ++ # 但 spark_desktop_macros 不能移除,因为它被 Appimage 构建部分依赖 ++ # Appimage 构建部分,要求(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop)) ++ spark_install_directory(/usr src/linux/usr/*) # 完整的 Linux 资源文件 + + # ------------------ INSTALL PLUGIN CONFIG ------------------ # + # ------------------ INSTALL PLUGIN CONFIG ------------------ # +-- +2.20.1 + diff --git a/patchs/coconil-cmake-version-3.16.patch b/patchs/coconil-cmake-version-3.16.patch new file mode 100644 index 0000000000000000000000000000000000000000..ff7b58fb0e6fdc190cabc85efb124feffd39faa0 --- /dev/null +++ b/patchs/coconil-cmake-version-3.16.patch @@ -0,0 +1,27 @@ +From 3dd815a0893c7200605ba0f3e0806e460d0b2be7 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Sun, 5 Feb 2023 13:59:44 +0800 +Subject: [PATCH] =?UTF-8?q?cmake-version:=20=E5=B0=86=E7=89=88=E6=9C=AC?= + =?UTF-8?q?=E9=99=8D=E5=88=B0=203.16=20=E4=BB=A5=E9=80=82=E7=94=A8?= + =?UTF-8?q?=E4=BA=8E=20cmake=20=E6=9E=84=E5=BB=BA?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d990b1d..e86ba02 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.22) ++cmake_minimum_required(VERSION 3.16) + + project(notepad-- VERSION 1.22.0) + +-- +2.20.1 + diff --git a/patchs/coconil-cmake-version-3.22.patch b/patchs/coconil-cmake-version-3.22.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f90ecd6381d1ba050a3f00a39c4ebcde53dabcc --- /dev/null +++ b/patchs/coconil-cmake-version-3.22.patch @@ -0,0 +1,38 @@ +From afb95e9e995366874845f021d4fb7dd9d7d2fdd1 Mon Sep 17 00:00:00 2001 +From: zinface +Date: Thu, 2 Feb 2023 14:47:56 +0800 +Subject: [PATCH] =?UTF-8?q?cmake-version:=20=E5=B0=86=E7=89=88=E6=9C=AC?= + =?UTF-8?q?=E9=99=8D=E5=88=B0=203.22=20=E4=BB=A5=E9=80=82=E7=94=A8?= + =?UTF-8?q?=E4=BA=8E=20cmake=20=E6=9E=84=E5=BB=BA?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 2 +- + src/qscint/CMakeLists.txt | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fed2a51..dc957c3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.24) ++cmake_minimum_required(VERSION 3.22) + project(notepad-- VERSION 1.22.0) + + set(CMAKE_AUTOMOC ON) +diff --git a/src/qscint/CMakeLists.txt b/src/qscint/CMakeLists.txt +index f132dc6..77f02f2 100644 +--- a/src/qscint/CMakeLists.txt ++++ b/src/qscint/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.24) ++cmake_minimum_required(VERSION 3.22) + project(qscint CXX) + + set(CMAKE_AUTOMOC ON) +-- +2.20.1 + diff --git a/patchs/fix-windows-qtcreator-build-fail.patch b/patchs/fix-windows-qtcreator-build-fail.patch new file mode 100644 index 0000000000000000000000000000000000000000..a16955eeff8288e658472029075fb938bda8d135 --- /dev/null +++ b/patchs/fix-windows-qtcreator-build-fail.patch @@ -0,0 +1,38 @@ +From 3ced487bd23b92a6f35eb590123bc510c9e2429c Mon Sep 17 00:00:00 2001 +From: zinface +Date: Mon, 6 Feb 2023 21:13:23 +0800 +Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=20Windows=20QtCreator=20?= + =?UTF-8?q?=E4=B8=AD=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=A4=84=E7=90=86=E5=AF=BC?= + =?UTF-8?q?=E8=87=B4=E7=BC=96=E8=AF=91=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= + =?UTF-8?q?=E9=A2=98?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + src/cceditor/ccnotepad.cpp | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp +index ae615be..b2071d3 100755 +--- a/src/cceditor/ccnotepad.cpp ++++ b/src/cceditor/ccnotepad.cpp +@@ -983,11 +983,12 @@ int CCNotePad::runAsAdmin(const QString& filePath) + //} + QString argStr = QString("-muti %1").arg(filePath); + +- std::basic_string args = StringToWString(argStr.toStdString()); +- size_t shellExecRes = (size_t)::ShellExecute(NULL, TEXT("runas"), nddFullPath, args.c_str(), TEXT("."), SW_SHOW); ++// std::basic_string args = StringToWString(argStr.toStdString()); ++// size_t shellExecRes = (size_t)::ShellExecute(NULL, TEXT("runas"), nddFullPath, args.c_str(), TEXT("."), SW_SHOW); ++ size_t shellExecRes = (size_t)::ShellExecute(NULL, TEXT("runas"), nddFullPath, argStr.toUtf8(), TEXT("."), SW_SHOW); + + // If the function succeeds, it returns a value greater than 32. If the function fails, +- // it returns an error value that indicates the cause of the failure. ++ // it returns an error value that indicates the cause of the failure. + // https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx + + if (shellExecRes < 32) +-- +2.39.1.windows.1 + diff --git a/src/CmpareMode.cpp b/src/CmpareMode.cpp index 270d62ae12273c0a40bafaa3b2d5c8163c3ae6e6..8da0240666ac3fceb73f79734dce6d89247c206e 100755 --- a/src/CmpareMode.cpp +++ b/src/CmpareMode.cpp @@ -10,6 +10,7 @@ #include #include #include +#include CmpareMode::CmpareMode() @@ -280,7 +281,11 @@ quint32 CmpareMode::readLineFromFileWithUnicodeLe(uchar* m_fileFpr, const int fi else if (mode == 2) { QString temp = lineInfo.unicodeStr; + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8()); + #else + md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8()); + #endif } }; @@ -528,7 +533,11 @@ CODE_ID CmpareMode::readLineFromFile(uchar* m_fileFpr, const int fileLength, con else if (mode == 2) { QString temp = lineInfo.unicodeStr; + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8()); + #else + md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8()); + #endif } }; diff --git a/src/batchfindreplace.cpp b/src/batchfindreplace.cpp index e305b9f61bea2c924d1b6a42b0d34ced6227e907..5b727664c8a6cccde8f9ac649c5a71b0566de2b9 100755 --- a/src/batchfindreplace.cpp +++ b/src/batchfindreplace.cpp @@ -1,4 +1,4 @@ -#include "batchfindreplace.h" +#include "batchfindreplace.h" #include "scintillaeditview.h" #include "ccnotepad.h" #include "progresswin.h" @@ -7,6 +7,7 @@ #include #include +#include BatchFindReplace::BatchFindReplace(QWidget *parent) : QMainWindow(parent), m_curEditWin(nullptr), m_editTabWidget(nullptr) @@ -32,7 +33,7 @@ void BatchFindReplace::setTabWidget(QTabWidget* editTabWidget) m_editTabWidget = editTabWidget; } -//Զǰڵ״̬˱仯Ҫ϶Ϊ״β +//自动调整当前窗口的状态,如果发生了变化,则需要认定为是首次查找 QWidget* BatchFindReplace::autoAdjustCurrentEditWin() { QWidget* pw = m_editTabWidget->currentWidget(); @@ -54,7 +55,7 @@ void BatchFindReplace::appendToFindTable(QString findKeyword) ui.findReplaceTable->setItem(rNum, 1, new QTableWidgetItem()); } -//ﲻ׷ӣDz룬ӦItemѾڡ򲻲 +//这里不能追加,而是插入,即对应的Item必须已经存在。否则不插入 void BatchFindReplace::insertToReplaceTable(int row, QString replaceKeyword) { QTableWidgetItem* item = ui.findReplaceTable->item(row, 1); @@ -98,11 +99,16 @@ void BatchFindReplace::appendToFindReplaceTable(QStringList& findKeyword) bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outputKeyWordList) { - //ѿհַո\t \r\n ַ滻Ϊո + //把空白字符,空格或者\t \r\n 等字符进行替换为空格 +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + //把空白字符,空格或者\t \r\n 等字符进行替换为空格 QRegExp re("\\s"); +#else + QRegularExpression re("\\s"); +#endif findKeyWord.replace(re, QString(" ")); - //ٽпոָ + //再进行空格分隔处理 outputKeyWordList = findKeyWord.split(" "); if (outputKeyWordList.size() > 20000) @@ -111,7 +117,7 @@ bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outpu return false; } - //ɾÿһյԪ + //删除每一个空的元素 for (int i = outputKeyWordList.size() - 1; i >= 0; --i) { if (outputKeyWordList[i].trimmed().isEmpty()) @@ -167,7 +173,7 @@ void BatchFindReplace::on_freshBtClick() } } -//ҹ +//进行批量查找工作 void BatchFindReplace::on_findBtClick() { if (m_mainNotepad != nullptr && m_mainNotepad) @@ -197,7 +203,7 @@ void BatchFindReplace::on_findBtClick() } } -//滻 +//进行批量替换工作 void BatchFindReplace::on_replaceBtClick() { if (m_mainNotepad != nullptr) @@ -254,7 +260,9 @@ void BatchFindReplace::on_export() if (!fileName.isEmpty()) { QSettings setting(fileName, QSettings::IniFormat); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) setting.setIniCodec("UTF-8"); + #endif int rowNums = ui.findReplaceTable->rowCount(); @@ -294,13 +302,15 @@ void BatchFindReplace::on_import() QFileDialog fd(this, QString(), CCNotePad::s_lastOpenDirPath); fd.setFileMode(QFileDialog::ExistingFile); - if (fd.exec() == QDialog::Accepted) //ɹִ + if (fd.exec() == QDialog::Accepted) //如果成功的执行 { - QStringList fileNameList = fd.selectedFiles(); //ļб + QStringList fileNameList = fd.selectedFiles(); //返回文件列表的名称 QFileInfo fi(fileNameList[0]); QSettings setting(fi.filePath(), QSettings::IniFormat); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) setting.setIniCodec("UTF-8"); + #endif ui.findKeywordEdit->setPlainText(setting.value("find").toStringList().join(" ")); ui.replaceKeywordEdit->setPlainText(setting.value("replace").toStringList().join(" ")); diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp index 3e137dc43ddfa241428f240afa68bf1eb3016997..0f27530b72b24e090736d5746d4ef4c5c9b71c78 100755 --- a/src/cceditor/ccnotepad.cpp +++ b/src/cceditor/ccnotepad.cpp @@ -57,9 +57,11 @@ #include #include #ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include #include #endif +#endif #include #include #include @@ -557,7 +559,9 @@ void initFileTypeLangMap() //把新语言tagName,和关联ext单独存放起来ext_tag.ini。只读取一个文件就能获取所有,避免遍历慢 QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); + #endif QStringList keys = qs.allKeys(); //LangType lexId = L_USER_TXT; @@ -5225,7 +5229,11 @@ void CCNotePad::initFileListDockWin() } }); m_dockFileListWin->setAttribute(Qt::WA_DeleteOnClose); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) m_dockFileListWin->layout()->setMargin(0); + #else + m_dockFileListWin->layout()->setContentsMargins(0, 0, 0, 0); + #endif m_dockFileListWin->layout()->setSpacing(0); //暂时不提供关闭,因为关闭后需要同步菜单的check状态 @@ -5659,7 +5667,11 @@ void CCNotePad::saveTabEdit(int tabIndex) if (pEdit != nullptr) { //如果是新建的文件,则弹出保存对话框,进行保存 + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (pEdit->property(Edit_File_New) >= 0) + #else + if (pEdit->property(Edit_File_New).toInt() >= 0) + #endif { QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)"); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QString(), filter); @@ -5826,7 +5838,11 @@ void CCNotePad::slot_actionSaveAsFile_toggle(bool /*checked*/) if (pEdit != nullptr) { //如果是新建的文件,则弹出保存对话框,进行保存 + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (pEdit->property(Edit_File_New) >= 0) + #else + if (pEdit->property(Edit_File_New).toInt() >= 0) + #endif { QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)"); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As ..."),QString(), filter); @@ -6116,7 +6132,11 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) //把文件记录到qs中去 //index一定不能重复。n表示新建 //如果是新建的文件 + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (pEdit->property(Edit_File_New) >= 0) + #else + if (pEdit->property(Edit_File_New).toInt() >= 0) + #endif { //不再保存新建的非脏文件。因为一定是空的,意义不大 //qs.setValue(QString("%1").arg(index), QString("%1|1").arg(fileName)); @@ -6136,7 +6156,11 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) } //如果是新建的文件 +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (pEdit->property(Edit_File_New) >= 0) +#else + if (pEdit->property(Edit_File_New).toInt() >= 0) +#endif { QString qsSavePath = qs.fileName(); @@ -6270,7 +6294,9 @@ void CCNotePad::closeAllFileStatic() { QString tempFileList = QString("notepad/temp/list"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif QString qsSavePath = qs.fileName(); QFileInfo fi(qsSavePath); QDir saveDir = fi.dir(); @@ -6957,7 +6983,9 @@ int CCNotePad::initFindWindow(FindTabIndex type) //从历史查找记录文件中加载 QString searchHistory = QString("notepad/searchHistory");//历史查找记录 QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); + #endif if (qs.contains("keys")) { @@ -7073,7 +7101,9 @@ void CCNotePad::slot_saveSearchHistory() //从历史查找记录文件中加载 QString searchHistory = QString("notepad/searchHistory");//历史查找记录 QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif if (s_findHistroy.count() > 15) { @@ -7306,7 +7336,11 @@ void CCNotePad::initFindResultDockWin() m_dockSelectTreeWin = new QDockWidget(tr("Find result"), this); connect(m_dockSelectTreeWin, &QDockWidget::dockLocationChanged, this, &CCNotePad::slot_findResultPosChangeed); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) m_dockSelectTreeWin->layout()->setMargin(0); + #else + m_dockSelectTreeWin->layout()->setContentsMargins(0, 0, 0, 0); + #endif m_dockSelectTreeWin->layout()->setSpacing(0); //暂时不提供关闭,因为关闭后需要同步菜单的check状态 @@ -8294,7 +8328,11 @@ bool CCNotePad::nativeOpenfile(QString openFilePath) this->activateWindow(); return true; } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * result) +#else +bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, qintptr * result) +#endif { MSG *param = static_cast(message); @@ -8873,7 +8911,9 @@ int CCNotePad::restoreLastFiles() QString tempFileList = QString("notepad/temp/list"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif QStringList fileList = qs.allKeys(); //从小到大排序一下。这里是按照ASCII排序,不得行。 diff --git a/src/cceditor/ccnotepad.h b/src/cceditor/ccnotepad.h index f6364d57a89bc89ead185708adebff4e25d22e03..ec8fb2324d6916ec61208fb0268ef8ada351cb29 100755 --- a/src/cceditor/ccnotepad.h +++ b/src/cceditor/ccnotepad.h @@ -206,7 +206,11 @@ protected: void dragLeaveEvent(QDragLeaveEvent* event); bool eventFilter(QObject *watched, QEvent *event)override; #ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +#else + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); +#endif bool nativeOpenfile(QString openFilePath); #endif #ifdef uos diff --git a/src/draglineedit.cpp b/src/draglineedit.cpp index a5e35ba88aac22b90fc6847a8e41f6b9a4127dd0..c5a14e906cde48c30992a6a55182f069574ae1bf 100755 --- a/src/draglineedit.cpp +++ b/src/draglineedit.cpp @@ -1,4 +1,5 @@ #include "draglineedit.h" +#include DragLineEdit::DragLineEdit(QWidget *parent) : QLineEdit(parent) diff --git a/src/encodeconvert.cpp b/src/encodeconvert.cpp index 7cdb18a4417e8f1bd899ea39633f526e36b28e62..2c14ebd2489b007761506a27f2f349d63685315f 100755 --- a/src/encodeconvert.cpp +++ b/src/encodeconvert.cpp @@ -11,6 +11,7 @@ #include #include #include +#include const int ITEM_CODE = Qt::UserRole + 1; diff --git a/src/findresultwin.cpp b/src/findresultwin.cpp index 8c6391e6fba4840ab8d62130d2c4070976f38754..575a77a13a88add63b8fd70f5f8fdf55693203b9 100755 --- a/src/findresultwin.cpp +++ b/src/findresultwin.cpp @@ -136,7 +136,11 @@ QString FindResultWin::highlightFindText(FindRecord& record) head = QString("%1").arg(head); src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); tail = QString(utf8bytes.mid(tailStart)); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (tail > MAX_TAIL_LENGTH) + #else + if (tail.size() > MAX_TAIL_LENGTH) + #endif { tail = (tail.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped(); } @@ -171,7 +175,11 @@ QString FindResultWin::highlightFindText(FindRecord& record) src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); QString tailContens = QString(utf8bytes.mid(tailStart)); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (tailContens > MAX_TAIL_LENGTH) + #else + if (tailContens.size() > MAX_TAIL_LENGTH) + #endif { tailContens = (tailContens.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped(); } diff --git a/src/findwin.cpp b/src/findwin.cpp index ed01d6076c9cb2f721dca81d95628f4d4ab0af90..ad7853cc4306c595bc5542445461f2bee5af5a43 100755 --- a/src/findwin.cpp +++ b/src/findwin.cpp @@ -787,8 +787,13 @@ bool readBase(const QChar * str, int * value, int base, int size) current = str[i]; if (current >= 'A') { + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) current = current.digitValue() & 0xdf; current = current.digitValue() - ('A' - '0' - 10); + #else + current = QChar(current.digitValue() & 0xdf); + current = QChar(current.digitValue() - ('A' - '0' - 10)); + #endif } else if (current > '9') return false; diff --git a/src/include/pluginGl.h b/src/include/pluginGl.h index e1e95750f07caeb4215484e331dd80c732317225..67c94ebf55aa1b79f3300d635e164b6afc6477cc 100755 --- a/src/include/pluginGl.h +++ b/src/include/pluginGl.h @@ -16,14 +16,14 @@ struct ndd_proc_data { - QString m_strPlugName; //插件名称 必选 - QString m_strFilePath; //lib 插件的全局路径。必选。插件内部不用管,主程序传递下来 - QString m_strComment; //插件说明 - QString m_version; //版本号码。可选 - QString m_auther;//作者名称。可选 - int m_menuType;//菜单类型。0:不使用二级菜单 1:创建二级菜单 - QMenu* m_rootMenu;//如果m_menuType = 1,给出二级根菜单的地址。其他值nullptr - QAction* m_pAction;//如果m_menuType = 0,给出一级菜单动作的地址。其他值nullptr 插件内部不用填写,主程序传递下来 + QString m_strPlugName; // [必选]插件名称 + QString m_strFilePath; // [留空]插件的全局路径, 由主程序传递下来的路径 + QString m_strComment; // [可选]插件说明 + QString m_version; // [可选]版本号码 + QString m_auther; // [可选]作者名称 + int m_menuType; // [可选]菜单类型(0:不使用二级菜单 1:创建二级菜单) + QMenu* m_rootMenu; // [依赖]当 m_menuType = 1,则给出二级根菜单的地址(默认为 nullptr) + QAction* m_pAction; // []如果m_menuType = 0,给出一级菜单动作的地址。其他值nullptr 插件内部不用填写,主程序传递下来 ndd_proc_data(): m_rootMenu(nullptr), m_pAction(nullptr),m_menuType(0) { @@ -36,3 +36,44 @@ typedef struct ndd_proc_data NDD_PROC_DATA; typedef bool (*NDD_PROC_IDENTIFY_CALLBACK)(NDD_PROC_DATA* pProcData); typedef void (*NDD_PROC_FOUND_CALLBACK)(NDD_PROC_DATA* pProcData, void* pUserData); + + +/***********在编译插件时提供的内容**************/ + +#ifdef NOTEPAD_PLUGIN_MANAGER + +#if defined(Q_OS_WIN) +# if defined(NDD_EXPORTDLL) +# define NDD_EXPORT __declspec(dllexport) +# else +# define NDD_EXPORT __declspec(dllimport) +# endif +#endif + +#include + +#ifdef __cplusplus + extern "C" { +#endif + + NDD_EXPORT bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData); + NDD_EXPORT int NDD_PROC_MAIN(QWidget* pNotepad, const QString& strFileName, std::functiongetCurEdit); + +#ifdef __cplusplus + } +#endif + +#define NOTEPAD_PLUGIN_METADATA(name, version, author, comment, filepath)\ + pProcData->m_strPlugName = QString(name); \ + pProcData->m_version = QString(version); \ + pProcData->m_strComment = QString(comment); \ + pProcData->m_auther = QString(author); \ + pProcData->m_strFilePath = QString(filepath); \ + +#define NOTEPAD_PLUGIN_IMPLEMENT(imp_class) \ + imp_class *imp = new imp_class(pNotepad, getCurEdit()); \ + //imp->setWindowFlag(Qt::Window); \ + imp->show(); + +#endif //NOTEPAD_PLUGIN_MANAGER +/***********在编译插件时提供的内容**************/ diff --git a/src/langextset.cpp b/src/langextset.cpp index a1db8342d0582c715a9dfc4d5096683b5e1390af..9513b49e4b354acf663032f2c461f30ea8969dc8 100755 --- a/src/langextset.cpp +++ b/src/langextset.cpp @@ -7,6 +7,7 @@ #include #include #include +#include int ITEM_CHANGED = Qt::UserRole; int ITEM_LEX_ID = Qt::UserRole + 1; //对应的语法lexer的 ID @@ -113,7 +114,9 @@ void LangExtSet::slot_save() QString userLangFile = QString("notepad/tag_ext"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif for (int i = 0; i < rowNums; ++i) { @@ -180,7 +183,9 @@ void LangExtSet::loadExtRelevanceToMagr() { QString userLangFile = QString("notepad/tag_ext");//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif if (!QFile::exists(qs.fileName())) { diff --git a/src/langstyledefine.cpp b/src/langstyledefine.cpp index 3945159d5b912c3e354d1b5ead23bc6539116fcd..c9f941df2c4eb5bdd784796cea7111c8ab43e23b 100755 --- a/src/langstyledefine.cpp +++ b/src/langstyledefine.cpp @@ -30,7 +30,9 @@ bool LangStyleDefine::readLangSetFile(QString langName, bool isLoadToUI) { QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif qDebug() << qs.fileName(); if (!qs.contains("mz")) @@ -160,7 +162,9 @@ void LangStyleDefine::slot_save() //把新语言tagName,和关联ext单独存放起来。后面只读取一个文件就能获取所有,避免遍历慢 QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif QStringList extList = ui.extNameLe->text().trimmed().split(" "); extList.append(QString::number(motherLangs)); //最后一个是mother lexer @@ -201,7 +205,9 @@ void LangStyleDefine::slot_delete() { QString userLangFile = QString("notepad/userlang/%1").arg(name);//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); + #endif //删除userlang下面的tag.ini QFile::remove(qs.fileName()); @@ -211,7 +217,9 @@ void LangStyleDefine::slot_delete() //把新语言在ext_tag中的关联文件记录也删除 QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件 QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); + #endif QStringList extList = qs.value(name).toStringList(); //更新当前ExtLexerManager::getInstance()。如果不更新,就要重启软件才能生效 diff --git a/src/main.cpp b/src/main.cpp index cd6934a9668cefee20d936e0ead840d03a45c500..f28590ce22e69e9534825e270337ebab6f1fc30a 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,9 +24,10 @@ #ifdef Q_OS_WIN #pragma comment(lib, "user32.lib") #if _DEBUG -#pragma comment(lib, "qmyedit_qt5d.lib") +// Bug: 在 Visual Studio 中引发无法构建的问题,此处为无法找到 qmyedit_x 库 +//#pragma comment(lib, "qmyedit_qt5d.lib") #else -#pragma comment(lib, "qmyedit_qt5.lib") +//#pragma comment(lib, "qmyedit_qt5.lib") #endif #include const ULONG_PTR CUSTOM_TYPE = 10000; diff --git a/src/nddsetting.cpp b/src/nddsetting.cpp index c224fb14d6e945d12d81bad5779d584221455bbc..f4826a73b8a8fe147aaab621b3b8cb5f6d5e66e3 100755 --- a/src/nddsetting.cpp +++ b/src/nddsetting.cpp @@ -50,7 +50,9 @@ void NddSetting::init() QString qsSetPath = qs.fileName(); s_nddSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) s_nddSet->setIniCodec("UTF-8"); +#endif bool initOk = true; auto initNddSet = []() { @@ -345,7 +347,9 @@ void NddSetting::nddDelaySetInit() QString qsSetPath = qs.fileName(); s_nddDelaySet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) s_nddDelaySet->setIniCodec("UTF-8"); + #endif } } diff --git a/src/ndstyleditemdelegate.h b/src/ndstyleditemdelegate.h deleted file mode 100755 index d1708d29bf2a520f075f43a3279d58423d75c1ba..0000000000000000000000000000000000000000 --- a/src/ndstyleditemdelegate.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include - -class NdStyledItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - NdStyledItemDelegate(QObject *parent); - virtual ~NdStyledItemDelegate(); - void setFontSize(int size); - -protected: - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - -private: - int m_defaultFontSize; -}; diff --git a/src/qscint/src/Qsci/qsciglobal.h b/src/qscint/src/Qsci/qsciglobal.h index 7ed96917fdb4e4f557bb379129c7141db6a82cdf..8ebaa5c262272c0ed42ac05fb888fd5c450682d9 100755 --- a/src/qscint/src/Qsci/qsciglobal.h +++ b/src/qscint/src/Qsci/qsciglobal.h @@ -37,18 +37,17 @@ // Define QSCINTILLA_MAKE_DLL to create a QScintilla shared library, or // define QSCINTILLA_DLL to link against a QScintilla shared library, or define // neither to either build or link against a static QScintilla library. -#ifdef QSCINTILLA_DLL -#undef QSCINTILLA_DLL -#endif -#define QSCINTILLA_DLL +// Bug: 在 Visual Studio 中引发无法构建的问题,此处被锁定构建为动态库 +// Unassign as Q_DECL_IMPORT. +// #define QSCINTILLA_DLL #if defined(QSCINTILLA_DLL) -#define QSCINTILLA_EXPORT Q_DECL_IMPORT +# define QSCINTILLA_EXPORT Q_DECL_IMPORT #elif defined(QSCINTILLA_MAKE_DLL) -#define QSCINTILLA_EXPORT Q_DECL_EXPORT +# define QSCINTILLA_EXPORT Q_DECL_EXPORT #else -#define QSCINTILLA_EXPORT +# define QSCINTILLA_EXPORT #endif diff --git a/src/qscint/src/qscilexer.cpp b/src/qscint/src/qscilexer.cpp index 5a20922ca771ff0e93b2197967edf519bd136177..6bffcc24acf42617b75056ac72d8dc55ab8dde55 100755 --- a/src/qscint/src/qscilexer.cpp +++ b/src/qscint/src/qscilexer.cpp @@ -907,7 +907,9 @@ const char* QsciLexer::getUserDefineKeywords() QString userLangFile = QString("notepad/userlang/%1").arg(m_tagName);//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif if (!qs.contains("mz")) { diff --git a/src/qtlangset.cpp b/src/qtlangset.cpp index f830406cef5fd26d305676d91e42abe242a83d47..641e3c286d87e2ae1cb8d1d109ff020e4cf4f8f6 100755 --- a/src/qtlangset.cpp +++ b/src/qtlangset.cpp @@ -383,7 +383,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) QsciLexer *pLexer = ScintillaEditView::createLexer(index); if (nullptr != pLexer) { - + switch (flag) { case GLOBAL_FONT: @@ -391,9 +391,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) //非全局修改所有的语法对应样式 if (index != L_GLOBAL) { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) { oldfont = pLexer->font(i); oldfont.setFamily(m_curStyleData.font.family()); @@ -424,9 +424,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) //非全局修改所有的语法对应样式 if (index != L_GLOBAL) { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) { oldfont = pLexer->font(i); oldfont.setPointSize(m_curStyleData.font.pointSize()); @@ -454,9 +454,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) break; case GLOBAL_FONT_BOLD: { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) { oldfont = pLexer->font(i); oldfont.setBold(m_curStyleData.font.bold()); @@ -467,9 +467,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) break; case GLOBAL_FONT_UNDERLINE: { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) { oldfont = pLexer->font(i); oldfont.setUnderline(m_curStyleData.font.underline()); @@ -480,9 +480,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) break; case GLOBAL_FONT_ITALIC: { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) { oldfont = pLexer->font(i); oldfont.setItalic(m_curStyleData.font.italic()); @@ -528,10 +528,10 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) break; default: break; - } + } saveLangeSet(pLexer); - } + } delete pLexer; } @@ -587,7 +587,7 @@ void QtLangSet::restoreOriginLangAllStyle() { QFile::remove(qs.fileName()); } - + delete pLexer; pLexer = nullptr; @@ -634,12 +634,12 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) QsciLexer *pLexer = ScintillaEditView::createLexer(index); QsciLexer *pOriginLexer = ScintillaEditView::createLexer(index,"",true); if (nullptr != pLexer) - { - for (int i = 0; i <= 255; ++i) - { - if (!pLexer->description(i).isEmpty()) - { - + { + for (int i = 0; i <= 255; ++i) + { + if (!pLexer->description(i).isEmpty()) + { + switch (flag) { case GLOBAL_FONT: @@ -694,8 +694,8 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) break; default: break; - } - } + } + } } switch (flag) @@ -713,7 +713,7 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) } saveLangeSet(pLexer); - } + } delete pLexer; delete pOriginLexer; } @@ -873,7 +873,9 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth { QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif //qDebug() << qs.fileName(); if (!qs.contains("mz")) @@ -1001,15 +1003,15 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) ExtLexerManager::getInstance()->getExtlistByLangTag(langName, extList); ui.extFileType->setText(extList.join(',')); - for (int i = 0; i <= 255; ++i) - { - QString desc = pLexer->description(i); - if (!desc.isEmpty()) - { + for (int i = 0; i <= 255; ++i) + { + QString desc = pLexer->description(i); + if (!desc.isEmpty()) + { QListWidgetItem *itemtemp = new QListWidgetItem(desc); - itemtemp->setData(Qt::UserRole, i); - ui.styleListWidget->addItem(itemtemp); - } + itemtemp->setData(Qt::UserRole, i); + ui.styleListWidget->addItem(itemtemp); + } } } diff --git a/src/rcglobal.h b/src/rcglobal.h index 47483d3bb33233ad26079851a259e45519eff327..87f2f53386d98bc68de79a0132a111b838fff6ca 100755 --- a/src/rcglobal.h +++ b/src/rcglobal.h @@ -8,14 +8,14 @@ //#define TEST_PRE #ifdef TEST_PRE -static const char* VersionStr = u8"(内部测试非稳定) v2.0.0"; +static const char* VersionStr = u8"(内部测试非稳定) v2.0.0, 核心编辑器组件 2.11"; #else static const char* VersionStr = "v2.0.0"; #endif // TEST_PRE - -#define NO_PLUGIN 1 +// Bug: 在 Visual Studio 中引发无法构建的问题,此处被重复定义(在 cmake 中已对其定义) +// #define NO_PLUGIN 1 #define CMP_CODE_NOEQUAL diff --git a/src/scintillaeditview.cpp b/src/scintillaeditview.cpp index 1ad4494e26a59d123b9e5b0a1917f1603c1d7fd3..ef6ceacdd82f899ee7acf2fe2f0e59d0e3213579 100755 --- a/src/scintillaeditview.cpp +++ b/src/scintillaeditview.cpp @@ -2723,7 +2723,11 @@ void ScintillaEditView::changeCase(const TextCaseType & caseToConvert, QString& else if (caseToConvert == TITLECASE_FORCE) strToConvert[i] = strToConvert[i].toLower(); //An exception + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if ((i < 2) ? false : (strToConvert[i - 1] == L'\'' && (strToConvert[i - 2].isLetter()))) + #else + if ((i < 2) ? false : (strToConvert[i - 1] == '\'' && (strToConvert[i - 2].isLetter()))) + #endif strToConvert[i] = strToConvert[i].toLower(); } } @@ -2751,11 +2755,19 @@ void ScintillaEditView::changeCase(const TextCaseType & caseToConvert, QString& wasEolR = false; wasEolN = false; //An exception + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (strToConvert[i] == L'i' && + #else + if (strToConvert[i] == 'i' && + #endif ((i < 1) ? false : (strToConvert[i - 1].isSpace() || strToConvert[i - 1] == '(' || strToConvert[i - 1] == '"')) && \ ((i + 1 == nbChars) ? false : (strToConvert[i + 1].isSpace() || strToConvert[i + 1] == '\''))) { + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) strToConvert[i] = L'I'; + #else + strToConvert[i] = 'I'; + #endif } } else if (strToConvert[i] == '.' || strToConvert[i] == '!' || strToConvert[i] == '?') @@ -3424,7 +3436,11 @@ bool isUrlQueryDelimiter(QChar const c) void scanToUrlEnd(QString & text, int textLen, int start, int* distance) { int p = start; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QChar q = 0; +#else + QChar q(0); +#endif enum { sHostAndPath, sQuery, sQueryAfterDelimiter, sQueryQuotes, sQueryAfterQuotes, sFragment } s = sHostAndPath; while (p < textLen) { diff --git a/src/shortcutkeymgr.cpp b/src/shortcutkeymgr.cpp index 88e3969bbfce01dd9962ddef3c46043276e6214d..8561271de38660e76fa5e89c172e983e43d8a06a 100755 --- a/src/shortcutkeymgr.cpp +++ b/src/shortcutkeymgr.cpp @@ -154,7 +154,9 @@ void ShortcutKeyMgr::loadUserDefSet() { QString userDefFile = QString("notepad/shortcuttab"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif QStringList keys = qs.allKeys(); @@ -179,7 +181,9 @@ bool ShortcutKeyMgr::ModifyShortCutKey(QString initTag, QString keySeqStr) { QString userDefFile = QString("notepad/shortcuttab"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif if (s_shortcutKeysMap->contains(initTag)) { diff --git a/src/userlexdef.cpp b/src/userlexdef.cpp index a1983a6c8c95d12b9a82b72efaa8d2b2cd69206e..b10a744e48f06f0f4f48600f10267d1f613c1943 100755 --- a/src/userlexdef.cpp +++ b/src/userlexdef.cpp @@ -24,7 +24,9 @@ bool UserLexDef::readUserSettings(QString langTagName) QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif if (!qs.contains(QString("mz"))) { @@ -93,13 +95,19 @@ bool UserLexDef::writeUserSettings(QString langTagName) QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setIniCodec("UTF-8"); +#endif qs.clear(); qs.setValue("mz", langTagName); qs.setValue("mother", m_motherLang); qs.setValue("ext", m_extTypes); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qs.setValue("keyword", m_keyword.data()); +#else + qs.setValue("keyword", QString(m_keyword.data())); +#endif return true; }