diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2017-08-02 15:37:52 +0200 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-02-13 02:18:28 -0800 |
commit | c62b3eef559e9d47ee6fe5136a2edebca5111fad (patch) | |
tree | 14475ffcdcf11f96ce5795037e7b67ee50ef721b /lib | |
parent | 4e48bae0962c6494f421198afb756498e9580b66 (diff) | |
download | spack-c62b3eef559e9d47ee6fe5136a2edebca5111fad.tar.gz spack-c62b3eef559e9d47ee6fe5136a2edebca5111fad.tar.bz2 spack-c62b3eef559e9d47ee6fe5136a2edebca5111fad.tar.xz spack-c62b3eef559e9d47ee6fe5136a2edebca5111fad.zip |
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`.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/mixins.py | 43 |
1 files changed, 33 insertions, 10 deletions
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) |