增加java编译参数

This commit is contained in:
virusdefender 2015-07-07 18:07:54 +08:00
parent ef88a8a155
commit c033b2c1e8
2 changed files with 35 additions and 16 deletions

View File

@ -209,7 +209,7 @@ class JudgeClient(object):
src = """
c_src = """
#include <stdio.h>
int main()
{
@ -217,14 +217,30 @@ int main()
return 0;
}
"""
f = open("/var/judger/main.c", "w")
f.write(src)
f.close()
client = JudgeClient(language_code=1,
exe_path=compile_(languages["1"], "/var/judger/main.c", "/var/judger/main"),
max_cpu_time=1000000,
max_real_time=200000,
max_memory=1,
test_case_dir="/var/test_cases/1/")
print client.run()
java_src = """
public class Main {
public static void main(String[] args) {
System.out.print("Hello world");
}
}
"""
def judge(languege_code, source_string):
language = languages[str(languege_code)]
src_path = judger_workspace + language["src_name"]
f = open(src_path, "w")
f.write(source_string)
f.close()
client = JudgeClient(language_code=languege_code,
exe_path=compile_(languages[str(languege_code)],
src_path,
judger_workspace),
max_cpu_time=1000000,
max_real_time=200000,
max_memory=1000,
test_case_dir="/var/test_cases/1/")
print client.run()
judge(1, c_src)
judge(3, java_src)

View File

@ -5,21 +5,24 @@
languages = {
"1": {
"name": "c",
"src_name": "main.c",
"code": 1,
"compile_command": "gcc -DONLINE_JUDGE -O2 -Wall -std=c99 -pipe {src_path} -lm -o {exe_path}",
"execute_command": "{exe_path}"
"compile_command": "gcc -DONLINE_JUDGE -O2 -Wall -std=c99 -pipe {src_path} -lm -o {exe_path}main",
"execute_command": "{exe_path}main"
},
"2": {
"name": "cpp",
"src_name": "main.cpp",
"code": 2,
"compile_command": "g++ -DONLINE_JUDGE -O2 -Wall -std=c++11 -pipe {src_path} -lm -o {exe_path}",
"execute_command": "{exe_path}"
"compile_command": "g++ -DONLINE_JUDGE -O2 -Wall -std=c++11 -pipe {src_path} -lm -o {exe_path}main",
"execute_command": "{exe_path}main"
},
"3": {
"name": "java",
"src_name": "Main.java",
"code": 3,
"compile_command": "javac {src_path} -d {exe_path}",
"execute_command": "java {exe_path}"
"execute_command": "java -cp {exe_path} Main"
}
}