Skip to content
Snippets Groups Projects
Commit 3959ca62 authored by Massimiliano Culpo's avatar Massimiliano Culpo
Browse files

modules : added possibility to blacklist or whitelist module files

parent 0e2b1359
No related branches found
No related tags found
No related merge requests found
...@@ -89,7 +89,6 @@ def module_refresh(): ...@@ -89,7 +89,6 @@ def module_refresh():
shutil.rmtree(cls.path, ignore_errors=False) shutil.rmtree(cls.path, ignore_errors=False)
mkdirp(cls.path) mkdirp(cls.path)
for spec in specs: for spec in specs:
tty.debug(" Writing file for %s" % spec)
cls(spec).write() cls(spec).write()
......
...@@ -292,12 +292,17 @@ ...@@ -292,12 +292,17 @@
'module_type_configuration': { 'module_type_configuration': {
'type': 'object', 'type': 'object',
'default': {}, 'default': {},
'properties': { 'oneOf': [
'all': {'$ref': '#/definitions/module_file_configuration'} {
}, 'properties': {
'patternProperties': { 'whitelist': {'$ref': '#/definitions/array_of_strings'},
r'\w[\w-]*': {'$ref': '#/definitions/module_file_configuration'} 'blacklist': {'$ref': '#/definitions/array_of_strings'},
} }
},
{
'patternProperties': {r'\w[\w-]*': {'$ref': '#/definitions/module_file_configuration'}}
}
]
} }
}, },
'patternProperties': { 'patternProperties': {
......
...@@ -40,17 +40,15 @@ ...@@ -40,17 +40,15 @@
Each hook in hooks/ implements the logic for writing its specific type of module file. Each hook in hooks/ implements the logic for writing its specific type of module file.
""" """
import copy
import os import os
import os.path import os.path
import re import re
import shutil
import textwrap import textwrap
import copy
import llnl.util.tty as tty import llnl.util.tty as tty
import spack import spack
import spack.config import spack.config
from llnl.util.filesystem import join_path, mkdirp from llnl.util.filesystem import join_path, mkdirp
from spack.build_environment import parent_class_modules, set_module_variables_for_package from spack.build_environment import parent_class_modules, set_module_variables_for_package
from spack.environment import * from spack.environment import *
...@@ -225,6 +223,30 @@ def category(self): ...@@ -225,6 +223,30 @@ def category(self):
# Not very descriptive fallback # Not very descriptive fallback
return 'spack installed package' return 'spack installed package'
@property
def blacklisted(self):
configuration = CONFIGURATION.get(self.name, {})
whitelist_matches = [x for x in configuration.get('whitelist', []) if self.spec.satisfies(x)]
blacklist_matches = [x for x in configuration.get('blacklist', []) if self.spec.satisfies(x)]
if whitelist_matches:
message = '\t%s is whitelisted [matches : ' % self.spec.cshort_spec
for rule in whitelist_matches:
message += '%s ' % rule
message += ' ]'
tty.debug(message)
if blacklist_matches:
message = '\t%s is blacklisted [matches : ' % self.spec.cshort_spec
for rule in blacklist_matches:
message += '%s ' % rule
message += ' ]'
tty.debug(message)
if not whitelist_matches and blacklist_matches:
return True
return False
def write(self): def write(self):
""" """
Writes out a module file for this object. Writes out a module file for this object.
...@@ -233,6 +255,10 @@ def write(self): ...@@ -233,6 +255,10 @@ def write(self):
- override the header property - override the header property
- provide formats for autoload, prerequisites and environment changes - provide formats for autoload, prerequisites and environment changes
""" """
if self.blacklisted:
return
tty.debug("\t%s : writing module file" % self.spec.cshort_spec)
module_dir = os.path.dirname(self.file_name) module_dir = os.path.dirname(self.file_name)
if not os.path.exists(module_dir): if not os.path.exists(module_dir):
mkdirp(module_dir) mkdirp(module_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment