Skip to content

Commit

Permalink
Add :precompile = True flag to CURI.install (#4826)
Browse files Browse the repository at this point in the history
The idea behind this is to allow modules to just be installed and
have the runtime decide when it should (re-)precompile any compilation
units that were not precompiled yet.  This would e.g. allow the
DateTime::TimeZone distribution to be installed within a second,
rather than on 4+ minutes.  And only precompile those timezones that
are actually used at runtime.

Also add the --/precompile flag to install-dist.raku
  • Loading branch information
lizmat committed Mar 30, 2022
1 parent 4c4d379 commit 2511c21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/core.c/CompUnit/Repository/Installation.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
$!version = 2;
}

method install(Distribution $distribution, Bool :$force) {
method install(
Distribution:D $distribution,
Bool :$force,
Bool :$precompile = True,
) {
my $dist = CompUnit::Repository::Distribution.new($distribution);
my %files = $dist.meta<files>.grep(*.defined).map: -> $link {
$link ~~ Str ?? ($link => $link) !! ($link.keys[0] => $link.values[0])
Expand Down Expand Up @@ -223,7 +227,8 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
next unless $name-path.starts-with('bin/');
my $name = $name-path.subst(/^bin\//, '');
my $id = self!file-id(~$file, $dist-id);
my $destination = $resources-dir.add($id); # wrappers are put in bin/; originals in resources/
# wrappers are put in bin/; originals in resources/
my $destination = $resources-dir.add($id);
my $withoutext = $name-path.subst(/\.[exe|bat]$/, '');
for '', '-j', '-m', '-js' -> $be {
$.prefix.add("$withoutext$be").IO.spurt:
Expand Down Expand Up @@ -267,7 +272,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
# identity changes with every installation of a dist.
$!id = Any;

{
if $precompile {
my $head = $*REPO;
PROCESS::<$REPO> := self; # Precomp files should only depend on downstream repos
my $precomp = $*REPO.precomp-repository;
Expand Down
12 changes: 7 additions & 5 deletions tools/install-dist.raku
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ multi sub MAIN(
IO() :from(:$dist-prefix) = '.',
IO() :to(:$repo-prefix)!,
:for(:$repo-name)!,
Bool :$build = True,
Bool :$build = True,
Bool :$precompile = True,
) {
if fetch-dist-and-build($dist-prefix, $build) -> $dist {
my $staging := CompUnit::Repository::Staging.new(
:prefix($repo-prefix),
:next-repo(CompUnit::RepositoryRegistry.repository-for-name($repo-name)),
:name($repo-name),
);
$staging.install: $dist;
$staging.install: $dist, :$precompile;
$staging.remove-artifacts;
}
else {
Expand All @@ -27,15 +28,16 @@ multi sub MAIN(
multi sub MAIN(
IO() :from(:$dist-prefix) = '.',
:to(:$repo-id) = 'site',
Bool :$force = False,
Bool :$build = True,
Bool :$force = False,
Bool :$build = True,
Bool :$precompile = True,
) {
with (
CompUnit::RepositoryRegistry.repository-for-name($repo-id),
CompUnit::RepositoryRegistry.repository-for-spec($repo-id),
).first(* ~~ CompUnit::Repository::Installable) -> $repo {
if fetch-dist-and-build($dist-prefix, $build) -> $dist {
$repo.install: $dist, :$force;
$repo.install: $dist, :$precompile, :$force;
}
else {
meh "Could not find distribution at '$dist-prefix'";
Expand Down

0 comments on commit 2511c21

Please sign in to comment.