mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 08:18:41 +00:00
feat: add C++14 and C++17 support
This commit is contained in:
parent
c48966420b
commit
af58465477
@ -987,6 +987,14 @@ RunCompilerResult compile_cpp11(const string &name, const string &path = work_pa
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp17(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++17", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp98(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++98", NULL);
|
||||
}
|
||||
RunCompilerResult compile_python2(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/python2.7", "-E", "-s", "-B", "-O", "-c",
|
||||
@ -1000,7 +1008,7 @@ RunCompilerResult compile_python3(const string &name, const string &path = work_
|
||||
RunCompilerResult compile(const char *name) {
|
||||
string lang = conf_str(string(name) + "_language");
|
||||
|
||||
if ((lang == "C++" || lang == "C++11" || lang == "C") && has_illegal_keywords_in_file(work_path + "/" + name + ".code"))
|
||||
if ((lang == "C++" || lang == "C++11" || lang == "C++17" || lang == "C++98" || lang == "C") && has_illegal_keywords_in_file(work_path + "/" + name + ".code"))
|
||||
{
|
||||
RunCompilerResult res;
|
||||
res.type = RS_DGS;
|
||||
@ -1017,6 +1025,12 @@ RunCompilerResult compile(const char *name) {
|
||||
if (lang == "C++11") {
|
||||
return compile_cpp11(name);
|
||||
}
|
||||
if (lang == "C++17") {
|
||||
return compile_cpp17(name);
|
||||
}
|
||||
if (lang == "C++98") {
|
||||
return compile_cpp98(name);
|
||||
}
|
||||
if (lang == "Python2") {
|
||||
return compile_python2(name);
|
||||
}
|
||||
@ -1046,12 +1060,20 @@ RunCompilerResult compile_pas_with_implementer(const string &name, const string
|
||||
}
|
||||
RunCompilerResult compile_cpp_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
"/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++14", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp98_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++98", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp11_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp17_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++17", NULL);
|
||||
}
|
||||
/*
|
||||
RunCompilerResult compile_python2(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
@ -1083,6 +1105,12 @@ RunCompilerResult compile_with_implementer(const char *name) {
|
||||
if (lang == "C++11") {
|
||||
return compile_cpp11_with_implementer(name);
|
||||
}
|
||||
if (lang == "C++17") {
|
||||
return compile_cpp17_with_implementer(name);
|
||||
}
|
||||
if (lang == "C++98") {
|
||||
return compile_cpp98_with_implementer(name);
|
||||
}
|
||||
if (lang == "C") {
|
||||
return compile_c_with_implementer(name);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
<div class="card-body">
|
||||
<p>默认的测评环境是 Ubuntu Linux 20.04 LTS x64。</p>
|
||||
<p>C的编译器是 gcc 9.4.0,编译命令:<code>gcc code.c -o code -lm -O2 -DONLINE_JUDGE</code>。</p>
|
||||
<p>C++的编译器是 g++ 9.4.0,编译命令:<code>g++ code.cpp -o code -lm -O2 -DONLINE_JUDGE</code>。如果选择C++11会在编译命令后面添加<code>-std=c++11</code>。</p>
|
||||
<p>C++的编译器是 g++ 9.4.0,编译命令:<code>g++ code.cpp -o code -lm -O2 -DONLINE_JUDGE</code>。默认为 C++14,如果选择特定语言版本会添加 <code>-std=</code> 参数。</p>
|
||||
<p>Pascal的编译器是 fpc 3.0.4,编译命令:<code>fpc code.pas -O2</code>。</p>
|
||||
<p>Python会先编译为优化过的字节码<samp>.pyo</samp>文件。支持的Python版本分别为Python 2.7和3.8。</p>
|
||||
</div>
|
||||
|
@ -430,6 +430,8 @@ function echoSubmissionContent($submission, $requirement) {
|
||||
switch ($file_language) {
|
||||
case 'C++':
|
||||
case 'C++11':
|
||||
case 'C++17':
|
||||
case 'C++98':
|
||||
$sh_class = 'sh_cpp';
|
||||
break;
|
||||
case 'Python2':
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
global $uojSupportedLanguages, $uojMainJudgerWorkPath;
|
||||
$uojSupportedLanguages = array('C', 'C++', 'C++11', 'Pascal', 'Python2', 'Python3');
|
||||
$uojSupportedLanguages = array('C', 'C++', 'C++11', 'C++17', 'C++98', 'Pascal', 'Python2', 'Python3');
|
||||
$uojMainJudgerWorkPath = "/opt/uoj/judger/uoj_judger";
|
||||
|
||||
function authenticateJudger() {
|
||||
|
@ -561,6 +561,8 @@ function get_codemirror_mode(lang) {
|
||||
switch (lang) {
|
||||
case 'C++':
|
||||
case 'C++11':
|
||||
case 'C++17':
|
||||
case 'C++98':
|
||||
return 'text/x-c++src';
|
||||
case 'C':
|
||||
return 'text/x-csrc';
|
||||
|
Loading…
Reference in New Issue
Block a user