1
0
forked from 0ad/0ad

Updated Errors.cpp-generating program: stopped use of external DLL, added parameters and help and file/LOC count

This was SVN commit r2558.
This commit is contained in:
Ykkrosh 2005-07-27 21:51:43 +00:00
parent bb65fdc105
commit f9b9e46436
2 changed files with 36 additions and 2 deletions

Binary file not shown.

View File

@ -1,14 +1,40 @@
#!perl -w
++$|;
END { print "\n\nPress enter to exit.\n"; <STDIN> }
use strict;
use warnings;
my $source = '../../source';
my ($source, $output);
for (@ARGV) {
# Note to self: "perl errorlist.pl --source=../../source/i18n --output=../../source/i18n/tests/ps/Errors.cpp"
if (/[-\/]\?|--\?|--help/) {
print <<EOH;
$0 parameters:
--source=../../source - root directory for source code
--output=../../source/ps/Errors.cpp - output file to generate
--help - route to enlightenment
EOH
exit;
} elsif (/^--source="?(.*?)"?$/) {
$source = $1;
} elsif (/^--output="?(.*?)"?$/) {
$output = $1;
}
}
$source ||= '../../source';
$output ||= "$source/ps/Errors.cpp";
print "Reading files from $source... ";
my (%topgroups, %groups, %types);
my @files = cpp_files("$source/");
my $loc = 0;
for (@files) {
open my $f, $_ or die "Error opening file '$_' ($!)";
while (<$f>) {
@ -21,15 +47,22 @@ for (@files) {
$types{join '~', split /,\s*/, $1} = 1;
}
}
++$loc;
}
}
# Add commas to number in groups of three
1 while $loc =~ s/(\d+)(\d{3})/$1,$2/;
print "(".@files." files read - $loc lines of code)\n";
print "Generating $output... ";
# Add "PSERROR_Error_InvalidError", so that an error to throw when being
# told to throw an error that doesn't exist exists.
$topgroups{Error} = 1;
$types{'Error~InvalidError'} = 1;
open my $out, '>', "$source/ps/Errors.cpp" or die "Error opening $source/ps/Errors.cpp ($!)";
open my $out, '>', "$output" or die "Error opening $output ($!)";
print $out <<'.';
// Auto-generated by errorlist.pl - do not edit.
@ -199,6 +232,7 @@ print $out <<".";
}
.
print "Finished.\n";
sub cpp_files {
opendir my $d, $_[0] or die "Error opening directory '$_[0]' ($!)";