From f72e2155042efa2d540b1a97b6ba9a09a11802ef Mon Sep 17 00:00:00 2001 From: Menci Date: Fri, 30 Nov 2018 00:47:31 +0800 Subject: [PATCH] Adapt for new version of sandbox-rootfs --- src/languages/cpp.ts | 2 +- src/languages/cpp17.ts | 47 ++++++++++++++++++++++++++++++++++++++++ src/languages/java.ts | 2 +- src/languages/ocaml.ts | 2 +- src/languages/python2.ts | 6 ++--- src/languages/python3.ts | 6 ++--- 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/languages/cpp17.ts diff --git a/src/languages/cpp.ts b/src/languages/cpp.ts index b1b8020..9697590 100644 --- a/src/languages/cpp.ts +++ b/src/languages/cpp.ts @@ -10,7 +10,7 @@ export const lang = { // write a shell script or some other stuff, // and put it to your sandbox. executable: "/usr/bin/g++", - parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], + parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++03", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], time: 5000, memory: 1024 * 1024 * 1024, process: 10, diff --git a/src/languages/cpp17.ts b/src/languages/cpp17.ts new file mode 100644 index 0000000..c0a8809 --- /dev/null +++ b/src/languages/cpp17.ts @@ -0,0 +1,47 @@ +export const lang = { + name: "cpp17", + sourceFileName: "a.cpp", + fileExtension: "cpp", + binarySizeLimit: 5000 * 1024, + + // Note that these two paths are in the sandboxed environment. + compile: (sourcePath, outputDirectory) => ({ + // To customize the compilation process, + // write a shell script or some other stuff, + // and put it to your sandbox. + executable: "/usr/bin/g++", + parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++17", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], + time: 5000, + memory: 1024 * 1024 * 1024, + process: 10, + // This is just a redirection. You can simply ignore this + // if you can specify custom location for message output + // in the parameter of the compiler, or have redirected the compilation + // message to somewhere. + // An example will be available soon. + stderr: `${outputDirectory}/message.txt`, + // We will read this file for message in the output directory. + messageFile: 'message.txt', + workingDirectory: outputDirectory + }), + + run: (binaryDirectory: string, + workingDirectory: string, + time: number, + memory: number, + stdinFile = null, + stdoutFile = null, + stderrFile = null + ) => ({ + executable: `${binaryDirectory}/a.out`, + parameters: [], + time: time, + memory: memory, + stackSize: memory, + process: 1, + stdin: stdinFile, + stdout: stdoutFile, + stderr: stderrFile, + workingDirectory: workingDirectory + }) +}; diff --git a/src/languages/java.ts b/src/languages/java.ts index 872567c..c097b73 100644 --- a/src/languages/java.ts +++ b/src/languages/java.ts @@ -37,7 +37,7 @@ export const lang = { parameters: ["run"], time: time, memory: memory, - process: 15, + process: 25, stdin: stdinFile, stdout: stdoutFile, stderr: stderrFile, diff --git a/src/languages/ocaml.ts b/src/languages/ocaml.ts index a6d62b9..c0d990f 100644 --- a/src/languages/ocaml.ts +++ b/src/languages/ocaml.ts @@ -13,7 +13,7 @@ export const lang = { parameters: ["compile-ocaml", sourcePath, outputDirectory], time: 5000, memory: 1024 * 1024 * 1024, - process: 10, + process: 20, // This is just a redirection. You can simply ignore this // if you can specify custom location for message output // in the parameter of the compiler, or have redirected the compilation diff --git a/src/languages/python2.ts b/src/languages/python2.ts index 844b096..522ca8c 100644 --- a/src/languages/python2.ts +++ b/src/languages/python2.ts @@ -10,7 +10,7 @@ export const lang = { // write a shell script or some other stuff, // and put it to your sandbox. executable: "/usr/bin/compile-script", - parameters: ["compile-script", sourcePath, outputDirectory, "python2 -m py_compile a.py"], + parameters: ["compile-script", sourcePath, outputDirectory, "pypy -m py_compile a.py"], time: 5000, memory: 1024 * 1024 * 1024, process: 10, @@ -33,8 +33,8 @@ export const lang = { stdoutFile = null, stderrFile = null ) => ({ - executable: "/usr/bin/python2", - parameters: ["python2", `${binaryDirectory}/a.py`], + executable: "/usr/bin/pypy", + parameters: ["pypy", `${binaryDirectory}/a.py`], time: time, memory: memory, process: 1, diff --git a/src/languages/python3.ts b/src/languages/python3.ts index 6d62886..49f7b35 100644 --- a/src/languages/python3.ts +++ b/src/languages/python3.ts @@ -10,7 +10,7 @@ export const lang = { // write a shell script or some other stuff, // and put it to your sandbox. executable: "/usr/bin/compile-script", - parameters: ["compile-script", sourcePath, outputDirectory, "python3 -m py_compile a.py"], + parameters: ["compile-script", sourcePath, outputDirectory, "pypy3 -m py_compile a.py"], time: 5000, memory: 1024 * 1024 * 1024, process: 10, @@ -33,8 +33,8 @@ export const lang = { stdoutFile = null, stderrFile = null ) => ({ - executable: "/usr/bin/python3", - parameters: ["python3", `${binaryDirectory}/a.py`], + executable: "/usr/bin/pypy3", + parameters: ["pypy3", `${binaryDirectory}/a.py`], time: time, memory: memory, process: 1,