xref: /aoo42x/main/offapi/util/checknewapi.pl (revision cdf0e10c)
1#
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
5#
6# Copyright 2000, 2010 Oracle and/or its affiliates.
7#
8
9if($#ARGV != 3)
10{
11    die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n";
12}
13
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";
17
18# debug flag
19$DEBUG = 0;
20
21$main::buildinfo = "$ARGV[2]";
22$main::regview = "$ARGV[3]";
23%{$main::reftypes} = ();
24%{$main::currenttypes} = ();
25%{$main::removedtypes} = ();
26
27open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";
28
29if ($DEBUG == 1)
30{
31	open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
32}
33
34$first = 1;
35$linebefore = "";
36$published = 0;
37$typeclass = "";
38while (<FILEIN>)
39{
40    if ($first == 0)
41    {
42		if ( $linebefore =~ m#type class: published (.+)# )
43		{
44			$published = 1;
45			$typeclass = $1;
46		} elsif ( $linebefore =~ m#type class: (.+)# )
47		{
48			$published = 0;
49			$typeclass = $1;
50		} else
51		{
52			$published = 0;
53			$typeclass = "";
54		}
55	} else
56    {
57		$first = 0;
58    }
59
60    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
61    {
62		if ($DEBUG == 1)
63		{
64			print CURRENT "$1\n";
65		}
66	    if ( ! exists $main::currenttypes->{$1} )
67	    {
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";
72	    }
73    }
74    $linebefore = $_;
75}
76close( FILEIN );
77close( CURRENT );
78
79open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";
80
81if ($DEBUG == 1)
82{
83	open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
84}
85
86# reset variables
87$first = 1;
88$linebefore = "";
89$published = 0;
90$typeclass = "";
91while (<FILEIN>)
92{
93    if ($first == 0)
94    {
95		if ( $linebefore =~ m#type class: published (.+)# )
96		{
97			$published = 1;
98			$typeclass = $1;
99		} elsif ( $linebefore =~ m#type class: (.+)# )
100		{
101			$published = 0;
102			$typeclass = $1;
103		} else
104		{
105			$published = 0;
106			$typeclass = "";
107		}
108	} else
109    {
110		$first = 0;
111    }
112
113    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
114    {
115		if ($DEBUG == 1)
116		{
117			print REFERENCE "$1\n";
118		}
119	    if ( ! exists $main::reftypes->{$1} )
120	    {
121			$main::reftypes->{$1}++;
122
123			if ( exists $main::currenttypes->{$1} )
124			{
125				$main::currenttypes->{$1}->{COUNT}++;
126#				print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
127			} else
128			{
129				if ($published == 0)
130				{
131					$main::removedtypes->{$1} = { PUBLISHED => $published,
132												  TYPECLASS => $typeclass };
133				} else
134				{
135					print "ERROR: type $1 is only in reference type library, this can't be happen\n";
136				}
137			}
138	    }
139    }
140    $linebefore = $_;
141}
142close( FILEIN );
143close( REFERENCE );
144
145
146@typekeys = keys %{$main::currenttypes};
147$allunotypes = $#typekeys+1;
148$newunotypes = 0;
149$newpublished = 0;
150$draftscount = 0;
151$draftspublished = 0;
152foreach $i ( sort @typekeys )
153{
154    if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
155		 !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
156    {
157		$newunotypes++;
158		my $t = $i;
159		$t =~ s#/#\.#go;
160		if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
161		{
162			print "published ";
163			$newpublished++;
164		}
165		if ( $t =~ m#drafts\.com.+#)
166		{
167			$draftscount++;
168			if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
169			{
170				$draftspublished++;
171			}
172		}
173		print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
174	}
175}
176
177# count removed not yet published types
178$removednotpublished = 0;
179
180@removedtypekeys = keys %{$main::removedtypes};
181foreach $i ( sort @removedtypekeys )
182{
183    $removednotpublished++;
184    my $t = $i;
185    $t =~ s#/#\.#go;
186    print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
187}
188
189print "\n=======================================================\n\n";
190print "Summary [last check for $main::buildinfo]:\n\n";
191print "Number of UNO types = $allunotypes\n";
192print "Number of new UNO types = $newunotypes\n";
193print "New and published types = $newpublished\n";
194print "New and draft types = $draftscount\n";
195print "New, draft and published = $draftspublished\n";
196print "Removed and not published = $removednotpublished\n";
197
198exit 0;
199