diff --git a/CMakeLists.txt b/CMakeLists.txt index f11220a..b046ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -project(notepad-- VERSION 1.22.0) +project(Notepad-- VERSION 1.22.0) include(cmake/SparkEnvConfig.cmake) include(cmake/SparkMacrosConfig.cmake) @@ -27,12 +27,76 @@ if(TRUE) endif(TRUE) # ----------------- Notepad-- 其它主线构建相关 ----------------- # +option(USE_MACOS_UNIVERSAL "通用 MacOS 平台构建" OFF) +# +option(USE_LINUX_UNIVERSAL "通用 Linux 平台构建" OFF) +option(USE_LINUX_DEBIAN "通用 Debian Linux 平台构建" OFF) +option(USE_LINUX_APPIMGE "通用 Appimage Linux 平台构建" OFF) +# +option(USE_LINUX_UOS "独立 Linux 平台的 Uos 构建" OFF) +# +option(USE_WINDOWS_UNIVERSAL "通用 Windows 平台构建" OFF) +option(USE_WINDOWS_MINGW "通用 Windows 平台 MinGW 构建" OFF) +option(USE_WINDOWS_MSVC "通用 Windows 平台 MSVC 构建" OFF) +# +option(WINDOWS_DEPLOY_QT5 "通用 Windows Qt5 构建 windeployqt" OFF) +option(WINDOWS_DEPLOY_QT6 "通用 Windows Qt6 构建 windeployqt" OFF) + # 使用 macos.cmake / linux.cmake / windows.cmake 维护构建. if(APPLE) - include(cmake/platforms/macos.cmake) + # 通用 MacOS 平台的构建(一个无具体实现的空构建) + # include(cmake/platforms/macos.cmake) + + # 在 Linux 中此处将由通用构建、Debian 打包构建、Appimage 打包构建、Uos 打包构建组成 elseif(UNIX AND NOT APPLE AND NOT WIN32 AND NOT ANDROID) - include(cmake/platforms/linux.cmake) + + # 通用 Linux 平台构建,一切的起始 + if(USE_LINUX_UNIVERSAL) + # include(cmake/platforms/linux-universal.cmake) + + # 通用平台的 Debian deb 构建 + if(USE_LINUX_DEBIAN) + # include(cmake/platforms/linux-debian.cmake) + endif() + + # 通用平台的 Appimage 构建 + if(USE_LINUX_APPIMGE) + # 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.cmake) + endif(USE_LINUX_UNIVERSAL) + + # 在 Windows 中此处将由通用构建、MinGW 构建、MSVC 构建组成 elseif(WIN32) - include(cmake/platforms/windows.cmake) + + # 通用 Windows 平台构建,一切的起始 + if(USE_WINDOWS_UNIVERSAL) + # include(cmake/platforms/windows.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.cmake) + endif(USE_WINDOWS_UNIVERSAL) + endif() + +# ----------------- Notepad-- 其它主线构建相关 ----------------- # + diff --git a/Makefile b/Makefile index b71b27f..bd4b430 100644 --- a/Makefile +++ b/Makefile @@ -1,84 +1,27 @@ -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) +# 主体构建入口 + +# 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 -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 - -# 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/linux.mk b/linux.mk new file mode 100644 index 0000000..8a0c07a --- /dev/null +++ b/linux.mk @@ -0,0 +1,4 @@ +Msg := 'Build with the following configuration:' + +all: + @echo $(Msg) diff --git a/macos.mk b/macos.mk new file mode 100644 index 0000000..8a0c07a --- /dev/null +++ b/macos.mk @@ -0,0 +1,4 @@ +Msg := 'Build with the following configuration:' + +all: + @echo $(Msg) diff --git a/windows.mk b/windows.mk new file mode 100644 index 0000000..e2f3111 --- /dev/null +++ b/windows.mk @@ -0,0 +1,4 @@ +Msg := 'Build with the following configuration:' + +all: + @echo -e $(Msg)