williamr/find_public_apis.pl
changeset 2 a600c1a596f7
child 3 8b87ea768cb8
equal deleted inserted replaced
1:4a4ca5a019bb 2:a600c1a596f7
       
     1 #!/usr/bin/perl
       
     2 
       
     3 # Copyright (c) 2009 Symbian Foundation Ltd
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation Ltd - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # Identify "Public APIs" - defined as
       
    16 # 1. Files in epoc32\include which are not in epoc32\include\platform, 
       
    17 # 2. And contain either no Symbian API classification doxygen tags (Public by export)
       
    18 # 3. Or contain @publishedAll (Public by tag - now deprecated)
       
    19 
       
    20 use strict;
       
    21 my $debug = 0;
       
    22 
       
    23 sub is_public_api($$)
       
    24   {
       
    25   my ($file,$name) = @_;
       
    26   
       
    27   if ($name =~ /^epoc32\/include\/platform\//)
       
    28     {
       
    29     # /epoc32/include/platform files are "Platform by export"
       
    30     return 0; # Not public
       
    31     }
       
    32   
       
    33   open FILE, "<$file" or print "ERROR: Cannot open $file: $!\n" and return 1; # assume Public
       
    34   my @lines = <FILE>; # they are all of a modest size
       
    35   close FILE;
       
    36   
       
    37   my @apitaglines = grep /\@published|\@internal/, @lines;
       
    38   if (scalar @apitaglines == 0)
       
    39     {
       
    40     # no API classification tags - must be "Public by export" 
       
    41     return 1; # Public API
       
    42     }
       
    43   
       
    44   if ($debug)
       
    45     {
       
    46     print join("\n\t", $file, @apitaglines), "\n";
       
    47     }
       
    48   my @publishedAll = grep /\@publishedAll/, @apitaglines;
       
    49   if (scalar @publishedAll == 0)
       
    50     {
       
    51     # the API classification tags are all @publishedPartner or @internal
       
    52     return 0; # not public
       
    53     }
       
    54   # contains at least one @publishedAll element - must be "Public by tag"
       
    55   return 1; # Public API
       
    56   }
       
    57 
       
    58 sub scan_directory($$)
       
    59   {
       
    60   my ($path, $name) = @_;
       
    61   
       
    62   opendir DIR, $path;
       
    63   my @files = grep !/^\.\.?$/, readdir DIR;
       
    64   closedir DIR;
       
    65   
       
    66   foreach my $file (@files)
       
    67     {
       
    68     my $newpath = "$path/$file";
       
    69     my $newname = "$name/$file";
       
    70     
       
    71     if (-d $newpath)
       
    72       {
       
    73       scan_directory($newpath, $newname);
       
    74       next;
       
    75       }
       
    76     
       
    77     if (is_public_api($newpath,$newname))
       
    78       {
       
    79       print "$newname\n";
       
    80       }
       
    81     else
       
    82       {
       
    83       # print "PARTNER\t$newname\n";
       
    84       }
       
    85     }
       
    86   }
       
    87 
       
    88 scan_directory("/epoc32/include", "epoc32/include");