From 6bf37e377035c60ac5ef04de000a1cbdf8e747a1 Mon Sep 17 00:00:00 2001 From: equalsraf Date: Wed, 24 Jul 2024 15:10:25 +0100 Subject: [PATCH] Try to make builds reproducible Reproducible builds for neovim-qt are not working because mapping flags passed to the cmake build are included in the code (through version.h.in). Meaning that builds with slightly different mapping flags end up being different; even if no other compiler flags are different. ref https://github.com/equalsraf/neovim-qt/issues/1111 Adds build option for reproducible builds. Currently only affects the use of compilation flags in the --version output. --- CMakeLists.txt | 1 + src/gui/app.cpp | 2 ++ src/version.h.in | 3 +++ 3 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88bb5e01a..697a73206 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ endif() set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +option(REPRODUCIBLE_BUILD "Make this build reproducible" OFF) option(USE_GCOV "Enable gcov support" OFF) option(ENABLE_CLAZY "Build with KDE Clang Clazy Linter" OFF) option(ENABLE_TIDY "Build with Clang Tidy Linter" OFF) diff --git a/src/gui/app.cpp b/src/gui/app.cpp index d1ead8053..00d6f3d53 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -446,7 +446,9 @@ void App::showVersionInfo(QCommandLineParser& parser) noexcept out << "NVIM-QT v" << PROJECT_VERSION << QT_ENDL; out << "Build type: " << CMAKE_BUILD_TYPE << QT_ENDL; +#if !defined(REPRODUCIBLE_BUILD) out << "Compilation:" << CMAKE_CXX_FLAGS << QT_ENDL; +#endif out << "Qt Version: " << QT_VERSION_STR << QT_ENDL; out << "Environment: " << QT_ENDL; out << " nvim: " << nvimExecutable << QT_ENDL; diff --git a/src/version.h.in b/src/version.h.in index efb6b7289..f522cb599 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -16,7 +16,10 @@ #define RC_PROJECT_NAME "@PROJECT_NAME@\0" #define RC_PROJECT_VERSION "@PROJECT_VERSION@\0" +#cmakedefine REPRODUCIBLE_BUILD +#if !defined(REPRODUCIBLE_BUILD) #define CMAKE_CXX_FLAGS "@CMAKE_CXX_FLAGS@" +#endif #define CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" #endif // NEOVIM_QT_VERSION