aboutsummaryrefslogtreecommitdiff
path: root/libcpp/init.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-11-03 04:59:48 -0800
committerNathan Sidwell <nathan@acm.org>2020-11-03 05:16:19 -0800
commit918e8b10a716ec720215afafb7baa1b9b75e4fa1 (patch)
tree48548ad8236285ceca1910f4a6413b1c99126891 /libcpp/init.c
parentf7d6961126a7f06c8089d8a58bd21be43bc16806 (diff)
downloadgcc-918e8b10a716ec720215afafb7baa1b9b75e4fa1.zip
gcc-918e8b10a716ec720215afafb7baa1b9b75e4fa1.tar.gz
gcc-918e8b10a716ec720215afafb7baa1b9b75e4fa1.tar.bz2
libcpp: dependency emission tidying
This patch cleans up the interface to the dependency generation a little. We now only check the option in one place, and the cpp_get_deps function returns nullptr if there are no dependencies. I also reworded the -MT and -MQ help text to be make agnostic -- as there are ideas about emitting, say, JSON. libcpp/ * include/mkdeps.h: Include cpplib.h (deps_write): Adjust first parm type. * mkdeps.c: Include internal.h (make_write): Adjust first parm type. Check phony option directly. (deps_write): Adjust first parm type. * init.c (cpp_read_main_file): Use get_deps. * directives.c (cpp_get_deps): Check option before initializing. gcc/c-family/ * c.opt (MQ,MT): Reword description to be make-agnostic. gcc/fortran/ * cpp.c (gfc_cpp_add_dep): Only add dependency if we're recording them. (gfc_cpp_init): Likewise for target.
Diffstat (limited to 'libcpp/init.c')
-rw-r--r--libcpp/init.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/libcpp/init.c b/libcpp/init.c
index 454a183..5b2607e 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -667,14 +667,9 @@ cpp_post_options (cpp_reader *pfile)
const char *
cpp_read_main_file (cpp_reader *pfile, const char *fname, bool injecting)
{
- if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
- {
- if (!pfile->deps)
- pfile->deps = deps_init ();
-
- /* Set the default target (if there is none already). */
- deps_add_default_target (pfile->deps, fname);
- }
+ if (mkdeps *deps = cpp_get_deps (pfile))
+ /* Set the default target (if there is none already). */
+ deps_add_default_target (pfile->deps, fname);
pfile->main_file
= _cpp_find_file (pfile, fname, &pfile->no_search_path, /*angle=*/0,
@@ -813,9 +808,8 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream)
while (pfile->buffer)
_cpp_pop_buffer (pfile);
- if (CPP_OPTION (pfile, deps.style) != DEPS_NONE && deps_stream)
- deps_write (pfile->deps, deps_stream,
- CPP_OPTION (pfile, deps.phony_targets), 72);
+ if (deps_stream)
+ deps_write (pfile, deps_stream, 72);
/* Report on headers that could use multiple include guards. */
if (CPP_OPTION (pfile, print_include_names))