dtoolutil: Allow overriding PandaSystem::get_build_date()

This is useful to create bit-for-bit reproducible builds.  In the buildbots, we set it to the timestamp of the latest commit.
This commit is contained in:
rdb 2021-01-18 14:16:59 +01:00
parent 6520b68c2c
commit 54638bfc10
2 changed files with 12 additions and 0 deletions

View File

@ -268,7 +268,11 @@ get_compiler() {
*/
string PandaSystem::
get_build_date() {
#ifdef PANDA_BUILD_DATE_STR
return PANDA_BUILD_DATE_STR;
#else
return __DATE__ " " __TIME__;
#endif
}
/**

View File

@ -3001,6 +3001,14 @@ def CreatePandaVersionFiles():
if GIT_COMMIT:
pandaversion_h += "\n#define PANDA_GIT_COMMIT_STR \"%s\"\n" % (GIT_COMMIT)
# Allow creating a deterministic build by setting this.
source_date = os.environ.get("SOURCE_DATE_EPOCH")
if source_date:
# This matches the GCC / Clang format for __DATE__ __TIME__
source_date = time.gmtime(int(source_date))
source_date = time.strftime('%b %e %Y %H:%M:%S', source_date)
pandaversion_h += "\n#define PANDA_BUILD_DATE_STR \"%s\"\n" % (source_date)
if not RUNTIME:
checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))