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 <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Bernhard M. Wiedemann 2023-08-03 08:56:09 +02:00
parent c63c46037d
commit 297fe90329

View File

@ -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())