White-space.
[u/mrichter/AliRoot.git] / EVE / reve-genclass.pl
CommitLineData
915dabe1 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
3250fd54 10Should be in module sub-directory (Reve/ or Alieve/).
0473d1af 11Note that GL and Editor suffixes are not present!
915dabe1 12fnord
13 exit 1;
14}
15
16my $MODULE = $ARGV[0];
17# Flat structure now.
18# die "'$MODULE' not a directory" unless -d $MODULE;
19
20%suff = ( 'gl' => 'GL', 'ged' => 'Editor');
21my $STEM = $ARGV[1];
22my $CLASS = $STEM . $suff{$MODULE};
23
24# Flat structure now.
25# my $H_NAME = "$MODULE/$CLASS.h";
26# my $C_NAME = "$MODULE/$CLASS.cxx";
27my $H_NAME = "$CLASS.h";
28my $C_NAME = "$CLASS.cxx";
29
30die "File '$H_NAME' already exists" if -e $H_NAME;
31die "File '$C_NAME' already exists" if -e $C_NAME;
32
33sub find_skel {
34 my ($stem, $suff) = @_;
35 my $file1 = "$stem-$MODULE.$suff";
36 return $file1 if -e $file1;
37 my $file2 = "$stem.$suff";
38 return $file2 if -e $file2;
39 die "Skeleton file not found neither as '$file 1' nor '$file2'";
40}
41
42my $SKEL_H_NAME = find_skel(".SKEL", "h");
43my $SKEL_C_NAME = find_skel(".SKEL", "cxx");
44
45print "Using skeleton files '$SKEL_H_NAME' and '$SKEL_C_NAME'\n";
46
47my ($skel_h, $skel_c);
48{
49 my $ex_sla = $/; undef $/;
50 open H, "$SKEL_H_NAME" or die "can't open $SKEL_H_NAME";
51 $skel_h = <H>; close H;
52 open C, "$SKEL_C_NAME" or die "can't open $SKEL_C_NAME";
53 $skel_c = <C>; close C;
54 $/ = $ex_sla;
55}
56
57print "Replacing CLASS -> $CLASS, STEM -> $STEM.\n";
58
59for $f ($skel_h, $skel_c) {
60 $f =~ s/CLASS/$CLASS/g;
61 $f =~ s/STEM/$STEM/g;
62}
63
64print "Writing files '$H_NAME', '$C_NAME'.\n";
65
66open H, ">$H_NAME" or
67 die "can't open $H_NAME";
68print H $skel_h; close H;
69open H, ">$C_NAME" or
70 die "can't open $C_NAME";
71print H $skel_c; close H;
72
73if($DUMPINFO) {
74 print "# Now you should also edit the link-def file.\n";
75 print "# Remember to run 'make depend'.\n";
76}