MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / CompileSpecialJudgeCodeFile

Function CompileSpecialJudgeCodeFile

executor/utils.go:98–124  ·  view source on GitHub ↗

CompileSpecialJudgeCodeFile 普通特殊评测的编译方法

(source, name, binRoot, configDir, libraryDir, lang string)

Source from the content-addressed store, hash-verified

96
97// CompileSpecialJudgeCodeFile 普通特殊评测的编译方法
98func 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}

Callers 2

compileWorkCodeFilesFunction · 0.92
compileJudgerProgramMethod · 0.85

Calls 4

ManualCompileMethod · 0.95
NewGnucppCompileProviderFunction · 0.92
NewGolangCompileProviderFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected