Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Precompile installed modules in Repository::Installation
  • Loading branch information
niner committed Nov 15, 2015
1 parent 4a64a9c commit 6f4b5b5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/core/CompUnit/Repository/Installation.pm
Expand Up @@ -2,6 +2,7 @@ class CompUnit::Repository::Installation does CompUnit::Repository::Locally does
has %!dists;
has $!cver = nqp::hllize(nqp::atkey(nqp::gethllsym('perl6', '$COMPILER_CONFIG'), 'version'));
has %!loaded;
has $!precomp;

submethod BUILD(:$!prefix, :$!lock, :$!WHICH, :$!next-repo) {
my $manifest := $!prefix.child("MANIFEST");
Expand Down Expand Up @@ -108,12 +109,21 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
for @files -> $file is copy {
$file = $is-win ?? ~$file.subst('\\', '/', :g) !! ~$file;
if [||] @provides>>.ACCEPTS($file) -> $/ {
my $name = $/.ast;
$has-provides = True;
$d.provides{ $/.ast }{ $<ext> } = {
$d.provides{ $name }{ $<ext> } = {
:file($file-id),
:time(try $file.IO.modified.Num),
:$!cver
}
my $precomp = self.precomp-repository;
if $precomp.may-precomp {
my $id = nqp::sha1($name ~ self.id);
my $compunit = CompUnit.new(
$file, :$name, :extension(''), :has-source, :repo(self)
);
$precomp.precompile($compunit, $id);
}
}
else {
if $file ~~ /^bin<[\\\/]>/ {
Expand Down Expand Up @@ -228,6 +238,17 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
return %!loaded.values;
}

method precomp-repository() returns CompUnit::PrecompilationRepository {
$!precomp := CompUnit::PrecompilationRepository::Default.new(
:store(
CompUnit::PrecompilationStore::File.new(
:prefix(self.prefix.child('precomp')),
)
),
) unless $!precomp;
$!precomp
}

sub provides-warning($is-win, $name) {
my $color = %*ENV<RAKUDO_ERROR_COLOR> // !$is-win;
my ($red, $green, $yellow, $clear) = $color
Expand Down

0 comments on commit 6f4b5b5

Please sign in to comment.