Skip to content

Commit

Permalink
Merge pull request #548 from ugexe/ugexe/precomp-flag
Browse files Browse the repository at this point in the history
Add --/precompile-install flag
  • Loading branch information
ugexe authored Feb 9, 2024
2 parents cb8e045 + 5d4cf5b commit 90b04cc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ test_script:
# test zef test
- raku -I. bin/zef --debug --raku-test test .

# run relative local path test + install
# run relative local path test + install + disable precompilation
# (we also test --/precompile-install in other ci tests here, but
# it doesn't seem to work right on appveyor)
- raku -I. bin/zef --debug install .

# test uninstall
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ variables:
# test zef test
raku -I. bin/zef --debug test .
# run relative local path test + install
raku -I. bin/zef --debug install .
# run relative local path test + install + disable precompilation
raku -I. bin/zef --debug --/precompile-install install .
# test uninstall
raku -I. bin/zef uninstall zef
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ to fulfill any dependencies of other requested identities.
--test-timeout=3600
--install-timeout=3600

# or set the default to all unset --*-timeout flags to 0
--timeout=0

# Number of simultaneous distributions/jobs to process for the corresponding phases
--fetch-degree=5
--test-degree=1

# or set the default to all unset --*-timeout flags to 0
--timeout=0
# Disable precompilation during installation
--/precompile-install

