-
Notifications
You must be signed in to change notification settings - Fork 56
/
Common.pm
64 lines (56 loc) · 1.34 KB
/
Common.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Panda::Common;
use Shell::Command;
sub dirname ($mod as Str) is export {
$mod.subst(':', '_', :g);
}
sub indir (Str $where, Callable $what) is export {
mkpath $where;
temp $*CWD = IO::Spec.rel2abs($where);
$what()
}
sub withp6lib(&what) is export {
my $oldp6lib = %*ENV<PERL6LIB>;
LEAVE {
if $oldp6lib.defined {
%*ENV<PERL6LIB> = $oldp6lib;
}
else {
%*ENV.delete('PERL6LIB');
}
}
my $sep = $*OS eq 'MSWin32' ?? ';' !! ':';
%*ENV<PERL6LIB> = join $sep,
cwd() ~ '/blib/lib',
cwd() ~ '/lib',
%*ENV<PERL6LIB> // '';
what();
}
sub compsuffix is export {
given $*VM<name> {
when 'parrot' {
return 'pir';
}
when 'jvm' {
return 'jar';
}
default {
die($_ ~ ' is an unsuppored backend VM.');
}
}
}
class X::Panda is Exception {
has $.module is rw;
has $.stage;
has $.description;
method new($module, $stage, $description is copy) {
if $description ~~ Failure {
$description = $description.exception.message
}
self.bless(*, :$module, :$stage, :$description)
}
method message {
sprintf "%s stage failed for %s: %s",
$.stage, $.module, $.description
}
}
# vim: ft=perl6