diff --git a/webapp/migrations/Version20240511091916.php b/webapp/migrations/Version20240511091916.php new file mode 100644 index 0000000000..47fd04c297 --- /dev/null +++ b/webapp/migrations/Version20240511091916.php @@ -0,0 +1,82 @@ + '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; + } +} diff --git a/webapp/src/DataFixtures/DefaultData/LanguageFixture.php b/webapp/src/DataFixtures/DefaultData/LanguageFixture.php index 1ee4ce8be5..09c090ae0a 100644 --- a/webapp/src/DataFixtures/DefaultData/LanguageFixture.php +++ b/webapp/src/DataFixtures/DefaultData/LanguageFixture.php @@ -26,8 +26,8 @@ public function load(ObjectManager $manager): void // 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', 'gnatmake --version', ''], - ['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', ''], - ['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --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'], @@ -35,18 +35,18 @@ public function load(ObjectManager $manager): void ['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', 'nodejs --version', 'nodejs --version'], - ['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', ''], + ['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', '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', 'swipl --version'], + ['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', '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', 'md5sum /bin/sh', ''], + ['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', ''], ];