mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Added english id caching to speed up builds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29498 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a43fb47ed6
commit
d0fdeca19e
1 changed files with 49 additions and 11 deletions
|
@ -123,6 +123,11 @@ if(!$target && !$update && !$sortfile) {
|
||||||
}
|
}
|
||||||
my @target_parts = split ':', $target;
|
my @target_parts = split ':', $target;
|
||||||
|
|
||||||
|
my $binpath = "";
|
||||||
|
if ($binary =~ m|(.*)/[^/]+|) {
|
||||||
|
$binpath = $1;
|
||||||
|
}
|
||||||
|
|
||||||
my $verbose=$v;
|
my $verbose=$v;
|
||||||
|
|
||||||
my %id; # string to num hash
|
my %id; # string to num hash
|
||||||
|
@ -148,12 +153,6 @@ sub trim {
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub match {
|
|
||||||
my ($string, $pattern)=@_;
|
|
||||||
|
|
||||||
return ($string =~ /^$pattern\z/);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub blank {
|
sub blank {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
}
|
}
|
||||||
|
@ -212,15 +211,44 @@ sub voice {
|
||||||
parsetarget("voice", \$voice, @_);
|
parsetarget("voice", \$voice, @_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub file_is_newer {
|
||||||
|
my ($file1, $file2) = @_;
|
||||||
|
|
||||||
|
my @s1 = stat $file1;
|
||||||
|
my @s2 = stat $file2;
|
||||||
|
|
||||||
|
return 1 if ($s1[9] > $s2[9]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
my %idmap;
|
my %idmap;
|
||||||
my %english;
|
my %english;
|
||||||
if($english) {
|
if($english) {
|
||||||
|
readenglish();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub readenglish {
|
||||||
# For the cases where the english file needs to be scanned/read, we do
|
# For the cases where the english file needs to be scanned/read, we do
|
||||||
# it before we read the translated file. For -b it isn't necessary, but for
|
# it before we read the translated file. For -b it isn't necessary, but for
|
||||||
# -u it is convenient.
|
# -u it is convenient.
|
||||||
|
|
||||||
my @idnum = ((0)); # start with a true number
|
my @idnum = ((0)); # start with a true number
|
||||||
my @vidnum = ((0x8000)); # first voice id
|
my @vidnum = ((0x8000)); # first voice id
|
||||||
|
|
||||||
|
|
||||||
|
if (!$update and file_is_newer("$binpath/english.list", $english)) {
|
||||||
|
open(ENG, "<$binpath/english.list") ||
|
||||||
|
die "Error: can't open $binpath/english.list";
|
||||||
|
while (<ENG>) {
|
||||||
|
my ($user, $id, $value) = split ':', $_;
|
||||||
|
$idmap[$user]{$id} = $value;
|
||||||
|
$english{$id} = 1;
|
||||||
|
}
|
||||||
|
close ENG;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
open(ENG, "<$english") || die "Error: can't open $english";
|
open(ENG, "<$english") || die "Error: can't open $english";
|
||||||
my @phrase;
|
my @phrase;
|
||||||
my $id;
|
my $id;
|
||||||
|
@ -233,12 +261,12 @@ if($english) {
|
||||||
while(<ENG>) {
|
while(<ENG>) {
|
||||||
|
|
||||||
# get rid of DOS newlines
|
# get rid of DOS newlines
|
||||||
$_ =~ s/\r//g;
|
$_ =~ tr/\r//d;
|
||||||
|
|
||||||
if($_ =~ /^ *\<phrase\>/) {
|
if($_ =~ /^ *\<phrase\>/) {
|
||||||
# this is the start of a phrase
|
# this is the start of a phrase
|
||||||
}
|
}
|
||||||
elsif($_ =~ /^ *\<\/phrase\>/) {
|
elsif($_ =~ /\<\/phrase\>/) {
|
||||||
|
|
||||||
# if id is something, when we count and store this phrase
|
# if id is something, when we count and store this phrase
|
||||||
if($id) {
|
if($id) {
|
||||||
|
@ -409,7 +437,7 @@ while(<LANG>) {
|
||||||
$line++;
|
$line++;
|
||||||
|
|
||||||
# get rid of DOS newlines
|
# get rid of DOS newlines
|
||||||
$_ =~ s/\r//g;
|
$_ =~ tr/\r//d;
|
||||||
|
|
||||||
if($_ =~ /^( *\#|[ \t\n\r]*\z)/) {
|
if($_ =~ /^( *\#|[ \t\n\r]*\z)/) {
|
||||||
# comment or empty line - output it if it's part of the header
|
# comment or empty line - output it if it's part of the header
|
||||||
|
@ -640,7 +668,7 @@ MOO
|
||||||
for $i (0 .. $idcount[$users{"core"}]-1) {
|
for $i (0 .. $idcount[$users{"core"}]-1) {
|
||||||
my $name=$idnum[$users{"core"}][$i]; # get the ID name
|
my $name=$idnum[$users{"core"}][$i]; # get the ID name
|
||||||
|
|
||||||
$name =~ s/\"//g; # cut off the quotes
|
$name =~ tr/\"//d; # cut off the quotes
|
||||||
|
|
||||||
printf HFILE_CORE (" %s, /* %d */\n", $name, $i);
|
printf HFILE_CORE (" %s, /* %d */\n", $name, $i);
|
||||||
}
|
}
|
||||||
|
@ -658,7 +686,7 @@ MOO
|
||||||
for $i (0x8001 .. ($voiceid[$users{"core"}]-1)) {
|
for $i (0x8001 .. ($voiceid[$users{"core"}]-1)) {
|
||||||
my $name=$idnum[$users{"core"}][$i]; # get the ID name
|
my $name=$idnum[$users{"core"}][$i]; # get the ID name
|
||||||
|
|
||||||
$name =~ s/\"//g; # cut off the quotes
|
$name =~ tr/\"//d; # cut off the quotes
|
||||||
|
|
||||||
printf HFILE_CORE (" %s, /* 0x%x */\n", $name, $i);
|
printf HFILE_CORE (" %s, /* 0x%x */\n", $name, $i);
|
||||||
}
|
}
|
||||||
|
@ -802,3 +830,13 @@ if($verbose) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!-r "$binpath/english.list") {
|
||||||
|
open(ENGLIST, ">$binpath/english.list") ||
|
||||||
|
die "Failed creating $binpath/english.list";
|
||||||
|
for my $user (keys %users) {
|
||||||
|
for my $id (keys %{$idmap[$user]}) {
|
||||||
|
print ENGLIST "$user:$id:$idmap[$user]{$id}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close ENGLIST;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue