From c08b1ef5d1262307245d4d090bbf5e16a70ec9b7 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 20 Oct 2018 22:20:03 -0500 Subject: [PATCH] Add new 'depclean' make target at top level It deletes all dependency (.d) files in the O.arch directories. This is useful when headers get moved or removed; recreating just the dependency data is much faster than rebuilding the whole tree. It is also possible to run the depclean.pl script manually when only part of the tree needs its dependencies regenerating. --- configure/RULES_TOP | 8 +++++++- src/tools/Makefile | 1 + src/tools/depclean.pl | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/tools/depclean.pl diff --git a/configure/RULES_TOP b/configure/RULES_TOP index 838994bd0..b18fbf026 100644 --- a/configure/RULES_TOP +++ b/configure/RULES_TOP @@ -15,6 +15,10 @@ CVSCLEAN = $(call FIND_TOOL,cvsclean.pl) cvsclean: $(PERL) $(CVSCLEAN) +DEPCLEAN = $(call FIND_TOOL,depclean.pl) +depclean: + $(PERL) $(DEPCLEAN) + realuninstall: uninstallDirs $(RMDIR) $(INSTALL_LOCATION_BIN) $(RMDIR) $(INSTALL_LOCATION_LIB) @@ -73,12 +77,14 @@ help: @echo " uninstall - Remove install directories created by this hostarch." @echo " realuninstall - Removes ALL install dirs" @echo " distclean - Same as realclean cvsclean realuninstall." + @echo " depclean - Removes all .d files from O. directories." @echo " cvsclean - Removes cvs .#* files in all dirs of directory tree" @echo " help - Prints this list of valid make targets " @echo "Indiv. object targets are supported by O. level Makefile .e.g" @echo " xxxRecord.o" -.PHONY: cleandirs distclean cvsclean realuninstall archuninstall uninstallDirs +.PHONY: cleandirs distclean cvsclean depclean +.PHONY: realuninstall archuninstall uninstallDirs .PHONY: uninstall help # Include /cfg/TOP_RULES* files from tops defined in RELEASE* files diff --git a/src/tools/Makefile b/src/tools/Makefile index d07092271..b7d6582cb 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -20,6 +20,7 @@ PERL_MODULES += EPICS/Getopts.pm PERL_SCRIPTS += assembleSnippets.pl PERL_SCRIPTS += convertRelease.pl PERL_SCRIPTS += cvsclean.pl +PERL_SCRIPTS += depclean.pl PERL_SCRIPTS += dos2unix.pl PERL_SCRIPTS += expandVars.pl PERL_SCRIPTS += fullPathName.pl diff --git a/src/tools/depclean.pl b/src/tools/depclean.pl new file mode 100644 index 000000000..cbf6077d1 --- /dev/null +++ b/src/tools/depclean.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +#************************************************************************* +# Copyright (c) 2018 UChicago Argonne LLC, as Operator of Argonne +# National Laboratory. +# This file is distributed subject to a Software License Agreement found +# in the file LICENSE that is included with this distribution. +#************************************************************************* + +# Find and delete dependency files from all build dirs in the source tree. +# The extension for dependency files is assumed to be .d (currently true). + +use File::Find; + +@ARGV = ('.') unless @ARGV; + +sub check { + unlink if -f && m(/O\.[^/]+/[^/]+\.d$); +} + +find({ wanted => \&check, no_chdir => 1 }, @ARGV);