From 72278cf094bb1bbd6a7fe32ca4f2bebac3282810 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Tue, 11 Nov 2025 20:13:01 +0800 Subject: [PATCH 1/2] feat: add reproducible build parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added CMAKE_SKIP_BUILD_RPATH flag to enable reproducible builds This change ensures consistent binary output across different build environments by preventing the inclusion of build-specific paths in the compiled binaries The flag is added to DEB_CMAKE_EXTRA_FLAGS which is then passed to the configure command Influence: 1. Verify that builds produce identical binaries when built in different environments 2. Test that the application still functions correctly with the new build flag 3. Check that RPATH is not embedded in the resulting binaries 4. Validate that the build process completes successfully with the new parameter feat: 添加可重复编译参数 添加 CMAKE_SKIP_BUILD_RPATH 标志以启用可重复构建 此更改通过防止在编译的二进制文件中包含特定于构建的路径 确保在不同构建环境中产生一致的二进制输出 该标志被添加到 DEB_CMAKE_EXTRA_FLAGS 中,然后传递给配置命令 Influence: 1. 验证在不同环境中构建时是否产生相同的二进制文件 2. 测试应用程序在使用新构建标志后是否仍能正常运行 3. 检查生成的二进制文件中是否未嵌入 RPATH 4. 验证构建过程在使用新参数后是否成功完成 --- debian/rules | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index a56027f0..ce06521d 100755 --- a/debian/rules +++ b/debian/rules @@ -9,6 +9,9 @@ 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 +# reproducible编译参数 +DEB_CMAKE_EXTRA_FLAGS += -DCMAKE_SKIP_BUILD_RPATH=ON + DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) VERSION = $(DEB_VERSION_UPSTREAM) @@ -20,4 +23,4 @@ BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0- dh $@ override_dh_auto_configure: - dh_auto_configure -- -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=ON -DBUILD_VERSION=$(BUILD_VER) -DDTK_VERSION=$(PACK_VER) + dh_auto_configure -- $(DEB_CMAKE_EXTRA_FLAGS) -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=ON -DBUILD_VERSION=$(BUILD_VER) -DDTK_VERSION=$(PACK_VER) From f866f0d558a8c7f0d1f8afefa90720457b7464ce Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Fri, 14 Nov 2025 10:59:14 +0800 Subject: [PATCH 2/2] fix: resolve duplicate compilation issue by removing redundant install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove CHAMELEON_PATH definition and usage from CMakeLists.txt 2. Replace compile-time CHAMELEON_PATH with runtime path calculation using QGuiApplication::applicationDirPath() 3. Change install directive from copying entire plugin directory to only installing qmldir file 4. This prevents duplicate files during installation and resolves recompilation issues The changes address a problem where redundant installation content was causing repeatable compilation problems. By removing the compile- time path definition and dynamically calculating the path at runtime, we eliminate dependency on build-time paths. Additionally, installing only the qmldir file instead of the entire plugin directory prevents duplicate file conflicts during installation. Influence: 1. Verify that examples can still find and load Chameleon plugins at runtime 2. Test that QML import paths are correctly set in both exhibition and qml-inspect examples 3. Confirm that plugin installation only includes necessary qmldir file 4. Check that style settings work correctly across different Qt versions 5. Validate that no duplicate files are created during build/install process fix: 解决重复编译问题,移除冗余安装内容 1. 从 CMakeLists.txt 中移除 CHAMELEON_PATH 定义和使用 2. 使用 QGuiApplication::applicationDirPath() 运行时路径计算替换编译 时 CHAMELEON_PATH 3. 将安装指令从复制整个插件目录改为仅安装 qmldir 文件 4. 这防止了安装过程中的重复文件问题并解决了重新编译问题 这些更改解决了冗余安装内容导致可重复编译的问题。通过移除编译时路径定义并 在运行时动态计算路径,我们消除了对构建时路径的依赖。此外,仅安装 qmldir 文件而不是整个插件目录可以防止安装过程中的重复文件冲突。 Influence: 1. 验证示例程序在运行时仍能找到并加载 Chameleon 插件 2. 测试 exhibition 和 qml-inspect 示例中的 QML 导入路径是否正确设置 3. 确认插件安装仅包含必要的 qmldir 文件 4. 检查样式设置在不同 Qt 版本中是否正常工作 5. 验证构建/安装过程中不会创建重复文件 --- examples/CMakeLists.txt | 2 -- examples/exhibition/main.cpp | 7 ++++--- examples/qml-inspect/main.cpp | 7 ++++--- qt6/src/CMakeLists.txt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cfbef0d1..38fbb7ea 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,4 @@ -set(CHAMELEON_PATH "${PROJECT_BINARY_DIR}/plugins") add_definitions( - -DCHAMELEON_PATH="${CHAMELEON_PATH}" -DQT_DEPRECATED_WARNINGS ) add_subdirectory(exhibition) diff --git a/examples/exhibition/main.cpp b/examples/exhibition/main.cpp index 37288b32..52a0cd5d 100644 --- a/examples/exhibition/main.cpp +++ b/examples/exhibition/main.cpp @@ -71,16 +71,17 @@ int main(int argc, char **argv) QQmlApplicationEngine engine; - engine.addImportPath(CHAMELEON_PATH); + const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath()); + engine.addImportPath(chameleonPath); #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQuickStyle::addStylePath(CHAMELEON_PATH); + QQuickStyle::addStylePath(chameleonPath); // QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software); #else // QQuickWindow::setGraphicsApi(QSGRendererInterface::Software); #endif #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG) - QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon"); + QQuickStyle::setStyle(chameleonPath"/Chameleon"); #else QQuickStyle::setStyle("Chameleon"); #endif diff --git a/examples/qml-inspect/main.cpp b/examples/qml-inspect/main.cpp index b4eff902..2c6fb5c1 100644 --- a/examples/qml-inspect/main.cpp +++ b/examples/qml-inspect/main.cpp @@ -20,16 +20,17 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; - engine.addImportPath(CHAMELEON_PATH); + const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath()); + engine.addImportPath(chameleonPath); #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQuickStyle::addStylePath(CHAMELEON_PATH); + QQuickStyle::addStylePath(chameleonPath); // QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software); #else // QQuickWindow::setGraphicsApi(QSGRendererInterface::Software); #endif #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG) - QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon"); + QQuickStyle::setStyle(chameleonPath"/Chameleon"); #else QQuickStyle::setStyle("Chameleon"); #endif diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt index 4f593e1f..63b82ca3 100644 --- a/qt6/src/CMakeLists.txt +++ b/qt6/src/CMakeLists.txt @@ -87,4 +87,4 @@ install(EXPORT Dtk${DTK_VERSION_MAJOR}DeclarativeTargets NAMESPACE Dtk${DTK_VERS install(FILES ${QM_FILES} DESTINATION "${TRANSLATIONS_INSTALL_PATH}") # Install plugin install(TARGETS ${PLUGIN_NAME} DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}") -install(DIRECTORY "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}") +install(FILES "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/qmldir" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")