Repository navigation
Custom Languages
dxx114514-stack edited this page Oct 1, 2026
·
2 revisions
内置语言之外的扩展名(如 C#、Kotlin 或自研语言)可在 data/config.json 注册后评测,提交与 ide run 均生效。
编辑 data/config.json,加入 judge.custom_languages:
{
"judge": {
"custom_languages": {
"csharp": { "extensions": [".cs"], "compile": "csc /nologo /out:{exe} {src}", "run": "{exe}" },
"judgelang": { "extensions": [".jlang", ".judgelang"], "compile": "", "run": "judgelang {src}" }
}
}
}-
extensions关联扩展名(自动小写、补.);run必填,为运行命令模板;compile为编译命令模板,留空 = 脚本语言(跳过编译直接执行run)。无效条目(无扩展名或无run)被忽略。 -
模板占位符:
-
{src}— 选手源文件绝对路径(多源文件各自独立成参) -
{exe}— 编译产物路径(<workDir>/program<exeSuffix>) -
{dir}— 编译工作目录绝对路径
-
- 模板按空白分词(可用双引号包裹含空格的片段),参数直传沙箱、不经 shell。
- 编译命令与内置编译器一样以可信模式运行,受
compile_time_limit_ms约束;run引用了{exe}但产物缺失 →CE(Compilation produced no output)。 - 命令可为 PATH 上的裸名(如
python3、judgelang,沙箱环境白名单保留 PATH)或绝对路径。 - 内置扩展名优先:与自定义注册冲突时内置生效。
-
custom_languages键缺失时自动内置示例语言judgelang(.jlang/.judgelang,运行judgelang {src},需自行在 PATH 上提供同名解释器,否则提交判SE);显式给出该键(包括空对象{})则完全以配置为准。 - 编译器按扩展名识别源语言的(如 g++/gcc),需自行在
compile中指定语言,如g++ -O2 -x c++ -o {exe} {src}。
{
"judge": {
"custom_languages": {
"kotlin": { "extensions": [".kt"], "compile": "kotlinc {src} -include-runtime -d {exe}", "run": "{exe}" },
"rust": { "extensions": [".rs"], "compile": "rustc -O -o {exe} {src}", "run": "{exe}" },
"go": { "extensions": [".go"], "compile": "go build -o {exe} {src}", "run": "{exe}" },
"lua": { "extensions": [".lua"], "compile": "", "run": "lua {src}" }
}
}
}修改 config.json 后下一条命令生效:配置每个进程只读一次并缓存(settings::get()),同一条命令内的多次评测不会重读;由于每次 clijudge … 调用都是新进程,实际表现为「保存后下次评测即生效」。