Compare commits

..

No commits in common. "61a833ca3c47fefdddff27c1df08cf462dac8139" and "16e4f08dfaf93e1dbca7154dccd8c5e633d17a84" have entirely different histories.

35 changed files with 222 additions and 265 deletions

22
packages/brainfuck/2.7.3/build.sh vendored Normal file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Put instructions to build your package in here
PREFIX=$(realpath $(dirname $0))
git clone https://github.com/fabianishere/brainfuck.git
cd brainfuck
git checkout 06f84462e0a96487670a4b8024e3ec531e0377ee
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX/ -DENABLE_EDITLINE=OFF
make -j$(nproc)
make install -j$(nproc)
cd ../../
rm -rf brainfuck

4
packages/brainfuck/2.7.3/environment vendored Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/bin:$PATH

View file

@ -0,0 +1,5 @@
{
"language": "brainfuck",
"version": "2.7.3",
"aliases": ["bf"]
}

4
packages/brainfuck/2.7.3/run vendored Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Put instructions to run the runtime
fold -w1 | brainfuck $1

1
packages/brainfuck/2.7.3/test.bf vendored Normal file
View file

@ -0,0 +1 @@
-[--->+<]>------.----.

10
packages/coffeescript/2.5.1/build.sh vendored Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# Download and install NodeJS
curl "https://nodejs.org/dist/v15.10.0/node-v15.10.0-linux-x64.tar.xz" -o node.tar.xz
tar xf node.tar.xz --strip-components=1
rm node.tar.xz
export PATH=$PWD/bin:$PATH
# Install CoffeeScript via npm and done
npm install --global coffeescript@2.5.1

View file

@ -0,0 +1 @@
export PATH=$PWD/bin:$PATH

View file

@ -0,0 +1,5 @@
{
"language": "coffeescript",
"version": "2.5.1",
"aliases": ["coffeescript", "coffee"]
}

3
packages/coffeescript/2.5.1/run vendored Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
coffee "$@"

View file

@ -0,0 +1 @@
console.log "OK"

6
packages/llvm_ir/12.0.1/build.sh vendored Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz" -o llvm-ir.tar.xz
tar xf llvm-ir.tar.xz clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-/bin --strip-components=1
rm llvm-ir.tar.xz

4
packages/llvm_ir/12.0.1/compile vendored Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
llc "$@" -o binary.s
clang binary.s -o binary

2
packages/llvm_ir/12.0.1/environment vendored Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
export PATH=$PWD/bin:$PATH

5
packages/llvm_ir/12.0.1/metadata.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"language": "llvm_ir",
"version": "12.0.1",
"aliases": ["llvm", "llvm-ir", "ll"]
}

4
packages/llvm_ir/12.0.1/run vendored Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
shift
binary "$@"

10
packages/llvm_ir/12.0.1/test.ll vendored Normal file
View file

@ -0,0 +1,10 @@
@.str = private unnamed_addr constant [2 x i8] c"OK"
declare i32 @puts(i8* nocapture) nounwind
define i32 @main() {
%cast210 = getelementptr [2 x i8],[2 x i8]* @.str, i64 0, i64 0
call i32 @puts(i8* %cast210)
ret i32 0
}

32
packages/mono/6.12.0/build.sh vendored Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
PREFIX=$(realpath $(dirname $0))
mkdir -p build/mono build/mono-basic
cd build
curl "https://download.mono-project.com/sources/mono/mono-6.12.0.122.tar.xz" -o mono.tar.xz
curl -L "https://github.com/mono/mono-basic/archive/refs/tags/4.7.tar.gz" -o mono-basic.tar.gz
tar xf mono.tar.xz --strip-components=1 -C mono
tar xf mono-basic.tar.gz --strip-components=1 -C mono-basic
# Compiling Mono
cd mono
./configure --prefix "$PREFIX"
make -j$(nproc)
make install -j$(nproc)
export PATH="$PREFIX/bin:$PATH" # To be able to use mono commands
# Compiling mono-basic
cd ../mono-basic
./configure --prefix="$PREFIX"
make -j$(nproc) PLATFORM="linux" # Avoids conflict with the $PLATFORM variable we have
make install -j$(nproc) PLATFORM="linux"
# Remove redundant files
cd ../../
rm -rf build

