From 53d623911fdd093105692c35fc6c58ae196b2893 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 12 Dec 2018 18:37:49 -0600 Subject: [PATCH 01/10] common::utility::run_command() --- common/utility.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/common/utility.pm b/common/utility.pm index 4059b0c31..279236ae9 100755 --- a/common/utility.pm +++ b/common/utility.pm @@ -1,6 +1,31 @@ +use strict; package utility; +# Run command, returns 0 if there was an error +sub run_command ($;$) { + my $command = shift; + my $ignore_failure = shift; + if (!defined $ignore_failure) { + $ignore_failure = 0; + } + + if (system ($command)) { + my $error_message; + if ($? == -1) { + $error_message = "Failed to Run: $!"; + } elsif ($? & 127) { + $error_message = sprintf ("Exited on Singal %d, %s coredump", + ($? & 127), ($? & 128) ? 'with' : 'without'); + } else { + $error_message = sprintf ("Returned %d", $? >> 8); + } + print STDERR "Command \"$command\" $error_message\n"; + return !$ignore_failure; + } + return 1; +} + ############################################################################### # # index_logs From 84c1440371d7a9e8bfb381d7d7bdc5e0966e317e Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 12 Dec 2018 18:50:18 -0600 Subject: [PATCH 02/10] Return 1 if a autobuild command fails --- autobuild.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autobuild.pl b/autobuild.pl index 69d80be35..c010a29ba 100755 --- a/autobuild.pl +++ b/autobuild.pl @@ -37,6 +37,7 @@ my $cvs_tag; my $starting_dir= getcwd (); my $warn_nonfatal; +my $status = 0; ############################################################################## # Load the commands allowed here @@ -807,6 +808,7 @@ (\%) if ($command_table{$NAME}->Run ($OPTIONS) == 0) { print STDERR "ERROR: While $CMD $CMD2:\n" if ($verbose <= 1); print STDERR " The command failed"; + $status = 1; if (!$keep_going) { print STDERR ", exiting.\n"; chdir ($starting_dir); @@ -829,3 +831,5 @@ (\%) chdir ($starting_dir); ChangeENV (%originalENV); } ## next input file + +exit $status; From 1ca8c40e0df4f95665ec32ad19b8d09226bf670a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 12 Dec 2018 18:54:07 -0600 Subject: [PATCH 03/10] Return process failure for several commands --- command/anonymous_shell.pm | 6 ++- command/check_compiler.pm | 84 +++++++++++++++++++++----------------- command/make.pm | 15 +++---- command/shell.pm | 6 ++- command/test.pm | 6 ++- command/vc6make.pm | 11 +++-- command/vc7make.pm | 11 +++-- 7 files changed, 80 insertions(+), 59 deletions(-) diff --git a/command/anonymous_shell.pm b/command/anonymous_shell.pm index 26c9ef304..573cc3e77 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 @@ -63,11 +65,11 @@ sub Run ($) print "Running: ${options}\n"; - system ($options); + my $status = utility::run_command ($options); chdir $current_dir; - return 1; + return $status; } ############################################################################## diff --git a/command/check_compiler.pm b/command/check_compiler.pm index 4df7f7454..a7d48837b 100644 --- a/command/check_compiler.pm +++ b/command/check_compiler.pm @@ -7,6 +7,8 @@ use warnings; use Cwd; +use common::utility; + ############################################################################### # Constructor @@ -45,93 +47,99 @@ 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"); - } - } + if (not utility::run_command ($compiler." -v 2>&1")) { + return 0; + } + 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$/){ + 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 =~ m/^(sun_cc|studio|suncc)/) { - system("CC -V"); + return utility::run_command ("CC -V"); } elsif(lc $compiler eq "mingwcygwin"){ - system("g++ -v -mno-cygwin"); + return utility::run_command ("g++ -v -mno-cygwin"); } elsif(lc $compiler eq "bcc32"){ - system("bcc32 --version"); + return utility::run_command ("bcc32 --version"); } elsif(lc $compiler eq "bcc32c"){ - system("bcc32c --version"); + return utility::run_command ("bcc32c --version"); } elsif(lc $compiler eq "bcc64"){ - system("bcc64 --version"); + return utility::run_command ("bcc64 --version"); } elsif(lc $compiler eq "bccx"){ - system("bccx --version"); + return utility::run_command ("bccx --version"); } elsif(lc $compiler eq "kylix"){ - system("bc++ -V"); + return utility::run_command ("bc++ -V"); } elsif($compiler =~ m/^(dcc|dplus)/){ - system($compiler . " -V"); + return utility::run_command ($compiler . " -V"); } elsif(lc $compiler eq "dm"){ - system("scppn"); + return utility::run_command ("scppn"); } elsif(lc $compiler =~ m/^(msvc|vc|cl)/){ - system("cl"); + return utility::run_command ("cl"); } elsif(lc $compiler eq "deccxx"){ - system("cxx/VERSION"); + return utility::run_command ("cxx/VERSION"); } elsif(lc $compiler eq "cxx"){ - system("cxx -V"); + return utility::run_command ("cxx -V"); } elsif(lc $compiler eq "acc"){ - system("aCC -V"); + return utility::run_command ("aCC -V"); } elsif(lc $compiler eq "pgcc"){ - system("pgCC -V"); + return utility::run_command ("pgCC -V"); } elsif(lc $compiler eq "mipspro"){ - system("CC -version"); + return utility::run_command ("CC -version"); } elsif(lc $compiler eq "doxygen"){ - system("doxygen --version"); + return utility::run_command ("doxygen --version"); } elsif($compiler =~ m/^(ecc|icc|icpc)/){ - system($compiler." -V 2>&1"); + return utility::run_command ($compiler." -V 2>&1"); } elsif(lc $compiler eq "icl"){ - system("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"; + 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"; + 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"); + return utility::run_command ("c89 -Whelp 2>&1 | tail -2"); } else{ - system($compiler); + print STDERR __FILE__, ": " . "Invalid Compiler Option: $compiler\n"; } - return 1; + return 0; } ############################################################################## diff --git a/command/make.pm b/command/make.pm index 65671a39f..f6306eaa8 100644 --- a/command/make.pm +++ b/command/make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +using common::utility; + ############################################################################### # Constructor @@ -134,7 +136,7 @@ sub Run ($) my $command; my $pattern; - my $ret = 0; + my $ret; if ($options =~ s/find=([^\s]*)//) { $pattern = $1; @@ -146,18 +148,17 @@ sub Run ($) next unless -f $makefile; # skip directories $command = "$make_program -f $makefile $options"; print "Running: $command\n"; - $ret = system ($command); + $ret = utility::run_command ($command); } } else { $options =~ s/'/"/g; $command = "$make_program $options"; print "Running: $command\n"; - $ret = system ($command); + $ret = utility::run_command ($command); } - if( $ret != 0 ) - { + if (!$ret) { my $working_dir = getcwd(); ## If we used 'make -C' to change the directory, let's @@ -168,7 +169,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 +177,7 @@ sub Run ($) ## Return PWD to the correct setting $ENV{PWD} = getcwd(); - return 1; + return $ret; } ############################################################################## diff --git a/command/shell.pm b/command/shell.pm index 0d1d5e4a3..b97c341f3 100644 --- a/command/shell.pm +++ b/command/shell.pm @@ -9,6 +9,8 @@ use Cwd; use FileHandle; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -65,11 +67,11 @@ sub Run ($) print "Running: ${options}\n"; - system ($options); + my $status = utility::run_command ($options); chdir $current_dir; - return 1; + return $status; } ############################################################################## diff --git a/command/test.pm b/command/test.pm index bb94b008d..dafad98c6 100644 --- a/command/test.pm +++ b/command/test.pm @@ -13,6 +13,8 @@ use warnings; use Cwd; use FileHandle; +use common::utility; + ############################################################################### # Constructor @@ -69,11 +71,11 @@ sub Run ($) print "Running: ${options}\n"; - system ($options); + my $status = utility::run_command ($options); chdir $current_dir; - return 1; + return status; } ############################################################################## diff --git a/command/vc6make.pm b/command/vc6make.pm index ac6234da1..fbad5b8ca 100644 --- a/command/vc6make.pm +++ b/command/vc6make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -86,23 +88,24 @@ sub Run ($) $workspace = $1; } + my $ret = 1; if (defined $workspace && ! -r $workspace) { print "Skipping: $workspace not found\n"; } else { print "Running: $command\n"; - my $ret = system ($command); + $ret = utility::run_command ($command); - if ($ret != 0) + if (!$ret) { - print "[BUILD ERROR detected in ", getcwd(), "]\n"; + print STDERR "[BUILD ERROR detected in ", getcwd(), "]\n"; } } chdir $current_dir; - return 1; + return $ret; } ############################################################################## diff --git a/command/vc7make.pm b/command/vc7make.pm index 493bdfae5..0c1b8f6d0 100644 --- a/command/vc7make.pm +++ b/command/vc7make.pm @@ -8,6 +8,8 @@ use warnings; use Cwd; use File::Path; +use common::utility; + ############################################################################### # Constructor @@ -105,22 +107,23 @@ sub Run ($) $workspace = $1; } + my $ret = 1; if (defined $workspace && ! -r $workspace) { print "Skipping: $workspace not found\n"; } else { print "Running: $command\n"; - my $ret = system ($command); + my $ret = utility::run_command ($command); - if ($ret != 0) { - print "[BUILD ERROR detected in ", getcwd(), "]\n"; + if (!$ret) { + print STDERR "[BUILD ERROR detected in ", getcwd(), "]\n"; } } chdir $current_dir; - return 1; + return $ret; } ############################################################################## From ef3e1dbf288459c18a2ed7b0425089da2d7b359c Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 17 Dec 2018 15:00:43 -0600 Subject: [PATCH 04/10] Fix Typos in Commands --- command/make.pm | 2 +- command/test.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command/make.pm b/command/make.pm index f6306eaa8..65af329e3 100644 --- a/command/make.pm +++ b/command/make.pm @@ -8,7 +8,7 @@ use warnings; use Cwd; use File::Path; -using common::utility; +use common::utility; ############################################################################### # Constructor diff --git a/command/test.pm b/command/test.pm index dafad98c6..a71da1a4e 100644 --- a/command/test.pm +++ b/command/test.pm @@ -75,7 +75,7 @@ sub Run ($) chdir $current_dir; - return status; + return $status; } ############################################################################## From c559977009e477372fd627fae350e4a1419dacaa Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 19 Dec 2018 11:09:34 -0600 Subject: [PATCH 05/10] Fix run_command return value --- common/utility.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/utility.pm b/common/utility.pm index 279236ae9..238d897fa 100755 --- a/common/utility.pm +++ b/common/utility.pm @@ -21,7 +21,7 @@ sub run_command ($;$) { $error_message = sprintf ("Returned %d", $? >> 8); } print STDERR "Command \"$command\" $error_message\n"; - return !$ignore_failure; + return $ignore_failure; } return 1; } From fd8fc6debc961acc2cdc26e20b7d019b35cf8617 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 19 Dec 2018 11:13:46 -0600 Subject: [PATCH 06/10] Add required command attribute --- autobuild.pl | 3 ++- common/betterparser.pm | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/autobuild.pl b/autobuild.pl index c010a29ba..0b0258203 100755 --- a/autobuild.pl +++ b/autobuild.pl @@ -737,6 +737,7 @@ (\%) my $FILE = $command->{FILE}; my $LINE_FROM = $command->{LINE_FROM}; my $LINE_TO = $command->{LINE_FROM}; + my $required = $command->{REQUIRED}; my $CMD = "Executing \"$NAME\" line"; if (!defined $LINE_TO || $LINE_FROM == $LINE_TO) { @@ -809,7 +810,7 @@ (\%) print STDERR "ERROR: While $CMD $CMD2:\n" if ($verbose <= 1); print STDERR " The command failed"; $status = 1; - if (!$keep_going) { + if (!$keep_going && $required) { print STDERR ", exiting.\n"; chdir ($starting_dir); ChangeENV (%originalENV); diff --git a/common/betterparser.pm b/common/betterparser.pm index ef583cae8..0d1a2b29e 100644 --- a/common/betterparser.pm +++ b/common/betterparser.pm @@ -1230,6 +1230,7 @@ sub DealWithCommandTag ($$$$$\%) my $JOIN = ' '; my $SUBVARS = 2; ## use default, if 0 don't subsitute, if 1 subsitute. my $GROUP; + my $required = 0; while (scalar @$PAIRS) { my $thisPAIR = shift (@$PAIRS); @@ -1299,6 +1300,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; @@ -1424,7 +1440,8 @@ sub DealWithCommandTag ($$$$$\%) IF_TEXT => (defined $IF_TEXT ? $IF_TEXT : 1), FILE => $file, LINE_FROM => $lineStart, - LINE_TO => $lineEnd + LINE_TO => $lineEnd, + REQUIRED => $required, ); push @{$data->{COMMANDS}}, \%value; } From 71668d0333031ca2142a1a7d7d27cbb0718404b8 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 11 Mar 2021 17:52:28 -0600 Subject: [PATCH 07/10] Tweak run_command --- common/utility.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/utility.pm b/common/utility.pm index 238d897fa..7c20b48c2 100755 --- a/common/utility.pm +++ b/common/utility.pm @@ -2,7 +2,8 @@ use strict; package utility; -# Run command, returns 0 if there was an error +# Run command, returns 0 if there was an error. If the second argument is +# passed and is true, then it always returns 1. sub run_command ($;$) { my $command = shift; my $ignore_failure = shift; @@ -15,7 +16,7 @@ sub run_command ($;$) { if ($? == -1) { $error_message = "Failed to Run: $!"; } elsif ($? & 127) { - $error_message = sprintf ("Exited on Singal %d, %s coredump", + $error_message = sprintf ("Exited on Signal %d, %s coredump", ($? & 127), ($? & 128) ? 'with' : 'without'); } else { $error_message = sprintf ("Returned %d", $? >> 8); From 690eb1e76de54366688d2db6f8b30d64fff7a300 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 11 Mar 2021 17:52:37 -0600 Subject: [PATCH 08/10] Make auto_run_tests Required By Default --- autobuild.pl | 9 +++++++++ command/auto_run_tests.pm | 7 +++++-- command/check_compiler.pm | 4 +++- common/betterparser.pm | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/autobuild.pl b/autobuild.pl index c5eebdfcc..f79b92aa6 100755 --- a/autobuild.pl +++ b/autobuild.pl @@ -740,6 +740,15 @@ (\%) my $CONTENTS = $command->{CONTENTS}; 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) { $CMD .= " $LINE_FROM"; diff --git a/command/auto_run_tests.pm b/command/auto_run_tests.pm index b35690d7b..2730337f4 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 @@ -19,6 +21,7 @@ sub new my $self = {'internal_options' => {'-envmod' => \&Handle_Envmod, }, 'substitute_vars_in_options' => 1, + 'required_by_default' => 1, }; bless ($self, $class); @@ -178,9 +181,9 @@ sub Run ($) print "Running: $command\n"; } - system ($command); + my $success = utility::run_command ($command); chdir $current_dir; - return 1; + return $success; } ############################################################################## diff --git a/command/check_compiler.pm b/command/check_compiler.pm index a7d48837b..f9b9731e3 100644 --- a/command/check_compiler.pm +++ b/command/check_compiler.pm @@ -16,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; diff --git a/common/betterparser.pm b/common/betterparser.pm index 9d0e460ba..2b8fb2d1a 100644 --- a/common/betterparser.pm +++ b/common/betterparser.pm @@ -1240,7 +1240,7 @@ sub DealWithCommandTag ($$$$$\%) my $JOIN = ' '; my $SUBVARS = 2; ## use default, if 0 don't substitute, if 1 substitute. my $GROUP; - my $required = 0; + my $required; while (scalar @$PAIRS) { my $thisPAIR = shift (@$PAIRS); From f1bbea1f2289271e87b3c868c93166dc2300e8bf Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 19 Apr 2021 22:12:46 -0500 Subject: [PATCH 09/10] Update Commands to Return Non-Fatal --- command/anonymous_shell.pm | 15 +++++---------- command/auto_run_tests.pm | 6 +++--- command/make.pm | 13 +++++++------ command/shell.pm | 15 +++++---------- command/test.pm | 15 +++++---------- command/vc6make.pm | 22 +++++++++------------- command/vc7make.pm | 21 +++++++++------------ 7 files changed, 43 insertions(+), 64 deletions(-) diff --git a/command/anonymous_shell.pm b/command/anonymous_shell.pm index 573cc3e77..7e5c285a4 100644 --- a/command/anonymous_shell.pm +++ b/command/anonymous_shell.pm @@ -56,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"; - my $status = utility::run_command ($options); - - chdir $current_dir; + my $result = {}; + utility::run_command ($options, $result); - return $status; + return $result; } ############################################################################## diff --git a/command/auto_run_tests.pm b/command/auto_run_tests.pm index 2730337f4..3d3a190fe 100644 --- a/command/auto_run_tests.pm +++ b/command/auto_run_tests.pm @@ -21,7 +21,6 @@ sub new my $self = {'internal_options' => {'-envmod' => \&Handle_Envmod, }, 'substitute_vars_in_options' => 1, - 'required_by_default' => 1, }; bless ($self, $class); @@ -181,9 +180,10 @@ sub Run ($) print "Running: $command\n"; } - my $success = utility::run_command ($command); + my $result = {}; + utility::run_command ($command, $result); chdir $current_dir; - return $success; + return $result; } ############################################################################## diff --git a/command/make.pm b/command/make.pm index 65af329e3..38cdc07e4 100644 --- a/command/make.pm +++ b/command/make.pm @@ -123,7 +123,7 @@ sub Run ($) { if(!chdir $dir) { print STDERR __FILE__, ": Cannot change to $dir\n"; - return 1; + return 0; } } @@ -136,7 +136,8 @@ sub Run ($) my $command; my $pattern; - my $ret; + my $success = 0; + my $result = {}; if ($options =~ s/find=([^\s]*)//) { $pattern = $1; @@ -148,17 +149,17 @@ sub Run ($) next unless -f $makefile; # skip directories $command = "$make_program -f $makefile $options"; print "Running: $command\n"; - $ret = utility::run_command ($command); + $success = utility::run_command ($command, $result); } } else { $options =~ s/'/"/g; $command = "$make_program $options"; print "Running: $command\n"; - $ret = utility::run_command ($command); + $success = utility::run_command ($command, $result); } - if (!$ret) { + if (!$success) { my $working_dir = getcwd(); ## If we used 'make -C' to change the directory, let's @@ -177,7 +178,7 @@ sub Run ($) ## Return PWD to the correct setting $ENV{PWD} = getcwd(); - return $ret; + return $result; } ############################################################################## diff --git a/command/shell.pm b/command/shell.pm index b97c341f3..fd4d825eb 100644 --- a/command/shell.pm +++ b/command/shell.pm @@ -58,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"; - my $status = utility::run_command ($options); - - chdir $current_dir; + my $result = {}; + utility::run_command ($options, $result); - return $status; + return $result; } ############################################################################## diff --git a/command/test.pm b/command/test.pm index a71da1a4e..8514c6c7e 100644 --- a/command/test.pm +++ b/command/test.pm @@ -62,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"; - my $status = utility::run_command ($options); - - chdir $current_dir; + my $result = {}; + my $status = utility::run_command ($options, $result); - return $status; + return $result; } ############################################################################## diff --git a/command/vc6make.pm b/command/vc6make.pm index fbad5b8ca..89c413388 100644 --- a/command/vc6make.pm +++ b/command/vc6make.pm @@ -82,30 +82,26 @@ sub Run ($) my $workspace = undef; if ($options =~ /"([^"]+\.dsw)"/) { - $workspace = $1; + $workspace = $1; } elsif ($options =~ /([\w\-\\\/\.]+\.dsw)/) { - $workspace = $1; + $workspace = $1; } - my $ret = 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"; - - $ret = utility::run_command ($command); - - if (!$ret) - { - print STDERR "[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 $ret; + return $result; } ############################################################################## diff --git a/command/vc7make.pm b/command/vc7make.pm index 0c1b8f6d0..7eb14f14b 100644 --- a/command/vc7make.pm +++ b/command/vc7make.pm @@ -101,29 +101,26 @@ sub Run ($) my $workspace = undef; if ($options =~ /"([^"]+\.sln)"/) { - $workspace = $1; + $workspace = $1; } elsif ($options =~ /([\w\.\-\\\/]+\.sln)/) { - $workspace = $1; + $workspace = $1; } - my $ret = 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 = utility::run_command ($command); - - if (!$ret) { - print STDERR "[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 $ret; + return $result; } ############################################################################## From 61b2307a411d7d5e13f16ba37d63d65bc7208a2a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 19 Apr 2021 22:38:11 -0500 Subject: [PATCH 10/10] check_compiler: Simplify and Fix Formating --- command/check_compiler.pm | 76 ++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/command/check_compiler.pm b/command/check_compiler.pm index f9b9731e3..e84aef75c 100644 --- a/command/check_compiler.pm +++ b/command/check_compiler.pm @@ -48,97 +48,91 @@ 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\.]+)?/){ - if (not utility::run_command ($compiler." -v 2>&1")) { + if ($compiler =~ m/^(\w*-)*(gcc|g\+\+|clang|ccsimpc|(cc|c\+\+)(pentium|ppc))/) { + if (!utility::run_command ("$compiler -v 2>&1")) { return 0; } - if($compiler =~ m/^(\w*-)*(gcc|g\+\+|g\+\+-?[0-9])/ || $compiler =~ m/^clang(\+\+)?(-[0-9\.]+)?/){ + if ($compiler =~ /^(\w*-)*(gcc|g\+\+|clang)/) { my $linker = `$compiler -print-prog-name=ld`; chomp $linker; - if($linker =~ m/ld$/){ + if ($linker =~ m/ld$/) { return utility::run_command ($linker." -v 2>&1"); } - elsif($linker =~ m/ccs/){ + elsif ($linker =~ m/ccs/) { return utility::run_command ($linker." -V 2>&1"); - } else { - print STDERR __FILE__, ": ERROR: Unexpected Linker: $linker\n"; + } + else { + print STDERR __FILE__, ": ERROR: Unexpected Linker: $linker\n"; } } } - elsif(lc $compiler =~ m/^(sun_cc|studio|suncc)/) { + elsif (lc $compiler =~ m/^(sun_cc|studio|suncc)/) { return utility::run_command ("CC -V"); } - elsif(lc $compiler eq "mingwcygwin"){ + elsif (lc $compiler eq "mingwcygwin") { return utility::run_command ("g++ -v -mno-cygwin"); } - elsif(lc $compiler eq "bcc32"){ - return utility::run_command ("bcc32 --version"); - } - elsif(lc $compiler eq "bcc32c"){ - return utility::run_command ("bcc32c --version"); - } - elsif(lc $compiler eq "bcc64"){ - return utility::run_command ("bcc64 --version"); + elsif (lc $compiler =~ m/^(bcc(.*))$/) { + return utility::run_command ("$1 --version"); } - elsif(lc $compiler eq "bccx"){ - return utility::run_command ("bccx --version"); - } - elsif(lc $compiler eq "kylix"){ + elsif (lc $compiler eq "kylix") { return utility::run_command ("bc++ -V"); } - elsif($compiler =~ m/^(dcc|dplus)/){ + elsif ($compiler =~ m/^(dcc|dplus)/) { return utility::run_command ($compiler . " -V"); } - elsif(lc $compiler eq "dm"){ + elsif (lc $compiler eq "dm") { return utility::run_command ("scppn"); } - elsif(lc $compiler =~ m/^(msvc|vc|cl)/){ + elsif (lc $compiler =~ m/^(msvc|vc|cl)/) { return utility::run_command ("cl"); } - elsif(lc $compiler eq "deccxx"){ + elsif (lc $compiler eq "deccxx") { return utility::run_command ("cxx/VERSION"); } - elsif(lc $compiler eq "cxx"){ + elsif (lc $compiler eq "cxx") { return utility::run_command ("cxx -V"); } - elsif(lc $compiler eq "acc"){ + elsif (lc $compiler eq "acc") { return utility::run_command ("aCC -V"); } - elsif(lc $compiler eq "pgcc"){ + elsif (lc $compiler eq "pgcc") { return utility::run_command ("pgCC -V"); } - elsif(lc $compiler eq "mipspro"){ + elsif (lc $compiler eq "mipspro") { return utility::run_command ("CC -version"); } - elsif(lc $compiler eq "doxygen"){ + elsif (lc $compiler eq "doxygen") { return utility::run_command ("doxygen --version"); } - elsif($compiler =~ m/^(ecc|icc|icpc)/){ - return utility::run_command ($compiler." -V 2>&1"); + elsif ($compiler =~ m/^(ecc|icc|icpc)/) { + return utility::run_command ("$compiler -V 2>&1"); } - elsif(lc $compiler eq "icl"){ + elsif (lc $compiler eq "icl") { return utility::run_command ("icl"); } - elsif($compiler =~ m/^(ibmcxx)/i ){ - if(-x "/usr/bin/lslpp"){ + elsif ($compiler =~ m/^(ibmcxx)/i) { + if (-x "/usr/bin/lslpp") { return utility::run_command ("/usr/bin/lslpp -l ibmcxx.cmp | grep ibmcxx.cmp"); - } else { + } + else { print STDERR __FILE__, ": " . "ERROR: Could not find /usr/bin/lslpp!!\n"; } } - elsif($compiler =~ m/^(vacpp)/i ){ - if(-x "/usr/bin/lslpp"){ + elsif ($compiler =~ m/^(vacpp)/i) { + if (-x "/usr/bin/lslpp") { return utility::run_command ("/usr/bin/lslpp -l | grep -i \'C++ Compiler\'"); - } else { + } + else { print STDERR __FILE__, ": " . "ERROR: Could not find /usr/bin/lslpp!!\n"; } } - elsif(lc $compiler eq "c89"){ + elsif (lc $compiler eq "c89") { return utility::run_command ("c89 -Whelp 2>&1 | tail -2"); } - else{ + else { print STDERR __FILE__, ": " . "Invalid Compiler Option: $compiler\n"; } return 0;