From b97cf9f350c77ad56895b7bd67424dd71e349a17 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 10:28:40 +0200 Subject: [PATCH 01/14] [ext] update to latest version of File::Find --- ext/File/Find.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/File/Find.pm b/ext/File/Find.pm index c649980..9986078 100755 --- a/ext/File/Find.pm +++ b/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) ); } } From 97ebac04593a5371636805fcbb613096d90edd57 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 10:50:53 +0200 Subject: [PATCH 02/14] empty projectsfile is also a reason to update it --- lib/Panda/Ecosystem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Panda/Ecosystem.pm b/lib/Panda/Ecosystem.pm index 5c61f56..4caf7ae 100644 --- a/lib/Panda/Ecosystem.pm +++ b/lib/Panda/Ecosystem.pm @@ -25,7 +25,7 @@ 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; for $list.list -> $mod { my $p = Pies::Project.new( From 8800ec5d8b11b70f670bfa9ab0046f8b98c90fde Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 10:53:20 +0200 Subject: [PATCH 03/14] fix precedence problem in previous commit (97ebac0) --- lib/Panda/Ecosystem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Panda/Ecosystem.pm b/lib/Panda/Ecosystem.pm index 4caf7ae..ac2bd7a 100644 --- a/lib/Panda/Ecosystem.pm +++ b/lib/Panda/Ecosystem.pm @@ -25,7 +25,7 @@ class Panda::Ecosystem does Pies::Ecosystem { } } - self.update if ! $!projectsfile.IO ~~ :f || $!projectsfile.IO ~~ :z; + self.update if $!projectsfile.IO !~~ :f || $!projectsfile.IO ~~ :z; my $list = from-json slurp $!projectsfile; for $list.list -> $mod { my $p = Pies::Project.new( From f3a494dac607d26e886aabf98c2acb3a89a2e176 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 11:04:38 +0200 Subject: [PATCH 04/14] die if from_json($projectsfile) is not defined this gives a slightly better error message than the "Odd number of elements found where hash expected" which Gabor reported on perl6-users@perl.org --- lib/Panda/Ecosystem.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Panda/Ecosystem.pm b/lib/Panda/Ecosystem.pm index ac2bd7a..f3ab528 100644 --- a/lib/Panda/Ecosystem.pm +++ b/lib/Panda/Ecosystem.pm @@ -27,6 +27,9 @@ class Panda::Ecosystem does Pies::Ecosystem { 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, From f4e6b5c57fe6acd7afae35846b98b31b03d96e22 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 20:57:25 +0200 Subject: [PATCH 05/14] [bootstrap.bat] remove trailing space seems to cause damage on win7. [Coke]++ --- bootstrap.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.bat b/bootstrap.bat index a1a1a68..d491fe1 100644 --- a/bootstrap.bat +++ b/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 From 67cca94e87d7d439a51e743a09be3b25b3ccc3eb Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 20:57:38 +0200 Subject: [PATCH 06/14] cosmetic changes --- lib/Panda.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Panda.pm b/lib/Panda.pm index 1e6cccd..7c7c3ae 100644 --- a/lib/Panda.pm +++ b/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, From 2a794e3199c335678f8dfbe1bd9909355e500ebc Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 21:06:21 +0200 Subject: [PATCH 07/14] use double quotes for quoting shell arguments more windows friendly that way. [Coke]++ --- lib/Panda/Ecosystem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Panda/Ecosystem.pm b/lib/Panda/Ecosystem.pm index f3ab528..ffbc7c5 100644 --- a/lib/Panda/Ecosystem.pm +++ b/lib/Panda/Ecosystem.pm @@ -47,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 From 3a31d6ceef84cafb0ceca8f1db1e92a5fc0f9e7f Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 21:23:18 +0200 Subject: [PATCH 08/14] PERL6LIB separator is OS sensitive --- lib/Panda/Builder.pm | 6 +++++- lib/Panda/Tester.pm | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Panda/Builder.pm b/lib/Panda/Builder.pm index a8aa25b..0464085 100644 --- a/lib/Panda/Builder.pm +++ b/lib/Panda/Builder.pm @@ -41,7 +41,11 @@ class Panda::Builder does Pies::Builder { mkpath "blib/$_" for @dirs; my @tobuild = self.build-order(@files); - my $p6lib = "{cwd}/blib/lib:{cwd}/lib:{%*ENV // ''}"; + my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; + my $p6lib = join $sep, + cwd() ~ '/blib/lib', + cwd() ~ '/lib', + %*ENV // ''; for @tobuild -> $file { $file.IO.copy: "blib/{$file.dir}/{$file.name}"; say "Compiling $file"; diff --git a/lib/Panda/Tester.pm b/lib/Panda/Tester.pm index 77ad0ad..7d719b9 100644 --- a/lib/Panda/Tester.pm +++ b/lib/Panda/Tester.pm @@ -11,7 +11,11 @@ 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 // ''}"; + my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; + my $p6lib = join $sep, + cwd() ~ '/blib/lib', + cwd() ~ '/lib', + %*ENV // ''; my $c = "env PERL6LIB=$p6lib prove -e perl6 -r t/"; shell $c and die $p, "Tests failed"; } From 68dc4fe6b4532c81aa52ed17b1bf65a8f9d10bbc Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 1 Jul 2012 21:40:02 +0200 Subject: [PATCH 09/14] set environment variables through %*ENV more portable that way, hopefully --- lib/Panda/Builder.pm | 6 ++++-- lib/Panda/Tester.pm | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Panda/Builder.pm b/lib/Panda/Builder.pm index 0464085..d609942 100644 --- a/lib/Panda/Builder.pm +++ b/lib/Panda/Builder.pm @@ -41,15 +41,17 @@ class Panda::Builder does Pies::Builder { mkpath "blib/$_" for @dirs; my @tobuild = self.build-order(@files); + my $oldp6lib = %*ENV; + LEAVE %*ENV = $oldp6lib; my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; - my $p6lib = join $sep, + %*ENV = join $sep, cwd() ~ '/blib/lib', cwd() ~ '/lib', %*ENV // ''; for @tobuild -> $file { $file.IO.copy: "blib/{$file.dir}/{$file.name}"; say "Compiling $file"; - shell "env PERL6LIB=$p6lib perl6 --target=pir " + shell "perl6 --target=pir " ~ "--output=blib/{$file.dir}/" ~ "{$file.name.subst(/\.pm6?$/, '.pir')} $file" and die $p, "Failed building $file"; diff --git a/lib/Panda/Tester.pm b/lib/Panda/Tester.pm index 7d719b9..729bf0d 100644 --- a/lib/Panda/Tester.pm +++ b/lib/Panda/Tester.pm @@ -12,11 +12,13 @@ class Panda::Tester does Pies::Tester { indir $!resources.workdir($p), { if 't'.IO ~~ :d { my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; - my $p6lib = join $sep, + my $oldp6lib = %*ENV; + LEAVE %*ENV = $oldp6lib; + %*ENV = join $sep, cwd() ~ '/blib/lib', cwd() ~ '/lib', %*ENV // ''; - my $c = "env PERL6LIB=$p6lib prove -e perl6 -r t/"; + my $c = "prove -e perl6 -r t/"; shell $c and die $p, "Tests failed"; } }; From 2d2c253e92ecaf9afdc6320c715ad7e1012b3d56 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Tue, 3 Jul 2012 09:10:35 +0200 Subject: [PATCH 10/14] refactor handling of PERL6LIB setting into a common sub also improve robustness when PERL6LIB started off empty --- lib/Panda/Builder.pm | 23 +++++++++-------------- lib/Panda/Common.pm | 18 ++++++++++++++++++ lib/Panda/Tester.pm | 13 ++++--------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lib/Panda/Builder.pm b/lib/Panda/Builder.pm index d609942..c509f9f 100644 --- a/lib/Panda/Builder.pm +++ b/lib/Panda/Builder.pm @@ -41,20 +41,15 @@ class Panda::Builder does Pies::Builder { mkpath "blib/$_" for @dirs; my @tobuild = self.build-order(@files); - my $oldp6lib = %*ENV; - LEAVE %*ENV = $oldp6lib; - my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; - %*ENV = join $sep, - cwd() ~ '/blib/lib', - cwd() ~ '/lib', - %*ENV // ''; - for @tobuild -> $file { - $file.IO.copy: "blib/{$file.dir}/{$file.name}"; - say "Compiling $file"; - shell "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}"; + say "Compiling $file"; + shell "perl6 --target=pir " + ~ "--output=blib/{$file.dir}/" + ~ "{$file.name.subst(/\.pm6?$/, '.pir')} $file" + and die $p, "Failed building $file"; + } } }; } diff --git a/lib/Panda/Common.pm b/lib/Panda/Common.pm index 94cc3f9..ccf7f4a 100644 --- a/lib/Panda/Common.pm +++ b/lib/Panda/Common.pm @@ -15,6 +15,24 @@ sub indir (Str $where, Callable $what) is export { $!.throw if $!; } +sub withp6lib(&what) is export { + my $oldp6lib = %*ENV; + LEAVE { + if $oldp6lib.defined { + %*ENV = $oldp6lib; + } + else { + %*ENV.delete('PERL6LIB'); + } + } + my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; + %*ENV = join $sep, + cwd() ~ '/blib/lib', + cwd() ~ '/lib', + %*ENV // ''; + what(); +} + class X::Panda is Exception { has $.module; has $.stage; diff --git a/lib/Panda/Tester.pm b/lib/Panda/Tester.pm index 729bf0d..6d05e6d 100644 --- a/lib/Panda/Tester.pm +++ b/lib/Panda/Tester.pm @@ -11,15 +11,10 @@ class Panda::Tester does Pies::Tester { method test(Pies::Project $p) { indir $!resources.workdir($p), { if 't'.IO ~~ :d { - my $sep = $*VM eq 'MSWin32' ?? ';' !! ':'; - my $oldp6lib = %*ENV; - LEAVE %*ENV = $oldp6lib; - %*ENV = join $sep, - cwd() ~ '/blib/lib', - cwd() ~ '/lib', - %*ENV // ''; - my $c = "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"; + } } }; } From 2ce433c695f3c475ac62a0f2352bfcf05d3ba496 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Tue, 3 Jul 2012 09:18:23 +0200 Subject: [PATCH 11/14] simplify &indir --- lib/Panda/Common.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Panda/Common.pm b/lib/Panda/Common.pm index ccf7f4a..4b09d4f 100644 --- a/lib/Panda/Common.pm +++ b/lib/Panda/Common.pm @@ -7,12 +7,10 @@ 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 { From 9b8a6da81a0845e375f95fd0f0fb53f2440562a6 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Tue, 3 Jul 2012 09:23:08 +0200 Subject: [PATCH 12/14] tests for &indir --- t/panda/common.t | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 t/panda/common.t diff --git a/t/panda/common.t b/t/panda/common.t new file mode 100644 index 0000000..69c9148 --- /dev/null +++ b/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'; From a510e5d5a4b1ce15ed5c58378085aef44379fe35 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Wed, 4 Jul 2012 17:34:59 +0200 Subject: [PATCH 13/14] fix regex for finding files to build --- lib/Panda/Builder.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Panda/Builder.pm b/lib/Panda/Builder.pm index 44b4093..42997f9 100644 --- a/lib/Panda/Builder.pm +++ b/lib/Panda/Builder.pm @@ -37,7 +37,7 @@ 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; From 022c0fee7cf1acb05f73705c47e03393f86f3fef Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Wed, 4 Jul 2012 17:37:12 +0200 Subject: [PATCH 14/14] restore file installation order .pm and .pm6 files need to copied before .pir files, otherwise evil breakage ensures --- lib/Panda/Installer.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Panda/Installer.pm b/lib/Panda/Installer.pm index d778a8b..b117ae9 100644 --- a/lib/Panda/Installer.pm +++ b/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)}");