Skip to content

Commit

Permalink
Merge pull request #282 from saffroy/master
Browse files Browse the repository at this point in the history
Use a persistent cache file of perl scanning results.
  • Loading branch information
liske authored Feb 25, 2024
2 parents f99adab + 93a6770 commit aa36615
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ install: all

mkdir -p "$(DESTDIR)$(LOCALEDIR)"
cp -r po/.build/* "$(DESTDIR)$(LOCALEDIR)/"

mkdir -p "$(DESTDIR)/var/cache/needrestart"

clean:
[ ! -f perl/Makefile ] || ( cd perl && $(MAKE) realclean )
Expand Down
3 changes: 3 additions & 0 deletions ex/needrestart.conf
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ $nrconf{override_cont} = {
# Disable interpreter scanners.
#$nrconf{interpscan} = 0;

# Use a persistent cache file of perl scanning results
#$nrconf{perlcache} = "/var/cache/needrestart/perl_scandeps_cache";

# Ignore script files matching these regexs:
$nrconf{blacklist_interp} = [
# ignore temporary files
Expand Down
7 changes: 7 additions & 0 deletions needrestart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ our %nrconf = (
override_cont => {},
skip_mapfiles => -1,
interpscan => 1,
perlcache => undef,
kernelhints => 1,
kernelfilter => qr(.),
ucodehints => 1,
Expand Down Expand Up @@ -241,6 +242,12 @@ $opt_t = $nrconf{tolerance} unless(defined($opt_t));
$nrconf{defno}++ if($opt_n);
$opt_b++ if($opt_p);

needrestart_interp_configure({
perl => {
cache_file => $nrconf{perlcache},
},
});

# print version in verbose mode
print STDERR "$LOGPREF needrestart v$NeedRestart::VERSION\n" if($nrconf{verbosity} > 1);

Expand Down
12 changes: 10 additions & 2 deletions perl/lib/NeedRestart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ our @EXPORT = qw(
needrestart_ui
needrestart_ui_list
needrestart_interp_configure
needrestart_interp_check
needrestart_interp_source
needrestart_cont_check
Expand Down Expand Up @@ -135,13 +136,20 @@ sub needrestart_ui_list {


my %Interps;
my $InterpConf;
my %InterpCache;
my $idebug;

sub needrestart_interp_register($) {
sub needrestart_interp_configure($) {
my $conf = shift;
$InterpConf = $conf;
}

sub needrestart_interp_register($$) {
my $pkg = shift;
my $confkey = shift;

$Interps{$pkg} = new $pkg($idebug);
$Interps{$pkg} = new $pkg($idebug, $InterpConf->{$confkey});
}

sub needrestart_interp_init($) {
Expand Down
2 changes: 2 additions & 0 deletions perl/lib/NeedRestart/Interp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ use warnings;
sub new {
my $class = shift;
my $debug = shift;
my $conf = shift;

return bless {
debug => $debug,
conf => $conf,
}, $class;
}

Expand Down
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/Interp/Java.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use NeedRestart::Utils;

my $LOGPREF = '[Java]';

needrestart_interp_register(__PACKAGE__);
needrestart_interp_register(__PACKAGE__, "java");

sub isa {
my $self = shift;
Expand Down
3 changes: 2 additions & 1 deletion perl/lib/NeedRestart/Interp/Perl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use Module::ScanDeps;

my $LOGPREF = '[Perl]';

needrestart_interp_register(__PACKAGE__);
needrestart_interp_register(__PACKAGE__, "perl");

sub isa {
my $self = shift;
Expand Down Expand Up @@ -178,6 +178,7 @@ sub files {
$href = scan_deps(
files => [$src],
recurse => 1,
cache_file => $self->{conf}->{cache_file},
);
}

Expand Down
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/Interp/Python.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use NeedRestart::Utils;

my $LOGPREF = '[Python]';

needrestart_interp_register(__PACKAGE__);
needrestart_interp_register(__PACKAGE__, "python");

sub isa {
my $self = shift;
Expand Down
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/Interp/Ruby.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use NeedRestart::Utils;

my $LOGPREF = '[Ruby]';

needrestart_interp_register(__PACKAGE__);
needrestart_interp_register(__PACKAGE__, "ruby");

sub isa {
my $self = shift;
Expand Down

0 comments on commit aa36615

Please sign in to comment.