2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 2010-2011, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 # This script grew out of help from Przemyslaw Iskra and Balint Szilakszi
25 # a late evening in the #curl IRC channel on freenode.
30 use vars qw($Cpreprocessor);
33 # configurehelp perl module is generated by configure script
36 require configurehelp;
37 configurehelp->import(qw(
42 # Set default values if configure has not generated a configurehelp.pm file.
43 # This is the case with cmake.
45 $Cpreprocessor = 'cpp';
48 # we may get the dir root pointed out
49 my $root=$ARGV[0] || ".";
51 # need an include directory when building out-of-tree
52 my $i = ($ARGV[1]) ? "-I$ARGV[1] " : '';
54 my $h = "$root/include/curl/curl.h";
55 my $mh = "$root/include/curl/multi.h";
65 open H_IN, "-|", "$Cpreprocessor $i$h" || die "Cannot preprocess curl.h";
67 if ( /enum\s+(\S+\s+)?{/ .. /}/ ) {
75 close H_IN || die "Error preprocessing curl.h";
81 if (/^#define (CURL[A-Za-z0-9_]*)/) {
91 open S, "<$root/docs/libcurl/symbols-in-versions";
93 if(/(^CURL[^ \n]*) *(.*)/) {
94 my ($sym, $rest)=($1, $2);
96 print "Detected duplicate symbol: $sym\n";
101 my @a=split(/ +/, $rest);
103 # this symbol is documented to have been present the last time
112 for my $e (sort @syms) {
113 # OBSOLETE - names that are just placeholders for a position where we
114 # previously had a name, that is now removed. The OBSOLETE names should
115 # never be used for anything.
117 # CURL_EXTERN - is a define used for libcurl functions that are external,
118 # public. No app or other code should ever use it.
120 # *_LAST and *_LASTENTRY are just prefix for the placeholders used for the
121 # last entry in many enum series.
124 if($e =~ /(OBSOLETE|^CURL_EXTERN|_LAST\z|_LASTENTRY\z)/) {
142 # now scan through all symbols that were present in the symbols-in-versions
143 # but not in the headers
145 # If the symbols were marked 'removed' in symbols-in-versions we don't output
146 # anything about it since that is perfectly fine.
151 for my $e (sort keys %doc) {
152 if(($doc{$e} ne "used") && !$rem{$e}) {
155 print "Missing symbols mentioned in symbols-in-versions\n";
156 print "Add them to a header, or mark them as removed.\n";
166 printf "%d symbols in headers (out of which %d are ignored)\n", scalar(@syms),
168 printf "%d symbols in headers are interesting\n",
169 scalar(@syms)- $ignored;
170 printf "%d symbols are listed in symbols-in-versions\n (out of which %d are listed as removed)\n", scalar(keys %doc), scalar(keys %rem);
171 printf "%d symbols in symbols-in-versions should match the ones in headers\n", scalar(keys %doc) - scalar(keys %rem);
175 exit 2; # there are stuff to attend to!