From: Gereon Kremer Date: Tue, 14 Sep 2021 22:09:19 +0000 (+0200) Subject: Final cleanup (#7193) X-Git-Tag: cvc5-1.0.0~1212 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=560391cf71c1004716168a979782875de98b867f;p=cvc5.git Final cleanup (#7193) This PR does some final cleanup on the options generation code. --- diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py index c63e8b94b..c12a54ebb 100644 --- a/src/options/mkoptions.py +++ b/src/options/mkoptions.py @@ -192,6 +192,10 @@ class Option(object): if self.long_name: return True return False + def __str__(self): + return self.long_name if self.long_name else self.name + + ################################################################################ ################################################################################ # code generation functions @@ -853,41 +857,6 @@ def generate_sphinx_help(modules): return '\n'.join(res) -def long_get_option(name): - """ - Extract the name of a given long option long=ARG - """ - return name.split('=')[0] - - -def help_mode_format(option): - """ - Format help message for mode options. - """ - assert option.help_mode - assert option.mode - - wrapper = textwrap.TextWrapper(width=78, break_on_hyphens=False) - text = ['{}'.format(x) for x in wrapper.wrap(option.help_mode)] - - optname, optvalue = option.long.split('=') - text.append('Available {}s for --{} are:'.format( - optvalue.lower(), optname)) - - for value, attrib in option.mode.items(): - assert len(attrib) == 1 - attrib = attrib[0] - if 'help' not in attrib: - continue - if value == option.default and attrib['name'] != "default": - text.append('+ {} (default)'.format(attrib['name'])) - else: - text.append('+ {}'.format(attrib['name'])) - text.extend(' {}'.format(x) for x in wrapper.wrap(attrib['help'])) - - return '\n '.join('"{}\\n"'.format(x) for x in text) - - ################################################################################ # main code generation for individual modules @@ -920,12 +889,6 @@ def codegen_module(module, dst_dir, tpls): def codegen_all_modules(modules, build_dir, dst_dir, tpls): """Generate code for all option modules.""" - - headers_module = [] # generated *_options.h header includes - - for module in modules: - headers_module.append(format_include(module.header)) - short, cmdline_opts, parseinternal = generate_parsing(modules) help_common, help_others = generate_cli_help(modules) @@ -949,9 +912,9 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpls): 'get_impl': generate_get_impl(modules), 'set_impl': generate_set_impl(modules), 'getinfo_impl': generate_getinfo_impl(modules), + # main/options.cpp 'help_common': help_common, 'help_others': help_others, - # main/options.cpp 'cmdoptions_long': cmdline_opts, 'cmdoptions_short': short, 'parseinternal_impl': parseinternal, @@ -960,6 +923,10 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpls): write_file(dst_dir, tpl['output'], tpl['content'].format(**data)) +################################################################################ +# sanity checking + + class Checker: """Performs a variety of sanity checks on options and option modules, and constructs `Module` and `Option` from dictionaries.""" @@ -1058,6 +1025,10 @@ class Checker: return o +################################################################################ +# main entrypoint + + def usage(): """Print the command-line usage""" print('mkoptions.py +')