[ovs-dev] [PATCH 2/2] vlog: Check that all declared vlog modules are used, at "make dist" time.
Ben Pfaff
blp at nicira.com
Wed Jun 9 00:06:33 UTC 2010
---
Makefile.am | 4 ++--
lib/automake.mk | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index c902e41..c717c0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -90,7 +90,7 @@ SUFFIXES += .in
# If we're checked out from a Git repository, make sure that every
# file that is in Git is distributed.
-dist-hook-git:
+check-all-files-are-distributed:
if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
rc=0; \
for d in `cd $(srcdir) && git ls-files`; do \
@@ -109,7 +109,7 @@ dist-hook-git:
done; \
exit $$rc; \
fi
-DIST_HOOKS += dist-hook-git
+DIST_HOOKS += check-all-files-are-distributed
dist-hook: $(DIST_HOOKS)
.PHONY: $(DIST_HOOKS)
diff --git a/lib/automake.mk b/lib/automake.mk
index 5cc4e0f..b3e5198 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -260,3 +260,30 @@ lib/coverage-counters.c: $(COVERAGE_FILES) lib/coverage-scan.pl
(cd $(srcdir) && $(PERL) lib/coverage-scan.pl $(COVERAGE_FILES)) > $@.tmp
mv $@.tmp $@
EXTRA_DIST += lib/coverage-scan.pl
+
+
+# Make sure that every vlog module listed in vlog-modules.def is
+# actually used somewhere.
+check-for-unused-vlog-modules:
+ if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
+ cd $(srcdir); \
+ decl_vlog=`sed -n 's/^VLOG_MODULE(\([_a-z0-9]\{1,\}\)).*$$/\1/p' \
+ lib/vlog-modules.def | \
+ LC_ALL=C sort -u | \
+ xargs echo`; \
+ used_vlog=`git grep VLM_ | \
+ sed -n 's/.*VLM_\([a-z_0-9]\{1,\}\).*/\1/p' | \
+ LC_ALL=C sort -u | \
+ xargs echo`; \
+ rc=0; \
+ for decl in $$decl_vlog; do \
+ case " $$used_vlog " in \
+ *" $$decl "*) ;; \
+ *) echo "vlog module $$decl is declared in lib/vlog-modules.def \
+but not used by any source file"; \
+ rc=1 ;; \
+ esac \
+ done; \
+ exit $$rc; \
+ fi
+DIST_HOOKS += check-for-unused-vlog-modules
--
1.7.1
More information about the dev
mailing list