@@ -20,12 +20,13 @@ def naturalSort(s):
20
20
return [int (text ) if text .isdigit () else text .lower ()
21
21
for text in re .split ('([0-9]+)' , s )]
22
22
23
- def run (command ):
23
+ def run (command , directory ):
24
24
logger .log ("Running command: " + command )
25
25
result = subprocess .run (command ,
26
26
stdout = subprocess .PIPE ,
27
27
stderr = subprocess .STDOUT ,
28
- shell = True )
28
+ shell = True ,
29
+ cwd = directory )
29
30
logger .log (result .stdout .decode ('utf-8' ))
30
31
if result .returncode != 0 :
31
32
logger .log (f"Error running the command: { command } " )
@@ -183,10 +184,16 @@ def main():
183
184
184
185
solution_file_name = os .path .join (src_dir , "solution.cpp" )
185
186
solution_function_file_name = os .path .join (src_dir , "solutionfunction.h" )
186
- ret = functionextractor .get_function (solution_file_name ,
187
- solution_function_file_name )
188
- logger .log (f"Extracted function name: { ret } " )
189
- logger .log (f"Writing the function name to { solution_function_file_name } " )
187
+ if not os .path .isfile (solution_function_file_name ):
188
+ ret = functionextractor .get_function (solution_file_name ,
189
+ solution_function_file_name )
190
+ logger .log (f"Extracted function name: { ret } " )
191
+ logger .log (f"Writing the function name to { solution_function_file_name } " )
192
+
193
+ if not ret :
194
+ print (logger .red (f"Could not extract the function name from "
195
+ f"{ solution_file_name } ." ))
196
+ sys .exit (1 )
190
197
191
198
validation_schema_file = os .path .abspath (
192
199
os .path .join (openleetcode_dir , VALIDATION_SCHEMA_FILE_NAME ))
@@ -204,20 +211,19 @@ def main():
204
211
sys .exit (1 )
205
212
resultsvalidator .set_schema (schema )
206
213
207
- if not ret :
208
- print (logger .red (f"Could not extract the function name from "
209
- f"{ solution_file_name } ." ))
210
- sys .exit (1 )
211
-
212
- if run (f"cmake -B { build_dir } -S { src_dir } " ) != 0 :
213
- print (logger .red (f"CMake failed!" ))
214
- sys .exit (1 )
214
+ if not os .path .isfile (os .path .join (build_dir , "CMakeCache.txt" )):
215
+ print ("CMakeCache.txt does not exist. Running CMake to configure the " )
216
+ if run (f"cmake -B { build_dir } " , src_dir ) != 0 :
217
+ print (logger .red (f"CMake failed!" ))
218
+ sys .exit (1 )
219
+ else :
220
+ print ("CMakeCache.txt exists. Skipping CMake configuration." )
215
221
216
- if run (f"cmake --build { build_dir } --config Release" ) != 0 :
222
+ if run (f"cmake --build . --config Release -j" , build_dir ) != 0 :
217
223
print (logger .red ("Build failed!" ))
218
224
sys .exit (1 )
219
225
220
- if run (f"cmake --install { build_dir } " ) != 0 :
226
+ if run (f"cmake --install ." , build_dir ) != 0 :
221
227
print (logger .red ("Cmake install failed!" ))
222
228
sys .exit (1 )
223
229
@@ -253,7 +259,6 @@ def main():
253
259
254
260
output_file_dir = os .path .abspath (os .path .join (TESTCAST_OUTPUT_DIR ))
255
261
256
- # Run the tests
257
262
ret , error_message = testrunner .runTests (exe_file ,
258
263
testcases_dir ,
259
264
output_file_dir ,
0 commit comments