From 297fe90329782d35dc4f155185ded045551ef52f Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Thu, 3 Aug 2023 08:56:09 +0200 Subject: [PATCH] Allow to override build date with SOURCE_DATE_EPOCH [ChangeLog][qmake] Allows to override _DATE_ with SOURCE_DATE_EPOCH to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. Fixes: QTBUG-115737 Change-Id: I1964aa0a3d849628440618aa6f0a51af2017d824 Reviewed-by: Alexey Edelev Reviewed-by: Alexandru Croitor Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index d4cb8aad7a..df3f92d7d5 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1013,10 +1013,13 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa void QMakeEvaluator::loadDefaults() { ProValueMap &vars = m_valuemapStack.top(); + qlonglong sde = qgetenv("SOURCE_DATE_EPOCH").toLongLong(); + QDateTime builddate = sde ? QDateTime::fromSecsSinceEpoch(sde) + : QDateTime::currentDateTime(); vars[ProKey("DIR_SEPARATOR")] << ProString(m_option->dir_sep); vars[ProKey("DIRLIST_SEPARATOR")] << ProString(m_option->dirlist_sep); - vars[ProKey("_DATE_")] << ProString(QDateTime::currentDateTime().toString()); + vars[ProKey("_DATE_")] << ProString(builddate.toString()); if (!m_option->qmake_abslocation.isEmpty()) vars[ProKey("QMAKE_QMAKE")] << ProString(m_option->qmake_abslocation); if (!m_option->qmake_args.isEmpty())