seL4/tools/circular_includes.pl
Adrian Danis 2bdc2941be Check for circular includes
Adds a tool that checks for pre-process kernel_all.c_pp for any
circular include chains, and runs this as part of the kernel
compilation process
2016-10-21 12:05:03 +11:00

28 lines
725 B
Perl
Executable file

#!/usr/bin/perl -w
@file_stack=();
while (<>) {
$input=$_;
if ($input =~ /^# 1 "kernel_all.c"/) {
} elsif ($input =~ /^# 1 "(.*\..)"/) {
# Found a new header
$header = $1;
foreach $item (@file_stack) {
if ($item eq $header) {
print "Circular includes found:\n";
map { print "$_\n" } @file_stack;
print "$header\n";
exit -1;
}
}
push @file_stack, $header;
} elsif ($input =~ /^# \d+ "(.*\..)"/) {
# Have popped back up to an earlier header
$header = $1;
while ($file_stack[$#file_stack] ne $header) {
pop @file_stack;
}
}
}
exit 0;