From c62b3eef559e9d47ee6fe5136a2edebca5111fad Mon Sep 17 00:00:00 2001 From: alalazo Date: Wed, 2 Aug 2017 15:37:52 +0200 Subject: filter_compiler_path: added the possibility to narrow search path Following a comment from Todd, the search path for the files listed in `filter_compiler_wrappers` can now be narrowed. Anyhow, the function implementation still makes use of `find`, the rationale being that we have already seen packages that install artifacts in e.g. architecture dependent folders. The possibility to have a relative search path might be a good compromise between the previous approach and the one suggested in the review. Also: 'ignore_absent' and 'backup' keyword arguments can be optionally forwarded to `filter_file`. --- lib/spack/spack/mixins.py | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/mixins.py b/lib/spack/spack/mixins.py index 82e6f8bdad..0a43e76961 100644 --- a/lib/spack/spack/mixins.py +++ b/lib/spack/spack/mixins.py @@ -143,24 +143,47 @@ def filter_compiler_wrappers(*files, **kwargs): whatever compiler they were built with. Args: - *files: files to be filtered - **kwargs: at present supports the keyword 'after' to specify after - which phase the files should be filtered (defaults to 'install'). + *files: files to be filtered relative to the search root (which is, + by default, the installation prefix) + + **kwargs: allowed keyword arguments + + after + specifies after which phase the files should be + filtered (defaults to 'install') + + relative_root + path relative to prefix where to start searching for + the files to be filtered. If not set the install prefix + wil be used as the search root. **It is highly recommended + to set this, as searching from the installation prefix may + affect performance severely in some cases**. + + ignore_absent, backup + these two keyword arguments, if present, will be forwarded + to ``filter_file`` (see its documentation for more information + on their behavior) """ after = kwargs.get('after', 'install') + relative_root = kwargs.get('relative_root', None) + + filter_kwargs = { + 'ignore_absent': kwargs.get('ignore_absent', True), + 'backup': kwargs.get('backup', False), + 'string': True + } def _filter_compiler_wrappers_impl(self): + # Compute the absolute path of the search root + root = os.path.join( + self.prefix, relative_root + ) if relative_root else self.prefix + # Compute the absolute path of the files to be filtered and # remove links from the list. - abs_files = llnl.util.filesystem.find(self.prefix, files) + abs_files = llnl.util.filesystem.find(root, files) abs_files = [x for x in abs_files if not os.path.islink(x)] - filter_kwargs = { - 'ignore_absent': True, - 'backup': False, - 'string': True - } - x = llnl.util.filesystem.FileFilter(*abs_files) x.filter(os.environ['CC'], self.compiler.cc, **filter_kwargs) -- cgit v1.2.3-70-g09d2