aboutsummaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/jasmin
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2019-11-05 19:50:31 +0100
committerFrancesco Gazzetta <fgaz@fgaz.me>2019-11-06 15:43:29 +0100
commit446368e5290f98617838c73d4905d85f40494a4f (patch)
treebf3665d2eb1b3e84a86633c6fa44cee7a472056e /pkgs/development/compilers/jasmin
parentfa2909bf51c29d568dd9ce5c27cdbf7393644909 (diff)
jasmin: init at 2.4
Diffstat (limited to 'pkgs/development/compilers/jasmin')
-rw-r--r--pkgs/development/compilers/jasmin/default.nix44
-rw-r--r--pkgs/development/compilers/jasmin/test-assemble-hello-world/HelloWorld.j31
-rw-r--r--pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix12
3 files changed, 87 insertions, 0 deletions
diff --git a/pkgs/development/compilers/jasmin/default.nix b/pkgs/development/compilers/jasmin/default.nix
new file mode 100644
index 000000000000..ef1b3055190e
--- /dev/null
+++ b/pkgs/development/compilers/jasmin/default.nix
@@ -0,0 +1,44 @@
+{ stdenv
+, fetchurl
+, unzip
+, jdk
+, ant
+, makeWrapper
+, jre
+, callPackage
+}:
+
+stdenv.mkDerivation rec {
+ pname = "jasmin";
+ version = "2.4";
+
+ src = fetchurl {
+ url = "mirror://sourceforge/jasmin/jasmin-${version}/jasmin-${version}.zip";
+ sha256 = "17a41vr96glcdrdbk88805wwvv1r6w8wg7if23yhd0n6rrl0r8ga";
+ };
+
+ nativeBuildInputs = [ unzip jdk ant makeWrapper ];
+
+ buildPhase = "ant all";
+ installPhase =
+ ''
+ install -Dm644 jasmin.jar $out/share/java/jasmin.jar
+ mkdir -p $out/bin
+ makeWrapper ${jre}/bin/java $out/bin/jasmin \
+ --add-flags "-jar $out/share/java/jasmin.jar"
+ '';
+
+ passthru.tests = {
+ minimal-module = callPackage ./test-assemble-hello-world {};
+ };
+
+ meta = with stdenv.lib; {
+ description = "An assembler for the Java Virtual Machine";
+ homepage = "http://jasmin.sourceforge.net/";
+ downloadPage = "https://sourceforge.net/projects/jasmin/files/latest/download";
+ license = licenses.bsd3;
+ maintainers = with maintainers; [ fgaz ];
+ platforms = platforms.all;
+ };
+}
+
diff --git a/pkgs/development/compilers/jasmin/test-assemble-hello-world/HelloWorld.j b/pkgs/development/compilers/jasmin/test-assemble-hello-world/HelloWorld.j
new file mode 100644
index 000000000000..564e6c8a9aa2
--- /dev/null
+++ b/pkgs/development/compilers/jasmin/test-assemble-hello-world/HelloWorld.j
@@ -0,0 +1,31 @@
+.class public HelloWorld
+.super java/lang/Object
+
+;
+; standard initializer (calls java.lang.Object's initializer)
+;
+.method public <init>()V
+ aload_0
+ invokenonvirtual java/lang/Object/<init>()V
+ return
+.end method
+
+;
+; main() - prints out Hello World
+;
+.method public static main([Ljava/lang/String;)V
+ .limit stack 2 ; up to two items can be pushed
+
+ ; push System.out onto the stack
+ getstatic java/lang/System/out Ljava/io/PrintStream;
+
+ ; push a string onto the stack
+ ldc "Hello World!"
+
+ ; call the PrintStream.println() method.
+ invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
+
+ ; done
+ return
+.end method
+
diff --git a/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix b/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix
new file mode 100644
index 000000000000..1840edffa779
--- /dev/null
+++ b/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix
@@ -0,0 +1,12 @@
+{ stdenv, jasmin, jre }:
+
+stdenv.mkDerivation {
+ name = "jasmin-test-assemble-hello-world";
+ meta.timeout = 60;
+ buildCommand = ''
+ ${jasmin}/bin/jasmin ${./HelloWorld.j}
+ ${jre}/bin/java HelloWorld | grep "Hello World"
+ touch $out
+ '';
+}
+