GetCompiler get a compiler provider from session.CodeLangName 如果不设置codeStr,默认会读取配置文件里的code_file字段并打开对应文件
(codeStr string)
| 47 | // GetCompiler get a compiler provider from session.CodeLangName |
| 48 | // 如果不设置codeStr,默认会读取配置文件里的code_file字段并打开对应文件 |
| 49 | func (session *JudgeSession) GetCompiler(codeStr string) (provider.CodeCompileProviderInterface, error) { |
| 50 | if codeStr == "" { |
| 51 | codeFileBytes, err := ioutil.ReadFile(session.CodeFile) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | codeStr = string(codeFileBytes) |
| 56 | } |
| 57 | |
| 58 | compiler, err := matchCodeLanguage(session.CodeLangName, session.CodeFile) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | err = compiler.Init(codeStr, session.SessionDir) |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | return compiler, err |
| 67 | } |
| 68 | |
| 69 | // 编译目标程序 |
| 70 | func (session *JudgeSession) compileTargetProgram(judgeResult *commonStructs.JudgeResult) error { |
no test coverage detected