16
packages/mono/6.12.0/compile vendored Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
case "${PISTON_LANGUAGE}" in
csharp)
rename 's/$/\.cs/' "$@" # Add .cs extension
csc -out:out *.cs
;;
basic)
rename 's/$/\.vb/' "$@" # Add .vb extension
vbnc -out:out *.vb
;;
*)
echo "How did you get here? (${PISTON_LANGUAGE})"
exit 1
;;
esac

1
packages/mono/6.12.0/environment vendored Normal file
View file

@ -0,0 +1 @@
export PATH=$PWD/bin:$PATH

20
packages/mono/6.12.0/metadata.json vendored Normal file
View file

@ -0,0 +1,20 @@
{
"language": "mono",
"version": "6.12.0",
"provides": [
{
"language": "csharp",
"aliases": ["mono", "mono-csharp", "mono-c#", "mono-cs", "c#", "cs"]
},
{
"language": "basic",
"aliases": [
"vb",
"mono-vb",
"mono-basic",
"visual-basic",
"visual basic"
]
}
]
}

4
packages/mono/6.12.0/run vendored Normal file
View file

@ -0,0 +1,4 @@
#!/bin/bash
shift
mono out "$@"

9
packages/mono/6.12.0/test.cs vendored Normal file
View file

@ -0,0 +1,9 @@
using System;
public class Test
{
public static void Main(string[] args)
{
Console.WriteLine("OK");
}
}

9
packages/mono/6.12.0/test.vb vendored Normal file
View file

@ -0,0 +1,9 @@
Imports System
Module Module1
Sub Main()
Console.WriteLine("OK")
End Sub
End Module

11
packages/scala/3.0.0/build.sh vendored Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Download and extract JDK8
curl -L "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz" -o jdk.tar.gz
tar xzf jdk.tar.gz --strip-components=1
rm jdk.tar.gz
# Download and extract Scala 3
curl -L "https://github.com/lampepfl/dotty/releases/download/3.0.0/scala3-3.0.0.tar.gz" -o scala.tar.gz
tar -xzf scala.tar.gz --strip-components=1
rm scala.tar.gz

