disable-scan.pl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 2010-2019, Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.haxx.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. ###########################################################################
  23. #
  24. use strict;
  25. use warnings;
  26. # the DISABLE options that can be set by configure
  27. my %disable;
  28. # the DISABLE options that are used in C files
  29. my %file;
  30. # we may get the dir root pointed out
  31. my $root=$ARGV[0] || ".";
  32. sub scan_configure {
  33. open S, "<$root/configure.ac";
  34. while(<S>) {
  35. if(/(CURL_DISABLE_[A-Z_]+)/g) {
  36. my ($sym)=($1);
  37. $disable{$sym} = 1;
  38. }
  39. }
  40. close S;
  41. }
  42. sub scan_file {
  43. my ($source)=@_;
  44. open F, "<$source";
  45. while(<F>) {
  46. if(/(CURL_DISABLE_[A-Z_]+)/g) {
  47. my ($sym)=($1);
  48. $file{$sym} = $source;
  49. }
  50. }
  51. close F;
  52. }
  53. sub scan_dir {
  54. my ($dir)=@_;
  55. opendir(my $dh, $dir) || die "Can't opendir $dir: $!";
  56. my @cfiles = grep { /\.c\z/ && -f "$dir/$_" } readdir($dh);
  57. closedir $dh;
  58. for my $f (sort @cfiles) {
  59. scan_file("$dir/$f");
  60. }
  61. }
  62. sub scan_sources {
  63. scan_dir("$root/src");
  64. scan_dir("$root/lib");
  65. scan_dir("$root/lib/vtls");
  66. scan_dir("$root/lib/vauth");
  67. }
  68. scan_configure();
  69. scan_sources();
  70. my $error = 0;
  71. # Check the configure symbols for use in code
  72. for my $s (sort keys %disable) {
  73. if(!$file{$s}) {
  74. printf "Present in configure.ac, not used by code: %s\n", $s;
  75. $error++;
  76. }
  77. }
  78. # Check the code symbols for use in configure
  79. for my $s (sort keys %file) {
  80. if(!$disable{$s}) {
  81. printf "Not set by configure: %s (%s)\n", $s, $file{$s};
  82. $error++;
  83. }
  84. }
  85. exit $error;