diff options
Diffstat (limited to 'mesalib/src/mapi/glapi/gen/remap_helper.py')
-rw-r--r-- | mesalib/src/mapi/glapi/gen/remap_helper.py | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/mesalib/src/mapi/glapi/gen/remap_helper.py b/mesalib/src/mapi/glapi/gen/remap_helper.py index e1a13d0b3..94ae1936d 100644 --- a/mesalib/src/mapi/glapi/gen/remap_helper.py +++ b/mesalib/src/mapi/glapi/gen/remap_helper.py @@ -24,9 +24,11 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -import gl_XML +import argparse + import license -import sys, getopt, string +import gl_XML + def get_function_spec(func): sig = "" @@ -54,6 +56,7 @@ def get_function_spec(func): return spec + class PrintGlRemap(gl_XML.gl_print_base): def __init__(self): gl_XML.gl_print_base.__init__(self) @@ -163,30 +166,34 @@ class PrintGlRemap(gl_XML.gl_print_base): return -def show_usage(): - print "Usage: %s [-f input_file_name] [-c ver]" % sys.argv[0] - print " -c ver Version can be 'es1' or 'es2'." - sys.exit(1) +def _parser(): + """Parse input options and return a namsepace.""" + parser = argparse.ArgumentParser() + parser.add_argument('-f', '--filename', + default="gl_API.xml", + metavar="input_file_name", + dest='file_name', + help="An xml description file.") + parser.add_argument('-c', '--es-version', + choices=[None, 'es1', 'es2'], + default=None, + metavar='ver', + dest='es', + help='A GLES version to support') + return parser.parse_args() -if __name__ == '__main__': - file_name = "gl_API.xml" - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:c:") - except Exception,e: - show_usage() +def main(): + """Main function.""" + args = _parser() - es = None - for (arg,val) in args: - if arg == "-f": - file_name = val - elif arg == "-c": - es = val + api = gl_XML.parse_GL_API(args.file_name) + if args.es is not None: + api.filter_functions_by_api(args.es) - api = gl_XML.parse_GL_API( file_name ) + printer = PrintGlRemap() + printer.Print(api) - if es is not None: - api.filter_functions_by_api(es) - printer = PrintGlRemap() - printer.Print( api ) +if __name__ == '__main__': + main() |