Skip to content

Commit

Permalink
Use a persistent cache for configure
Browse files Browse the repository at this point in the history
The cache is cleared if configure has changed, or for a forced run, or
in the case of from_source if the cache file is older than the configure
script.

Idea from Tom Lane, and based on his patch, but significantly tweaked by
me.
  • Loading branch information
adunstan committed Jul 10, 2017
1 parent 21045a6 commit f54bd87
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions build-farm.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ my $branch;
use_default_ccache_dir => 1,
# set this to allow caching of the configure script's results
use_accache => 1,
# env settings to apply within build/report process
# these settings will be seen by all the processes, including the
# configure process.
Expand Down
37 changes: 35 additions & 2 deletions run_build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ BEGIN
$make, $optional_steps, $use_vpath,
$tar_log_cmd, $using_msvc, $extra_config,
$make_jobs, $core_file_glob, $ccache_failure_remove,
$wait_timeout
$wait_timeout, $use_accache
)
=@PGBuild::conf{
qw(build_root target animal aux_path trigger_exclude
trigger_include secret keep_error_builds force_every make optional_steps
use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob
ccache_failure_remove wait_timeout)
ccache_failure_remove wait_timeout use_accache)
};

# default use_accache to on
$use_accache = 1 unless exists $PGBuild::conf{use_accache};

#default is no parallel build
$make_jobs ||= 1;

Expand Down Expand Up @@ -2065,6 +2068,36 @@ sub configure
my $confstr =
join(" ",@quoted_opts,"--prefix=$installdir","--with-pgport=$buildport");

if ($use_accache)
{
# set up cache directory for autoconf cache
my $accachedir = "$buildroot/accache-$animal";
mkpath $accachedir;
$accachedir = abs_path($accachedir);

# remove old cache file if configure script is newer
# in the case of from_source, or has been changed for this run
# or the run is forced, in the usual build from git case
my $accachefile = "$accachedir/config-$branch.cache";
my $obsolete;
if ($from_source)
{
my $conffile = "$from_source/configure";
$obsolete =
-e $accachefile
&& -e $conffile
&&(stat $conffile)[9] > (stat $accachefile)[9];
}
else
{
$obsolete = grep { /^configure / } @changed_files;
$obsolete ||= $last_status = 0;
}
unlink $accachefile if $obsolete;

$confstr .= " --cache-file='$accachefile'";
}

my $env = $PGBuild::conf{config_env};

my $envstr = "";
Expand Down

0 comments on commit f54bd87

Please sign in to comment.