Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Have Repository::Installation's id change when installing a module
The repository's identity needs to depend on its content so installation of
a module into this repo can automatically invalidate precomp files of repos
nearer the head of the repo chain. Those precomp ids contain the ids of all
repos in the chain.
  • Loading branch information
niner committed Nov 21, 2015
1 parent 4291711 commit 9104866
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/CompUnit/Repository/Installation.pm
Expand Up @@ -2,6 +2,7 @@ class CompUnit::Repository::Installation does CompUnit::Repository::Locally does
has $!cver = nqp::hllize(nqp::atkey(nqp::gethllsym('perl6', '$COMPILER_CONFIG'), 'version'));
has %!loaded;
has $!precomp;
has $!id;

submethod BUILD(:$!prefix, :$!lock, :$!WHICH, :$!next-repo) { }

Expand Down Expand Up @@ -121,7 +122,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
my $has-provides;
for @files -> $file is copy {
$file = $is-win ?? ~$file.subst('\\', '/', :g) !! ~$file;
my $id = nqp::sha1($file ~ self.id);
my $id = nqp::sha1($file ~ self.prefix);
my $destination = $sources-dir.child($id);
if [||] @provides>>.ACCEPTS($file) -> $/ {
my $name = $/.ast;
Expand Down Expand Up @@ -164,7 +165,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
for $d.provides.values.map(*.values[0]<file>) -> $file-id {
my $source = $sources-dir.child($file-id);
if $precomp.may-precomp {
my $id = nqp::sha1($source ~ self.id);
my $id = nqp::sha1($source ~ self.prefix);
my $rev-deps-file = ($precomp.store.path($*PERL.compiler.id, $id) ~ '.rev-deps').IO;
my @rev-deps = $rev-deps-file.e ?? $rev-deps-file.lines !! ();

Expand All @@ -175,6 +176,10 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
}
}
}

# reset cached id so it's generated again on next access.
# identity changes with every installation of a dist.
$!id = Any;
$lock.unlock;
} ) }

Expand Down Expand Up @@ -234,7 +239,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
);
my $handle;
if $precomp.may-precomp {
my $id = nqp::sha1($loader ~ self.id);
my $id = nqp::sha1($loader ~ self.prefix);
if $*W and $*W.is_precompilation_mode {
say $id;
$handle = $precomp.load($id) or $precomp.precompile($loader, $id);
Expand All @@ -260,6 +265,12 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
nqp::die("Could not find $file in:\n" ~ $*REPO.repo-chain.map(*.Str).join("\n").indent(4));
}

method id() {
return $!id if $!id;
$!id = self.CompUnit::Repository::Locally::id();
$!id = nqp::sha1($!id ~ self!dist-dir.dir)
}

method short-id() { 'inst' }

method loaded() returns Iterable {
Expand Down

0 comments on commit 9104866

Please sign in to comment.