Skip to content

Commit 1274a2b

Browse files
committed
[refactor] Extract function generating the relative base builddir path
The base builddir path is used to construct the builddir by - pre-pending the asboloute build path, and - adding a numerical suffix to ensure uniqueness.
1 parent 2fdf10a commit 1274a2b

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

easybuild/framework/easyblock.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,16 +1039,23 @@ def moduleGenerator(self):
10391039
#
10401040
# DIRECTORY UTILITY FUNCTIONS
10411041
#
1042-
def gen_builddir(self):
1043-
"""Generate the (unique) name for the builddir"""
1042+
def get_relative_builddir_base_path(self):
1043+
"""Generate builddir base name relative to build_path"""
10441044
clean_name = remove_unwanted_chars(self.name)
10451045

10461046
# if a toolchain version starts with a -, remove the - so prevent a -- in the path name
10471047
tc = self.cfg['toolchain']
10481048
tcversion = tc['version'].lstrip('-')
10491049
lastdir = "%s%s-%s%s" % (self.cfg['versionprefix'], tc['name'], tcversion, self.cfg['versionsuffix'])
10501050

1051-
builddir = os.path.join(os.path.abspath(build_path()), clean_name, self.version, lastdir)
1051+
relative_builddir = os.path.join(clean_name, self.version, lastdir)
1052+
1053+
return relative_builddir
1054+
1055+
def gen_builddir(self):
1056+
"""Generate the (unique) name for the builddir"""
1057+
relative_builddir = self.get_relative_builddir_base_path()
1058+
builddir = os.path.join(os.path.abspath(build_path()), relative_builddir)
10521059

10531060
# make sure build dir is unique if cleanupoldbuild is False or not set
10541061
if not self.cfg.get('cleanupoldbuild', False):
@@ -4190,20 +4197,24 @@ def print_dry_run_note(loc, silent=True):
41904197
dry_run_msg(msg, silent=silent)
41914198

41924199

4193-
def persists_failed_compilation_log_and_artifacts(success, application_log, log, silent, builddir, err_log_path):
4200+
def persists_failed_compilation_log_and_artifacts(success, application_log, silent, app, err_log_path):
41944201
if application_log:
41954202
# there may be multiple log files, or the file name may be different due to zipping
41964203
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)
4204+
print_msg(
4205+
"Results of the build can be found in the log file(s) %s" % ', '.join(logs),
4206+
log=_log,
4207+
silent=silent
4208+
)
4209+
41984210
if err_log_path and not(success):
41994211
for log_file in logs:
42004212
target_file = os.path.join(err_log_path, os.path.basename(log_file))
42014213
copy_file(log_file, target_file)
42024214

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-
4215+
builddir = app.builddir
42064216
if is_readable(builddir):
4217+
build_artifact_log_path = os.path.join(err_log_path, app.get_relative_builddir_base_path())
42074218
copy_dir(builddir, build_artifact_log_path)
42084219

42094220
print_msg(
@@ -4470,7 +4481,7 @@ def ensure_writable_log_dir(log_dir):
44704481
dry_run_msg("(no ignored errors during dry run)\n", silent=silent)
44714482

44724483
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)
4484+
persists_failed_compilation_log_and_artifacts(success, application_log, _log, silent, app, err_log_path)
44744485

44754486
del app
44764487

0 commit comments

Comments
 (0)