From e81a13d375e031b203287f29275eef2f8cfc95c7 Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 23 Mar 2023 15:49:17 +0800 Subject: [PATCH] judge: add compile_time_limit option --- packages/hydrojudge/src/compile.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/hydrojudge/src/compile.ts b/packages/hydrojudge/src/compile.ts index 34e3a0840..43078149f 100644 --- a/packages/hydrojudge/src/compile.ts +++ b/packages/hydrojudge/src/compile.ts @@ -23,8 +23,12 @@ export default async function compile( copyIn: { ...copyIn, [lang.code_file]: code }, copyOutCached: [target], env: { HYDRO_LANG: lang.key }, + time: lang.compile_time_limit || 10000, + memory: lang.compile_memory_limit || 256 * 1024 * 1024, }, ); + if (status === STATUS.STATUS_TIME_LIMIT_EXCEEDED) next?.({ message: 'Compile timeout.' }); + if (status === STATUS.STATUS_MEMORY_LIMIT_EXCEEDED) next?.({ message: 'Compile memory limit exceeded.' }); if (status !== STATUS.STATUS_ACCEPTED) throw new CompileError({ status, stdout, stderr }); if (!fileIds[target]) throw new CompileError({ stderr: 'Executable file not found.' }); next?.({ compilerText: compilerText(stdout, stderr) });