shi-yang / jnoj

Jiangnan Online Judge
https://www.jnoj.dev
Other
240 stars 62 forks source link

如何增加新的编程语言如FreeBASIC? #45

Open fyshi2015 opened 5 years ago

fyshi2015 commented 5 years ago

如何增加新的编程语言如FreeBASIC,判题机要怎么改?

shi-yang commented 5 years ago

判题机方面:

判题机是来自 hustoj 的定制,因此语言方面你可以参考 hustoj 的实现: https://github.com/zhblue/hustoj/tree/master/trunk/core/judge_client

由于已经修改了不少,在此简要说一下:

第一,在这个文件增加语言,如何编译,运行的命令:

https://github.com/shi-yang/jnoj/blob/8b01e17de8f16dfea21589f1651042e7c3a93e75/judge/src/language.h#L12

第二,在 okcalls64.h 增加白名单限制。具体参考 hustoj 的 okcalls64.h

https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/judge/src/okcalls64.h#L45

你对比下 hustoj 这两个函数的相关实现,只需要看懂如何选择不同语言来运行程序

编译函数 https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/judge/src/judge.c#L399

运行函数 https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/judge/src/judge.c#L685

网页端涉及到编程语言的有:

这里是语言的常量定义

https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/models/Solution.php#L57-L60

这里添加语言是要添加个数字,就 [0, 1, 2, 3, 4 .... 之类]

https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/models/Solution.php#L90

https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/models/Solution.php#L167-L187

https://github.com/shi-yang/jnoj/blob/32acce2e5e2a7406de4919fdf092c55806ce0dfd/models/Solution.php#L228-L238

需要注意的是

添加语言网页端和判题机要一一对应,比如现在是 0 对应 C,1 对应 C++,2对应 Java, 3对应 Python。再添加就是 4 对应某某语言,依次类推。