woj-server/resource/runner/problem/example/judge/custom.Makefile

42 lines
2.3 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 默认环境变量有 PREFIX, TEMPLATE, TESTLIB
include ${TEMPLATE}/c.mk ${TEMPLATE}/Judger.mk
# 评测分四个阶段
# 1. prebuild: 用于提前生成测试数据、评测器、spj等工具runner 只执行一次
# 2. compile: 用于编译用户提交的程序
# 目录映射情况:
# /woj/problem/judge 映射到题目目录的 ./judge <-- Readonly
# /woj/user 映射到题目目录的 ./user <-- 用户提交的程序在这里,命名:$(USER_PROG).$(LANG)
# 环境变量:
# USER_PROG=... <-- 一段随机字符串
# LANG=... <-- 用户提交的程序的语言,如 c, cpp
# 其余通用环境变量,详见 ubuntu-full.Dockerfile
# 执行限制:
# 目前版本硬编码限制:时间 60s内存 256mb
# 3. run: 运行用户程序
# 只有 ./data/input/*.input 和 ./user/$(USER_PROG).out 可见
# 用户输出存放于 ./user/?.out.usr
# 使用 woj-sandbox 运行,等效于 $(PREFIX)/user/$(USER_PROG).out < $(PREFIX)/problem/data/input/$(TEST_NUM).input > $(PREFIX)/user/$(TEST_NUM).out.usr
# 4. judge: 用于判定输出结果 环境变量 TEST_NUM 表示当前测试点编号,每个测试点都会执行一次
# 目录映射情况:
# /woj/problem
# ├── data 映射到题目目录的 ./data <-- Readonly
# └── judge 映射到题目目录的 ./judge <-- Readonly
# /woj/user
# ├── $(TEST_NUM).out.usr <-- 用户程序在 $(TEST_NUM) 上的输出
# └── $(TEST_NUM).judge <-- 评测结果写在这里,格式要求为 testlib 的 XML 格式
# 环境变量:
# TEST_NUM=... <-- 当前测试点编号
# CMP=... <-- 在 config.json 中配置的比较器,如 NCMP
# 其余通用环境变量,详见 ubuntu-full.Dockerfile
compile:
$(CC) $(CFLAGS) -o $(PREFIX)/user/$(USER_PROG).out $(PREFIX)/user/$(USER_PROG).$(LANG) $(PREFIX)/problem/judge/gadget.c
judge:
# !! Rename on *.out.usr or *.judge is not allowed !!
# 自定义评测方式
sed '/gadgets/d' $(PREFIX)/user/$(TEST_NUM).out.usr >$(PREFIX)/user/$(TEST_NUM).out.usr1
# 评测结果要求符合 testlib 的格式 -> $(TEST_NUM).judge
$(NCMP) $(PREFIX)/problem/data/input/$(TEST_NUM).input $(PREFIX)/user/$(TEST_NUM).out.usr1 $(PREFIX)/problem/data/output/$(TEST_NUM).output $(PREFIX)/user/$(TEST_NUM).judge -appes