DistributionBuilder
=title class Zef::Service::Shell::DistributionBuilder
=subtitle A META6-supplied raku module based implementation of the Builder interface
Synopsis
use Zef;
use Zef::Service::Shell::DistributionBuilder;
my $builder = Zef::Service::Shell::DistributionBuilder.new;
# Add logging if we want to see output
my $stdout = Supplier.new;
my $stderr = Supplier.new;
$stdout.Supply.tap: { say $_ };
$stderr.Supply.tap: { note $_ };
# Assuming our current directory is a raku distribution with something like
# `"builder" : "Distribution::Builder::MakeFromJSON"` in its META6.json
# and has no dependencies (or all dependencies already installed)...
my $dist-to-build = Zef::Distribution::Local.new($*CWD);
my Str @includes = $*CWD.absolute;
my $built-ok = so $builder.build($dist-to-build, :@includes, :$stdout, :$stderr);
say $built-ok ?? "OK" !! "Something went wrong";
Description
Builder
class for handling local distributions that include a "builder" : "..."
in their META6.json
.
For example "builder" : "Distribution::Builder::MakeFromJSON"
will spawn a process where it passes the
module Distribution::Builder::MakeFromJSON
the path of the distribution and the parsed meta data (from which
it may use other instructions from non-standard fields in the META6.json
).
Methods
method probe
method probe(--> Bool:D)
Returns True
if this module can successfully launch the raku
command (i.e. always returns True
).
method build-matcher
method build-matcher(Zef::Distribution::Local $dist --> Bool:D)
Returns True
if this module knows how to test $uri
. This module always returns True
right now since
it just uses the raku
command.
method build
method build(Zef::Distribution::Local $dist, Str :@includes, Supplier :$stdout, Supplier :$stderr --> Bool:D)
Launches a process to invoke whatever module is in the builder
field of the $dist
META6.json while passing
that module the meta data of $dist
it is to build (allowing non-spec keys to be used by such modules to allow
consumers/authors to supply additional data). A Supplier
can be supplied as :$stdout
and :$stderr
to receive
any output.
See Distribution::Builder::MakeFromJSON
in the ecosystem for an example of such a builder
, and see Inline::Python
for an example of a distribution built using such a builder
.
Returns True
if the raku
process spawned to run the build module exits 0.