]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EVE/reve-genclass.pl
From Alexandru
[u/mrichter/AliRoot.git] / EVE / reve-genclass.pl
... / ...
CommitLineData
1#!/usr/bin/perl
2
3my ($BINDIR, $BINNAME) = $0 =~ m!^(.*)/(.*)!;
4if ($#ARGV != 1) {
5 print STDERR <<"fnord";
6usage: $BINNAME <module> <class-base>
7 eg: $BINNAME base QuadSet
8 $BINNAME gl QuadSet
9 $BINNAME ged QuadSet
10 $BINNAME gedsubed QuadSet
11Should be in module sub-directory (Reve/ or Alieve/).
12Note that GL and Editor suffixes are not present!
13fnord
14 exit 1;
15}
16
17my $MODULE = $ARGV[0];
18# Flat structure now.
19# die "'$MODULE' not a directory" unless -d $MODULE;
20
21%suff = ( 'gl' => 'GL', 'ged' => 'Editor', 'gedsubed' => 'Editor');
22my $STEM = $ARGV[1];
23my $CLASS = $STEM . $suff{$MODULE};
24
25if ($MODULE eq 'gedsubed') {
26 $replace_xxclass = 1;
27 $XXCLASS = $STEM . 'SubEditor';
28}
29
30# Flat structure now.
31# my $H_NAME = "$MODULE/$CLASS.h";
32# my $C_NAME = "$MODULE/$CLASS.cxx";
33my $H_NAME = "$CLASS.h";
34my $C_NAME = "$CLASS.cxx";
35
36die "File '$H_NAME' already exists" if -e $H_NAME;
37die "File '$C_NAME' already exists" if -e $C_NAME;
38
39sub find_skel {
40 my ($stem, $suff) = @_;
41 my $file1 = "$stem-$MODULE.$suff";
42 return $file1 if -e $file1;
43 my $file2 = "$stem.$suff";
44 return $file2 if -e $file2;
45 die "Skeleton file not found neither as '$file 1' nor '$file2'";
46}
47
48my $SKEL_H_NAME = find_skel(".SKEL", "h");
49my $SKEL_C_NAME = find_skel(".SKEL", "cxx");
50
51print "Using skeleton files '$SKEL_H_NAME' and '$SKEL_C_NAME'\n";
52
53my ($skel_h, $skel_c);
54{
55 my $ex_sla = $/; undef $/;
56 open H, "$SKEL_H_NAME" or die "can't open $SKEL_H_NAME";
57 $skel_h = <H>; close H;
58 open C, "$SKEL_C_NAME" or die "can't open $SKEL_C_NAME";
59 $skel_c = <C>; close C;
60 $/ = $ex_sla;
61}
62
63print "Replacing CLASS -> $CLASS, STEM -> $STEM.\n";
64
65for $f ($skel_h, $skel_c) {
66 $f =~ s/XXCLASS/$XXCLASS/g if ($replace_xxclass);
67 $f =~ s/CLASS/$CLASS/g;
68 $f =~ s/STEM/$STEM/g;
69}
70
71print "Writing files '$H_NAME', '$C_NAME'.\n";
72
73open H, ">$H_NAME" or
74 die "can't open $H_NAME";
75print H $skel_h; close H;
76open H, ">$C_NAME" or
77 die "can't open $C_NAME";
78print H $skel_c; close H;
79
80if($DUMPINFO) {
81 print "# Now you should also edit the link-def file.\n";
82 print "# Remember to run 'make depend'.\n";
83}