Skip to content

Commit

Permalink
Make build process consistent with non-build dependencies (#253)
Browse files Browse the repository at this point in the history
* Return to spawning in a new process -- this is so its easier to
set the libs available to the dependency. There is probably a nice
way to do this with a temp $*REPO to avoid spawning a new process.

* No longer install build dependencies differently than other
dependencies -- this allows --dry --serial etc to continue being
useful.

Essentially we want each set of dependencies to have an isolated
environment, but installing build dependencies prior to anything
else means its much more difficult to get reproducibility between
run.
  • Loading branch information
ugexe committed May 15, 2018
1 parent 5d203a2 commit b4a9bfb
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion META6.json
Expand Up @@ -31,7 +31,7 @@
"Zef::Service::TAP" : "lib/Zef/Service/TAP.pm6",
"Zef::Service::P6CReporter" : "lib/Zef/Service/P6CReporter.pm6",

"Zef::Service::DistributionBuilder" : "lib/Zef/Service/DistributionBuilder.pm6",
"Zef::Service::Shell::DistributionBuilder" : "lib/Zef/Service/Shell/DistributionBuilder.pm6",
"Zef::Service::Shell::LegacyBuild" : "lib/Zef/Service/Shell/LegacyBuild.pm6",
"Zef::Service::Shell::Test" : "lib/Zef/Service/Shell/Test.pm6",
"Zef::Service::Shell::prove" : "lib/Zef/Service/Shell/prove.pm6",
Expand Down
13 changes: 1 addition & 12 deletions lib/Zef/Client.pm6
@@ -1,7 +1,6 @@
use Zef;
use Zef::Distribution;
use Zef::Distribution::Local;
use Zef::Identity;
use Zef::Repository;
use Zef::Utils::FileSystem;

Expand Down Expand Up @@ -301,6 +300,7 @@ class Zef::Client {
method build(*@candidates ($, *@)) {
my @built = eager gather for @candidates -> $candi {
my $dist := $candi.dist;

unless $!builder.needs-build($dist) {
self.logger.emit({
level => DEBUG,
Expand Down Expand Up @@ -504,17 +504,6 @@ class Zef::Client {
die "Something went terribly wrong determining the build order" unless +@sorted-candidates;


for @sorted-candidates.grep: *.dist.builder -> $candi {
my $builder = "Distribution::Builder::$candi.dist.builder()";
try require ::($builder);
if $! {
my @builder-candidates = self.find-candidates(str2identity($builder));
@builder-candidates.append(self.find-prereq-candidates(|@builder-candidates));
self.install(:@to, |self.fetch(|@builder-candidates));
}
}


# Setup(?) Phase:
# Attach appropriate metadata so we can do --dry runs using -I/some/dep/path
# and can install after we know they pass any required tests
Expand Down
11 changes: 9 additions & 2 deletions lib/Zef/Distribution.pm6
Expand Up @@ -73,8 +73,15 @@ class Zef::Distribution does Distribution is Zef::Distribution::DependencySpecif
}
}
method build-depends-specs {
gather for $.build-depends.grep(*.defined) {
take Zef::Distribution::DependencySpecification.new(system-collapse($_));
gather {
for $.build-depends.grep(*.defined) {
take Zef::Distribution::DependencySpecification.new(system-collapse($_));
}

# XXX: Maybe the full namespace should be required? Otherwise makes it harder
# to handle :ver<> etc like everything else. It also requires external tools
# to have prior knowledge of this special build depends naming convention.
take Zef::Distribution::DependencySpecification.new("Distribution::Builder::{$.builder}") if $.builder
}
}
method test-depends-specs {
Expand Down
13 changes: 0 additions & 13 deletions lib/Zef/Service/DistributionBuilder.pm6

This file was deleted.

27 changes: 27 additions & 0 deletions lib/Zef/Service/Shell/DistributionBuilder.pm6
@@ -0,0 +1,27 @@
use Zef;

class Zef::Service::Shell::DistributionBuilder does Builder does Messenger {
method build-matcher($dist) { ($dist.meta-version // 0) == 1 }
method needs-build($dist) { self.build-matcher($dist) and $dist.builder }

method probe { True }

method build($dist, :@includes) {
die "path does not exist: {$dist.path}" unless $dist.path.IO.e;

my $cmd = "(require ::('Distribution::Builder::$dist.builder()')).new(meta => $dist.meta.perl()).build('$dist.path()') ?? exit(0) !! exit(1)";
my @exec = |($*EXECUTABLE, '-I.', |@includes.grep(*.defined).map({ "-I{$_}" }), '-e', "$cmd");

$.stdout.emit("Command: {@exec.join(' ')}");

my $ENV := %*ENV;
my $passed;
react {
my $proc = zrun-async(@exec);
whenever $proc.stdout.lines { $.stdout.emit($_) }
whenever $proc.stderr.lines { $.stderr.emit($_) }
whenever $proc.start(:$ENV, :cwd($dist.path)) { $passed = $_.so }
}
return $passed;
}
}
2 changes: 1 addition & 1 deletion resources/config.json
Expand Up @@ -119,7 +119,7 @@
"Build" : [
{
"short-name" : "default-builder",
"module" : "Zef::Service::DistributionBuilder"
"module" : "Zef::Service::Shell::DistributionBuilder"
},
{
"short-name" : "legacy-builder",
Expand Down
2 changes: 1 addition & 1 deletion t/00-load.t
Expand Up @@ -31,7 +31,7 @@ subtest {
subtest {
use-ok("Zef::Service::FetchPath");
use-ok("Zef::Service::TAP");
use-ok("Zef::Service::DistributionBuilder");
use-ok("Zef::Service::Shell::DistributionBuilder");
use-ok("Zef::Service::Shell::LegacyBuild");
use-ok("Zef::Service::Shell::Test");
use-ok("Zef::Service::Shell::prove");
Expand Down

0 comments on commit b4a9bfb

Please sign in to comment.