Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version commands for more languages/executables #2541

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/manual/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Appendices
problem-format
shadow
configuration-reference
install-language
97 changes: 97 additions & 0 deletions doc/manual/install-language.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
Appendix: Installing the example languages
==========================================

DOMjudge ships with some default languages with a default configuration.
As you might set up contests with those languages we provide how those languages were
installed in the past as guideline. Use ``dj_run_chroot`` for most of those packages, and see
the section :ref:`make-chroot` for more information.

Most of the languages can be installed from the table below as there is a package available
to install inside the judging chroot. Given that you can install your own chroot we only provide the
packages for Ubuntu as that is the most used at the moment of writing.

.. list-table:: Packages for languages
:header-rows: 1

* - Language
- Ubuntu package
- Remarks
* - Ada
- `gnat`
-
* - AWK
- `mawk`/`gawk`
- `mawk` is default installed
* - Bash
- `bash`
- Default installed in the chroot
* - C
- `gcc`
- Default installed in the chroot
* - C++
- `g++`
- Default installed in the chroot
* - C#
- `mono-mcs`
-
* - Fortran
- `gfortran`
-
* - Haskell
- `ghc`
- After installing you need to move these files
`/{usr->var}/lib/ghc/package.conf.d` as `/var`
is not mounted during compilation.
* - Java
- `default-jdk-headless`
- Default installed in the chroot
* - Javascript
- `nodejs`
-
* - Kotlin
- `kotlin`
-
* - Lua
- `lua5.4`
- Ubuntu does not ship a generic meta package (yet).
* - Pascal
- `fp-compiler`
-
* - Perl
- `perl-base`
- Default installed in the chroot
* - POSIX shell
- `dash`
- Default installed in the chroot
* - Prolog
- `swi-prolog-core-packages`
-
* - Python3
- `pypy3`/`python3`
- Default installed in the chroot.
DOMjudge assumes `pypy3` as it runs faster in general.
Consider the `PyPy3 PPA`_ if you need the latest python3 features. PyPy3 does not have 100%
compatibility with all non-standard libraries. In case this is needed you should reconsider the default
CPython implementation.
* - OCaml
- `ocaml`
-
* - R
- `r-base-core`
-
* - Ruby
- `ruby`
-
* - Rust
- `rustc`
-
* - Scala
- `scala`
-
* - Swift
-
- See the `Swift instructions`_, unpack the directory in the chroot and install `libncurses6`. Depending
on where you install the directory you might need to extend the `PATH` in the `run` script.

.. _PyPy3 PPA: https://launchpad.net/~pypy/+archive/ubuntu/ppa
.. _Swift instructions: https://www.swift.org/documentation/server/guides/deploying/ubuntu.html
3 changes: 3 additions & 0 deletions sql/files/defaultdata/hs/run
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ MAINSOURCE="$1"
# Set non-existing HOME variable to make GHC program happy, see:
# https://ghc.haskell.org/trac/ghc/ticket/11678
export HOME=/does/not/exist
# Allow temporary files during compilation, this directory is not
# available during the submission run.
export TMPDIR="$PWD"

# Add -DONLINE_JUDGE or -DDOMJUDGE below if you want it make easier for teams
# to do local debugging.
Expand Down
82 changes: 82 additions & 0 deletions webapp/migrations/Version20240511091916.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240511091916 extends AbstractMigration
{
private const COMPILER_VERSION_COMMAND = ['adb'=> 'gnatmake --version',
'awk'=> 'awk --version',
'bash'=> 'bash --version',
'c' => 'gcc --version',
'cpp' => 'g++ --version',
'csharp' => 'mcs --version',
'f95' => 'gfortran --version',
'hs' => 'ghc --version',
'java' => 'javac --version',
'js' => 'nodejs --version',
'kt' => 'kotlinc --version',
'lua' => 'luac -v',
'pas' => 'fpc -iW',
'pl' => 'perl -v',
'plg' => 'swipl --version',
'py3' => 'pypy3 --version',
'ocaml' => 'ocamlopt --version',
'r' => 'Rscript --version',
'rb' => 'ruby --version',
'rs' => 'rustc --version',
'scala' => 'scalac --version',
'sh' => 'md5sum /bin/sh',
'swift' => 'swiftc --version'];

private const RUNNER_VERSION_COMMAND = ['awk'=> 'awk --version',
'bash'=> 'bash --version',
'csharp' => 'mono --version',
'java' => 'java --version',
'js' => 'nodejs --version',
'kt' => 'kotlin --version',
'lua' => 'lua -v',
'pl' => 'perl -v',
'py3' => 'pypy3 --version',
'r' => 'Rscript --version',
'rb' => 'ruby --version',
'scala' => 'scala --version',
'sh' => 'md5sum /bin/sh'];

public function getDescription(): string
{
return 'Fill default version command for compiler/runner.';
}

public function up(Schema $schema): void
{
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET compiler_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND compiler_version_command IS NULL;");
}
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET runner_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND runner_version_command IS NULL;");
}
}

