xref: /aoo42x/main/offapi/util/checknewapi.pl (revision 841807c9)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21#
22# checknewapi - a perl script to check for new API's
23# using two outputs from regview and dump the interscetion
24# of new types
25#
26
27if($#ARGV != 3)
28{
29    die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n";
30}
31
32-e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n";
33-e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n";
34-e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n";
35
36# debug flag
37$DEBUG = 0;
38
39$main::buildinfo = "$ARGV[2]";
40$main::regview = "$ARGV[3]";
41%{$main::reftypes} = ();
42%{$main::currenttypes} = ();
43%{$main::removedtypes} = ();
44
45open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";
46
47if ($DEBUG == 1)
48{
49	open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
50}
51
52$first = 1;
53$linebefore = "";
54$published = 0;
55$typeclass = "";
56while (<FILEIN>)
57{
58    if ($first == 0)
59    {
60		if ( $linebefore =~ m#type class: published (.+)# )
61		{
62			$published = 1;
63			$typeclass = $1;
64		} elsif ( $linebefore =~ m#type class: (.+)# )
65		{
66			$published = 0;
67			$typeclass = $1;
68		} else
69		{
70			$published = 0;
71			$typeclass = "";
72		}
73	} else
74    {
75		$first = 0;
76    }
77
78    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
79    {
80		if ($DEBUG == 1)
81		{
82			print CURRENT "$1\n";
83		}
84	    if ( ! exists $main::currenttypes->{$1} )
85	    {
86			$main::currenttypes->{$1} = { PUBLISHED => $published,
87										  TYPECLASS => $typeclass,
88										  COUNT => 1 };
89#			print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
90	    }
91    }
92    $linebefore = $_;
93}
94close( FILEIN );
95close( CURRENT );
96
97open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";
98
99if ($DEBUG == 1)
100{
101	open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
102}
103
104# reset variables
105$first = 1;
106$linebefore = "";
107$published = 0;
108$typeclass = "";
109while (<FILEIN>)
110{
111    if ($first == 0)
112    {
113		if ( $linebefore =~ m#type class: published (.+)# )
114		{
115			$published = 1;
116			$typeclass = $1;
117		} elsif ( $linebefore =~ m#type class: (.+)# )
118		{
119			$published = 0;
120			$typeclass = $1;
121		} else
122		{
123			$published = 0;
124			$typeclass = "";
125		}
126	} else
127    {
128		$first = 0;
129    }
130
131    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
132    {
133		if ($DEBUG == 1)
134		{
135			print REFERENCE "$1\n";
136		}
137	    if ( ! exists $main::reftypes->{$1} )
138	    {
139			$main::reftypes->{$1}++;
140
141			if ( exists $main::currenttypes->{$1} )
142			{
143				$main::currenttypes->{$1}->{COUNT}++;
144#				print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
145			} else
146			{
147				if ($published == 0)
148				{
149					$main::removedtypes->{$1} = { PUBLISHED => $published,
150												  TYPECLASS => $typeclass };
151				} else
152				{
153					print "ERROR: type $1 is only in reference type library, this can't be happen\n";
154				}
155			}
156	    }
157    }
158    $linebefore = $_;
159}
160close( FILEIN );
161close( REFERENCE );
162
163
164@typekeys = keys %{$main::currenttypes};
165$allunotypes = $#typekeys+1;
166$newunotypes = 0;
167$newpublished = 0;
168$draftscount = 0;
169$draftspublished = 0;
170foreach $i ( sort @typekeys )
171{
172    if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
173		 !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
174    {
175		$newunotypes++;
176		my $t = $i;
177		$t =~ s#/#\.#go;
178		if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
179		{
180			print "published ";
181			$newpublished++;
182		}
183		if ( $t =~ m#drafts\.com.+#)
184		{
185			$draftscount++;
186			if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
187			{
188				$draftspublished++;
189			}
190		}
191		print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
192	}
193}
194
195# count removed not yet published types
196$removednotpublished = 0;
197
198@removedtypekeys = keys %{$main::removedtypes};
199foreach $i ( sort @removedtypekeys )
200{
201    $removednotpublished++;
202    my $t = $i;
203    $t =~ s#/#\.#go;
204    print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
205}
206
207print "\n=======================================================\n\n";
208print "Summary [last check for $main::buildinfo]:\n\n";
209print "Number of UNO types = $allunotypes\n";
210print "Number of new UNO types = $newunotypes\n";
211print "New and published types = $newpublished\n";
212print "New and draft types = $draftscount\n";
213print "New, draft and published = $draftspublished\n";
214print "Removed and not published = $removednotpublished\n";
215
216exit 0;
217