-
-
Save ugexe/c9222be48783d9e81163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Zef::Phase::Building; | |
use Zef::Depends; | |
use JSON::Tiny; | |
class Zef::Builder does Zef::Phase::Building { | |
has @.plugins; | |
submethod BUILD(:@!plugins) { | |
for @!plugins -> $p { | |
self does ::($p) if do { require ::($p); ::($p).does(Zef::Phase::Building) }; | |
} | |
} | |
multi method pre-compile(*@paths is copy) { | |
my @precompiled; | |
while @paths.shift -> $path { | |
my @INC = "$path/lib".IO, "$path/blib/lib".IO; | |
my @sources = Zef::Depends.comb($*SPEC.catpath('', $path, 'lib')); | |
for @sources -> $module { | |
my $cu = CompUnit.new($module<file>); | |
my $out = "{$*CWD}/blib/{$module<file>.IO.relative}.{$*VM.precomp-ext}" andthen .IO.dirname.IO.mkdir; | |
$out.IO.unlink if $out.IO.e; | |
my $result = $cu.precomp(:force, $out, :@INC); | |
"[{$module<file>.subst(/ $path ['/' || '\\'] /, '')}] {'.' x 77 - $module<file>.chars} ".print; | |
if $result && $out.IO ~~ :e { # so just check for the file's existence | |
@precompiled.push($out.IO); | |
"OK $out".say; | |
} | |
else { | |
"FAILED".say; | |
die "Failed to compile: $out"; | |
} | |
} | |
} | |
return @precompiled; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment