Closed OPNA2608 closed 2 years ago
Support for SOURCE_DATE_EPOCH
looks like a reasonable addition. At the very least cosmetically this would be handy for building the many packages for binary releases, which sometimes will have different date stamps depending on the platform and the order that the builds were compiled.
We have something similar we could possibly follow; the repository commit hash can be baked in to the build: https://github.com/freebasic/fbc/blob/70741db519941ff5209a28d8d6f2f4f6d2f62194/makefile#L545 we can either set the hash explicitly or grab it automatically from the current repository.
I would expect that SOURCE_DATE_EPOCH
is externally managed by the builder/maintainer, because trying to commit meta data in to the repository that itself needs to reference the repository's meta data would be convoluted, I think.
Simplest starting approach would be to check for SOURCE_DATE_EPOCH
already set and compute a BUILD_DATE
by the host to pass in to the build.
SOURCE_DATE_EPOCH
is handled externally by the build / package environment setup yep.
https://github.com/NixOS/nixpkgs/blob/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/stdenv/generic/setup.sh#L258-L264 https://github.com/NixOS/nixpkgs/blob/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/build-support/setup-hooks/set-source-date-epoch-to-latest.sh
bt1cn@NixTop:~
↪ nix-shell -p stdenv
[nix-shell:~]$ echo $SOURCE_DATE_EPOCH
315532800
[nix-shell:~]$ LANG=en_GB.UTF-8 date -ud @$SOURCE_DATE_EPOCH
Tue 1 Jan 00:00:00 UTC 1980
For usage of SOURCE_DATE_EPOCH
, checking directly by the compiler seems straightforward. See #392
The drawback of course is that we have to compile fbc twice to get it working: first to add the feature, second time to use it to (within fbc itself).
Since the setting of SOURCE_DATE_EPOCH
is handled externally and is imho an arbitrary value, then it is ultimately up to the builder / maintainer what to use - i.e. changelog.txt file timestamp from a source tarball, last git log timestamp from repository, etc. Adding a rule to the makefile
to set this for releases is an option can explore later.
Support added by #392
Documentation (at least a brief reference) added at FreeBASIC Build Options
SOURCE_DATE_EPOCH
is an environment variable that provides the seconds since the Unix epoch that should be used for any build time/date macros and functions. It's a functionality that helps with build result reproducibility and has found adoption in projects like Debian and GCC.It would be great if fbc could support
SOURCE_DATE_EPOCH
for both its own date infbc --version
and any other code that uses its affected date and time macros/functions.