14
14
from sinol_make .helpers .parsers import add_compilation_arguments
15
15
from sinol_make .interfaces .BaseCommand import BaseCommand
16
16
from sinol_make .interfaces .Errors import CompilationError , CheckerOutputException , UnknownContestType
17
- from sinol_make .helpers import compile , compiler , package_util , printer
17
+ from sinol_make .helpers import compile , compiler , package_util , printer , paths
18
18
from sinol_make .structs .status_structs import Status
19
19
import sinol_make .util as util
20
20
import yaml , os , collections , sys , re , math , dictdiffer
@@ -339,8 +339,8 @@ def get_groups(self, tests):
339
339
340
340
341
341
def compile_solutions (self , solutions ):
342
- os .makedirs (self . COMPILATION_DIR , exist_ok = True )
343
- os .makedirs (self . EXECUTABLES_DIR , exist_ok = True )
342
+ os .makedirs (paths . get_compilation_log_path () , exist_ok = True )
343
+ os .makedirs (paths . get_executables_path () , exist_ok = True )
344
344
print ("Compiling %d solutions..." % len (solutions ))
345
345
args = [(solution , True ) for solution in solutions ]
346
346
with mp .Pool (self .cpus ) as pool :
@@ -349,10 +349,9 @@ def compile_solutions(self, solutions):
349
349
350
350
351
351
def compile (self , solution , use_extras = False ):
352
- compile_log_file = os .path .join (
353
- self .COMPILATION_DIR , "%s.compile_log" % package_util .get_file_name (solution ))
352
+ compile_log_file = paths .get_compilation_log_path ("%s.compile_log" % package_util .get_file_name (solution ))
354
353
source_file = os .path .join (os .getcwd (), "prog" , self .get_solution_from_exe (solution ))
355
- output = os . path . join ( self . EXECUTABLES_DIR , package_util .get_executable (solution ))
354
+ output = paths . get_executables_path ( package_util .get_executable (solution ))
356
355
357
356
extra_compilation_args = []
358
357
extra_compilation_files = []
@@ -581,7 +580,7 @@ def run_solution(self, data_for_execution: ExecutionData):
581
580
"""
582
581
583
582
(name , executable , test , time_limit , memory_limit , timetool_path ) = data_for_execution
584
- file_no_ext = os . path . join ( self . EXECUTIONS_DIR , name , package_util .extract_test_id (test ))
583
+ file_no_ext = paths . get_executions_path ( name , package_util .extract_test_id (test ))
585
584
output_file = file_no_ext + ".out"
586
585
result_file = file_no_ext + ".res"
587
586
hard_time_limit_in_s = math .ceil (2 * time_limit / 1000.0 )
@@ -620,7 +619,7 @@ def run_solutions(self, compiled_commands, names, solutions):
620
619
executions .append ((name , executable , test , package_util .get_time_limit (test , self .config , lang , self .args ),
621
620
package_util .get_memory_limit (test , self .config , lang , self .args ), self .timetool_path ))
622
621
all_results [name ][self .get_group (test )][test ] = ExecutionResult (Status .PENDING )
623
- os .makedirs (os . path . join ( self . EXECUTIONS_DIR , name ), exist_ok = True )
622
+ os .makedirs (paths . get_executions_path ( name ), exist_ok = True )
624
623
else :
625
624
for test in self .tests :
626
625
all_results [name ][self .get_group (test )][test ] = ExecutionResult (Status .CE )
@@ -685,9 +684,8 @@ def compile_and_run(self, solutions):
685
684
for i in range (len (solutions )):
686
685
if not compilation_results [i ]:
687
686
self .failed_compilations .append (solutions [i ])
688
- os .makedirs (self .EXECUTIONS_DIR , exist_ok = True )
689
- executables = [os .path .join (self .EXECUTABLES_DIR , package_util .get_executable (solution ))
690
- for solution in solutions ]
687
+ os .makedirs (paths .get_executions_path (), exist_ok = True )
688
+ executables = [paths .get_executables_path (package_util .get_executable (solution )) for solution in solutions ]
691
689
compiled_commands = zip (solutions , executables , compilation_results )
692
690
names = solutions
693
691
return self .run_solutions (compiled_commands , names , solutions )
@@ -966,12 +964,7 @@ def set_group_result(solution, group, result):
966
964
967
965
def set_constants (self ):
968
966
self .ID = package_util .get_task_id ()
969
- self .TMP_DIR = os .path .join (os .getcwd (), "cache" )
970
- self .COMPILATION_DIR = os .path .join (self .TMP_DIR , "compilation" )
971
- self .EXECUTIONS_DIR = os .path .join (self .TMP_DIR , "executions" )
972
- self .EXECUTABLES_DIR = os .path .join (self .TMP_DIR , "executables" )
973
967
self .SOURCE_EXTENSIONS = ['.c' , '.cpp' , '.py' , '.java' ]
974
- self .PROGRAMS_IN_ROW = 8
975
968
self .SOLUTIONS_RE = re .compile (r"^%s[bs]?[0-9]*\.(cpp|cc|java|py|pas)$" % self .ID )
976
969
977
970
@@ -1138,7 +1131,7 @@ def run(self, args):
1138
1131
print (util .info ("Checker found: %s" % os .path .basename (checker [0 ])))
1139
1132
self .checker = checker [0 ]
1140
1133
checker_basename = os .path .basename (self .checker )
1141
- self .checker_executable = os . path . join ( self . EXECUTABLES_DIR , checker_basename + ".e" )
1134
+ self .checker_executable = paths . get_executables_path ( checker_basename + ".e" )
1142
1135
1143
1136
checker_compilation = self .compile_solutions ([self .checker ])
1144
1137
if not checker_compilation [0 ]:
0 commit comments