merged tag ooo/OOO330_m14
[LibreOffice.git] / offapi / util / checknewapi.pl
blobde7866f69716082338ebac6be327658b185774e5
2 # checknewapi - a perl script to check for new API's
3 # using two outputs from regview and dump the interscetion
4 # of new types
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
9 if($#ARGV != 3)
11 die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n";
14 -e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n";
15 -e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n";
16 -e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n";
18 # debug flag
19 $DEBUG = 0;
21 $main::buildinfo = "$ARGV[2]";
22 $main::regview = "$ARGV[3]";
23 %{$main::reftypes} = ();
24 %{$main::currenttypes} = ();
25 %{$main::removedtypes} = ();
27 open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";
29 if ($DEBUG == 1)
31 open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
34 $first = 1;
35 $linebefore = "";
36 $published = 0;
37 $typeclass = "";
38 while (<FILEIN>)
40 if ($first == 0)
42 if ( $linebefore =~ m#type class: published (.+)# )
44 $published = 1;
45 $typeclass = $1;
46 } elsif ( $linebefore =~ m#type class: (.+)# )
48 $published = 0;
49 $typeclass = $1;
50 } else
52 $published = 0;
53 $typeclass = "";
55 } else
57 $first = 0;
60 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
62 if ($DEBUG == 1)
64 print CURRENT "$1\n";
66 if ( ! exists $main::currenttypes->{$1} )
68 $main::currenttypes->{$1} = { PUBLISHED => $published,
69 TYPECLASS => $typeclass,
70 COUNT => 1 };
71 # print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
74 $linebefore = $_;
76 close( FILEIN );
77 close( CURRENT );
79 open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";
81 if ($DEBUG == 1)
83 open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
86 # reset variables
87 $first = 1;
88 $linebefore = "";
89 $published = 0;
90 $typeclass = "";
91 while (<FILEIN>)
93 if ($first == 0)
95 if ( $linebefore =~ m#type class: published (.+)# )
97 $published = 1;
98 $typeclass = $1;
99 } elsif ( $linebefore =~ m#type class: (.+)# )
101 $published = 0;
102 $typeclass = $1;
103 } else
105 $published = 0;
106 $typeclass = "";
108 } else
110 $first = 0;
113 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
115 if ($DEBUG == 1)
117 print REFERENCE "$1\n";
119 if ( ! exists $main::reftypes->{$1} )
121 $main::reftypes->{$1}++;
123 if ( exists $main::currenttypes->{$1} )
125 $main::currenttypes->{$1}->{COUNT}++;
126 # print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
127 } else
129 if ($published == 0)
131 $main::removedtypes->{$1} = { PUBLISHED => $published,
132 TYPECLASS => $typeclass };
133 } else
135 print "ERROR: type $1 is only in reference type library, this can't be happen\n";
140 $linebefore = $_;
142 close( FILEIN );
143 close( REFERENCE );
146 @typekeys = keys %{$main::currenttypes};
147 $allunotypes = $#typekeys+1;
148 $newunotypes = 0;
149 $newpublished = 0;
150 $draftscount = 0;
151 $draftspublished = 0;
152 foreach $i ( sort @typekeys )
154 if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
155 !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
157 $newunotypes++;
158 my $t = $i;
159 $t =~ s#/#\.#go;
160 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
162 print "published ";
163 $newpublished++;
165 if ( $t =~ m#drafts\.com.+#)
167 $draftscount++;
168 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
170 $draftspublished++;
173 print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
177 # count removed not yet published types
178 $removednotpublished = 0;
180 @removedtypekeys = keys %{$main::removedtypes};
181 foreach $i ( sort @removedtypekeys )
183 $removednotpublished++;
184 my $t = $i;
185 $t =~ s#/#\.#go;
186 print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
189 print "\n=======================================================\n\n";
190 print "Summary [last check for $main::buildinfo]:\n\n";
191 print "Number of UNO types = $allunotypes\n";
192 print "Number of new UNO types = $newunotypes\n";
193 print "New and published types = $newpublished\n";
194 print "New and draft types = $draftscount\n";
195 print "New, draft and published = $draftspublished\n";
196 print "Removed and not published = $removednotpublished\n";
198 exit 0;