mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 #!/usr/bin/perl
markrad 0:cdf462088d13 2
markrad 0:cdf462088d13 3 # Detect comment blocks that are likely meant to be doxygen blocks but aren't.
markrad 0:cdf462088d13 4 #
markrad 0:cdf462088d13 5 # More precisely, look for normal comment block containing '\'.
markrad 0:cdf462088d13 6 # Of course one could use doxygen warnings, eg with:
markrad 0:cdf462088d13 7 # sed -e '/EXTRACT/s/YES/NO/' doxygen/mbedtls.doxyfile | doxygen -
markrad 0:cdf462088d13 8 # but that would warn about any undocumented item, while our goal is to find
markrad 0:cdf462088d13 9 # items that are documented, but not marked as such by mistake.
markrad 0:cdf462088d13 10
markrad 0:cdf462088d13 11 use warnings;
markrad 0:cdf462088d13 12 use strict;
markrad 0:cdf462088d13 13 use File::Basename;
markrad 0:cdf462088d13 14
markrad 0:cdf462088d13 15 # C/header files in the following directories will be checked
markrad 0:cdf462088d13 16 my @directories = qw(include/mbedtls library doxygen/input);
markrad 0:cdf462088d13 17
markrad 0:cdf462088d13 18 # very naive pattern to find directives:
markrad 0:cdf462088d13 19 # everything with a backslach except '\0' and backslash at EOL
markrad 0:cdf462088d13 20 my $doxy_re = qr/\\(?!0|\n)/;
markrad 0:cdf462088d13 21
markrad 0:cdf462088d13 22 sub check_file {
markrad 0:cdf462088d13 23 my ($fname) = @_;
markrad 0:cdf462088d13 24 open my $fh, '<', $fname or die "Failed to open '$fname': $!\n";
markrad 0:cdf462088d13 25
markrad 0:cdf462088d13 26 # first line of the last normal comment block,
markrad 0:cdf462088d13 27 # or 0 if not in a normal comment block
markrad 0:cdf462088d13 28 my $block_start = 0;
markrad 0:cdf462088d13 29 while (my $line = <$fh>) {
markrad 0:cdf462088d13 30 $block_start = $. if $line =~ m/\/\*(?![*!])/;
markrad 0:cdf462088d13 31 $block_start = 0 if $line =~ m/\*\//;
markrad 0:cdf462088d13 32 if ($block_start and $line =~ m/$doxy_re/) {
markrad 0:cdf462088d13 33 print "$fname:$block_start: directive on line $.\n";
markrad 0:cdf462088d13 34 $block_start = 0; # report only one directive per block
markrad 0:cdf462088d13 35 }
markrad 0:cdf462088d13 36 }
markrad 0:cdf462088d13 37
markrad 0:cdf462088d13 38 close $fh;
markrad 0:cdf462088d13 39 }
markrad 0:cdf462088d13 40
markrad 0:cdf462088d13 41 sub check_dir {
markrad 0:cdf462088d13 42 my ($dirname) = @_;
markrad 0:cdf462088d13 43 for my $file (<$dirname/*.[ch]>) {
markrad 0:cdf462088d13 44 check_file($file);
markrad 0:cdf462088d13 45 }
markrad 0:cdf462088d13 46 }
markrad 0:cdf462088d13 47
markrad 0:cdf462088d13 48 # locate root directory based on invocation name
markrad 0:cdf462088d13 49 my $root = dirname($0) . '/..';
markrad 0:cdf462088d13 50 chdir $root or die "Can't chdir to '$root': $!\n";
markrad 0:cdf462088d13 51
markrad 0:cdf462088d13 52 # just do it
markrad 0:cdf462088d13 53 for my $dir (@directories) {
markrad 0:cdf462088d13 54 check_dir($dir)
markrad 0:cdf462088d13 55 }
markrad 0:cdf462088d13 56
markrad 0:cdf462088d13 57 __END__