Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #55 from donaldh/jvm-support

Add support for building and installing jars for JVM.
  • Loading branch information...
commit 4547e9616c38879189d450627eb32887d9dc941c 2 parents 6ec5264 + 8674991
@tadzik authored
View
6 lib/Panda/Builder.pm
@@ -76,15 +76,15 @@ method build($where) {
$file.copy: "blib/$file";
next unless $file ~~ /\.pm6?$/;
my $dest = "blib/{$file.directory}/"
- ~ "{$file.basename.subst(/\.pm6?$/, '.pir')}";
+ ~ "{$file.basename.subst(/\.pm6?$/, ".{compsuffix}" )}";
#note "$dest modified: ", $dest.IO.modified;
#note "$file modified: ", $file.IO.modified;
#if $dest.IO.modified >= $file.IO.modified {
# say "$file already compiled, skipping";
# next;
#}
- say "Compiling $file";
- shell "$*EXECUTABLE_NAME --target=pir "
+ say "Compiling $file to {compsuffix}";
+ shell "$*EXECUTABLE_NAME --target={compsuffix} "
~ "--output=$dest $file"
and fail "Failed building $file";
}
View
14 lib/Panda/Common.pm
@@ -31,6 +31,20 @@ sub withp6lib(&what) is export {
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;
View
6 lib/Panda/Installer.pm
@@ -6,9 +6,9 @@ use Shell::Command;
has $.destdir = self.destdir();
method sort-lib-contents(@lib) {
- my @pirs = @lib.grep({ $_ ~~ /\.pir$/});
- my @rest = @lib.grep({ $_ !~~ /\.pir$/});
- return @rest, @pirs;
+ my @generated = @lib.grep({ $_ ~~ / \. <{compsuffix}> $/});
+ my @rest = @lib.grep({ $_ !~~ / \. <{compsuffix}> $/});
+ return @rest, @generated;
}
# default install location
View
5 t/builder.t
@@ -1,4 +1,5 @@
use Test;
+use Panda::Common;
use Panda::Builder;
use Shell::Command;
@@ -8,10 +9,10 @@ my $srcdir = 'testmodules';
lives_ok { Panda::Builder.build("$srcdir/dummymodule") };
-ok "$srcdir/dummymodule/blib/lib/foo.pir".IO ~~ :f, 'module compiled';
+ok "$srcdir/dummymodule/blib/lib/foo.{compsuffix}".IO ~~ :f, 'module compiled';
ok "$srcdir/dummymodule/blib/lib/foo.pm".IO ~~ :f, 'and opied to blib';
ok "$srcdir/dummymodule/blib/lib/manual.pod".IO ~~ :f, 'pod copied too';
-ok "$srcdir/dummymodule/blib/lib/bar.pir".IO !~~ :f, 'pod not compiled';
+ok "$srcdir/dummymodule/blib/lib/bar.{compsuffix}".IO !~~ :f, 'pod not compiled';
ok "$srcdir/dummymodule/blib/lib/foo.js".IO ~~ :f,
'random files also copied to blib';
View
11 t/installer.t
@@ -1,4 +1,5 @@
use Test;
+use Panda::Common;
use Panda::Installer;
use Shell::Command;
@@ -14,7 +15,7 @@ sub file_exists_ok($a as Str, $msg as Str) {
}
file_exists_ok "$dest/lib/foo.pm", 'module installed';
-file_exists_ok "$dest/lib/foo.pir", 'pir installed';
+file_exists_ok "$dest/lib/foo.{compsuffix}", "{compsuffix} installed";
file_exists_ok "$dest/lib/bar.pod", 'pod installed';
file_exists_ok "$dest/lib/baz.js", 'random files installed';
file_exists_ok "$dest/bin/bar", 'bin installed';
@@ -22,10 +23,12 @@ ok "$dest/.git".IO !~~ :e, 'git files not copied';
rm_rf $dest;
-my @lib = <foo.pm foo.pir bam.pir bam.pm blaz.pm blaz.pir shazam.js>;
+my @lib = 'foo.pm', 'foo.' ~ compsuffix, 'bam.' ~ compsuffix,
+ 'bam.pm', 'blaz.pm', 'blaz.' ~ compsuffix, 'shazam.js';
my @order = Panda::Installer.sort-lib-contents(@lib);
is_deeply @order,
- [<foo.pm bam.pm blaz.pm shazam.js foo.pir bam.pir blaz.pir>],
- 'pirs will get installed after rest of the things';
+ [<foo.pm bam.pm blaz.pm shazam.js>,
+ 'foo.' ~ compsuffix, 'bam.' ~ compsuffix, 'blaz.' ~ compsuffix],
+ "{compsuffix}s will get installed after rest of the things";
# vim: ft=perl6
View
0  testmodules/compiled__module/blib/lib/foo.jar
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.