@@ -23,13 +23,17 @@ var langMap = map[string]apipb.LanguageGroup{
2323 "ruby" : apipb .LanguageGroup_RUBY ,
2424 "rust" : apipb .LanguageGroup_RUST ,
2525 "java" : apipb .LanguageGroup_JAVA ,
26- "csharp" : apipb .LanguageGroup_CSHARP ,
26+ "csharp" : apipb .LanguageGroup_CSHARP ,
2727}
2828
2929type submissionJson struct {
3030 Files map [string ]string
3131}
3232
33+ type includedCodeJson struct {
34+ FilesByLanguage map [string ]map [string ]string `json:"files_by_language"`
35+ }
36+
3337var evalMutex sync.Mutex
3438
3539func toStorageVerdict (verdict apipb.Verdict ) storage.Verdict {
@@ -62,18 +66,27 @@ func evaluate(runId int64) error {
6266 }
6367 lang , ok := langMap [run .Submission .Language ]
6468 if ! ok {
65- return fmt .Errorf ("run has unknown language %s" , run .Submission .Language )
69+ return fmt .Errorf ("run has unknown language %s" , run .Submission .Language )
6670 }
6771 program := & apipb.Program {
6872 Language : lang ,
6973 }
7074 submissionFiles := submissionJson {}
71- err := json .Unmarshal (run .Submission .SubmissionFiles , & submissionFiles )
72- if err != nil {
75+ if err := json .Unmarshal (run .Submission .SubmissionFiles , & submissionFiles ); err != nil {
7376 return err
7477 }
78+ includedCode := includedCodeJson {}
79+ if err := json .Unmarshal (run .ProblemVersion .IncludedFiles , & includedCode ); err != nil {
80+ return err
81+ }
82+ logger .Infof ("Lang: %v, included code:" , run .Submission .Language , includedCode )
83+ extraFiles := includedCode .FilesByLanguage [run .Submission .Language ]
84+
7585 logger .Infof ("Files: %v" , submissionFiles )
7686 for path , content := range submissionFiles .Files {
87+ if _ , hasExtraFile := extraFiles [path ]; hasExtraFile {
88+ continue
89+ }
7790 content , err := base64 .StdEncoding .DecodeString (content )
7891 if err != nil {
7992 return err
@@ -83,6 +96,15 @@ func evaluate(runId int64) error {
8396 Contents : content ,
8497 })
8598 }
99+
100+ logger .Infof ("Extra files: %v" , extraFiles )
101+ for path , content := range extraFiles {
102+ program .Sources = append (program .Sources , & apipb.SourceFile {
103+ Path : filepath .Base (path ),
104+ Contents : []byte (content ),
105+ })
106+ }
107+
86108 // In case we retry judging of the run, put it in a new folder instead to avoid collisions
87109 subRoot := fmt .Sprintf ("/var/lib/omogen/submissions/%d-%d" , runId , time .Now ().Unix ())
88110 compile , err := eval .Compile (program , filepath .Join (subRoot , "compile" ))
0 commit comments