mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 12:58:42 +00:00
style(judge_client/1/uoj_judger): remove compiler version specification
Due to historic reasons, the version and path of compilers are specified. This will remove these specifications to make judger more adaptable. Also provide defines to specify new version and keep for default.
This commit is contained in:
parent
64683ad93f
commit
6cc048d9d1
@ -202,7 +202,7 @@ make
|
||||
mkdir ~/judge_client/uoj_judger/run/runtime && cd ~/judge_client/uoj_judger/run/runtime
|
||||
mv ~/jdkdist.list ~/jdk-*-linux-x64.tar.gz .
|
||||
tar -xzf jdk-7*-linux-x64.tar.gz && tar -xzf jdk-8*-linux-x64.tar.gz
|
||||
mv jdk1.7* jdk1.7.0_latest && mv jdk1.8* jdk1.8.0_latest
|
||||
mv jdk1.7* jdk1.7.0 && mv jdk1.8* jdk1.8.0
|
||||
EOD
|
||||
#Set judge_client config file
|
||||
cat >/home/local_main_judger/judge_client/.conf.json <<UOJEOF
|
||||
|
@ -591,13 +591,13 @@ struct RunProgramConfig {
|
||||
if (lang == "Python2.7") {
|
||||
type = "python2.7";
|
||||
} else if (lang == "Python3") {
|
||||
type = "python3.4";
|
||||
type = "python3";
|
||||
} else if (lang == "Java7") {
|
||||
program_name += "." + conf_str(name + "_main_class");
|
||||
type = "java7u76";
|
||||
type = "java7";
|
||||
} else if (lang == "Java8") {
|
||||
program_name += "." + conf_str(name + "_main_class");
|
||||
type = "java8u31";
|
||||
type = "java8";
|
||||
}
|
||||
|
||||
set_argv(program_name.c_str(), NULL);
|
||||
@ -1136,19 +1136,19 @@ RunCompilerResult prepare_java_source(const string &name, const string &path = w
|
||||
|
||||
RunCompilerResult compile_c(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/gcc-4.8", "-o", name.c_str(), "-x", "c", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
"/usr/bin/gcc", "-o", name.c_str(), "-x", "c", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
}
|
||||
RunCompilerResult compile_pas(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/fpc-2.6.2", (name + ".code").c_str(), "-O2", NULL);
|
||||
"/usr/bin/fpc", (name + ".code").c_str(), "-O2", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++-4.8", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
"/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp11(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++-4.8", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL);
|
||||
"/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL);
|
||||
}
|
||||
RunCompilerResult compile_python2_7(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
@ -1157,7 +1157,7 @@ RunCompilerResult compile_python2_7(const string &name, const string &path = wor
|
||||
}
|
||||
RunCompilerResult compile_python3(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/python3.4", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
|
||||
"/usr/bin/python3", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
|
||||
}
|
||||
RunCompilerResult compile_java7(const string &name, const string &path = work_path) {
|
||||
RunCompilerResult ret = prepare_java_source(name, path);
|
||||
@ -1170,7 +1170,7 @@ RunCompilerResult compile_java7(const string &name, const string &path = work_pa
|
||||
executef("echo package %s\\; | cat - %s/%s.code >%s/%s/%s.java", name.c_str(), path.c_str(), name.c_str(), path.c_str(), name.c_str(), main_class.c_str());
|
||||
|
||||
return run_compiler((path + "/" + name).c_str(),
|
||||
(main_path + "/run/runtime/jdk1.7.0_latest/bin/javac").c_str(), (main_class + ".java").c_str(), NULL);
|
||||
(main_path + "/run/runtime/jdk1.7.0/bin/javac").c_str(), (main_class + ".java").c_str(), NULL);
|
||||
}
|
||||
RunCompilerResult compile_java8(const string &name, const string &path = work_path) {
|
||||
RunCompilerResult ret = prepare_java_source(name, path);
|
||||
@ -1183,7 +1183,7 @@ RunCompilerResult compile_java8(const string &name, const string &path = work_pa
|
||||
executef("echo package %s\\; | cat - %s/%s.code >%s/%s/%s.java", name.c_str(), path.c_str(), name.c_str(), path.c_str(), name.c_str(), main_class.c_str());
|
||||
|
||||
return run_compiler((path + "/" + name).c_str(),
|
||||
(main_path + "/run/runtime/jdk1.8.0_latest/bin/javac").c_str(), (main_class + ".java").c_str(), NULL);
|
||||
(main_path + "/run/runtime/jdk1.8.0/bin/javac").c_str(), (main_class + ".java").c_str(), NULL);
|
||||
}
|
||||
|
||||
RunCompilerResult compile(const char *name) {
|
||||
@ -1232,20 +1232,20 @@ RunCompilerResult compile(const char *name) {
|
||||
|
||||
RunCompilerResult compile_c_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/gcc-4.8", "-o", name.c_str(), "implementer.c", "-x", "c", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
"/usr/bin/gcc", "-o", name.c_str(), "implementer.c", "-x", "c", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL);
|
||||
}
|
||||
RunCompilerResult compile_pas_with_implementer(const string &name, const string &path = work_path) {
|
||||
executef("cp %s %s", (path + "/" + name + ".code").c_str(), (path + "/" + conf_str(name + "_unit_name") + ".pas").c_str());
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/fpc-2.6.2", "implementer.pas", ("-o" + name).c_str(), "-O2", NULL);
|
||||
"/usr/bin/fpc", "implementer.pas", ("-o" + name).c_str(), "-O2", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++-4.8", "-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", NULL);
|
||||
}
|
||||
RunCompilerResult compile_cpp11_with_implementer(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/g++-4.8", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL);
|
||||
"/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_python2_7(const string &name, const string &path = work_path) {
|
||||
@ -1255,7 +1255,7 @@ RunCompilerResult compile_python2_7(const string &name, const string &path = wor
|
||||
}
|
||||
RunCompilerResult compile_python3(const string &name, const string &path = work_path) {
|
||||
return run_compiler(path.c_str(),
|
||||
"/usr/bin/python3.4", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
|
||||
"/usr/bin/python3", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
|
||||
}
|
||||
*/
|
||||
RunCompilerResult compile_with_implementer(const char *name) {
|
||||
|
@ -221,7 +221,7 @@ void parse_args(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (run_program_config.type == "java7u76" || run_program_config.type == "java8u31") {
|
||||
if (run_program_config.type == "java7" || run_program_config.type == "java8") {
|
||||
run_program_config.program_name = run_program_config.argv[0];
|
||||
} else {
|
||||
run_program_config.program_name = realpath(run_program_config.argv[0]);
|
||||
@ -239,14 +239,14 @@ void parse_args(int argc, char **argv) {
|
||||
if (run_program_config.type == "python2.7") {
|
||||
string pre[4] = {"/usr/bin/python2.7", "-E", "-s", "-B"};
|
||||
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 4);
|
||||
} else if (run_program_config.type == "python3.4") {
|
||||
string pre[3] = {"/usr/bin/python3.4", "-I", "-B"};
|
||||
} else if (run_program_config.type == "python3") {
|
||||
string pre[3] = {"/usr/bin/python3", "-I", "-B"};
|
||||
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3);
|
||||
} else if (run_program_config.type == "java7u76") {
|
||||
string pre[3] = {abspath(0, string(self_path) + "/../runtime/jdk1.7.0_latest/bin/java"), "-Xmx1024m", "-Xss1024m"};
|
||||
} else if (run_program_config.type == "java7") {
|
||||
string pre[3] = {abspath(0, string(self_path) + "/../runtime/jdk1.7.0/bin/java"), "-Xmx1024m", "-Xss1024m"};
|
||||
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3);
|
||||
} else if (run_program_config.type == "java8u31") {
|
||||
string pre[3] = {abspath(0, string(self_path) + "/../runtime/jdk1.8.0_latest/bin/java"), "-Xmx1024m", "-Xss1024m"};
|
||||
} else if (run_program_config.type == "java8") {
|
||||
string pre[3] = {abspath(0, string(self_path) + "/../runtime/jdk1.8.0/bin/java"), "-Xmx1024m", "-Xss1024m"};
|
||||
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3);
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ void init_conf(const RunProgramConfig &config) {
|
||||
}
|
||||
statable_file_name_set.insert(config.work_path + "/");
|
||||
|
||||
if (config.type != "java7u76" && config.type != "java8u31") {
|
||||
if (config.type != "java7" && config.type != "java8") {
|
||||
add_file_permission(config.program_name, 'r');
|
||||
} else {
|
||||
int p = config.program_name.find('.');
|
||||
@ -343,7 +343,7 @@ void init_conf(const RunProgramConfig &config) {
|
||||
|
||||
statable_file_name_set.insert("/usr");
|
||||
statable_file_name_set.insert("/usr/bin");
|
||||
} else if (config.type == "python3.4") {
|
||||
} else if (config.type == "python3") {
|
||||
syscall_max_cnt[__NR_set_tid_address] = 1;
|
||||
syscall_max_cnt[__NR_set_robust_list] = 1;
|
||||
syscall_max_cnt[__NR_futex ] = -1;
|
||||
@ -351,11 +351,20 @@ void init_conf(const RunProgramConfig &config) {
|
||||
syscall_max_cnt[__NR_getdents ] = -1;
|
||||
syscall_max_cnt[__NR_getdents64 ] = -1;
|
||||
|
||||
readable_file_name_set.insert("/usr/bin/python3");
|
||||
readable_file_name_set.insert("/usr/lib/python3/");
|
||||
# ifndef UOJ_JUDGER_PYTHON3_VERSION
|
||||
readable_file_name_set.insert("/usr/bin/python3.4");
|
||||
readable_file_name_set.insert("/usr/lib/python3.4/");
|
||||
readable_file_name_set.insert("/usr/lib/python3/");
|
||||
readable_file_name_set.insert("/usr/bin/lib/python3.4/");
|
||||
readable_file_name_set.insert("/usr/local/lib/python3.4/");
|
||||
# endif
|
||||
# ifdef UOJ_JUDGER_PYTHON3_VERSION
|
||||
readable_file_name_set.insert("/usr/bin/python" UOJ_JUDGER_PYTHON3_VERSION);
|
||||
readable_file_name_set.insert("/usr/lib/python" UOJ_JUDGER_PYTHON3_VERSION "/");
|
||||
readable_file_name_set.insert("/usr/bin/lib/python" UOJ_JUDGER_PYTHON3_VERSION "/");
|
||||
readable_file_name_set.insert("/usr/local/lib/python" UOJ_JUDGER_PYTHON3_VERSION "/");
|
||||
# endif
|
||||
readable_file_name_set.insert("/usr/bin/pyvenv.cfg");
|
||||
readable_file_name_set.insert("/usr/pyvenv.cfg");
|
||||
readable_file_name_set.insert("/usr/bin/Modules/");
|
||||
@ -365,7 +374,7 @@ void init_conf(const RunProgramConfig &config) {
|
||||
statable_file_name_set.insert("/usr");
|
||||
statable_file_name_set.insert("/usr/bin");
|
||||
statable_file_name_set.insert("/usr/lib");
|
||||
} else if (config.type == "java7u76") {
|
||||
} else if (config.type == "java7") {
|
||||
syscall_max_cnt[__NR_gettid ] = -1;
|
||||
syscall_max_cnt[__NR_set_tid_address] = 1;
|
||||
syscall_max_cnt[__NR_set_robust_list] = 14;
|
||||
@ -392,12 +401,12 @@ void init_conf(const RunProgramConfig &config) {
|
||||
soft_ban_file_name_set.insert("/etc/nsswitch.conf");
|
||||
soft_ban_file_name_set.insert("/etc/passwd");
|
||||
|
||||
add_file_permission(abspath(0, string(self_path) + "/../runtime/jdk1.7.0_latest") + "/", 'r');
|
||||
add_file_permission(abspath(0, string(self_path) + "/../runtime/jdk1.7.0") + "/", 'r');
|
||||
readable_file_name_set.insert("/sys/devices/system/cpu/");
|
||||
readable_file_name_set.insert("/proc/");
|
||||
statable_file_name_set.insert("/usr/java/");
|
||||
statable_file_name_set.insert("/tmp/");
|
||||
} else if (config.type == "java8u31") {
|
||||
} else if (config.type == "java8") {
|
||||
syscall_max_cnt[__NR_gettid ] = -1;
|
||||
syscall_max_cnt[__NR_set_tid_address] = 1;
|
||||
syscall_max_cnt[__NR_set_robust_list] = 15;
|
||||
@ -424,7 +433,7 @@ void init_conf(const RunProgramConfig &config) {
|
||||
soft_ban_file_name_set.insert("/etc/nsswitch.conf");
|
||||
soft_ban_file_name_set.insert("/etc/passwd");
|
||||
|
||||
add_file_permission(abspath(0, string(self_path) + "/../runtime/jdk1.8.0_latest") + "/", 'r');
|
||||
add_file_permission(abspath(0, string(self_path) + "/../runtime/jdk1.8.0") + "/", 'r');
|
||||
readable_file_name_set.insert("/sys/devices/system/cpu/");
|
||||
readable_file_name_set.insert("/proc/");
|
||||
statable_file_name_set.insert("/usr/java/");
|
||||
@ -494,7 +503,12 @@ void init_conf(const RunProgramConfig &config) {
|
||||
soft_ban_file_name_set.insert("/etc/passwd"); // for javac = =
|
||||
|
||||
readable_file_name_set.insert("/etc/timezone");
|
||||
# ifndef UOJ_JUDGER_FPC_VERSION
|
||||
readable_file_name_set.insert("/etc/fpc-2.6.2.cfg.d/");
|
||||
# endif
|
||||
# ifdef UOJ_JUDGER_FPC_VERSION
|
||||
readable_file_name_set.insert("/etc/fpc-" UOJ_JUDGER_FPC_VERSION ".cfg.d/");
|
||||
# endif
|
||||
readable_file_name_set.insert("/etc/fpc.cfg");
|
||||
|
||||
statable_file_name_set.insert("/*");
|
||||
|
Loading…
Reference in New Issue
Block a user