Skip to content

Commit 93a6770

Browse files
committed
Use a persistent cache file of perl scanning results.
The new configuration option "perlcache" enables caching and sets the path to the cache file managed by Module::ScanDeps. Fixes #279
1 parent 280c1ae commit 93a6770

File tree

9 files changed

+29
-6
lines changed

9 files changed

+29
-6
lines changed

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ install: all
4141

4242
mkdir -p "$(DESTDIR)$(LOCALEDIR)"
4343
cp -r po/.build/* "$(DESTDIR)$(LOCALEDIR)/"
44+
45+
mkdir -p "$(DESTDIR)/var/cache/needrestart"
4446

4547
clean:
4648
[ ! -f perl/Makefile ] || ( cd perl && $(MAKE) realclean )

ex/needrestart.conf

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ $nrconf{override_cont} = {
141141
# Disable interpreter scanners.
142142
#$nrconf{interpscan} = 0;
143143

144+
# Use a persistent cache file of perl scanning results
145+
#$nrconf{perlcache} = "/var/cache/needrestart/perl_scandeps_cache";
146+
144147
# Ignore script files matching these regexs:
145148
$nrconf{blacklist_interp} = [
146149
# ignore temporary files

needrestart

+7
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ our %nrconf = (
155155
override_cont => {},
156156
skip_mapfiles => -1,
157157
interpscan => 1,
158+
perlcache => undef,
158159
kernelhints => 1,
159160
kernelfilter => qr(.),
160161
ucodehints => 1,
@@ -241,6 +242,12 @@ $opt_t = $nrconf{tolerance} unless(defined($opt_t));
241242
$nrconf{defno}++ if($opt_n);
242243
$opt_b++ if($opt_p);
243244

245+
needrestart_interp_configure({
246+
perl => {
247+
cache_file => $nrconf{perlcache},
248+
},
249+
});
250+
244251
# print version in verbose mode
245252
print STDERR "$LOGPREF needrestart v$NeedRestart::VERSION\n" if($nrconf{verbosity} > 1);
246253

perl/lib/NeedRestart.pm

+10-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ our @EXPORT = qw(
4949
5050
needrestart_ui
5151
needrestart_ui_list
52+
needrestart_interp_configure
5253
needrestart_interp_check
5354
needrestart_interp_source
5455
needrestart_cont_check
@@ -135,13 +136,20 @@ sub needrestart_ui_list {
135136

136137

137138
my %Interps;
139+
my $InterpConf;
138140
my %InterpCache;
139141
my $idebug;
140142

141-
sub needrestart_interp_register($) {
143+
sub needrestart_interp_configure($) {
144+
my $conf = shift;
145+
$InterpConf = $conf;
146+
}
147+
148+
sub needrestart_interp_register($$) {
142149
my $pkg = shift;
150+
my $confkey = shift;
143151

144-
$Interps{$pkg} = new $pkg($idebug);
152+
$Interps{$pkg} = new $pkg($idebug, $InterpConf->{$confkey});
145153
}
146154

147155
sub needrestart_interp_init($) {

perl/lib/NeedRestart/Interp.pm

+2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ use warnings;
3030
sub new {
3131
my $class = shift;
3232
my $debug = shift;
33+
my $conf = shift;
3334

3435
return bless {
3536
debug => $debug,
37+
conf => $conf,
3638
}, $class;
3739
}
3840

perl/lib/NeedRestart/Interp/Java.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use NeedRestart::Utils;
3333

3434
my $LOGPREF = '[Java]';
3535

36-
needrestart_interp_register(__PACKAGE__);
36+
needrestart_interp_register(__PACKAGE__, "java");
3737

3838
sub isa {
3939
my $self = shift;

perl/lib/NeedRestart/Interp/Perl.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use Module::ScanDeps;
3636

3737
my $LOGPREF = '[Perl]';
3838

39-
needrestart_interp_register(__PACKAGE__);
39+
needrestart_interp_register(__PACKAGE__, "perl");
4040

4141
sub isa {
4242
my $self = shift;
@@ -178,6 +178,7 @@ sub files {
178178
$href = scan_deps(
179179
files => [$src],
180180
recurse => 1,
181+
cache_file => $self->{conf}->{cache_file},
181182
);
182183
}
183184

perl/lib/NeedRestart/Interp/Python.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use NeedRestart::Utils;
3535

3636
my $LOGPREF = '[Python]';
3737

38-
needrestart_interp_register(__PACKAGE__);
38+
needrestart_interp_register(__PACKAGE__, "python");
3939

4040
sub isa {
4141
my $self = shift;

perl/lib/NeedRestart/Interp/Ruby.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use NeedRestart::Utils;
3535

3636
my $LOGPREF = '[Ruby]';
3737

38-
needrestart_interp_register(__PACKAGE__);
38+
needrestart_interp_register(__PACKAGE__, "ruby");
3939

4040
sub isa {
4141
my $self = shift;

0 commit comments

Comments
 (0)