import compare
import extensions
import opengl


compare.diff_functions_by_extension(
    extensions.FUNCTIONS_BY_EXTENSION, opengl.FUNCTIONS_BY_EXTENSION,
    'extension specs', 'opengl')
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])))
compare.diff_functions_by_extension(
    mesa.FUNCTIONS_BY_EXTENSION, opengl.FUNCTIONS_BY_EXTENSION,
    'mesa', 'opengl')

# To compare alias sets we first eliminate any functions from the
# alias sets that aren't known to both opengl and mesa, and reorganize
# into maps from (frozenset of function names) to the original alias
# set.
#
# NOTE: we don't care if mesa and opengl differ in which function they
# call canonical.  Also, to reduce the volume of output, we don't
# print out alias sets that contain just a single function.
mesa_alias_sets = process_alias_sets(mesa.ALIAS_SETS, common_keys)
opengl_alias_sets = process_alias_sets(opengl.ALIAS_SETS, common_keys)
mesa_alias_keys = frozenset(mesa_alias_sets.keys())
opengl_alias_sets = frozenset(opengl_alias_sets.keys())
compare.diff_keys(mesa_alias_keys, opengl_alias_sets, 'mesa', 'opengl',