mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
build-sys: add check-includes build target and script
This commit is contained in:
parent
63a1b905d8
commit
bfb35cfda1
|
@ -4936,6 +4936,14 @@ CLEANFILES += \
|
||||||
check-api-unused: defined undefined exported
|
check-api-unused: defined undefined exported
|
||||||
( cat exported undefined ) | sort -u | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
|
( cat exported undefined ) | sort -u | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
|
||||||
|
|
||||||
|
.PHONY: check-includes
|
||||||
|
check-includes: $(top_srcdir)/tools/check-includes.pl
|
||||||
|
$(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
|
||||||
|
| xargs $(top_srcdir)/tools/check-includes.pl
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
$(top_srcdir)/tools/check-includes.pl
|
||||||
|
|
||||||
# Stupid test that everything purported to be exported really is
|
# Stupid test that everything purported to be exported really is
|
||||||
|
|
||||||
define generate-sym-test
|
define generate-sym-test
|
||||||
|
|
23
tools/check-includes.pl
Executable file
23
tools/check-includes.pl
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# checkincludes: Find files included more than once in (other) files.
|
||||||
|
# Copyright abandoned, 2000, Niels Kristian Bech Jensen <nkbj@image.dk>.
|
||||||
|
|
||||||
|
foreach $file (@ARGV) {
|
||||||
|
open(FILE, $file) or die "Cannot open $file: $!.\n";
|
||||||
|
|
||||||
|
my %includedfiles = ();
|
||||||
|
|
||||||
|
while (<FILE>) {
|
||||||
|
if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
|
||||||
|
++$includedfiles{$1};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach $filename (keys %includedfiles) {
|
||||||
|
if ($includedfiles{$filename} > 1) {
|
||||||
|
print "$file: $filename is included more than once.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(FILE);
|
||||||
|
}
|
Loading…
Reference in a new issue