Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions easybuild/easyblocks/generic/buildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,35 @@

@author: Alan O'Cais (Juelich Supercomputing Centre)
"""
import os

from easybuild.easyblocks.generic.bundle import Bundle
from easybuild.tools.config import build_option, update_build_option
from easybuild.tools.toolchain.toolchain import RPATH_WRAPPERS_SUBDIR


class BuildEnv(Bundle):
"""
Build environment of toolchain: only generate module file
"""

def prepare_step(self, *args, **kwargs):
"""
Custom prepare step for buildenv: export rpath wrappers if they are being used
"""
# We export the rpath wrappers under special conditions
# (the wrappers are needed if LD_LIBRARY_PATH is being filtered)
filtered_env_vars = build_option('filter_env_vars') or []
if build_option('rpath') and 'LD_LIBRARY_PATH' in filtered_env_vars and 'LIBRARY_PATH' not in filtered_env_vars:
# re-create installation dir (deletes old installation),
self.make_installdir()
# then set keeppreviousinstall to True (to avoid deleting wrappers we create)
self.cfg['keeppreviousinstall'] = True
# export our RPATH wrappers during the prepare step
update_build_option('rpath_wrappers_dir', os.path.join(self.installdir, 'bin'))

super(BuildEnv, self).prepare_step(*args, **kwargs)

def make_module_extra(self):
"""Add all the build environment variables."""
txt = super(BuildEnv, self).make_module_extra()
Expand All @@ -47,3 +68,16 @@ def make_module_extra(self):

self.log.debug("make_module_extra added this: %s" % txt)
return txt

def make_module_step(self, fake=False):
"""Specify correct bin directories for buildenv installation."""
filtered_env_vars = build_option('filter_env_vars') or []
if build_option('rpath') and 'LD_LIBRARY_PATH' in filtered_env_vars and 'LIBRARY_PATH' not in filtered_env_vars:
# Final location of wrappers includes a subdirectory
wrappers_dir = os.path.join(self.installdir, 'bin', RPATH_WRAPPERS_SUBDIR)
if os.path.exists(wrappers_dir):
wrappers_dir_subdirs = [os.path.join(wrappers_dir, dir) for dir in os.listdir(wrappers_dir)]
if wrappers_dir_subdirs:
self.module_load_environment.PATH = wrappers_dir_subdirs

return super(BuildEnv, self).make_module_step(fake=fake)