source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/tools/MakeListOfClasses.pl @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 2.0 KB
Line 
1#!/usr/bin/perl
2# Dmitry Naumov
3
4$packname  = $ARGV[0];
5$InputList    = $ARGV[1];
6$ESAFDOC = $ARGV[2];
7$listofclasses =  "$ESAFDOC/ListOfClasses";
8$listofpaths   =  "$ESAFDOC/ListOfPaths";
9
10my @classes = ();
11
12&makelist();
13
14sub makelist()
15{
16    if ($InputList eq "dummy") {
17        $linkdef ="include/LinkDef.hh";
18    } else {
19        $linkdef  ="include/$InputList[0]LinkDef.hh";
20        $packname =$InputList;
21    }
22    open(in,$linkdef);
23
24    my $pwd = `pwd`;
25    chomp($pwd);
26
27    while(<in>)
28    {
29        # collect the entries of LinkDef
30        if ( $_ =~ /\#pragma link C\+\+ (class|namespace)[ ]+([^\+\-;]+)/o ) {
31            push @classes,$2;
32        }
33    }
34    close(in);
35
36    if ($#classes ne -1 && update_paths($pwd) ) {
37        print "Current directory added to ListOfPaths\n";
38    } 
39
40    if ( my $n = update_names(@classes) ) {
41        print "$n entries added to ListOfClasses.\n";
42    }
43
44}
45
46sub update_names() {
47    my @names = @_;
48    my $nEntries = 0;
49
50    # open fo reading
51    open(fileNames,"<$listofclasses");
52    for my $entry (<fileNames>) {
53        # loop on the names already in ListOfClasses
54        $nEntries++;
55        chomp($entry);
56
57        for($idx = 0; $idx < @names; ) {
58            # loop on the LinkDef classes
59            # if the name is already in ListOfClasses, remove it frm the list
60            if ( @names[$idx] eq $entry ) {
61                splice(@names,$idx,1);
62                last;
63            }
64            $idx++;
65        }
66
67    }
68    close fileNames;
69
70    # re-open the file in append mode
71    open(fileNames,">>$listofclasses");
72    # append the new classes
73    for(@names) { print fileNames "$_\n"; }
74    close fileNames;
75
76    return $#names+1;
77}
78
79sub update_paths()
80{
81    my $pwd = @_[0];
82
83    open(filePaths,"<$listofpaths") ;
84    while(<filePaths>)
85    {
86        chomp;
87        if($_ eq $pwd)
88        {
89            close(filePaths);
90            return 0;
91        }
92    }
93    close(filePaths);
94
95    open(filePaths,">>$listofpaths") ;
96#    print "$pwd\n";
97    print filePaths "$pwd\n";
98    close(filePaths);
99
100    return 1;
101}
102
Note: See TracBrowser for help on using the repository browser.