1
0
Fork 0
forked from len0rd/rockbox

Commit FS#12188 - Fix perl scripts that used Switch by Sean Bartell.

Perl 5.14 removed Switch which means that Rockbox will no longer build
with the current release of Perl. The patch replaces Switch
with given/when which was introduced in Perl 5.10.0.

Debian stable has 5.10.1, cygwin 1.7 has 5.10.1 and Mac OSX 10.6 comes
with 5.10.0. I'm not sure what version older versions of OSX come with,
but newer versions are apparently available from Macports.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30169 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Alex Parker 2011-07-19 19:16:54 +00:00
parent 31b7ecb09b
commit 354d8fbc63
2 changed files with 18 additions and 18 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/perl #!/usr/bin/perl
use Switch; use feature "switch";
use List::Util 'shuffle'; # standard from Perl 5.8 and later use List::Util 'shuffle'; # standard from Perl 5.8 and later
my $tempfile = "multigcc.out"; my $tempfile = "multigcc.out";
@ -26,16 +26,16 @@ my $command = join " ", @params;
# count number of cores # count number of cores
my $cores; my $cores;
switch($^O) { given ($^O) {
case "darwin" { when ("darwin") {
chomp($cores = `sysctl -n hw.ncpu`); chomp($cores = `sysctl -n hw.ncpu`);
$cores = 1 if ($?); $cores = 1 if ($?);
} }
case "solaris" { when ("solaris") {
$cores = scalar grep /on-line/i, `psrinfo`; $cores = scalar grep /on-line/i, `psrinfo`;
$cores = 1 if ($?); $cores = 1 if ($?);
} }
else { default {
if (open CPUINFO, "</proc/cpuinfo") { if (open CPUINFO, "</proc/cpuinfo") {
$cores = scalar grep /^processor/i, <CPUINFO>; $cores = scalar grep /^processor/i, <CPUINFO>;
close CPUINFO; close CPUINFO;

View file

@ -17,9 +17,9 @@
use strict; use strict;
use warnings; use warnings;
use feature 'switch';
use File::Basename; use File::Basename;
use File::Copy; use File::Copy;
use Switch;
use vars qw($V $C $t $l $e $E $s $S $i $v); use vars qw($V $C $t $l $e $E $s $S $i $v);
use IPC::Open2; use IPC::Open2;
use IPC::Open3; use IPC::Open3;
@ -74,8 +74,8 @@ sub init_tts {
our $verbose; our $verbose;
my ($tts_engine, $tts_engine_opts, $language) = @_; my ($tts_engine, $tts_engine_opts, $language) = @_;
my %ret = ("name" => $tts_engine); my %ret = ("name" => $tts_engine);
switch($tts_engine) { given ($tts_engine) {
case "festival" { when ("festival") {
print("> festival $tts_engine_opts --server\n") if $verbose; print("> festival $tts_engine_opts --server\n") if $verbose;
my $pid = open(FESTIVAL_SERVER, "| festival $tts_engine_opts --server > /dev/null 2>&1"); my $pid = open(FESTIVAL_SERVER, "| festival $tts_engine_opts --server > /dev/null 2>&1");
my $dummy = *FESTIVAL_SERVER; #suppress warning my $dummy = *FESTIVAL_SERVER; #suppress warning
@ -83,7 +83,7 @@ sub init_tts {
$SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); }; $SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); };
$ret{"pid"} = $pid; $ret{"pid"} = $pid;
} }
case "sapi" { when ("sapi") {
my $toolsdir = dirname($0); my $toolsdir = dirname($0);
my $path = `cygpath $toolsdir -a -w`; my $path = `cygpath $toolsdir -a -w`;
chomp($path); chomp($path);
@ -111,12 +111,12 @@ sub init_tts {
# Shutdown TTS engine if necessary. # Shutdown TTS engine if necessary.
sub shutdown_tts { sub shutdown_tts {
my ($tts_object) = @_; my ($tts_object) = @_;
switch($$tts_object{"name"}) { given ($$tts_object{"name"}) {
case "festival" { when ("festival") {
# Send SIGTERM to festival server # Send SIGTERM to festival server
kill TERM => $$tts_object{"pid"}; kill TERM => $$tts_object{"pid"};
} }
case "sapi" { when ("sapi") {
print({$$tts_object{"stdin"}} "QUIT\r\n"); print({$$tts_object{"stdin"}} "QUIT\r\n");
close($$tts_object{"stdin"}); close($$tts_object{"stdin"});
} }
@ -147,8 +147,8 @@ sub voicestring {
my ($string, $output, $tts_engine_opts, $tts_object) = @_; my ($string, $output, $tts_engine_opts, $tts_object) = @_;
my $cmd; my $cmd;
printf("Generate \"%s\" with %s in file %s\n", $string, $$tts_object{"name"}, $output) if $verbose; printf("Generate \"%s\" with %s in file %s\n", $string, $$tts_object{"name"}, $output) if $verbose;
switch($$tts_object{"name"}) { given ($$tts_object{"name"}) {
case "festival" { when ("festival") {
# festival_client lies to us, so we have to do awful soul-eating # festival_client lies to us, so we have to do awful soul-eating
# work with IPC::open3() # work with IPC::open3()
$cmd = "festival_client --server localhost --otype riff --ttw --output \"$output\""; $cmd = "festival_client --server localhost --otype riff --ttw --output \"$output\"";
@ -168,22 +168,22 @@ sub voicestring {
close(CMD_OUT); close(CMD_OUT);
close(CMD_ERR); close(CMD_ERR);
} }
case "flite" { when ("flite") {
$cmd = "flite $tts_engine_opts -t \"$string\" \"$output\""; $cmd = "flite $tts_engine_opts -t \"$string\" \"$output\"";
print("> $cmd\n") if $verbose; print("> $cmd\n") if $verbose;
`$cmd`; `$cmd`;
} }
case "espeak" { when ("espeak") {
$cmd = "espeak $tts_engine_opts -w \"$output\""; $cmd = "espeak $tts_engine_opts -w \"$output\"";
print("> $cmd\n") if $verbose; print("> $cmd\n") if $verbose;
open(ESPEAK, "| $cmd"); open(ESPEAK, "| $cmd");
print ESPEAK $string . "\n"; print ESPEAK $string . "\n";
close(ESPEAK); close(ESPEAK);
} }
case "sapi" { when ("sapi") {
print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n"); print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n");
} }
case "swift" { when ("swift") {
$cmd = "swift $tts_engine_opts -o \"$output\" \"$string\""; $cmd = "swift $tts_engine_opts -o \"$output\" \"$string\"";
print("> $cmd\n") if $verbose; print("> $cmd\n") if $verbose;
system($cmd); system($cmd);