Browse Source

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.
rdb 4 years ago
parent
commit
54638bfc10
2 changed files with 12 additions and 0 deletions
  1. 4 0
      dtool/src/dtoolutil/pandaSystem.cxx
  2. 8 0
      makepanda/makepanda.py

+ 4 - 0
dtool/src/dtoolutil/pandaSystem.cxx

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

+ 8 - 0
makepanda/makepanda.py

@@ -3001,6 +3001,14 @@ def CreatePandaVersionFiles():
     if GIT_COMMIT:
     if GIT_COMMIT:
         pandaversion_h += "\n#define PANDA_GIT_COMMIT_STR \"%s\"\n" % (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:
     if not RUNTIME:
         checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
         checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
         checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))
         checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))