public function down(Schema $schema): void
{
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET compiler_version_command = NULL WHERE langid='" . $lang . "' AND compiler_version_command = '" . $versionCommand ."';");
}
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET runner_version_command = NULL WHERE langid='" . $lang . "' AND runner_version_command = '" . $versionCommand ."';");
}
}

public function isTransactional(): bool
{
return false;
}
}
28 changes: 14 additions & 14 deletions webapp/src/DataFixtures/DefaultData/LanguageFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ public function load(ObjectManager $manager): void
$data = [
// ID external ID name extensions require entry point allow allow time compile compiler version runner version
// entry point description submit judge factor script command command
['adb', 'ada', 'Ada', ['adb', 'ads'], false, null, false, true, 1, 'adb', '', ''],
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', '', ''],
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', '', ''],
['adb', 'ada', 'Ada', ['adb', 'ads'], false, null, false, true, 1, 'adb', 'gnatmake --version', ''],
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', 'awk --version'],
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --version', 'bash --version'],
['c', 'c', 'C', ['c'], false, null, true, true, 1, 'c', 'gcc --version', ''],
['cpp', 'cpp', 'C++', ['cpp', 'cc', 'cxx', 'c++'], false, null, true, true, 1, 'cpp', 'g++ --version', ''],
['csharp', 'csharp', 'C#', ['csharp', 'cs'], false, null, false, true, 1, 'csharp', 'mcs --version', 'mono --version'],
['f95', 'f95', 'Fortran', ['f95', 'f90'], false, null, false, true, 1, 'f95', '', ''],
['hs', 'haskell', 'Haskell', ['hs', 'lhs'], false, null, false, true, 1, 'hs', '', ''],
['f95', 'f95', 'Fortran', ['f95', 'f90'], false, null, false, true, 1, 'f95', 'gfortran --version', ''],
['hs', 'haskell', 'Haskell', ['hs', 'lhs'], false, null, false, true, 1, 'hs', 'ghc --version', ''],
['java', 'java', 'Java', ['java'], false, 'Main class', true, true, 1, 'java_javac_detect', 'javac -version', 'java -version'],
['js', 'javascript', 'JavaScript', ['js'], false, 'Main file', false, true, 1, 'js', '', ''],
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', '', ''],
['js', 'javascript', 'JavaScript', ['js'], false, 'Main file', false, true, 1, 'js', 'nodejs --version', 'nodejs --version'],
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', 'lua -v'],
['kt', 'kotlin', 'Kotlin', ['kt'], true, 'Main class', false, true, 1, 'kt', 'kotlinc -version', 'kotlin -version'],
['pas', 'pascal', 'Pascal', ['pas', 'p'], false, 'Main file', false, true, 1, 'pas', '', ''],
['pl', 'pl', 'Perl', ['pl'], false, 'Main file', false, true, 1, 'pl', '', ''],
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', '', ''],
['pas', 'pascal', 'Pascal', ['pas', 'p'], false, 'Main file', false, true, 1, 'pas', 'fpc -iW', ''],
['pl', 'pl', 'Perl', ['pl'], false, 'Main file', false, true, 1, 'pl', 'perl -v', 'perl -v'],
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', 'swipl --version', ''],
['py3', 'python3', 'Python 3', ['py'], false, 'Main file', true, true, 1, 'py3', 'pypy3 --version', 'pypy3 --version'],
['ocaml', 'ocaml', 'OCaml', ['ml'], false, null, false, true, 1, 'ocaml', 'ocamlopt --version', ''],
['r', 'r', 'R', ['R'], false, 'Main file', false, true, 1, 'r', '', ''],
['rb', 'ruby', 'Ruby', ['rb'], false, 'Main file', false, true, 1, 'rb', '', ''],
['r', 'r', 'R', ['R'], false, 'Main file', false, true, 1, 'r', 'Rscript --version', 'Rscript --version'],
['rb', 'ruby', 'Ruby', ['rb'], false, 'Main file', false, true, 1, 'rb', 'ruby --version', 'ruby --version'],
['rs', 'rust', 'Rust', ['rs'], false, null, false, true, 1, 'rs', 'rustc --version', ''],
['scala', 'scala', 'Scala', ['scala'], false, null, false, true, 1, 'scala', 'scalac -version', 'scala -version'],
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', '', ''],
['swift', 'swift', 'Swift', ['swift'], false, 'Main file', false, true, 1, 'swift', '', ''],
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', 'md5sum /bin/sh', 'md5sum /bin/sh'],
['swift', 'swift', 'Swift', ['swift'], false, 'Main file', false, true, 1, 'swift', 'swiftc --version', ''],
];

foreach ($data as $item) {
Expand Down
Loading