def _parse_options(self, options_file): """ Returns a set of options defined in the provides meson_options.txt file Parameters: options_file The file containing options """ oi = optinterpreter.OptionInterpreter('') oi.process(options_file) return oi.options
from mesonbuild import optinterpreter (COLUMNS, _) = get_terminal_size() def describe_option(option_name: str, option_default_value: str, option_type: str, option_message: str) -> None: print(('name: ' + option_name)) print(('default: ' + option_default_value)) print(('type: ' + option_type)) for line in wrap(option_message, width=COLUMNS - 9): print((' ' + line)) print('---') oi = optinterpreter.OptionInterpreter('') oi.process('meson_options.txt') for (name, value) in list(oi.options.items()): if isinstance(value, coredata.UserStringOption): describe_option( name, value.value, 'string', "You can type what you want, but make sure it makes sense") elif isinstance(value, coredata.UserBooleanOption): describe_option(name, 'true' if value.value else 'false', 'boolean', "You can set it to 'true' or 'false'") elif isinstance(value, coredata.UserIntegerOption): describe_option( name, str(value.value), 'integer', "You can set it to any integer value between '{}' and '{}'".format( value.min_value, value.max_value))