repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / 3rdparty / cppcheck / checksources.pl
blob082dcae044838860e17ac2377c74ff5eccf503e9
1 #!/usr/bin/perl
3 use warnings;
4 use strict;
5 use File::Basename;
6 use File::Find;
8 if (scalar @ARGV < 2) {
9 die "Usage: $0 <dir to check> <file to log> <optional number of jobs>\n";
12 if (!-e "./ReadMe.cross-compile") {
13 die "ERROR: $0 must be called from Haiku top directory!\n";
16 my %headers;
17 my $dirToCheck = shift @ARGV;
18 my $fileToLog = shift @ARGV;
19 my $jobs = 1;
20 if (scalar @ARGV) {
21 $jobs = shift @ARGV;
23 my $headersDirs;
24 my $cppcheck;
26 print "Scanning headers...\n";
27 find({ wanted => \&process, no_chdir => 1},
28 ("headers/posix", "headers/libs", "headers/os", "headers/private"));
30 foreach my $dir (sort keys %headers) {
31 $headersDirs .= "-I $dir ";
34 print "Running cppcheck tool...\n";
35 $cppcheck = "cppcheck -j $jobs --force --auto-dealloc 3rdparty/cppcheck/haiku.lst --enable=exceptRealloc,possibleError $headersDirs $dirToCheck 2> $fileToLog";
37 system($cppcheck);
39 sub process
41 if (substr($_, -4, 4) eq '.svn') {
42 $File::Find::prune = 1;
43 } else {
44 return if $File::Find::dir eq $_; # skip toplevel folders
45 my $name = (fileparse($_))[0];
46 if (-d $_) {
47 push @{$headers{$File::Find::name}->{subdirs}}, $name;
48 return;