mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
q3rcc: Allow to override build date
Allow to override __DATE__ and __TIME__ with SOURCE_DATE_EPOCH in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This behavior is what gcc already does.
This commit is contained in:
parent
350b8f9c7c
commit
a96f32eba2
1 changed files with 10 additions and 1 deletions
|
@ -19,6 +19,15 @@ int ifdepth;
|
||||||
int ifsatisfied[NIF];
|
int ifsatisfied[NIF];
|
||||||
int skipping;
|
int skipping;
|
||||||
|
|
||||||
|
time_t reproducible_time()
|
||||||
|
{
|
||||||
|
char *source_date_epoch;
|
||||||
|
time_t t;
|
||||||
|
if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
|
||||||
|
(t = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0)
|
||||||
|
return time(NULL);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
|
@ -28,7 +37,7 @@ main(int argc, char **argv)
|
||||||
char ebuf[BUFSIZ];
|
char ebuf[BUFSIZ];
|
||||||
|
|
||||||
setbuf(stderr, ebuf);
|
setbuf(stderr, ebuf);
|
||||||
t = time(NULL);
|
t = reproducible_time();
|
||||||
curtime = ctime(&t);
|
curtime = ctime(&t);
|
||||||
maketokenrow(3, &tr);
|
maketokenrow(3, &tr);
|
||||||
expandlex();
|
expandlex();
|
||||||
|
|
Loading…
Reference in a new issue