Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / offapi / util / checknewapi.pl
blob2e70e64f7d9d5a6dad49c0e86573aa4fcf6135e8
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 # checknewapi - a perl script to check for new API's
20 # using two outputs from regview and dump the intersection
21 # of new types
24 if($#ARGV != 3)
26 die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n";
29 -e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n";
30 -e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n";
31 -e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n";
33 # debug flag
34 $DEBUG = 0;
36 $main::buildinfo = "$ARGV[2]";
37 $main::regview = "$ARGV[3]";
38 %{$main::reftypes} = ();
39 %{$main::currenttypes} = ();
40 %{$main::removedtypes} = ();
42 open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";
44 if ($DEBUG == 1)
46 open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
49 $first = 1;
50 $linebefore = "";
51 $published = 0;
52 $typeclass = "";
53 while (<FILEIN>)
55 if ($first == 0)
57 if ( $linebefore =~ m#type class: published (.+)# )
59 $published = 1;
60 $typeclass = $1;
61 } elsif ( $linebefore =~ m#type class: (.+)# )
63 $published = 0;
64 $typeclass = $1;
65 } else
67 $published = 0;
68 $typeclass = "";
70 } else
72 $first = 0;
75 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
77 if ($DEBUG == 1)
79 print CURRENT "$1\n";
81 if ( ! exists $main::currenttypes->{$1} )
83 $main::currenttypes->{$1} = { PUBLISHED => $published,
84 TYPECLASS => $typeclass,
85 COUNT => 1 };
86 # print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
89 $linebefore = $_;
91 close( FILEIN );
92 close( CURRENT );
94 open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";
96 if ($DEBUG == 1)
98 open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
101 # reset variables
102 $first = 1;
103 $linebefore = "";
104 $published = 0;
105 $typeclass = "";
106 while (<FILEIN>)
108 if ($first == 0)
110 if ( $linebefore =~ m#type class: published (.+)# )
112 $published = 1;
113 $typeclass = $1;
114 } elsif ( $linebefore =~ m#type class: (.+)# )
116 $published = 0;
117 $typeclass = $1;
118 } else
120 $published = 0;
121 $typeclass = "";
123 } else
125 $first = 0;
128 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
130 if ($DEBUG == 1)
132 print REFERENCE "$1\n";
134 if ( ! exists $main::reftypes->{$1} )
136 $main::reftypes->{$1}++;
138 if ( exists $main::currenttypes->{$1} )
140 $main::currenttypes->{$1}->{COUNT}++;
141 # print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
142 } else
144 if ($published == 0)
146 $main::removedtypes->{$1} = { PUBLISHED => $published,
147 TYPECLASS => $typeclass };
148 } else
150 print "ERROR: type $1 is only in reference type library, this can't be happen\n";
155 $linebefore = $_;
157 close( FILEIN );
158 close( REFERENCE );
161 @typekeys = keys %{$main::currenttypes};
162 $allunotypes = $#typekeys+1;
163 $newunotypes = 0;
164 $newpublished = 0;
165 $draftscount = 0;
166 $draftspublished = 0;
167 foreach $i ( sort @typekeys )
169 if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
170 !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
172 $newunotypes++;
173 my $t = $i;
174 $t =~ s#/#\.#go;
175 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
177 print "published ";
178 $newpublished++;
180 if ( $t =~ m#drafts\.com.+#)
182 $draftscount++;
183 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
185 $draftspublished++;
188 print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
192 # count removed not yet published types
193 $removednotpublished = 0;
195 @removedtypekeys = keys %{$main::removedtypes};
196 foreach $i ( sort @removedtypekeys )
198 $removednotpublished++;
199 my $t = $i;
200 $t =~ s#/#\.#go;
201 print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
204 print "\n=======================================================\n\n";
205 print "Summary [last check for $main::buildinfo]:\n\n";
206 print "Number of UNO types = $allunotypes\n";
207 print "Number of new UNO types = $newunotypes\n";
208 print "New and published types = $newpublished\n";
209 print "New and draft types = $draftscount\n";
210 print "New, draft and published = $draftspublished\n";
211 print "Removed and not published = $removednotpublished\n";
213 exit 0;