diff --git a/autobuild.pl b/autobuild.pl index d858e8c16..ac1a48b79 100755 --- a/autobuild.pl +++ b/autobuild.pl @@ -853,15 +853,44 @@ (\%) } } - if ($command_table{$NAME}->Run ($OPTIONS, $args) == 0) { + my $result = $command_table{$NAME}->Run ($OPTIONS, $args); + my $result_type = ref ($result); + my $failure = undef; + if ($result_type eq '') { + # This is the traditional command return mechanism. 0 is a fatal error + # and other values (usually 1) are a success. + $failure = 'fatal' if $result == 0; + } + elsif ($result_type eq 'HASH') { + # Newer command return mechanism: + # {} is success + # {failure => 'fatal'} is a fatal error intended for when something + # is probably fundamentally wrong with autobuild xml file and/or + # the command couldn't function correctly. + # {failure => 'non-fatal'} is a non-fatal error intended for when the + # command failed, but in a "normal" or at least possibly expected + # way, like if a test failed. + # (and others?) are a success. + if (exists ($result->{failure})) { + $failure = $result->{failure}; + if ($failure ne 'fatal' && $failure ne 'non-fatal') { + print STDERR "ERROR: $CMD $CMD2 " . + "set \"fail\" to unexpected value \"$failure\"\n"; + $failure = 'fatal'; + } + } + } + if (defined ($failure)) { 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); - ChangeENV (%originalENV); - next INPFILE; + if ($failure eq 'fatal') { + $status = 1; + if (!$keep_going) { + print STDERR ", exiting.\n"; + chdir ($starting_dir); + ChangeENV (%originalENV); + next INPFILE; + } } print STDERR "!\n"; } diff --git a/command/cmake.pm b/command/cmake.pm index 1423cc402..177fcee71 100644 --- a/command/cmake.pm +++ b/command/cmake.pm @@ -52,6 +52,10 @@ sub Run ($) my $command_name = $self->{simple} ? "cmake_cmd" : "cmake"; + main::PrintStatus ( + ($self->{simple} && $options !~ /\W--build\W/) ? 'Configure' : 'Compile', + $command_name); + # Get cmake_var_* Autobuild Variables my @cmake_vars = (); my $autobuild_var_cmake_var_re = qr/^cmake_var_(\w+)$/; @@ -93,7 +97,7 @@ sub Run ($) else { print STDERR __FILE__, ": unexpected arg name \"$name\" in $command_name command\n"; - return 0; + return {failure => 'fatal'}; } } @@ -104,14 +108,17 @@ sub Run ($) $config_args .= " -G \"$cmake_generator\""; } + my $result = {}; + # cmake_cmd commmand if ($self->{simple}) { - return utility::run_command ("$cmake_command $options"); + utility::run_command ("$cmake_command $options", $result); + return $result; } elsif (length ($options)) { print STDERR __FILE__, ": options attribute not allowed for the cmake command\n"; - return 0; + return {failure => 'fatal'}; } # Insert cmake_var_* Autobuild Variables and var_* Arguments @@ -124,28 +131,28 @@ sub Run ($) # Recreate Build Directory if (!utility::remove_tree ($build_dir)) { - return 0; + return {failure => 'fatal'}; } if (!mkdir ($build_dir)) { print STDERR __FILE__, ": failed to make build directory \"$build_dir\": $!\n"; - return 0; + return {failure => 'fatal'}; } # Change to Build Directory my $build_cd = ChangeDir->new({dir => $build_dir}); - return 0 unless ($build_cd); + return {failure => 'fatal'} unless ($build_cd); # Run Configure CMake Command - if (!utility::run_command ("$cmake_command $config_args")) { - return 0; + if (!utility::run_command ("$cmake_command $config_args", $result)) { + return $result; } # Run Build CMake Command - if (!utility::run_command ("$cmake_command $build_args")) { - return 0; + if (!utility::run_command ("$cmake_command $build_args", $result)) { + return $result; } - return 1; + return $result; } ############################################################################## diff --git a/command/print_cmake_version.pm b/command/print_cmake_version.pm index 046bd845f..b16f9941a 100644 --- a/command/print_cmake_version.pm +++ b/command/print_cmake_version.pm @@ -46,9 +46,7 @@ sub Run ($) my $cmake_command = main::GetVariable ('cmake_command'); $cmake_command = "\"$cmake_command\" --version"; - main::PrintStatus ('Config', "print CMake Version"); - - print "