functions_to_keep = frozenset(functions_to_keep)
    result = {}
    for alias_set in alias_sets:
        functions = frozenset(alias_set['functions']) & functions_to_keep
        if len(functions) > 1:
            result[functions] = alias_set
    return result


def alias_set_printer(alias_set):
    return '({0})'.format(', '.join(sorted(alias_set)))


mesa_keys = set(mesa.FUNCTIONS.keys())
opengl_keys = set(opengl.FUNCTIONS.keys())
compare.diff_keys(mesa_keys, opengl_keys, 'mesa', 'opengl', 'functions')
compare.diff_keys(opengl_keys, mesa_keys, 'opengl', 'mesa', 'functions')
common_keys = mesa_keys & opengl_keys
for key in sorted(common_keys):
    mesa_func = normalize_mesa_function(mesa.FUNCTIONS[key])
    opengl_func = normalize_opengl_function(opengl.FUNCTIONS[key])
    # TODO: temporary HACK: ignore deprecation for extension functions
    if not opengl.FUNCTIONS[key]['category'].startswith('VERSION_'):
        mesa_func['deprecated'] = None
        opengl_func['deprecated'] = None
    if mesa_func != opengl_func:
        print('Function {0} does not match:'.format(key))
        print('  mesa: {0}'.format(
                summarize_function(key, mesa.FUNCTIONS[key])))
        print('  opengl: {0}'.format(
                summarize_function(key, opengl.FUNCTIONS[key])))
Exemplo n.º 2
0
def main():
    src_dir = '/home/pberry/mesa/src/mesa/main'
    src_files = [file for file in os.listdir(src_dir) if file.endswith('.c')]
    trees = {}
    for file in src_files:
        with open(os.path.join(src_dir, file), 'r') as f:
            Scanner(f.read()).process_file(trees)
    analysis = []
    interpret_trees(trees, '_mesa_create_exec_table',
                    frozenset(['es1', 'es2', 'es3', 'core', 'compat']),
                    analysis)
    for entry in analysis:
        apis = entry[0]
        if 'core' in apis:
            assert 'compat' in apis
        desktop = 'compat' in apis
        if 'compat' in apis and not 'core' in apis:
            deprecated = '3.1'
        else:
            deprecated = None
        es1 = 'es1' in apis
        if 'es2' in apis:
            assert 'es3' in apis
            es2 = '2.0'
        elif 'es3' in apis:
            es2 = '3.0'
        else:
            es2 = None
        annotations = {'desktop': desktop, 'deprecated': deprecated, 'es1': es1, 'es2': es2}
        glname = entry[1]
        funcname = entry[2]
        assert glname not in FUNCTIONS
        FUNCTIONS[glname] = {'mesa_function': funcname, 'condition': annotations}

    xml_keys = set(alias_set['canonical_name']
                   for alias_set in mesa.ALIAS_SETS
                   if alias_set['exec'] not in ('skip', 'dynamic'))
    exec_keys = set(FUNCTIONS.keys())
    compare.diff_keys(xml_keys, exec_keys, 'XML', 'api_exec.c', 'functions')
    compare.diff_keys(exec_keys, xml_keys, 'api_exec.c', 'XML', 'functions')
    common_keys = xml_keys & exec_keys
    for name in sorted(common_keys):
        mesa_alias_set = mesa.ALIAS_SETS_BY_FUNCTION[name]
        mesa_name = mesa_alias_set['mesa_name']
        exec_flavour = mesa_alias_set['exec']
        if exec_flavour is None:
            xml_mesa_function = '_mesa_' + mesa_name
        elif exec_flavour == 'loopback':
            xml_mesa_function = 'loopback_' + mesa_name
        elif exec_flavour == 'es':
            xml_mesa_function = '_es_' + mesa_name
        elif exec_flavour == 'check':
            xml_mesa_function = '_check_' + mesa_name
        else:
            raise Exception('Function {0} has unexpected exec flavour {1!r}'.format(name, exec_flavour))
        if FUNCTIONS[name]['mesa_function'] != xml_mesa_function:
            print('{0}: XML says mesa function is {1!r}, but api_exec.c says it\'s {2!r}'.format(
                    name, xml_mesa_function, FUNCTIONS[name]['mesa_function']))
        condition = FUNCTIONS[name]['condition']
        for key in ('deprecated', 'es1', 'es2', 'desktop'):
            mesa_value = mesa_alias_set[key]
            if key == 'es1':
                mesa_value = (mesa_value is not None)
            api_exec_value = condition[key]
            if mesa_value != api_exec_value:
                print('{0}: XML says {1} is {2!r}, but api_exec.c says it\'s {3!r}'.format(
                        name, key, mesa_value, api_exec_value))