Skip to content

Commit 17a327f

Browse files
authored
Merge pull request #4966 from reneme/feature/module_wildcards
2 parents a13f950 + 9fa2704 commit 17a327f

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

configure.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,8 @@ def __init__(self, modules, module_policy, archinfo, osinfo, ccinfo, cc_min_vers
24422442
self._not_using_because = collections.defaultdict(set)
24432443

24442444
ModulesChooser._validate_dependencies_exist(self._modules)
2445+
self._options.enabled_modules = ModulesChooser._expand_wildcards_in_user_selection(self._modules, self._options.enabled_modules)
2446+
self._options.disabled_modules = ModulesChooser._expand_wildcards_in_user_selection(self._modules, self._options.disabled_modules)
24452447
ModulesChooser._validate_user_selection(
24462448
self._modules, self._options.enabled_modules, self._options.disabled_modules)
24472449

@@ -2519,6 +2521,21 @@ def _validate_dependencies_exist(modules):
25192521
for module in modules.values():
25202522
module.dependencies_exist(modules)
25212523

2524+
@staticmethod
2525+
def _expand_wildcards_in_user_selection(modules, user_selected_modules):
2526+
valid_module_name_with_wildcard = re.compile(r'^[a-z0-9_*]+$')
2527+
public_modules = [modname for modname, modinfo in modules.items() if modinfo.is_public()]
2528+
def expand(user_selected_module):
2529+
if not valid_module_name_with_wildcard.match(user_selected_module):
2530+
logging.error("Invalid module name with wildcard: %s", user_selected_module)
2531+
return []
2532+
regex_from_wildcards = re.compile("^%s$" % user_selected_module.replace('*', '[a-z0-9_]+'))
2533+
matching_modules = [mod for mod in public_modules if regex_from_wildcards.match(mod)]
2534+
if not matching_modules:
2535+
logging.warning("Wildcard '%s' did not match any modules", user_selected_module)
2536+
return matching_modules
2537+
return flatten([expand(mod) if '*' in mod else [mod] for mod in user_selected_modules])
2538+
25222539
@staticmethod
25232540
def _validate_user_selection(modules, enabled_modules, disabled_modules):
25242541
for modname in enabled_modules:

doc/building.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,11 @@ Minimized Builds
608608
Many developers wish to configure a minimized build which contains only the
609609
specific features their application will use. In general this is straighforward:
610610
use ``--minimized-build`` plus ``--enable-modules=`` to enable the specific modules
611-
you wish to use. Any such configurations should build and pass the tests; if you
612-
encounter a case where it doesn't please file an issue.
611+
you wish to use. It is possible to use an asterisk (``*``) as a wildcard for
612+
related modules. For instance to enable all available AES implementations, use
613+
``--enable-modules='aes*'`` which will enable ``aes_ni``, ``aes_power8``, etc.
614+
Any such configurations should build and pass the tests; if you encounter a case
615+
where it doesn't please file an issue.
613616

614617
The only trick is knowing which features you want to enable. The most common
615618
difficulty comes with entropy sources. By default, none are enabled, which means

src/scripts/ci_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def sanitize_kv(some_string):
231231
flags += ['--extra-cxxflags=/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR']
232232

233233
if target in ['minimized']:
234-
flags += ['--minimized-build', '--enable-modules=system_rng,sha2_32,sha2_64,aes']
234+
flags += ['--minimized-build', '--enable-modules=system_rng,sha2*,aes']
235235

236236
if target in ['no_pcurves']:
237237
flags += ['--disable-modules=pcurves_impl']

0 commit comments

Comments
 (0)