Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'pod-installing' of github.com:tadzik/panda into pod-ins…

…talling
  • Loading branch information...
commit de5092e11be0c0bad22c087542951ca35f61bfa4 2 parents 395943c + b7c1e4d
@tadzik authored
View
2  bootstrap.bat
@@ -1,4 +1,4 @@
-SET PERL6LIB=%CD%\ext;%CD%\lib
+SET PERL6LIB=%CD%\ext;%CD%\lib
perl6 bin\panda install File::Tools JSON::Tiny Test::Mock
SET PERL6LIB=%CD%\lib
perl6 bin\panda install panda
View
8 ext/File/Find.pm
@@ -44,13 +44,9 @@ sub checkrules ($elem, %opts) {
return True
}
-sub file-from-path($path) {
- $path.split('/')[*-1];
-}
-
sub find (:$dir!, :$name, :$type) is export {
my @targets = dir($dir).map: {
- File::Find::Result.new(dir => $dir, name => file-from-path(.path));
+ File::Find::Result.new(dir => $dir, name => .basename);
};
my $list = gather while @targets {
my $elem = @targets.shift;
@@ -58,7 +54,7 @@ sub find (:$dir!, :$name, :$type) is export {
if $elem.IO ~~ :d {
for dir($elem) -> $file {
@targets.push(
- File::Find::Result.new(dir => $elem, name => file-from-path($file.path))
+ File::Find::Result.new(dir => $elem, name => $file.basename)
);
}
}
View
16 lib/Panda.pm
@@ -17,16 +17,16 @@ class Panda is Pies {
method new(:$srcdir, :$destdir, :$statefile, :$projectsfile) {
my $ecosystem = Panda::Ecosystem.new(
- statefile => $statefile,
- projectsfile => $projectsfile,
+ :$statefile,
+ :$projectsfile,
);
- my $resources = Panda::Resources.new(srcdir => $srcdir);
- my $fetcher = Panda::Fetcher.new(resources => $resources);
- my $builder = Panda::Builder.new(resources => $resources);
- my $tester = Panda::Tester.new(resources => $resources);
+ my $resources = Panda::Resources.new(:$srcdir);
+ my $fetcher = Panda::Fetcher.new(:$resources);
+ my $builder = Panda::Builder.new(:$resources);
+ my $tester = Panda::Tester.new(:$resources);
my $installer = Panda::Installer.new(
- resources => $resources,
- destdir => $destdir,
+ :$resources,
+ :$destdir,
);
self.bless(*, :$srcdir, :$destdir, :$statefile, :$projectsfile,
:$ecosystem, :$fetcher, :$builder, :$tester,
View
21 lib/Panda/Builder.pm
@@ -37,20 +37,21 @@ class Panda::Builder does Pies::Builder {
return unless "$workdir/lib".IO ~~ :d;
indir $workdir, {
my @files = find(dir => 'lib',
- name => /\.p(m6?)|(od)$/).list;
+ name => /\.p(m6?|od)$/).list;
my @dirs = @files.map(*.dir).uniq;
mkpath "blib/$_" for @dirs;
my @tobuild = self.build-order(@files);
- my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV<PERL6LIB> // ''}";
- for @tobuild -> $file {
- $file.IO.copy: "blib/{$file.dir}/{$file.name}";
- next if $file ~~ /\.pod$/;
- say "Compiling $file";
- shell "env PERL6LIB=$p6lib perl6 --target=pir "
- ~ "--output=blib/{$file.dir}/"
- ~ "{$file.name.subst(/\.pm6?$/, '.pir')} $file"
- and die $p, "Failed building $file";
+ withp6lib {
+ for @tobuild -> $file {
+ $file.IO.copy: "blib/{$file.dir}/{$file.name}";
+ next if $file ~~ /\.pod$/;
+ say "Compiling $file";
+ shell "perl6 --target=pir "
+ ~ "--output=blib/{$file.dir}/"
+ ~ "{$file.name.subst(/\.pm6?$/, '.pir')} $file"
+ and die $p, "Failed building $file";
+ }
}
};
}
View
24 lib/Panda/Common.pm
@@ -7,12 +7,28 @@ sub dirname ($mod as Str) is export {
sub indir (Str $where, Callable $what) is export {
my $old = cwd;
+ LEAVE chdir $old;
mkpath $where;
chdir $where;
- my $fail;
- try { $what() }
- chdir $old;
- $!.throw if $!;
+ $what()
+}
+
+sub withp6lib(&what) is export {
+ my $oldp6lib = %*ENV<PERL6LIB>;
+ LEAVE {
+ if $oldp6lib.defined {
+ %*ENV<PERL6LIB> = $oldp6lib;
+ }
+ else {
+ %*ENV.delete('PERL6LIB');
+ }
+ }
+ my $sep = $*VM<config><osname> eq 'MSWin32' ?? ';' !! ':';
+ %*ENV<PERL6LIB> = join $sep,
+ cwd() ~ '/blib/lib',
+ cwd() ~ '/lib',
+ %*ENV<PERL6LIB> // '';
+ what();
}
class X::Panda is Exception {
View
7 lib/Panda/Ecosystem.pm
@@ -25,8 +25,11 @@ class Panda::Ecosystem does Pies::Ecosystem {
}
}
- self.update if not $!projectsfile.IO ~~ :f;
+ self.update if $!projectsfile.IO !~~ :f || $!projectsfile.IO ~~ :z;
my $list = from-json slurp $!projectsfile;
+ unless defined $list {
+ die "An unknown error occured while reading the projects file";
+ }
for $list.list -> $mod {
my $p = Pies::Project.new(
name => $mod<name>,
@@ -44,7 +47,7 @@ class Panda::Ecosystem does Pies::Ecosystem {
method update {
try unlink $!projectsfile;
- shell "wget 'feather.perl6.nl:3000/list' -O '$!projectsfile'";
+ shell qq[wget "feather.perl6.nl:3000/list" -O "$!projectsfile"];
}
# Pies::Ecosystem methods
View
4 lib/Panda/Installer.pm
@@ -14,7 +14,9 @@ class Panda::Installer does Pies::Installer {
method install(Pies::Project $p) {
indir $!resources.workdir($p), {
if 'blib'.IO ~~ :d {
- for find(dir => 'blib', type => 'file').list -> $i {
+ for find(dir => 'blib', name => /\.p[od|m6?]$/).list,
+ find(dir => 'blib', name => /\.pir$/).list
+ -> $i {
# .substr(5) to skip 'blib/'
mkpath "$!destdir/{$i.dir.substr(5)}";
$i.IO.copy("$!destdir/{$i.Str.substr(5)}");
View
7 lib/Panda/Tester.pm
@@ -11,9 +11,10 @@ class Panda::Tester does Pies::Tester {
method test(Pies::Project $p) {
indir $!resources.workdir($p), {
if 't'.IO ~~ :d {
- my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV<PERL6LIB> // ''}";
- my $c = "env PERL6LIB=$p6lib prove -e perl6 -r t/";
- shell $c and die $p, "Tests failed";
+ withp6lib {
+ my $c = "prove -e perl6 -r t/";
+ shell $c and die $p, "Tests failed";
+ }
}
};
}
View
9 t/panda/common.t
@@ -0,0 +1,9 @@
+use v6;
+use Test;
+use Panda::Common;
+
+plan 2;
+my $cwd = cwd;
+
+dies_ok { indir 't', { die "OH NOEZ" } }, '&indir passes exceptions on';
+is cwd(), $cwd, 'indir rewinds cwd even when exceptions were thrown';
Please sign in to comment.
Something went wrong with that request. Please try again.