Browse Source

Drop some languages and support both GCC and Clang for C++

master
Menci 6 years ago
parent
commit
2233136115
  1. 4
      src/languages/c.ts
  2. 4
      src/languages/cpp.ts
  3. 47
      src/languages/cpp11-clang.ts
  4. 4
      src/languages/cpp11.ts
  5. 47
      src/languages/cpp17-clang.ts
  6. 4
      src/languages/cpp17.ts
  7. 12
      src/languages/index.ts

4
src/languages/c.ts

@ -9,8 +9,8 @@ export const lang = {
// To customize the compilation process, // To customize the compilation process,
// write a shell script or some other stuff, // write a shell script or some other stuff,
// and put it to your sandbox. // and put it to your sandbox.
executable: "/usr/bin/gcc", executable: "/usr/bin/clang-7",
parameters: ["gcc", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], parameters: ["clang-7", sourcePath, "-o", `${outputDirectory}/a.out`, "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
time: 5000, time: 5000,
memory: 1024 * 1024 * 1024 * 2, memory: 1024 * 1024 * 1024 * 2,
process: 10, process: 10,

4
src/languages/cpp.ts

@ -9,8 +9,8 @@ export const lang = {
// To customize the compilation process, // To customize the compilation process,
// write a shell script or some other stuff, // write a shell script or some other stuff,
// and put it to your sandbox. // and put it to your sandbox.
executable: "/usr/bin/g++", executable: "/usr/bin/g++-8",
parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++03", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], parameters: ["g++-8", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++03", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
time: 5000, time: 5000,
memory: 1024 * 1024 * 1024 * 2, memory: 1024 * 1024 * 1024 * 2,
process: 10, process: 10,

47
src/languages/cpp11-clang.ts

@ -0,0 +1,47 @@
export const lang = {
name: "cpp11-clang",
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/clang++-7",
parameters: ["clang++-7", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++11", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
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.
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
})
};

4
src/languages/cpp11.ts

@ -9,8 +9,8 @@ export const lang = {
// To customize the compilation process, // To customize the compilation process,
// write a shell script or some other stuff, // write a shell script or some other stuff,
// and put it to your sandbox. // and put it to your sandbox.
executable: "/usr/bin/g++", executable: "/usr/bin/g++-8",
parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++11", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], parameters: ["g++-8", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++11", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
time: 5000, time: 5000,
memory: 1024 * 1024 * 1024 * 2, memory: 1024 * 1024 * 1024 * 2,
process: 10, process: 10,

47
src/languages/cpp17-clang.ts

@ -0,0 +1,47 @@
export const lang = {
name: "cpp17-clang",
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/clang++-7",
parameters: ["clang++-7", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++17", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
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.
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
})
};

4
src/languages/cpp17.ts

@ -9,8 +9,8 @@ export const lang = {
// To customize the compilation process, // To customize the compilation process,
// write a shell script or some other stuff, // write a shell script or some other stuff,
// and put it to your sandbox. // and put it to your sandbox.
executable: "/usr/bin/g++", executable: "/usr/bin/g++-8",
parameters: ["g++", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++17", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"], parameters: ["g++-8", sourcePath, "-o", `${outputDirectory}/a.out`, "-std=c++17", "-O2", "-fdiagnostics-color=always", "-DONLINE_JUDGE", "-mx32"],
time: 5000, time: 5000,
memory: 1024 * 1024 * 1024 * 2, memory: 1024 * 1024 * 1024 * 2,
process: 10, process: 10,

12
src/languages/index.ts

@ -33,19 +33,25 @@ export const languages: Language[] = [
require('./cpp'), require('./cpp'),
require('./cpp11'), require('./cpp11'),
require('./cpp17'), require('./cpp17'),
require('./cpp11-clang'),
require('./cpp17-clang'),
require('./csharp'), require('./csharp'),
require('./haskell'), require('./haskell'),
require('./java'), require('./java'),
require('./lua'),
require('./luajit'),
require('./nodejs'), require('./nodejs'),
require('./ocaml'),
require('./pascal'), require('./pascal'),
require('./python2'), require('./python2'),
require('./python3'), require('./python3'),
require('./ruby'), require('./ruby'),
// The following languages are dropped now since almost nobody uses them in LibreOJ.
// They won't be maintained and use it at your own risk!
/*
require('./vala'), require('./vala'),
require('./lua'),
require('./luajit'),
require('./ocaml'),
require('./vbnet') require('./vbnet')
*/
].map(f => f.lang); ].map(f => f.lang);
export function getLanguage(name: string): Language { export function getLanguage(name: string): Language {

Loading…
Cancel
Save