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/
This commit is contained in:
rdb 2021-01-18 02:34:16 +01:00
parent 8924b77da4
commit 0b53355347

View File

@ -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;