diff --git a/how_bild/CMakeLists.txt b/how_bild/CMakeLists.txt new file mode 100644 index 0000000..43888dd --- /dev/null +++ b/how_bild/CMakeLists.txt @@ -0,0 +1,90 @@ +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_bild/THIRDPARTY.md b/how_bild/THIRDPARTY.md new file mode 100644 index 0000000..cca4e3a --- /dev/null +++ b/how_bild/THIRDPARTY.md @@ -0,0 +1,15 @@ +## 第三方依赖 + +## 源码依赖 + +- [[GPL v3](src/qscint/LICENSE)] [QScintilla](https://riverbankcomputing.com/software/qscintilla/intro) +- [GPL v3] + - [boostregex](src/qscint/scintilla/boostregex) + - [rgba_icons.h](src/rgba_icons.h) + - [xmlMatchedTagsHighlighter.cpp](src/qscint/src/xmlMatchedTagsHighlighter.cpp) + - [xmlMatchedTagsHighlighter.h](src/qscint/src/xmlMatchedTagsHighlighter.h) + +## 开发、打包时依赖 + +- [[zlib/libpng](https://nsis.sourceforge.io/License)] [NSIS](https://nsis.sourceforge.io) + 打包工具 diff --git a/how_bild/cmake/deb_package_config.cmake b/how_bild/cmake/deb_package_config.cmake new file mode 100644 index 0000000..a0488aa --- /dev/null +++ b/how_bild/cmake/deb_package_config.cmake @@ -0,0 +1,13 @@ +set(CPACK_GENERATOR "DEB") +set(CPACK_PACKAGE_NAME "notepad--") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "a text editor like notepad++") +set(CPACK_PACKAGE_CONTACT "coconil") + +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") + +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5concurrent5,libqt5core5a,libqt5gui5,libqt5network5,libqt5printsupport5,libqt5xmlpatterns5") \ No newline at end of file diff --git a/how_bild/cmake/nsis_package_config.cmake b/how_bild/cmake/nsis_package_config.cmake new file mode 100644 index 0000000..0098d39 --- /dev/null +++ b/how_bild/cmake/nsis_package_config.cmake @@ -0,0 +1,59 @@ +set(CPACK_GENERATOR NSIS) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}") +# 维护人员 +set(CPACK_PACKAGE_CONTACT "XiaoPb") + +set(P4_VERSION_INFO_CL_HIGH "0") +set(P4_VERSION_INFO_CL_LOW "0") +# set(CPACK_PACKAGE_VERSION_PATCH "0") + +set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") + +set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") + +set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License") + +set (CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}" ) + +# 设置 安装包属性信息 +set (CPACK_NSIS_DEFINES " + ${CPACK_NSIS_DEFINES} + VIProductVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIFileVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIAddVersionKey /LANG=0 \\\"ProductName\\\" \\\"${CPACK_PACKAGE_NAME}\\\" + VIAddVersionKey /LANG=0 \\\"ProductVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + VIAddVersionKey /LANG=0 \\\"Comments\\\" \\\"${CPACK_PACKAGE_DESCRIPTION}\\\" + VIAddVersionKey /LANG=0 \\\"CompanyName\\\" \\\"${CPACK_PACKAGE_VENDOR}\\\" + VIAddVersionKey /LANG=0 \\\"LegalCopyright\\\" \\\"${CPACK_PACKAGE_COPYRIGHT}\\\" + VIAddVersionKey /LANG=0 \\\"FileDescription\\\" \\\"${CPACK_PACKAGE_NAME} Installer\\\" + VIAddVersionKey /LANG=0 \\\"FileVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + " +) + +# 设置 安装时需要的环境变量 +set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + WriteRegStr SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\" \\\"\\\" \\\"open\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\\open\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" \\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"Edit with ${PROJECT_NAME}\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"Icon\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + ") + +# 设置 卸载时需要的环境变量 +set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\" + Delete \\\"$SMPROGRAMS\\\\${PROJECT_NAME}.lnk\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\bin\\\\${PROJECT_NAME}.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + DeleteRegKey SHCTX \\\"Software\\\\${PROJECT_NAME}\\\" + DeleteRegValue SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\" + ") diff --git a/how_bild/linux.mk b/how_bild/linux.mk new file mode 100644 index 0000000..43f4a79 --- /dev/null +++ b/how_bild/linux.mk @@ -0,0 +1,42 @@ +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_bild/linux开源编译及下载说明.txt b/how_bild/linux开源编译及下载说明.txt new file mode 100755 index 0000000..d8951a2 --- /dev/null +++ b/how_bild/linux开源编译及下载说明.txt @@ -0,0 +1,36 @@ +编译 +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/how_bild/win.bat b/how_bild/win.bat new file mode 100644 index 0000000..f2d9d63 --- /dev/null +++ b/how_bild/win.bat @@ -0,0 +1,5 @@ +cd build/bin + +windeployqt notepad--.exe +@REM copy .\src\qscint\libqscint.a .\%1\plugin +@REM copy .\src\plugin\^*\^*.dll .\%1\plugin diff --git a/how_bild/win.mk b/how_bild/win.mk new file mode 100644 index 0000000..7ac2002 --- /dev/null +++ b/how_bild/win.mk @@ -0,0 +1,42 @@ + +# 基于 Git Bash 环境编写 +# 设置编译链信息是为了避免环境存在多个Qt环境时编译异常 + +# 填入Qt的Mingw相关工具安装路径 (不使用MINGW时可不填) +# 填入Mingw Qt G++程序完整路径 +Qt_MINGW_CXX_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe +# 填入Mingw Qt GCC程序完整路径 +Qt_MINGW_C_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/gcc.exe +# 填入Mingw Qt库查找路径 +Qt_MINGW_PREFIX_PATH:=d:/SOFT/Qt/Qt5.14.2/5.14.2/mingw73_64 +# 指定生成的Makefiles格式 +Qt_MINGW_G:=CodeBlocks - MinGW Makefiles + +# 填入Qt的msvc相关工具安装路径 (不使用MSVC时可不填) +# 填入Msvc Qt库查找路径 +Qt_MSVC_PREFIX_PATH:=d:/CompilationTools/Qt/5.15.2/msvc2019_64 + + +all:msvc + + +mingw: + cmake -G"${Qt_MINGW_G}" -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MINGW_PREFIX_PATH} -DCMAKE_CXX_COMPILER=${Qt_MINGW_CXX_COMPILER} -DCMAKE_C_COMPILER=${Qt_MINGW_C_COMPILER} . + cmake --build ./build --config=Release -- -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MINGW_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/*.dll build/bin/plugin + cp -r -f build/src/*/*.a build/bin/plugin + cd build && cpack --config CPackConfig.cmake + +msvc: + cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} . + cmake --build ./build --config=Release -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/Release/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MSVC_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/Release/*.dll build/bin/plugin + cp -r -f build/src/*/Release/*.lib build/bin/plugin + cd build && cpack --config CPackConfig.cmake +