15
packages/scala/3.0.0/compile vendored Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Compile scala classes into a jar file
scalac "$@" -d out.jar
# Create the Manifest and include scala lib jars:
# NOTE: - entry point will only consider @main and App traits from the main file
# - scala lib jars will be added to the class path in order to run the jar properly
echo "Main-Class: $(grep -oP '\@main\s+def\s+\K[a-zA-Z][a-zA-Z0-9]*|object\s+\K[a-zA-Z][a-zA-Z0-9]*(?=\s+extends\s+App)' $1)
Class-Path: $(echo $JAVA_HOME/lib/*.jar | sed 's/\s/\n /g')
" > manifest.txt
# Update the jar with the manifest
jar ufm out.jar manifest.txt

5
packages/scala/3.0.0/environment vendored Normal file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Scala requires JAVA_HOME to be set
export JAVA_HOME=$PWD
export PATH=$PWD/bin:$PATH

5
packages/scala/3.0.0/metadata.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"language": "scala",
"version": "3.0.0",
"aliases": ["sc"]
}

5
packages/scala/3.0.0/run vendored Normal file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Run jar file
shift
java -jar out.jar "$@"

3
packages/scala/3.0.0/test.scala vendored Normal file
View file

@ -0,0 +1,3 @@
@main def run(): Unit = {
println("OK")
}

View file

@ -1,55 +0,0 @@
{pkgs, piston, ...}:
let
# All other BF packages are either marked as broken in nix-pkgs
# or have missing functionality. Yabi isn't perfect either.
pkg = pkgs.haskellPackages.yabi;
in piston.mkRuntime {
language = "brainfuck";
version = pkg.version;
aliases = [
"bf"
"yabi"
];
run = ''
# Yabi produces messages when parsing the BF file that are sent to stderr
# Yabi will also break when trying to take more input at EOF
${pkg}/bin/yabi "$1" 2> /dev/null
'';
tests = [
# stdout test
(piston.mkTest {
files = {
"test.bf" = ''-[--->+<]>------.----.'';
};
args = [];
stdin = "";
packages = [];
main = "test.bf";
})
# stdin test
(piston.mkTest {
files = {
"test.bf" = '',.,.'';
};
args = [];
stdin = "OK";
packages = [];
main = "test.bf";
})
# bf doesn't take args test
(piston.mkTest {
files = {
"test.bf" = ''-[--->+<]>------.----.'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.bf";
})
];
}

View file

@ -58,9 +58,4 @@ args: {
"dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args;
"dotnet-sdk-visual-basic" = import ./dotnet-sdk-visual-basic.nix args;
"fpc-pascal" = import ./fpc-pascal.nix args;
"brainfuck" = import ./brainfuck.nix args;
"node-coffeescript" = import ./node-coffeescript.nix args;
"jvm-scala" = import ./jvm-scala.nix args;
"llvm_ir" = import ./llvm_ir.nix args;
"mono-basic" = import ./mono-basic.nix args;
}

View file

@ -1,54 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.scala;
java = pkgs.jdk8;
sed = pkgs.gnused;
in piston.mkRuntime {
language = "scala";
version = pkg.version;
runtime = "jvm";
aliases = [
"sc"
];
compile = ''
# Compile scala classes into a jar file
${pkg}/bin/scalac "$@" -d out.jar
# Capture extra class-path libraries
java_libs="$(echo ${java}/lib/openjdk/lib/*.jar | ${sed}/bin/sed 's/\s/\\n /g')"
scala_libs="$(echo ${pkg}/lib/*.jar | ${sed}/bin/sed 's/\s/\\n /g')"
echo -e "Class-Path: $java_libs
$scala_libs
" > classPath
# Update the jar manifest with scala libs
${java}/bin/jar umf classPath out.jar
'';
run = ''
# Run jar from compile
shift
${java}/bin/java -jar out.jar "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.sc" = ''
object Main {
def main(args: Array[String]) = {
println("OK")
}
}
'';
};
args = [];
stdin = "";
packages = [];
main = "test.sc";
})
];
}

View file

@ -1,47 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.llvm;
clang = pkgs.llvmPackages_13.libcxxClang;
in piston.mkRuntime {
language = "llvm_ir";
version = clang.version;
aliases = [
"llvm"
"llvm-ir"
"ll"
];
compile = ''
${pkg}/bin/llc "$@" -o binary.s
${clang}/bin/clang binary.s -o binary
'';
run = ''
shift
./binary "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.ll" = ''
@.str = private unnamed_addr constant [2 x i8] c"OK"
declare i32 @puts(i8* nocapture) nounwind
define i32 @main() {
%cast210 = getelementptr [2 x i8],[2 x i8]* @.str, i64 0, i64 0
call i32 @puts(i8* %cast210)
ret i32 0
}
'';
};
args = [];
stdin = "";
packages = [];
main = "test.ll";
})
];
}

View file

@ -1,47 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.mono;
in piston.mkRuntime {
language = "basic";
version = pkg.version;
runtime = "mono";
aliases = [
"vb"
"mono-vb"
"mono-basic"
"visual-basic"
];
compile = ''
rename 's/$/\.vb/' "$@" # Add .vb extension
${pkg}/bin/vbc -out:out -sdkpath:${pkg}/lib/mono/4.8-api *.vb
'';
run = ''
shift
${pkg}/bin/mono out.exe "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.vb" = ''
Imports System
Module Module1
Sub Main()
Console.WriteLine("OK")
End Sub
End Module
'';
};
args = [];
stdin = "";
packages = [];
main = "test.vb";
})
];
}

View file

@ -1,57 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.nodePackages.coffee-script;
in piston.mkRuntime {
language = "coffeescript";
version = pkg.version;
runtime = "node";
aliases = [
"coffee"
];
run = ''
${pkg}/bin/coffee "$@"
'';
tests = [
# stdout test
(piston.mkTest {
files = {
"test.coffee" = ''
console.log "OK"
'';
};
args = [];
stdin = "";
packages = [];
main = "test.coffee";
})
# args test
(piston.mkTest {
files = {
"test.coffee" = ''
console.log process.argv[2]
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.coffee";
})
# stdin test
(piston.mkTest {
files = {
"test.coffee" = ''
process.stdin.on('data', (data) => console.log(data.toString()))
'';
};
args = [];
stdin = "OK";
packages = [];
main = "test.coffee";
})
];
}