From 54638bfc10bd766563830adaac118a4e55b4b52b Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 18 Jan 2021 14:16:59 +0100 Subject: [PATCH] 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. --- dtool/src/dtoolutil/pandaSystem.cxx | 4 ++++ makepanda/makepanda.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index 667d08b8d9..fa09e065ca 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -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 } /** diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e8391482ff..6f65cc0253 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -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))