From 9e80c5710e8e8005dee553b4583dc062dfc3ca62 Mon Sep 17 00:00:00 2001 From: David Steele Date: Sat, 14 Mar 2020 12:39:29 -0400 Subject: [PATCH] Use a checksum to build configure.ac more efficiently. Building the configure.ac script can take multiple seconds depending on the state of the autoconf cache. Use a checksum to only rebuild when configure.ac has changed no matter how the timestamps have changed. --- src/.gitignore | 2 +- src/configure | 2 ++ test/test.pl | 35 ++++++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 535f11650..a5ef16f4f 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,5 +1,5 @@ /.build -/autom4te.cache +autom4te.cache /config.log /config.status /Makefile diff --git a/src/configure b/src/configure index 302f9a4b6..9016ecab7 100755 --- a/src/configure +++ b/src/configure @@ -5267,3 +5267,5 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + +# Generated from src/build/configure.ac sha1 ebb41aa471ed3dc451cf95db394ec83bf08f759d diff --git a/test/test.pl b/test/test.pl index 6e9eb6420..425a4e382 100755 --- a/test/test.pl +++ b/test/test.pl @@ -14,6 +14,7 @@ use English '-no_match_vars'; # Convert die to confess to capture the stack trace $SIG{__DIE__} = sub { Carp::confess @_ }; +use Digest::SHA qw(sha1_hex); use File::Basename qw(dirname); use Getopt::Long qw(GetOptions); use Cwd qw(abs_path cwd); @@ -486,21 +487,33 @@ eval #----------------------------------------------------------------------------------------------------------------------- if (!$bSmart || grep(/^src\/build\/configure\.ac/, @stryModifiedList)) { - my $strConfigure = executeTest("autoconf ${strBackRestBase}/src/build/configure.ac"); - - # Trim off any trailing LFs - $strConfigure = trim($strConfigure) . "\n"; - - # Remove unused options from help - $strConfigure =~ s/^ --((?!bin).)*dir=DIR.*\n//mg; - $strConfigure =~ s/^ --sbindir=DIR.*\n//mg; - - # Save into the src dir + # Set build file my @stryBuilt; my $strBuilt = 'src/configure'; - if (buildPutDiffers($oStorageBackRest, "${strBackRestBase}/${strBuilt}", $strConfigure)) + # Get configure.ac and configure to see if anything has changed + my $strConfigureAc = ${$oStorageBackRest->get('src/build/configure.ac')}; + my $strConfigureAcHash = sha1_hex($strConfigureAc); + my $rstrConfigure = $oStorageBackRest->get($oStorageBackRest->openRead($strBuilt, {bIgnoreMissing => true})); + + # Check if configure needs to be regenerated + if (!defined($rstrConfigure) || !defined($$rstrConfigure) || + $strConfigureAcHash ne substr($$rstrConfigure, length($$rstrConfigure) - 41, 40)) { + # Generate configure + my $strConfigure = executeTest("cd ${strBackRestBase}/src/build && autoconf --output=-"); + $strConfigure = + trim($strConfigure) . "\n\n# Generated from src/build/configure.ac sha1 ${strConfigureAcHash}\n"; + + # Remove unused options from help + $strConfigure =~ s/^ --((?!bin).)*dir=DIR.*\n//mg; + $strConfigure =~ s/^ --sbindir=DIR.*\n//mg; + + # Save into the src dir + $oStorageBackRest->put( + $oStorageBackRest->openWrite("${strBackRestBase}/${strBuilt}", {strMode => '0755'}), $strConfigure); + + # Add to built list push(@stryBuilt, $strBuilt); push(@stryBuiltAll, @stryBuilt); push(@stryModifiedList, @stryBuilt);