mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-25 09:30:58 +00:00
honor SOURCE_DATE_EPOCH variable when timestamping MacBinary files
This commit is contained in:
parent
e43fee2701
commit
e187bd21c2
@ -75,6 +75,19 @@ static void writeMacBinary(std::ostream& out, std::string filename,
|
||||
|
||||
const std::string& rsrcBytes = resstream.str();
|
||||
|
||||
// MacBinary files contain mandatory timestamps (creation date and modification date)
|
||||
// We set both of them, but to make reproducible builds possible, this optionally
|
||||
// takes the time from the $SOURCE_DATE_EPOCH environment variable instead of the system clock.
|
||||
// When building under `nix`, this is automatically set to the modification date of the newest source
|
||||
// file.
|
||||
auto timestamp = std::invoke([&] -> std::chrono::system_clock::time_point {
|
||||
const char *sourceDateEpochEnvVar = getenv("SOURCE_DATE_EPOCH");
|
||||
if (sourceDateEpochEnvVar && *sourceDateEpochEnvVar)
|
||||
return std::chrono::system_clock::from_time_t((time_t)std::atoll(sourceDateEpochEnvVar));
|
||||
else
|
||||
return std::chrono::system_clock::now();
|
||||
});
|
||||
|
||||
// Calculate Mac-style timestamp (seconds since 1 January 1904 00:00:00)
|
||||
std::tm mac_epoch_tm = {
|
||||
0, 0, 0, // 00:00:00
|
||||
|
Loading…
Reference in New Issue
Block a user