CompileSpecialJudgeCodeFile 普通特殊评测的编译方法
(source, name, binRoot, configDir, libraryDir, lang string)
| 96 | |
| 97 | // CompileSpecialJudgeCodeFile 普通特殊评测的编译方法 |
| 98 | func CompileSpecialJudgeCodeFile(source, name, binRoot, configDir, libraryDir, lang string) (string, error) { |
| 99 | genCodeFile := path.Join(configDir, source) |
| 100 | compileTarget := path.Join(binRoot, name) |
| 101 | _, err := os.Stat(genCodeFile) |
| 102 | if err != nil && os.IsNotExist(err) { |
| 103 | return compileTarget, errors.Errorf("checker source code file not exists") |
| 104 | } |
| 105 | var ok bool |
| 106 | var ceinfo string |
| 107 | switch lang { |
| 108 | case "c", "gcc", "gnu-c": |
| 109 | compiler := provider.NewGnucppCompileProvider() |
| 110 | ok, ceinfo = compiler.ManualCompile(genCodeFile, compileTarget, []string{libraryDir}) |
| 111 | case "go", "golang": |
| 112 | compiler := provider.NewGolangCompileProvider() |
| 113 | ok, ceinfo = compiler.ManualCompile(genCodeFile, compileTarget) |
| 114 | case "cpp", "gcc-cpp", "gcpp", "g++", "": |
| 115 | compiler := provider.NewGnucppCompileProvider() |
| 116 | ok, ceinfo = compiler.ManualCompile(genCodeFile, compileTarget, []string{libraryDir}) |
| 117 | default: |
| 118 | return compileTarget, errors.Errorf("checker must be written by c/c++/golang") |
| 119 | } |
| 120 | if ok { |
| 121 | return compileTarget, nil |
| 122 | } |
| 123 | return compileTarget, errors.Errorf("compile error: %s", ceinfo) |
| 124 | } |
no test coverage detected