From 174f66220d4d39ed503ded1ec3e7ba514cc4283e Mon Sep 17 00:00:00 2001 From: Eduard Sanou Date: Thu, 28 Apr 2016 09:12:05 +0000 Subject: c-common.c (get_source_date_epoch): New function... gcc/c-family/ChangeLog: 2016-04-28 Eduard Sanou Matthias Klose * c-common.c (get_source_date_epoch): New function, gets the environment variable SOURCE_DATE_EPOCH and parses it as long long with error handling. * c-common.h (get_source_date_epoch): Prototype. * c-lex.c (c_lex_with_flags): set parse_in->source_date_epoch. gcc/ChangeLog: 2016-04-28 Eduard Sanou Matthias Klose * doc/cppenv.texi: Document SOURCE_DATE_EPOCH environment variable. libcpp/ChangeLog: 2016-04-28 Eduard Sanou Matthias Klose * include/cpplib.h (cpp_init_source_date_epoch): Prototype. * init.c (cpp_init_source_date_epoch): New function. * internal.h: Added source_date_epoch variable to struct cpp_reader to store a reproducible date. * macro.c (_cpp_builtin_macro_text): Set pfile->date timestamp from pfile->source_date_epoch instead of localtime if source_date_epoch is set, to be used for __DATE__ and __TIME__ macros to help reproducible builds. Co-Authored-By: Matthias Klose From-SVN: r235550 --- libcpp/init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libcpp/init.c') diff --git a/libcpp/init.c b/libcpp/init.c index 4343075ba85..f5ff85b3bae 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -533,8 +533,15 @@ cpp_init_builtins (cpp_reader *pfile, int hosted) _cpp_define_builtin (pfile, "__OBJC__ 1"); } +/* Initialize the source_date_epoch value. */ +void +cpp_init_source_date_epoch (cpp_reader *pfile, time_t source_date_epoch) +{ + pfile->source_date_epoch = source_date_epoch; +} + /* Sanity-checks are dependent on command-line options, so it is - called as a subroutine of cpp_read_main_file (). */ + called as a subroutine of cpp_read_main_file. */ #if CHECKING_P static void sanity_checks (cpp_reader *); static void sanity_checks (cpp_reader *pfile) -- cgit v1.2.3