-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclonecomp.pl
47 lines (39 loc) · 929 Bytes
/
clonecomp.pl
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
#!/usr/bin/perl
# script to clone an openSMILE component
# .cpp and .hpp files are copied and the classname is updated
if ($#ARGV <3 ) {
print "USAGE: clonecomp.pl <inputCompBase> <outputCompBase> <inputCompName> <outputCompName>\n";
exit;
}
$src="src";
$in=$ARGV[2];
$on=$ARGV[3];
$inT=$in;
$inT=~tr/a-z/A-Z/;
$onT=$on;
$onT=~tr/a-z/A-Z/;
$if=$ARGV[0];
$of=$ARGV[1];
print "$in (in)\n";
print "$on (out)\n";
@ex=("cpp","hpp");
foreach $ext (@ex) {
open(IN,"<$src/".$ARGV[0].".$ext");
open(OUT,">$src/".$ARGV[1].".$ext");
while(<IN>) {
my $line=$_;
$line =~ s/$in/$on/g;
$line =~ s/_$inT/_$onT/;
if ($ext eq "cpp") {
$line =~ s/<$if.hpp>/<$of.hpp>/;
} else {
$onTh = $onT."_HPP";
$line =~ s/^#ifndef __.+?_HPP/#ifndef __$onTh/;
$line =~ s/^#define __.+?_HPP/#define __$onTh/;
$line =~ s/^#endif *\/\/ *__.+?_HPP/#endif \/\/ __$onTh/;
}
print OUT $line;
}
close(OUT);
close(IN);
}