From 013771c13a9e68a97d113cf268e52a4751cb4505 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Thu, 24 Jan 2019 13:10:39 -0800 Subject: [PATCH] feat(build): remove timestamps from build to allow reproducible builds avoid Qt embedding timestamps into translations after copying .ts to .qm to work towards reproducible builds. Now reproducible locally as long as there is absolutely no change to environment. --- CMakeLists.txt | 16 ++++++++++++++++ cmake/Dependencies.cmake | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa2ed7f12..9c318f7df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-overflow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +# avoid timestamps in binary for reproducible builds, not added until GCC 4.9 +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(-Wdate-time COMPILER_SUPPORTS_WDATE_TIME) +if(COMPILER_SUPPORTS_WDATE_TIME) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdate-time") +endif() + if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstack-protector") @@ -101,6 +108,15 @@ include_directories(${CMAKE_SOURCE_DIR}) include(Dependencies) +if(NOT Qt5Widgets_VERSION VERSION_LESS "5.9") + # Drop the file modification time of source files from generated files + # to help with reproducible builds. We do not use QFileInfo.lastModified + # so this has no unwanted side effects. This mtime started appearing in + # Qt 5.8. The option to force the old file format without mtime was + # added in Qt 5.9. See https://bugreports.qt.io/browse/QTBUG-58769 + set(RCC_OPTIONS ${RCC_OPTIONS} -format-version 1) +endif() + ################################################################################ # # :: qTox main library sources diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index ac3fa5de8..544916202 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -199,14 +199,6 @@ add_definitions( -DGIT_VERSION="${GIT_VERSION}" ) -if (NOT TIMESTAMP) - execute_process( - COMMAND date +%s - OUTPUT_VARIABLE TIMESTAMP - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -endif() - set(APPLE_EXT False) if (FOUNDATION_FOUND AND IOKIT_FOUND) set(APPLE_EXT True) @@ -230,6 +222,5 @@ if (PLATFORM_EXTENSIONS) endif() add_definitions( - -DTIMESTAMP=${TIMESTAMP} -DLOG_TO_FILE=1 )