From 8c8651e060bbdcd0e84fa61bfc2e1e3cd50c56b5 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Mon, 29 Dec 2025 15:58:48 +0800 Subject: [PATCH] refactor: unify DTK5/DTK6 build system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Replaced PROJECT_VERSION_MAJOR-based Qt version detection with explicit DTK5/DTK6 build option 2. Added DTK5 CMake option (default ON) to control DTK5 vs DTK6 builds 3. Updated DTK_VERSION calculation to use DTK_VERSION_MAJOR from build option instead of PROJECT_VERSION_MAJOR 4. Modified CMake logic to conditionally build wayland plugin only for DTK5 builds 5. Restructured debian/control to support both DTK5 and DTK6 packages with Build-Profiles 6. Added new dde-qt6xcb-plugin package for DTK6 builds 7. Implemented separate build directories (build-dtk5, build-dtk6) in debian/rules for parallel builds 8. Added build profile support (nodtk5, nodtk6) to control which packages are built 9. Updated package descriptions to clearly indicate DTK5/Qt5 vs DTK6/ Qt6 versions Log: Updated build system to support both DTK5 and DTK6 versions Influence: 1. Test building with default settings (DTK5=ON) to ensure DTK5 builds work 2. Test building with DTK5=OFF to verify DTK6 builds work correctly 3. Verify that wayland plugin is only built for DTK5 builds 4. Test package generation with different build profiles (nodtk5, nodtk6) 5. Verify that both dde-qt5xcb-plugin and dde-qt6xcb-plugin packages are created correctly 6. Test installation of both DTK5 and DTK6 packages on appropriate systems 7. Verify plugin paths are correct (Qt5 vs Qt6 plugin directories) refactor: 统一DTK5/DTK6构建系统 1. 将基于PROJECT_VERSION_MAJOR的Qt版本检测改为显式的DTK5/DTK6构建选项 2. 添加DTK5 CMake选项(默认开启)来控制DTK5与DTK6构建 3. 更新DTK_VERSION计算,使用构建选项中的DTK_VERSION_MAJOR而非 PROJECT_VERSION_MAJOR 4. 修改CMake逻辑,仅对DTK5构建有条件地构建wayland插件 5. 重构debian/control以支持带有Build-Profiles的DTK5和DTK6包 6. 为DTK6构建添加新的dde-qt6xcb-plugin包 7. 在debian/rules中实现独立的构建目录(build-dtk5, build-dtk6)用于并行 构建 8. 添加构建配置文件支持(nodtk5, nodtk6)来控制构建哪些包 9. 更新包描述以清晰标明DTK5/Qt5与DTK6/Qt6版本 Log: 更新构建系统以支持DTK5和DTK6版本 Influence: 1. 使用默认设置(DTK5=ON)测试构建,确保DTK5构建正常工作 2. 使用DTK5=OFF测试构建,验证DTK6构建正确工作 3. 验证wayland插件仅对DTK5构建进行构建 4. 使用不同的构建配置文件(nodtk5, nodtk6)测试包生成 5. 验证dde-qt5xcb-plugin和dde-qt6xcb-plugin包都正确创建 6. 在适当的系统上测试DTK5和DTK6包的安装 7. 验证插件路径正确(Qt5与Qt6插件目录) --- CMakeLists.txt | 28 +++++++------- archlinux/PKGBUILD | 4 +- debian/control | 66 +++++++++++++++++++++++++------- debian/dde-qt6xcb-plugin.install | 1 + debian/rules | 53 ++++++++++++++++++++++++- tests/CMakeLists.txt | 9 ++++- 6 files changed, 130 insertions(+), 31 deletions(-) create mode 100644 debian/dde-qt6xcb-plugin.install diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed9d3dc..a338b3b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,11 @@ cmake_minimum_required(VERSION 3.13) -file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION) -string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION) -set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "define project version") +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FILE_VERSION) +string(STRIP "${FILE_VERSION}" FILE_VERSION) project(qt5platform-plugins - VERSION ${DTK_VERSION} + VERSION ${FILE_VERSION} DESCRIPTION "DTK platform plugin module" HOMEPAGE_URL "https://github.com/linuxdeepin/qt5platform-plugins" LANGUAGES CXX C @@ -22,15 +21,19 @@ endif () include(GNUInstallDirs) include(CMakePackageConfigHelpers) -if("${PROJECT_VERSION_MAJOR}" STREQUAL "5") - set(QT_VERSION_MAJOR "5") -elseif("${PROJECT_VERSION_MAJOR}" STREQUAL "6") - set(QT_VERSION_MAJOR "6") - set(DTK_VERSION_MAJOR "6") +option(DTK5 "Build DTK5." ON) +if(DTK5) + set(DTK_VERSION_MAJOR "5") else() - message(SEND_ERROR "not support Prject Version ${PROJECT_VERSION}.") + set(DTK_VERSION_MAJOR "6") endif() -message(${PROJECT_VERSION_MAJOR}) + +set(DTK_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(DTK_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(DTK_VERSION "${DTK_VERSION_MAJOR}.${DTK_VERSION_MINOR}.${DTK_VERSION_PATCH}") +set(QT_VERSION_MAJOR ${DTK_VERSION_MAJOR}) + +message(STATUS "Building DTK${DTK_VERSION_MAJOR} (Qt${QT_VERSION_MAJOR}) version: ${DTK_VERSION}") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -48,11 +51,10 @@ endif () set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/plugins/platforms) add_subdirectory(xcb) -if("${PROJECT_VERSION_MAJOR}" STREQUAL "5") +if(DTK5) add_subdirectory(wayland) endif() if(BUILD_TESTING) enable_testing() add_subdirectory(tests) endif() -message(${PROJECT_VERSION_MAJOR}) diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index be01a02c..aeb83a21 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -22,8 +22,8 @@ build() { cmake . -GNinja \ -DCMAKE_INSTALL_LIBDIR=lib \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_BUILD_TYPE=Release \ - -DQT_XCB_PRIVATE_HEADERS=/usr/include/qtxcb-private + -DQT_XCB_PRIVATE_HEADERS=/usr/include/qtxcb-private \ + -DDTK5=ON ninja } diff --git a/debian/control b/debian/control index 836a840e..8a8b2645 100644 --- a/debian/control +++ b/debian/control @@ -1,17 +1,48 @@ Source: dde-qt5platform-plugins Section: devel Priority: optional -Maintainer: Deepin Packages Builder -Build-Depends: debhelper (>=9), qtbase5-dev, qtbase5-private-dev, - pkg-config, libqt5x11extras5-dev, libxcb-xkb-dev, libxcb-render-util0-dev, - libxcb-image0-dev, libxcb-icccm4-dev, libxcb-keysyms1-dev, libegl1-mesa-dev, - libmtdev-dev, libxkbcommon-x11-dev, libdbus-1-dev, libqt5opengl5-dev, - libudev-dev, libxrender-dev,libxi-dev, libsm-dev, libxcb-xinerama0-dev, - libfontconfig1-dev, libglib2.0-dev, libxcb-damage0-dev, - libxcb-composite0-dev, libcairo2-dev, libkf5wayland-dev, libdwayland-dev, - qtwayland5-private-dev | libqt5waylandclient5-dev, - libwayland-dev, libxcb-xinput-dev, libxcb-util-dev | libxcb-util0-dev, - libx11-xcb-dev, libxcb-sync-dev, libxcb-randr0-dev, cmake, libgtest-dev, libgmock-dev, libdtkcommon-dev(>=5.6.16) +Maintainer: Shanshan Ye +Build-Depends: debhelper-compat (= 12), + cmake, + pkg-config, + libgtest-dev, + libgmock-dev, + libdtkcommon-dev(>=5.6.16), + qtbase5-dev , + qtbase5-private-dev , + libqt5x11extras5-dev , + libqt5opengl5-dev , + qtwayland5-private-dev | libqt5waylandclient5-dev , + qt6-base-dev , + qt6-base-private-dev , + libxcb-cursor-dev , + libxcb-xkb-dev, + libxcb-render-util0-dev, + libxcb-image0-dev, + libxcb-icccm4-dev, + libxcb-keysyms1-dev, + libegl1-mesa-dev, + libmtdev-dev, + libxkbcommon-x11-dev, + libdbus-1-dev, + libudev-dev, + libxrender-dev, + libxi-dev, + libsm-dev, + libxcb-xinerama0-dev, + libfontconfig1-dev, + libglib2.0-dev, + libxcb-damage0-dev, + libxcb-composite0-dev, + libcairo2-dev, + libkf5wayland-dev , + libdwayland-dev , + libwayland-dev, + libxcb-xinput-dev, + libxcb-util-dev | libxcb-util0-dev, + libx11-xcb-dev, + libxcb-sync-dev, + libxcb-randr0-dev Standards-Version: 3.9.8 Package: dde-qt5xcb-plugin @@ -21,11 +52,20 @@ Conflicts: libqt5dxcb-plugin, qt5dxcb-plugin Breaks:dde-qt5integration (<< 0.2.8.1) Replaces: qt5dxcb-plugin Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Qt platform plugins +Build-Profiles: +Description: Qt platform plugins (DTK5 with Qt5) Qt platform plugins for DDE. Package: dde-qt5wayland-plugin Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, qtwayland5 -Description: Qt platform plugins +Build-Profiles: +Description: Qt platform plugins (DTK5 with Qt5) Qt platform plugins for DDE. + +Package: dde-qt6xcb-plugin +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Build-Profiles: +Description: Qt platform plugins (DTK6 with Qt6) + Qt platform plugins for DDE (Qt6 version). diff --git a/debian/dde-qt6xcb-plugin.install b/debian/dde-qt6xcb-plugin.install new file mode 100644 index 00000000..0450f4e3 --- /dev/null +++ b/debian/dde-qt6xcb-plugin.install @@ -0,0 +1 @@ +usr/lib/*/qt6/plugins/platforms/libdxcb.so diff --git a/debian/rules b/debian/rules index 25327e10..3099bfe5 100755 --- a/debian/rules +++ b/debian/rules @@ -1,4 +1,6 @@ #!/usr/bin/make -f +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk # 安全编译参数 export DEB_BUILD_MAINT_OPTIONS = hardening=+all @@ -6,8 +8,57 @@ export DEB_CFLAGS_MAINT_APPEND = -Wall export DEB_CXXFLAGS_MAINT_APPEND = -Wall export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-E +# Build-Profiles 控制 +BUILD_DTK5 := $(if $(filter nodtk5,$(DEB_BUILD_PROFILES)),OFF,ON) +BUILD_DTK6 := $(if $(filter nodtk6,$(DEB_BUILD_PROFILES)),OFF,ON) + %: - dh $@ + dh $@ + +override_dh_auto_configure: +ifeq ($(BUILD_DTK5),ON) + mkdir -p build5 + QT_SELECT=qt5 dh_auto_configure --builddirectory=build5 -- \ + $(DEB_CMAKE_EXTRA_FLAGS) \ + -DBUILD_TESTING=OFF \ + -DDTK5=ON +endif +ifeq ($(BUILD_DTK6),ON) + mkdir -p build6 + dh_auto_configure --builddirectory=build6 -- \ + $(DEB_CMAKE_EXTRA_FLAGS) \ + -DBUILD_TESTING=OFF \ + -DDTK5=OFF +endif + +override_dh_auto_build: +ifeq ($(BUILD_DTK5),ON) + QT_SELECT=qt5 dh_auto_build --builddirectory=build5 +endif +ifeq ($(BUILD_DTK6),ON) + dh_auto_build --builddirectory=build6 +endif + +override_dh_auto_install: +ifeq ($(BUILD_DTK5),ON) + QT_SELECT=qt5 dh_auto_install --builddirectory=build5 +endif +ifeq ($(BUILD_DTK6),ON) + dh_auto_install --builddirectory=build6 +endif + +override_dh_auto_test: +ifeq ($(BUILD_DTK5),ON) + QT_SELECT=qt5 dh_auto_test --builddirectory=build5 +endif +ifeq ($(BUILD_DTK6),ON) + dh_auto_test --builddirectory=build6 +endif override_dh_shlibdeps: dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info + +override_dh_auto_clean: + dh_auto_clean --builddirectory=build5 + dh_auto_clean --builddirectory=build6 + rm -rf build5 build6 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 63071769..e6915f35 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,8 +26,11 @@ include(${CMAKE_SOURCE_DIR}/xcb/linux.cmake) add_definitions(-DPLUGIN_OUTPUT_PATH=\"${LIBRARY_OUTPUT_PATH}/..\") -target_compile_options(${PROJECT_NAME} PRIVATE -fno-access-control -fsanitize=address) -target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address) +target_compile_options(${PROJECT_NAME} PRIVATE -fno-access-control) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address) + target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address) +endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${PROJECT_NAME} PRIVATE -fprofile-instr-generate -ftest-coverage) endif() @@ -68,3 +71,5 @@ if(${QT_VERSION_MAJOR} STREQUAL "5") else() target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::OpenGL Qt6::OpenGLPrivate Qt6::XcbQpaPrivate) endif() + +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})