Browse Source

interrogate: respect SOURCE_DATE_EPOCH setting for file identifiers

This can be used to ensure that the build is bit-for-bit reproducible.

See https://reproducible-builds.org/docs/source-date-epoch/
rdb 4 years ago
parent
commit
0b53355347
1 changed files with 9 additions and 1 deletions
  1. 9 1
      dtool/src/interrogate/interrogate.cxx

+ 9 - 1
dtool/src/interrogate/interrogate.cxx

@@ -544,7 +544,15 @@ main(int argc, char **argv) {
   // Make up a file identifier.  This is just some bogus number that should be
   // the same in both the compiled-in code and in the database, so we can
   // check synchronicity at load time.
-  int file_identifier = time(nullptr);
+  // We allow overriding this value by setting SOURCE_DATE_EPOCH to support
+  // reproducible builds.
+  int file_identifier;
+  const char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+  if (source_date_epoch != nullptr && source_date_epoch[0] != 0) {
+    file_identifier = atoi(source_date_epoch);
+  } else {
+    file_identifier = time(nullptr);
+  }
   InterrogateModuleDef *def = builder.make_module_def(file_identifier);
 
   pofstream * the_output_include = nullptr;