From 918e8b10a716ec720215afafb7baa1b9b75e4fa1 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 3 Nov 2020 04:59:48 -0800 Subject: 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. --- gcc/c-family/c.opt | 4 ++-- gcc/fortran/cpp.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 10e53ea..426636b 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -242,11 +242,11 @@ Generate phony targets for all headers. MQ C ObjC C++ ObjC++ Joined Separate MissingArgError(missing makefile target after %qs) --MQ Add a MAKE-quoted target. +-MQ Add a target that may require quoting. MT C ObjC C++ ObjC++ Joined Separate MissingArgError(missing makefile target after %qs) --MT Add an unquoted target. +-MT Add a target that does not require quoting. P C ObjC C++ ObjC++ diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index dcde557..51baf141 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -222,13 +222,15 @@ void gfc_cpp_add_dep (const char *name, bool system) { if (!gfc_cpp_option.deps_skip_system || !system) - deps_add_dep (cpp_get_deps (cpp_in), name); + if (mkdeps *deps = cpp_get_deps (cpp_in)) + deps_add_dep (deps, name); } void gfc_cpp_add_target (const char *name) { - deps_add_target (cpp_get_deps (cpp_in), name, 0); + if (mkdeps *deps = cpp_get_deps (cpp_in)) + deps_add_target (deps, name, 0); } @@ -605,8 +607,8 @@ gfc_cpp_init (void) cpp_assert (cpp_in, opt->arg); } else if (opt->code == OPT_MT || opt->code == OPT_MQ) - deps_add_target (cpp_get_deps (cpp_in), - opt->arg, opt->code == OPT_MQ); + if (mkdeps *deps = cpp_get_deps (cpp_in)) + deps_add_target (deps, opt->arg, opt->code == OPT_MQ); } /* Pre-defined macros for non-required INTEGER kind types. */ -- cgit v1.1