From: Gereon Kremer Date: Fri, 4 Jun 2021 00:14:27 +0000 (+0200) Subject: Some cleanup in `mkoptions.py` (#6667) X-Git-Tag: cvc5-1.0.0~1644 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b68e0636fb839142f1515fc8551ade09d3ed1a5d;p=cvc5.git Some cleanup in `mkoptions.py` (#6667) This PR does some general cleanup in the mkoptions.py script: removal of obsolete code and some fixes to the comments. --- diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py index c355ff436..df0ef1a38 100644 --- a/src/options/mkoptions.py +++ b/src/options/mkoptions.py @@ -28,7 +28,6 @@ Directory must contain: - options_template.cpp - module_template.cpp - - options_holder_template.h - module_template.h + must be the list of all *.toml option configuration files from @@ -38,7 +37,6 @@ The script generates the following files: - /MODULE_options.h - /MODULE_options.cpp - - /options_holder.h - /options.cpp """ @@ -56,25 +54,17 @@ MODULE_ATTR_ALL = MODULE_ATTR_REQ + ['option'] OPTION_ATTR_REQ = ['category', 'type'] OPTION_ATTR_ALL = OPTION_ATTR_REQ + [ 'name', 'short', 'long', 'alias', - 'help', 'help_mode', 'default', - 'includes', 'handler', 'predicates', - 'alternate', 'mode' + 'default', 'alternate', 'mode', + 'handler', 'predicates', 'includes', + 'help', 'help_mode' ] CATEGORY_VALUES = ['common', 'expert', 'regular', 'undocumented'] - -SUPPORTED_CTYPES = ['int', 'unsigned', 'unsigned long', 'long', 'float', - 'double'] +SUPPORTED_CTYPES = ['int', 'unsigned', 'unsigned long', 'double'] ### Other globals -g_long_to_opt = dict() # maps long options to option objects -g_module_id_cache = dict() # maps ids to filename/lineno g_long_cache = dict() # maps long options to filename/fileno -g_short_cache = dict() # maps short options to filename/fileno -g_smt_cache = dict() # maps smt options to filename/fileno -g_name_cache = dict() # maps option names to filename/fileno -g_long_arguments = set() # set of long options that require an argument g_getopt_long_start = 256 @@ -104,8 +94,6 @@ TPL_CALL_SET_OPTION = 'setOption(std::string("{smtname}"), ("{value}"));' TPL_GETOPT_LONG = '{{ "{}", {}_argument, nullptr, {} }},' -TPL_PUSHBACK_PREEMPT = 'extender->pushBackPreemption({});' - TPL_HOLDER_MACRO_ATTR = ''' {type} {name}; bool {name}__setByUser = false;''' @@ -372,7 +360,7 @@ def die(msg): sys.exit('[error] {}'.format(msg)) -def perr(filename, msg, option = None): +def perr(filename, msg, option=None): msg_suffix = '' if option: if option.name: @@ -429,15 +417,6 @@ def long_get_option(name): return name.split('=')[0] -def get_long_name(option): - """ - Determine the name of the option used as option name. - """ - if option.long: - return long_get_option(option.long) - return None - - def is_numeric_cpp_type(ctype): """ Check if given type is a numeric C++ type (this should cover the most @@ -531,9 +510,7 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): """ Generate code for each option module (*_options.{h,cpp}) """ - global g_long_to_opt - - # *_options.h + # *_options.h / *.options.cpp includes = set() holder_specs = [] option_names = [] @@ -976,12 +953,6 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpl_options_h, tpl_options_ if os.path.isdir('{}/docs/'.format(build_dir)): sphinxgen.render('{}/docs/'.format(build_dir), 'options_generated.rst') -def lstrip(prefix, s): - """ - Remove prefix from the beginning of string s. - """ - return s[len(prefix):] if s.startswith(prefix) else s - def check_attribs(filename, req_attribs, valid_attribs, attribs, ctype): """ @@ -1089,6 +1060,7 @@ def usage(): print('mkoptions.py +') print('') print(' location of all *_template.{cpp,h} files') + print(' build directory') print(' destination directory for the generated files') print(' + one or more *_optios.toml files') print('') @@ -1131,18 +1103,13 @@ def mkoptions_main(): # applicable. for option in module.options: check_long(filename, option, option.long, option.type) - if option.long: - g_long_to_opt[long_get_option(option.long)] = option - # Add long option that requires an argument - if option.type not in ['bool', 'void']: - g_long_arguments.add(long_get_option(option.long)) modules.append(module) # Create *_options.{h,cpp} in destination directory for module in modules: codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp) - # Create options.cpp and options_holder.h in destination directory + # Create options.cpp in destination directory codegen_all_modules(modules, build_dir, dst_dir, tpl_options_h, tpl_options_cpp)