From c36c5a6e63fed7d417f57f1c6b18e5b0dadbf557 Mon Sep 17 00:00:00 2001 From: aveliz1999 Date: Thu, 4 Jun 2020 15:01:14 -0400 Subject: [PATCH] Add Kotlin support --- api/main.go | 1 + lxc/execute | 3 +++ lxc/executors/kotlin | 4 ++++ lxc/versions | 3 +++ readme.md | 8 ++++++++ tests/test.kt | 3 +++ tests/test_all_lxc | 2 ++ 7 files changed, 24 insertions(+) create mode 100755 lxc/executors/kotlin create mode 100644 tests/test.kt diff --git a/api/main.go b/api/main.go index 9cd0b3e..d42fe81 100644 --- a/api/main.go +++ b/api/main.go @@ -73,6 +73,7 @@ func Execute(res http.ResponseWriter, req *http.Request) { "go", "java", "julia", "jl", + "kotlin", "nasm", "asm", "node", "javascript", "js", "php", diff --git a/lxc/execute b/lxc/execute index e8a9f50..8d51760 100755 --- a/lxc/execute +++ b/lxc/execute @@ -66,6 +66,9 @@ case "$lang" in "julia" | "jl") bin=julia ;; +"kotlin") + bin=kotlin + ;; "nasm" | "asm") bin=nasm ;; diff --git a/lxc/executors/kotlin b/lxc/executors/kotlin new file mode 100755 index 0000000..dcd5eff --- /dev/null +++ b/lxc/executors/kotlin @@ -0,0 +1,4 @@ +cd /tmp/$2 +cp code.code code.kt +timeout -s KILL 10 kotlinc code.kt -include-runtime -d code.jar +runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 java -jar code.jar" diff --git a/lxc/versions b/lxc/versions index f53836e..024097e 100755 --- a/lxc/versions +++ b/lxc/versions @@ -24,6 +24,9 @@ echo '---' echo 'julia' lxc-attach --clear-env -n piston -- /bin/bash -l -c "julia --version" echo '---' +echo 'kotlin' +lxc-attach --clear-env -n piston -- /bin/bash -l -c "kotlinc -version" +echo '---' echo 'nasm' lxc-attach --clear-env -n piston -- /bin/bash -l -c "nasm -version" echo '---' diff --git a/readme.md b/readme.md index f9c9fd6..b5b1219 100644 --- a/readme.md +++ b/readme.md @@ -145,6 +145,14 @@ tar -xzf julia-1.4.1-linux-x86_64.tar.gz echo 'export PATH=$PATH:/opt/julia/julia-1.4.1/bin' >> /opt/.profile source /opt/.profile +#install kotlin +#final binary: /opt/kotlinc/bin/kotlinc +cd /opt +wget https://github.com/JetBrains/kotlin/releases/download/v1.3.72/kotlin-compiler-1.3.72.zip +unzip kotlin-compiler-1.3.72.zip +rm kotlin-compiler-1.3.72.zip +echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile +source /opt/.profile # create runnable users and apply limits for i in {1..150}; do diff --git a/tests/test.kt b/tests/test.kt new file mode 100644 index 0000000..a6f9758 --- /dev/null +++ b/tests/test.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + println("good") +} diff --git a/tests/test_all_lxc b/tests/test_all_lxc index e3cf275..ea9e5b3 100755 --- a/tests/test_all_lxc +++ b/tests/test_all_lxc @@ -12,6 +12,8 @@ echo 'testing go' ../lxc/execute go test.go echo 'testing java' ../lxc/execute java test.java +echo 'testing kotlin' +../lxc/execute kotlin test.kt echo 'testing asm' ../lxc/execute asm test.nasm echo 'testing js'