-
Notifications
You must be signed in to change notification settings - Fork 1
/
pri.pl
47 lines (40 loc) · 1.15 KB
/
pri.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
use strict;
use warnings;
my @dirs = ("src");
foreach my $dir (@dirs) {
opendir(my $dh, $dir) or die "cannot open directory $dir: $!";
my @files;
while (readdir $dh) {
push @files, $_;
}
closedir $dh;
my @headers = grep(/.*\.h$/, @files);
my @sources = grep(/.*\.cpp$/, @files);
@headers = sort @headers;
@sources = sort @sources;
my $script = $0;
$script =~ s/^[.\/\\]+//;
my $output = "### THIS FILE IS GENERATED BY $script - DO NOT EDIT IT BY HAND\n\n";
if (scalar @headers > 0) {
$output = $output . "HEADERS +=";
foreach (@headers) {
$output = $output . " \\\n $dir/$_";
}
}
if (scalar @headers > 0 and scalar @sources > 0) {
$output = $output . "\n\n";
}
if (scalar @sources > 0) {
$output = $output . "SOURCES +=";
foreach (@sources) {
$output = $output . " \\\n $dir/$_";
}
}
$output = $output . "\n";
my $outfile = "$dir.pri";
open (my $fh, ">", $outfile) or die "cannot open file $outfile for writing: $!";
print $fh $output;
close $fh;
}
exit 0;