From ddf1c4f830e7259c32baf0249f6ebff7e7614e6b Mon Sep 17 00:00:00 2001 From: Menci Date: Sun, 2 Dec 2018 23:30:49 +0800 Subject: [PATCH] Add NOI Linux C / C++ compilers --- src/languages/c-noilinux.ts | 48 +++++++++++++++++++++++++++++++++ src/languages/cpp-noilinux.ts | 48 +++++++++++++++++++++++++++++++++ src/languages/cpp11-noilinux.ts | 48 +++++++++++++++++++++++++++++++++ src/languages/index.ts | 5 +++- src/languages/java.ts | 2 +- 5 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 src/languages/c-noilinux.ts create mode 100644 src/languages/cpp-noilinux.ts create mode 100644 src/languages/cpp11-noilinux.ts diff --git a/src/languages/c-noilinux.ts b/src/languages/c-noilinux.ts new file mode 100644 index 0000000..1f50b0d --- /dev/null +++ b/src/languages/c-noilinux.ts @@ -0,0 +1,48 @@ +export const lang = { + name: "c-noilinux", + sourceFileName: "a.c", + fileExtension: "c", + 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/compile-c-noilinux", + parameters: ["compile-c-noilinux", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-DONLINE_JUDGE"], + time: 5000, + memory: 1024 * 1024 * 1024 * 2, + 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. + stdout: `${outputDirectory}/message.txt`, + 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/cpp-noilinux.ts b/src/languages/cpp-noilinux.ts new file mode 100644 index 0000000..9892d43 --- /dev/null +++ b/src/languages/cpp-noilinux.ts @@ -0,0 +1,48 @@ +export const lang = { + name: "cpp-noilinux", + 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/compile-cpp-noilinux", + parameters: ["compile-cpp-noilinux", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-DONLINE_JUDGE"], + time: 5000, + memory: 1024 * 1024 * 1024 * 2, + 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. + stdout: `${outputDirectory}/message.txt`, + 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/cpp11-noilinux.ts b/src/languages/cpp11-noilinux.ts new file mode 100644 index 0000000..9aa6e2d --- /dev/null +++ b/src/languages/cpp11-noilinux.ts @@ -0,0 +1,48 @@ +export const lang = { + name: "cpp11-noilinux", + 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/compile-cpp-noilinux", + parameters: ["compile-cpp-noilinux", "-std=c++11", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-DONLINE_JUDGE"], + time: 5000, + memory: 1024 * 1024 * 1024 * 2, + 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. + stdout: `${outputDirectory}/message.txt`, + 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/index.ts b/src/languages/index.ts index 074e246..093f90b 100644 --- a/src/languages/index.ts +++ b/src/languages/index.ts @@ -29,12 +29,15 @@ export interface Language { } export const languages: Language[] = [ - require('./c'), require('./cpp'), require('./cpp11'), require('./cpp17'), + require('./cpp-noilinux'), + require('./cpp11-noilinux'), require('./cpp11-clang'), require('./cpp17-clang'), + require('./c'), + require('./c-noilinux'), require('./csharp'), require('./haskell'), require('./java'), diff --git a/src/languages/java.ts b/src/languages/java.ts index 9d37d5e..68ebb31 100644 --- a/src/languages/java.ts +++ b/src/languages/java.ts @@ -13,7 +13,7 @@ export const lang = { parameters: ["compile-java", sourcePath, outputDirectory], time: 5000, memory: 1024 * 1024 * 1024 * 2, - process: 20, + process: 30, // 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