Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(build): remove timestamps from build to allow reproducible builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anthonybilinski committed Jan 29, 2019
1 parent edf6b67 commit 013771c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -230,6 +222,5 @@ if (PLATFORM_EXTENSIONS)
endif()

add_definitions(
-DTIMESTAMP=${TIMESTAMP}
-DLOG_TO_FILE=1
)

0 comments on commit 013771c

Please sign in to comment.