mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 08:48:17 +00:00
Fix check-doxy-blocks.pl to run from root dir
Modify tests/scripts/check-doxy-blocks.pl to ensure that: * It can only be run from the mbed TLS root directory. * An error code is returned to the environment when a potential error in the source code is found.
This commit is contained in:
parent
5634b8609b
commit
d3f0f5e1c8
1 changed files with 13 additions and 6 deletions
|
@ -19,6 +19,10 @@ my @directories = qw(include/mbedtls library doxygen/input);
|
|||
# everything with a backslach except '\0' and backslash at EOL
|
||||
my $doxy_re = qr/\\(?!0|\n)/;
|
||||
|
||||
# Return an error code to the environment if a potential error in the
|
||||
# source code is found.
|
||||
my $exit_code = 0;
|
||||
|
||||
sub check_file {
|
||||
my ($fname) = @_;
|
||||
open my $fh, '<', $fname or die "Failed to open '$fname': $!\n";
|
||||
|
@ -32,6 +36,7 @@ sub check_file {
|
|||
if ($block_start and $line =~ m/$doxy_re/) {
|
||||
print "$fname:$block_start: directive on line $.\n";
|
||||
$block_start = 0; # report only one directive per block
|
||||
$exit_code = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,13 +50,15 @@ sub check_dir {
|
|||
}
|
||||
}
|
||||
|
||||
# locate root directory based on invocation name
|
||||
my $root = dirname($0) . '/..';
|
||||
chdir $root or die "Can't chdir to '$root': $!\n";
|
||||
|
||||
# just do it
|
||||
# Check that the script is being run from the project's root directory.
|
||||
for my $dir (@directories) {
|
||||
check_dir($dir)
|
||||
if (! -d $dir) {
|
||||
die "This script must be run from the mbed TLS root directory";
|
||||
} else {
|
||||
check_dir($dir)
|
||||
}
|
||||
}
|
||||
|
||||
exit $exit_code;
|
||||
|
||||
__END__
|
||||
|
|
Loading…
Reference in a new issue