From 0e2131eb1d23aa4a876b03ae9e1bbdd1121bccc6 Mon Sep 17 00:00:00 2001 From: Titouan Teyssier Date: Sun, 14 Feb 2021 17:59:33 +0100 Subject: [PATCH] add prolog language support (#82) * add prolog language support --- config/languages.json | 7 +++++++ container/install_script.sh | 16 ++++++++++++++++ lxc/executors/prolog | 9 +++++++++ lxc/tests/_run | 2 ++ lxc/tests/prolog.pl | 1 + lxc/util/versions | 4 ++++ 6 files changed, 39 insertions(+) create mode 100755 lxc/executors/prolog create mode 100644 lxc/tests/prolog.pl diff --git a/config/languages.json b/config/languages.json index 2fd5b1e..f62ea5c 100644 --- a/config/languages.json +++ b/config/languages.json @@ -199,6 +199,13 @@ "php5" ] }, + { + "name": "prolog", + "aliases": [ + "prolog", + "plg" + ] + }, { "name": "python3", "aliases": [ diff --git a/container/install_script.sh b/container/install_script.sh index 65e72c1..bb7264f 100644 --- a/container/install_script.sh +++ b/container/install_script.sh @@ -283,6 +283,22 @@ MIX_ENV=prod mix escript.build --force echo 'export PATH=$PATH:/opt/05AB1E/05AB1E' >> /opt/.profile source /opt/.profile + +# install prolog +# final binary: /opt/swipl/swipl-/build/src/swipl +cd /opt && mkdir swipl && cd swipl +SUB_DIR=swipl-8.2.4 +wget https://www.swi-prolog.org/download/stable/src/$SUB_DIR.tar.gz +tar -xf $SUB_DIR.tar.gz +rm $SUB_DIR.tar.gz +cd $SUB_DIR +mkdir build +cd build +cmake -DSWIPL_PACKAGES_JAVA=OFF -DSWIPL_PACKAGES_X=OFF -DMULTI_THREADED=OFF -G Ninja .. +ninja +echo "export PATH=\$PATH:/opt/swipl/$SUB_DIR/build/src" >> /opt/.profile +source /opt/.profile + # create runnable users and apply limits for i in {1..150}; do useradd -M runner$i diff --git a/lxc/executors/prolog b/lxc/executors/prolog new file mode 100755 index 0000000..e5bb3ec --- /dev/null +++ b/lxc/executors/prolog @@ -0,0 +1,9 @@ +#!/bin/bash + +cd /tmp/$1 + +sed 's/^.*$/:- forall((Goal = (\0), call(Goal)), (write(Goal), nl))./' input.input | + cat code.code - > code.pl + +timeout -s KILL 3 swipl -g true -t halt code.pl + diff --git a/lxc/tests/_run b/lxc/tests/_run index e063d4f..b166802 100755 --- a/lxc/tests/_run +++ b/lxc/tests/_run @@ -52,6 +52,8 @@ echo -n 'testing perl = ' ../../cli/execute perl perl.pl echo -n 'testing php = ' ../../cli/execute php php.php +echo -n 'testing prolog = ' +../../cli/execute prolog prolog.pl echo -n 'testing python2 = ' ../../cli/execute python2 python2.py echo -n 'testing python3 = ' diff --git a/lxc/tests/prolog.pl b/lxc/tests/prolog.pl new file mode 100644 index 0000000..2521fb1 --- /dev/null +++ b/lxc/tests/prolog.pl @@ -0,0 +1 @@ +:- write('good'), nl. diff --git a/lxc/util/versions b/lxc/util/versions index f280210..f86b563 100755 --- a/lxc/util/versions +++ b/lxc/util/versions @@ -105,6 +105,10 @@ echo 'php' lxc-attach --clear-env -n piston -- /bin/bash -l -c "php -v" echo '---' +echo 'prolog' +lxc-attach --clear-env -n piston -- /bin/bash -l -c "swipl --version" +echo '---' + echo 'python2' lxc-attach --clear-env -n piston -- /bin/bash -l -c "python -V" echo '---'