From 4ad8c0daab866f3d811006846a8040c9f05c0384 Mon Sep 17 00:00:00 2001 From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com> Date: Fri, 18 Nov 2022 09:19:34 +1100 Subject: [PATCH 15/56] libcpp: Change deps_write and make_write to take class mkdeps instead of const cpp_reader and to learn about the the dependency phoniness via a bool argument.
libcpp/ChangeLog: * include/mkdeps.h (deps_write): Adjust first parm type, re-add phony argument. * init.cc (cpp_finish): Adjust accordingly. * mkdeps.cc (make_write): Adjust first parm type, re-add phony argument. (deps_write): Likewise. --- libcpp/include/mkdeps.h | 2 +- libcpp/init.cc | 2 +- libcpp/mkdeps.cc | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libcpp/include/mkdeps.h b/libcpp/include/mkdeps.h index 96d64641b1a..1eb96d3e8af 100644 --- a/libcpp/include/mkdeps.h +++ b/libcpp/include/mkdeps.h @@ -66,7 +66,7 @@ extern void deps_add_dep (class mkdeps *, const char *); /* Write out a deps buffer to a specified file. The last argument is the number of columns to word-wrap at (0 means don't wrap). */ -extern void deps_write (const cpp_reader *, FILE *, unsigned int); +extern void deps_write (class mkdeps *, FILE *, bool, unsigned int); /* Write out a deps buffer to a file, in a form that can be read back with deps_restore. Returns nonzero on error, in which case the diff --git a/libcpp/init.cc b/libcpp/init.cc index 5f34e3515d2..fb379dcc0cd 100644 --- a/libcpp/init.cc +++ b/libcpp/init.cc @@ -870,7 +870,7 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream) _cpp_pop_buffer (pfile); if (deps_stream) - deps_write (pfile, deps_stream, 72); + deps_write (pfile->deps, deps_stream, CPP_OPTION (pfile, deps.phony_targets), 72); /* Report on headers that could use multiple include guards. */ if (CPP_OPTION (pfile, print_include_names)) diff --git a/libcpp/mkdeps.cc b/libcpp/mkdeps.cc index 30e87d8b4d7..1921017622f 100644 --- a/libcpp/mkdeps.cc +++ b/libcpp/mkdeps.cc @@ -387,10 +387,8 @@ make_write_vec (const mkdeps::vec<const char *> &vec, FILE *fp, .PHONY targets for all the dependencies too. */ static void -make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) +make_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) { - const mkdeps *d = pfile->deps; - unsigned column = 0; if (colmax && colmax < 34) colmax = 34; @@ -398,20 +396,17 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) if (d->deps.size ()) { column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm); - if (CPP_OPTION (pfile, deps.modules) && d->cmi_name) + if ((d->module_name) && (d->cmi_name)) column = make_write_name (d->cmi_name, fp, column, colmax); fputs (":", fp); column++; make_write_vec (d->deps, fp, column, colmax); fputs ("\n", fp); - if (CPP_OPTION (pfile, deps.phony_targets)) + if (phony) for (unsigned i = 1; i < d->deps.size (); i++) fprintf (fp, "%s:\n", munge (d->deps[i])); } - if (!CPP_OPTION (pfile, deps.modules)) - return; - if (d->modules.size ()) { column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm); @@ -468,9 +463,9 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) /* Really we should be opening fp here. */ void -deps_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) +deps_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax) { - make_write (pfile, fp, colmax); + make_write (d, fp, phony, colmax); } /* Write out a deps buffer to a file, in a form that can be read back -- 2.38.1