diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-11-03 04:59:48 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-11-03 05:16:19 -0800 |
commit | 918e8b10a716ec720215afafb7baa1b9b75e4fa1 (patch) | |
tree | 48548ad8236285ceca1910f4a6413b1c99126891 /libcpp/mkdeps.c | |
parent | f7d6961126a7f06c8089d8a58bd21be43bc16806 (diff) | |
download | gcc-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/mkdeps.c')
-rw-r--r-- | libcpp/mkdeps.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c index 09a111f..ea5f060 100644 --- a/libcpp/mkdeps.c +++ b/libcpp/mkdeps.c @@ -23,6 +23,7 @@ along with this program; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "mkdeps.h" +#include "internal.h" /* Not set up to just include std::vector et al, here's a simple implementation. */ @@ -367,8 +368,10 @@ make_write_vec (const mkdeps::vec<const char *> &vec, FILE *fp, .PHONY targets for all the dependencies too. */ static void -make_write (const class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) +make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) { + const mkdeps *d = pfile->deps; + unsigned column = 0; if (colmax && colmax < 34) colmax = 34; @@ -380,7 +383,7 @@ make_write (const class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) column++; make_write_vec (d->deps, fp, column, colmax); fputs ("\n", fp); - if (phony) + if (CPP_OPTION (pfile, deps.phony_targets)) for (unsigned i = 1; i < d->deps.size (); i++) fprintf (fp, "%s:\n", munge (d->deps[i])); } @@ -388,11 +391,12 @@ make_write (const class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) /* Write out dependencies according to the selected format (which is only Make at the moment). */ +/* Really we should be opening fp here. */ void -deps_write (const class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) +deps_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) { - make_write (d, fp, phony, colmax); + make_write (pfile, fp, colmax); } /* Write out a deps buffer to a file, in a form that can be read back |