summaryrefslogtreecommitdiff
path: root/bin/regenerate_exports.pl
blob: 95e6bf67986991e4cb68dada6bc1f5026c4e6ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# Goes through ACE/TAO and replaces 

use File::Find;
use Cwd;

$args = '';
$root = cwd.'/';

while ($#ARGV >= 0) {
  $args = $args . ' ' . shift @ARGV;
}

# wanted is only used for the File::Find
sub wanted
{
    my $file = $File::Find::name;

    $file =~ s/\.\//$root/;

    if ($File::Find::name =~ /\_export\.h$/i) {
        my $flag = 0;
        my $name = '';

        if (!open (FILE, $file)) {
            print STDERR "Error: Could not open $file\n";
        }

        while (<FILE>) {
            $flag = 1 if ((/generate_export/ || /GenExportH/) && $flag == 0);
            $name = $1 if (/define (\w*)_Export/);
        }

        if ($flag == 1) {
            print "Regenerating: $file\n";
            if ($OSNAME eq 'MSWIn32') { 
                $file =~ s/\//\\/g;
            }
            system ("perl -S generate_export_file.pl $args $name > $file");
        }
        else {
            print "Skipping:     $file\n";
        }
        close FILE;
    }
}


find (\&wanted, ".");