piston: add zig support

This commit is contained in:
g-w1 2021-01-09 17:40:18 -05:00
parent b0c462d5ee
commit 82f67dd091
7 changed files with 32 additions and 0 deletions

View file

@ -94,6 +94,7 @@ func Execute(res http.ResponseWriter, req *http.Request) {
"rust", "rust",
"swift", "swift",
"typescript", "ts", "typescript", "ts",
"zig"
} }
// check if the supplied language is supported // check if the supplied language is supported

View file

@ -132,6 +132,9 @@ case "$lang" in
"typescript" | "ts") "typescript" | "ts")
bin=typescript bin=typescript
;; ;;
"zig")
bin=zig
;;
*) *)
echo "invalid language" echo "invalid language"
exit exit

4
lxc/executors/zig Executable file
View file

@ -0,0 +1,4 @@
cd /tmp/$2
cp code.code main.zig
timeout -s KILL 10 zig build-exe main.zig
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ./main"

View file

@ -53,3 +53,5 @@ echo 'testing python3'
../execute python3 test3.py ../execute python3 test3.py
echo 'testing paradoc' echo 'testing paradoc'
../execute python3 test_paradoc.py ../execute python3 test_paradoc.py
echo 'testing zig'
../execute zig test.zig

6
lxc/tests/test.zig Normal file
View file

@ -0,0 +1,6 @@
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("good\n", .{});
}

View file

@ -112,3 +112,7 @@ echo '---'
echo 'typescript' echo 'typescript'
lxc-attach --clear-env -n piston -- /bin/bash -l -c "tsc --version" lxc-attach --clear-env -n piston -- /bin/bash -l -c "tsc --version"
echo '---' echo '---'
echo 'zig'
lxc-attach --clear-env -n piston -- /bin/bash -l -c "zig version"
echo '---'

View file

@ -261,6 +261,18 @@ cd nim-1.4.0
echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile
source /opt/.profile source /opt/.profile
# install zig
# final binary: /opt/zig/zig
# get version: /opt/zig/zig version
cd /opt
wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz
tar -xf zig-linux-x86_64-0.7.1.tar.xz
mv zig-linux-x86_64-0.7.1 zig
rm zig-linux-x86_64-0.7.1.tar.xz
echo 'export PATH=$PATH:/opt/zig' >> /opt/.profile
source /opt/.profile
# create runnable users and apply limits # create runnable users and apply limits
for i in {1..150}; do for i in {1..150}; do
useradd -M runner$i useradd -M runner$i