@@ -4190,6 +4190,29 @@ def print_dry_run_note(loc, silent=True):
41904190 dry_run_msg (msg , silent = silent )
41914191
41924192
4193+ def persists_failed_compilation_log_and_artifacts (success , application_log , log , silent , builddir , err_log_path ):
4194+ if application_log :
4195+ # there may be multiple log files, or the file name may be different due to zipping
4196+ logs = glob .glob ('%s*' % application_log )
4197+ print_msg ("Results of the build can be found in the log file(s) %s" % ', ' .join (logs ), log = log , silent = silent )
4198+ if err_log_path and not (success ):
4199+ for log_file in logs :
4200+ target_file = os .path .join (err_log_path , os .path .basename (log_file ))
4201+ copy_file (log_file , target_file )
4202+
4203+ relative_build_artifact_log_path = os .path .relpath (builddir , build_path ())
4204+ build_artifact_log_path = os .path .join (err_log_path , relative_build_artifact_log_path )
4205+
4206+ if is_readable (builddir ):
4207+ copy_dir (builddir , build_artifact_log_path )
4208+
4209+ print_msg (
4210+ "Build log and any output artifacts copied to permanent storage: %s" % err_log_path ,
4211+ log = _log ,
4212+ silent = silent
4213+ )
4214+
4215+
41934216def build_and_install_one (ecdict , init_env ):
41944217 """
41954218 Build the software
@@ -4446,27 +4469,8 @@ def ensure_writable_log_dir(log_dir):
44464469 else :
44474470 dry_run_msg ("(no ignored errors during dry run)\n " , silent = silent )
44484471
4449- if application_log :
4450- # there may be multiple log files, or the file name may be different due to zipping
4451- logs = glob .glob ('%s*' % application_log )
4452- print_msg ("Results of the build can be found in the log file(s) %s" % ', ' .join (logs ), log = _log , silent = silent )
4453- err_log_path = error_log_path (ec = ecdict ['ec' ])
4454- if err_log_path and not (success ):
4455- for log_file in logs :
4456- target_file = os .path .join (err_log_path , os .path .basename (log_file ))
4457- copy_file (log_file , target_file )
4458-
4459- relative_build_artifact_log_path = os .path .relpath (app .builddir , build_path ())
4460- build_artifact_log_path = os .path .join (err_log_path , relative_build_artifact_log_path )
4461-
4462- if is_readable (app .builddir ):
4463- copy_dir (app .builddir , build_artifact_log_path )
4464-
4465- print_msg (
4466- "Build log and any output artifacts copied to permanent storage: %s" % err_log_path ,
4467- log = _log ,
4468- silent = silent
4469- )
4472+ err_log_path = error_log_path (ec = ecdict ['ec' ])
4473+ persists_failed_compilation_log_and_artifacts (success , application_log , _log , silent , app .builddir , err_log_path )
44704474
44714475 del app
44724476
0 commit comments