# Do everything except the actual installations
--dry
Expand Down
16 changes: 13 additions & 3 deletions lib/Zef/CLI.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ package Zef::CLI {
Int :$degree,
Int :$fetch-degree = %*ENV<ZEF_FETCH_DEGREE> || $degree || 5, # default different from Zef::Client
Int :$test-degree = %*ENV<ZEF_TEST_DEGREE> || $degree || 1,
Bool :$precompile-install,
Bool :$dry,
Bool :$upgrade,# Not Yet Implemented
Bool :$deps-only,
Expand Down Expand Up @@ -176,6 +177,8 @@ package Zef::CLI {
If C<$test-degree> is set zef will test up to that many distributions in parallel.
If C<$precompile-install> is set to C<False> then Raku code won't be precompiled during installation.
If C<$dry> is set to C<True> then the final step of actually installing the distribution will be skipped and considered a success.
If C<$deps-only> is set to C<True> then only the dependencies of the requested identities will be processed.
Expand Down Expand Up @@ -414,6 +417,7 @@ package Zef::CLI {
Int :$degree,
Int :$fetch-degree = %*ENV<ZEF_FETCH_DEGREE> || $degree || 5, # default different from Zef::Client
Int :$test-degree = %*ENV<ZEF_TEST_DEGREE> || $degree || 1,
Bool :$precompile-install = True,
Bool :$dry,
Bool :$upgrade,
Bool :$deps-only,
Expand Down Expand Up @@ -441,7 +445,7 @@ package Zef::CLI {
:$force-build, :$force-test, :$force-install,
:$fetch-timeout, :$extract-timeout, :$build-timeout,
:$test-timeout, :$install-timeout, :$fetch-degree,
:$test-degree,
:$test-degree, :$precompile-install,
);

my CompUnit::Repository @at = $install-to.map(*.&str2cur);
Expand Down Expand Up @@ -595,6 +599,7 @@ package Zef::CLI {
Int :$degree,
Int :$fetch-degree = %*ENV<ZEF_FETCH_DEGREE> || $degree || 5, # default different from Zef::Client,
Int :$test-degree = %*ENV<ZEF_TEST_DEGREE> || $degree || 1,
Bool :$precompile-install = True,
Bool :$dry,
Bool :$update,
Bool :$serial,
Expand All @@ -613,7 +618,7 @@ package Zef::CLI {
:$force-build, :$force-test, :$force-install,
:$fetch-timeout, :$extract-timeout, :$build-timeout,
:$test-timeout, :$install-timeout, :$fetch-degree,
:$test-degree
:$test-degree, :$precompile-install,
);

my @missing = @identities.grep: { not $client.is-installed($_) };
Expand Down Expand Up @@ -656,6 +661,7 @@ package Zef::CLI {
:$test-timeout,
:$fetch-degree,
:$test-degree,
:$precompile-install,
:$dry,
:$serial,
);
Expand Down Expand Up @@ -936,6 +942,7 @@ package Zef::CLI {
Int :$degree,
Int :$fetch-degree = %*ENV<ZEF_FETCH_DEGREE> || $degree || 5, # default different from Zef::Client,
Int :$test-degree = %*ENV<ZEF_TEST_DEGREE> || $degree || 1,
Bool :$precompile-install,
Bool :$update,
Bool :$upgrade,
Bool :$dry,
Expand All @@ -950,7 +957,7 @@ package Zef::CLI {
:$force-build, :$force-test, :$force-install,
:$fetch-timeout, :$extract-timeout, :$build-timeout,
:$test-timeout, :$install-timeout, :$fetch-degree,
:$test-degree,
:$test-degree, :$precompile-install,
);

my @identities = $client.list-available.map(*.dist.identity).unique;
Expand Down Expand Up @@ -979,6 +986,7 @@ package Zef::CLI {
:$test-timeout,
:$fetch-degree,
:$test-degree,
:$precompile-install,
:$dry,
:$serial,
);
Expand Down Expand Up @@ -1081,6 +1089,8 @@ package Zef::CLI {
--[phase]-timeout=[int] Set a timeout (in seconds) for the corresponding phase ( phase: fetch, extract, build, test, install )
--[phase]-degree=[int] Number of simultaneous distributions/jobs to process for the corresponding phase ( phase : fetch, test )
--/precompile-install Skip precompiling during installation
--update Force a refresh for all module indexes
--update=[ecosystem] Force a refresh for a specific ecosystem module index
Expand Down
7 changes: 5 additions & 2 deletions lib/Zef/Client.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ class Zef::Client {
#| If test time dependencies should be considered when building distributions
has Bool $.test-depends is rw = True;

#| If precompilation should occur during the installation stage
has Bool $.precompile-install is rw = True;

submethod TWEAK(
:$!cache = %!config<StoreDir>.IO,
:$!fetcher = Zef::Fetch.new(:backends(|%!config<Fetch>)),
Expand Down Expand Up @@ -807,7 +810,7 @@ class Zef::Client {
}
}

take $candi if $!installer.install($candi, :$cur, :force($!force-install), :$!logger, :timeout($!install-timeout));
take $candi if $!installer.install($candi, :$cur, :force($!force-install), :precompile($!precompile-install), :$!logger, :timeout($!install-timeout));
}
}

Expand Down Expand Up @@ -1084,7 +1087,7 @@ class Zef::Client {
});
my Str @includes = $staging-repo.path-spec;
$_.dist.metainfo<includes> = @includes;
$staging-repo.install($_.dist);
$staging-repo.install($_.dist, :precompile($!precompile-install));
self.logger.emit({
level => INFO,
stage => STAGING,
Expand Down
6 changes: 3 additions & 3 deletions lib/Zef/Install.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class Zef::Install does Installer does Pluggable {
=head2 method install
method install(Candidate $candi, CompUnit::Repository :$cur!, Bool :$force, Supplier :$logger, Int :$timeout --> Bool:D)
method install(Candidate $candi, CompUnit::Repository :$cur!, Bool :$force, Bool :$precompile, Supplier :$logger, Int :$timeout --> Bool:D)
Installs the distribution C<$candi.dist> to C<$cur> (see synopsis). Set C<$force> to C<True> to allow installing a distribution
that is already installed.
that is already installed. If C<$precompile> is C<False> then it will not precompile during installation.
An optional C<:$logger> can be supplied to receive events about what is occurring.
Expand Down Expand Up @@ -83,7 +83,7 @@ class Zef::Install does Installer does Pluggable {

#| Install the distribution in $candi.dist to the $cur CompUnit::Repository.
#| Use :force to install over an existing distribution using the same name/auth/ver/api
method install(Candidate $candi, CompUnit::Repository :$cur!, Bool :$force, Supplier :$logger, Int :$timeout --> Bool:D) {
method install(Candidate $candi, CompUnit::Repository :$cur!, Bool :$force, Bool :$precompile, Supplier :$logger, Int :$timeout --> Bool:D) {
my $dist = $candi.dist;
my $installer = self!install-matcher($dist).first(*.so);
die "No installing backend available" unless ?$installer;
Expand Down
11 changes: 6 additions & 5 deletions lib/Zef/Service/InstallRakuDistribution.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ class Zef::Service::InstallRakuDistribution does Installer {
=head2 method install
method install(Distribution $dist, CompUnit::Repository :$cur, Bool :$force, Supplier $stdout, Suppluer :$stderr --> Bool:D)
method install(Distribution $dist, CompUnit::Repository :$cur, Bool :$force, Bool :$precompile, Supplier $stdout, Suppluer :$stderr --> Bool:D)
Install the distribution C<$dist> to the CompUnit::Repository C<$cur>. If C<$force> is C<True>
then it will allow reinstalling an already installed distribution. A C<Supplier> can be supplied
as C<:$stdout> and C<:$stderr> to receive any output.
then it will allow reinstalling an already installed distribution. If C<$precompile> is C<False>
then it will not precompile during installation. A C<Supplier> can be supplied as C<:$stdout>
and C<:$stderr> to receive any output.
Returns C<True> if the install succeeded.
Expand All @@ -77,8 +78,8 @@ class Zef::Service::InstallRakuDistribution does Installer {

#| Install the distribution in $candi.dist to the $cur CompUnit::Repository.
#| Use :force to install over an existing distribution using the same name/auth/ver/api
method install(Distribution $dist, CompUnit::Repository :$cur, Bool :$force, Supplier :$stdout, Supplier :$stderr --> Bool:D) {
$cur.install($dist, :$force);
method install(Distribution $dist, CompUnit::Repository :$cur, Bool :$force, Bool :$precompile, Supplier :$stdout, Supplier :$stderr --> Bool:D) {
$cur.install($dist, :$precompile, :$force);
return True;
}
}

0 comments on commit 90b04cc

Please sign in to comment.