Tools: --disable-* argument for removing features

Optional argument --disable-* for removing features in install scripts.
This commit is contained in:
Marek Fiala
2022-05-20 15:15:52 +02:00
parent be4d13d888
commit 90a69c4490
4 changed files with 45 additions and 15 deletions

View File

@@ -13,13 +13,20 @@ from itertools import chain
def action_extract_features(args: str) -> None:
"""
Command line arguments starting with "--enable-" are features. This function selects those and prints them.
Command line arguments starting with "--enable-" or "--disable" are features. This function selects those, add them signs '+' or '-' and prints them.
"""
features = ['core'] # "core" features should be always installed
features = ['+core'] # "core" features should be always installed
if args:
arg_prefix = '--enable-'
features += [arg[len(arg_prefix):] for arg in args.split() if arg.startswith(arg_prefix)]
arg_enable_prefix = '--enable-'
arg_disable_prefix = '--disable-'
# features to be enabled has prefix '+', disabled has prefix '-'
for arg in args.split():
if arg.startswith(arg_enable_prefix):
features.append('+' + arg[len(arg_enable_prefix):])
elif arg.startswith(arg_disable_prefix):
features.append('-' + arg[len(arg_disable_prefix):])
features = list(set(features))
print(','.join(features))