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