diff --git a/autobuild.pl b/autobuild.pl index ac1a48b79..dabeaff3c 100755 --- a/autobuild.pl +++ b/autobuild.pl @@ -777,6 +777,16 @@ (\%) my $LINE_FROM = $command->{LINE_FROM}; my $LINE_TO = $command->{LINE_FROM}; my $args = $command->{ARGS}; + my $required = $command->{REQUIRED}; + + if (!defined($required)) { + if (exists($command_table{$NAME}->{required_by_default})) { + $required = $command_table{$NAME}->{required_by_default}; + } + else { + $required = 0; + } + } my $CMD = "Executing \"$NAME\" line"; if (!defined $LINE_TO || $LINE_FROM == $LINE_TO) { @@ -883,7 +893,7 @@ (\%) if (defined ($failure)) { print STDERR "ERROR: While $CMD $CMD2:\n" if ($verbose <= 1); print STDERR " The command failed"; - if ($failure eq 'fatal') { + if ($required || $failure eq 'fatal') { $status = 1; if (!$keep_going) { print STDERR ", exiting.\n"; diff --git a/command/anonymous_shell.pm b/command/anonymous_shell.pm index 26c9ef304..7e5c285a4 100644 --- a/command/anonymous_shell.pm +++ b/command/anonymous_shell.pm @@ -9,6 +9,8 @@ use Cwd; use FileHandle; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -54,20 +56,15 @@ sub Run ($) $root = $1; } - my $current_dir = getcwd (); - - if (!chdir $root) { - print STDERR __FILE__, ": Cannot change to $root\n"; - return 0; - } + my $cd = ChangeDir->new({dir => $root}); + return {'failure' => 'fatal'} unless ($cd); print "Running: ${options}\n"; - system ($options); - - chdir $current_dir; + my $result = {}; + utility::run_command ($options, $result); - return 1; + return $result; } ############################################################################## diff --git a/command/auto_run_tests.pm b/command/auto_run_tests.pm index b35690d7b..3d3a190fe 100644 --- a/command/auto_run_tests.pm +++ b/command/auto_run_tests.pm @@ -9,6 +9,8 @@ use Cwd; use FileHandle; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -178,9 +180,10 @@ sub Run ($) print "Running: $command\n"; } - system ($command); + my $result = {}; + utility::run_command ($command, $result); chdir $current_dir; - return 1; + return $result; } ############################################################################## diff --git a/command/check_compiler.pm b/command/check_compiler.pm index 4df7f7454..e84aef75c 100644 --- a/command/check_compiler.pm +++ b/command/check_compiler.pm @@ -7,6 +7,8 @@ use warnings; use Cwd; +use common::utility; + ############################################################################### # Constructor @@ -14,7 +16,9 @@ sub new { my $proto = shift; my $class = ref ($proto) || $proto; - my $self = {}; + my $self = { + 'required_by_default' => 1, + }; bless ($self, $class); return $self; @@ -44,94 +48,94 @@ sub Run ($) print "================ Compiler version ================\n"; - if($compiler =~ m/^(\w*-)*(gcc|g\+\+|g\+\+-?[0-9]|ccsimpc|ccpentium|ccppc|c\+\+ppc|c\+\+pentium)/ || $compiler =~ m/^clang(\+\+)?(-[0-9\.]+)?/){ - system($compiler." -v 2>&1"); - if($compiler =~ m/^(\w*-)*(gcc|g\+\+|g\+\+-?[0-9])/ || $compiler =~ m/^clang(\+\+)?(-[0-9\.]+)?/){ - my $linker = `$compiler -print-prog-name=ld`; - chomp $linker; - if($linker =~ m/ld$/){ - system($linker." -v 2>&1"); - } - elsif($linker =~ m/ccs/){ - system($linker." -V 2>&1"); - } - } - } - elsif(lc $compiler =~ m/^(sun_cc|studio|suncc)/) { - system("CC -V"); - } - elsif(lc $compiler eq "mingwcygwin"){ - system("g++ -v -mno-cygwin"); - } - elsif(lc $compiler eq "bcc32"){ - system("bcc32 --version"); + if ($compiler =~ m/^(\w*-)*(gcc|g\+\+|clang|ccsimpc|(cc|c\+\+)(pentium|ppc))/) { + if (!utility::run_command ("$compiler -v 2>&1")) { + return 0; + } + if ($compiler =~ /^(\w*-)*(gcc|g\+\+|clang)/) { + my $linker = `$compiler -print-prog-name=ld`; + chomp $linker; + if ($linker =~ m/ld$/) { + return utility::run_command ($linker." -v 2>&1"); + } + elsif ($linker =~ m/ccs/) { + return utility::run_command ($linker." -V 2>&1"); + } + else { + print STDERR __FILE__, ": ERROR: Unexpected Linker: $linker\n"; + } + } } - elsif(lc $compiler eq "bcc32c"){ - system("bcc32c --version"); + elsif (lc $compiler =~ m/^(sun_cc|studio|suncc)/) { + return utility::run_command ("CC -V"); } - elsif(lc $compiler eq "bcc64"){ - system("bcc64 --version"); + elsif (lc $compiler eq "mingwcygwin") { + return utility::run_command ("g++ -v -mno-cygwin"); } - elsif(lc $compiler eq "bccx"){ - system("bccx --version"); + elsif (lc $compiler =~ m/^(bcc(.*))$/) { + return utility::run_command ("$1 --version"); } - elsif(lc $compiler eq "kylix"){ - system("bc++ -V"); + elsif (lc $compiler eq "kylix") { + return utility::run_command ("bc++ -V"); } - elsif($compiler =~ m/^(dcc|dplus)/){ - system($compiler . " -V"); + elsif ($compiler =~ m/^(dcc|dplus)/) { + return utility::run_command ($compiler . " -V"); } - elsif(lc $compiler eq "dm"){ - system("scppn"); + elsif (lc $compiler eq "dm") { + return utility::run_command ("scppn"); } - elsif(lc $compiler =~ m/^(msvc|vc|cl)/){ - system("cl"); + elsif (lc $compiler =~ m/^(msvc|vc|cl)/) { + return utility::run_command ("cl"); } - elsif(lc $compiler eq "deccxx"){ - system("cxx/VERSION"); + elsif (lc $compiler eq "deccxx") { + return utility::run_command ("cxx/VERSION"); } - elsif(lc $compiler eq "cxx"){ - system("cxx -V"); + elsif (lc $compiler eq "cxx") { + return utility::run_command ("cxx -V"); } - elsif(lc $compiler eq "acc"){ - system("aCC -V"); + elsif (lc $compiler eq "acc") { + return utility::run_command ("aCC -V"); } - elsif(lc $compiler eq "pgcc"){ - system("pgCC -V"); + elsif (lc $compiler eq "pgcc") { + return utility::run_command ("pgCC -V"); } - elsif(lc $compiler eq "mipspro"){ - system("CC -version"); + elsif (lc $compiler eq "mipspro") { + return utility::run_command ("CC -version"); } - elsif(lc $compiler eq "doxygen"){ - system("doxygen --version"); + elsif (lc $compiler eq "doxygen") { + return utility::run_command ("doxygen --version"); } - elsif($compiler =~ m/^(ecc|icc|icpc)/){ - system($compiler." -V 2>&1"); + elsif ($compiler =~ m/^(ecc|icc|icpc)/) { + return utility::run_command ("$compiler -V 2>&1"); } - elsif(lc $compiler eq "icl"){ - system("icl"); + elsif (lc $compiler eq "icl") { + return utility::run_command ("icl"); } - elsif($compiler =~ m/^(ibmcxx)/i ){ - if(-x "/usr/bin/lslpp"){ - system("/usr/bin/lslpp -l ibmcxx.cmp | grep ibmcxx.cmp"); - }else { - print "ERROR: Could not find /usr/bin/lslpp!!\n"; + elsif ($compiler =~ m/^(ibmcxx)/i) { + if (-x "/usr/bin/lslpp") { + return utility::run_command ("/usr/bin/lslpp -l ibmcxx.cmp | grep ibmcxx.cmp"); + } + else { + print STDERR __FILE__, ": " . + "ERROR: Could not find /usr/bin/lslpp!!\n"; } } - elsif($compiler =~ m/^(vacpp)/i ){ - if(-x "/usr/bin/lslpp"){ - system("/usr/bin/lslpp -l | grep -i \'C++ Compiler\'"); - }else { - print "ERROR: Could not find /usr/bin/lslpp!!\n"; + elsif ($compiler =~ m/^(vacpp)/i) { + if (-x "/usr/bin/lslpp") { + return utility::run_command ("/usr/bin/lslpp -l | grep -i \'C++ Compiler\'"); + } + else { + print STDERR __FILE__, ": " . + "ERROR: Could not find /usr/bin/lslpp!!\n"; } } - elsif(lc $compiler eq "c89"){ - system("c89 -Whelp 2>&1 | tail -2"); + elsif (lc $compiler eq "c89") { + return utility::run_command ("c89 -Whelp 2>&1 | tail -2"); } - else{ - system($compiler); + else { + print STDERR __FILE__, ": " . "Invalid Compiler Option: $compiler\n"; } - return 1; + return 0; } ############################################################################## diff --git a/command/make.pm b/command/make.pm index 65671a39f..38cdc07e4 100644 --- a/command/make.pm +++ b/command/make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -121,7 +123,7 @@ sub Run ($) { if(!chdir $dir) { print STDERR __FILE__, ": Cannot change to $dir\n"; - return 1; + return 0; } } @@ -134,7 +136,8 @@ sub Run ($) my $command; my $pattern; - my $ret = 0; + my $success = 0; + my $result = {}; if ($options =~ s/find=([^\s]*)//) { $pattern = $1; @@ -146,18 +149,17 @@ sub Run ($) next unless -f $makefile; # skip directories $command = "$make_program -f $makefile $options"; print "Running: $command\n"; - $ret = system ($command); + $success = utility::run_command ($command, $result); } } else { $options =~ s/'/"/g; $command = "$make_program $options"; print "Running: $command\n"; - $ret = system ($command); + $success = utility::run_command ($command, $result); } - if( $ret != 0 ) - { + if (!$success) { my $working_dir = getcwd(); ## If we used 'make -C' to change the directory, let's @@ -168,7 +170,7 @@ sub Run ($) $working_dir = "$working_dir/$1"; } - print "[BUILD ERROR detected in $working_dir]\n "; + print STDERR "[BUILD ERROR detected in $working_dir]\n "; } chdir $current_dir; @@ -176,7 +178,7 @@ sub Run ($) ## Return PWD to the correct setting $ENV{PWD} = getcwd(); - return 1; + return $result; } ############################################################################## diff --git a/command/shell.pm b/command/shell.pm index 0d1d5e4a3..fd4d825eb 100644 --- a/command/shell.pm +++ b/command/shell.pm @@ -9,6 +9,8 @@ use Cwd; use FileHandle; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -56,20 +58,15 @@ sub Run ($) main::PrintStatus ('Setup', 'Shell'); - my $current_dir = getcwd (); - - if (!chdir $root) { - print STDERR __FILE__, ": Cannot change to $root\n"; - return 0; - } + my $cd = ChangeDir->new({dir => $root}); + return {'failure' => 'fatal'} unless ($cd); print "Running: ${options}\n"; - system ($options); - - chdir $current_dir; + my $result = {}; + utility::run_command ($options, $result); - return 1; + return $result; } ############################################################################## diff --git a/command/test.pm b/command/test.pm index bb94b008d..8514c6c7e 100644 --- a/command/test.pm +++ b/command/test.pm @@ -13,6 +13,8 @@ use warnings; use Cwd; use FileHandle; +use common::utility; + ############################################################################### # Constructor @@ -60,20 +62,15 @@ sub Run ($) main::PrintStatus ('Test', 'Shell'); - my $current_dir = getcwd (); - - if (!chdir $project_root) { - print STDERR __FILE__, ": Cannot change to $project_root\n"; - return 0; - } + my $cd = ChangeDir->new({dir => $project_root}); + return {'failure' => 'fatal'} unless ($cd); print "Running: ${options}\n"; - system ($options); - - chdir $current_dir; + my $result = {}; + my $status = utility::run_command ($options, $result); - return 1; + return $result; } ############################################################################## diff --git a/command/vc6make.pm b/command/vc6make.pm index ac6234da1..89c413388 100644 --- a/command/vc6make.pm +++ b/command/vc6make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -80,29 +82,26 @@ sub Run ($) my $workspace = undef; if ($options =~ /"([^"]+\.dsw)"/) { - $workspace = $1; + $workspace = $1; } elsif ($options =~ /([\w\-\\\/\.]+\.dsw)/) { - $workspace = $1; + $workspace = $1; } + my $result = {}; if (defined $workspace && ! -r $workspace) { - print "Skipping: $workspace not found\n"; + print "Skipping: $workspace not found\n"; } else { - print "Running: $command\n"; - - my $ret = system ($command); - - if ($ret != 0) - { - print "[BUILD ERROR detected in ", getcwd(), "]\n"; - } + print "Running: $command\n"; + if (!utility::run_command ($command, $result)) { + print STDERR "[BUILD ERROR detected in ", getcwd(), "]\n"; + } } chdir $current_dir; - return 1; + return $result; } ############################################################################## diff --git a/command/vc7make.pm b/command/vc7make.pm index 493bdfae5..7eb14f14b 100644 --- a/command/vc7make.pm +++ b/command/vc7make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -99,28 +101,26 @@ sub Run ($) my $workspace = undef; if ($options =~ /"([^"]+\.sln)"/) { - $workspace = $1; + $workspace = $1; } elsif ($options =~ /([\w\.\-\\\/]+\.sln)/) { - $workspace = $1; + $workspace = $1; } + my $result = {}; if (defined $workspace && ! -r $workspace) { - print "Skipping: $workspace not found\n"; + print "Skipping: $workspace not found\n"; } else { - print "Running: $command\n"; - - my $ret = system ($command); - - if ($ret != 0) { - print "[BUILD ERROR detected in ", getcwd(), "]\n"; - } + print "Running: $command\n"; + if (!utility::run_command ($command, $result)) { + print STDERR "[BUILD ERROR detected in ", getcwd(), "]\n"; + } } chdir $current_dir; - return 1; + return $result; } ############################################################################## diff --git a/common/betterparser.pm b/common/betterparser.pm index 8a4571e09..20eb9fbe1 100644 --- a/common/betterparser.pm +++ b/common/betterparser.pm @@ -1243,6 +1243,7 @@ sub DealWithCommandTag ($$$$$\%) my $JOIN = ' '; my $SUBVARS = 2; ## use default, if 0 don't substitute, if 1 substitute. my $GROUP; + my $required; while (scalar @$PAIRS) { my $thisPAIR = shift (@$PAIRS); @@ -1312,6 +1313,21 @@ sub DealWithCommandTag ($$$$$\%) } } #------------------------------------------------------------------------- + elsif ($thisAttrib =~ m/^required$/i) { + if ($thisValue =~ m/^true$/i) { + $required = 1; + } elsif ($thisValue =~ m/^false$/i) { + $required = 0; + } else { + DisplayProblem( + $file, + $lineStart, + $lineEnd, + "IGNORING", + "Invalid value for \"required\" attribute <$tag $thisAttrib=\"$thisValue\">"); + } + } + #------------------------------------------------------------------------- elsif ($thisAttrib =~ m/^join$/i) { if ($thisValue =~ m/^(?:dir(?:ectory)?|folder)$/i) { $JOIN = $main::dirsep; @@ -1439,6 +1455,7 @@ sub DealWithCommandTag ($$$$$\%) LINE_FROM => $lineStart, LINE_TO => $lineEnd, ARGS => [], + REQUIRED => $required, ); push @{$data->{COMMANDS}}, \%value; }