15bd8deadSopenharmony_ci#!/usr/bin/env python3 25bd8deadSopenharmony_ci# 35bd8deadSopenharmony_ci# Copyright 2013-2020 The Khronos Group Inc. 45bd8deadSopenharmony_ci# SPDX-License-Identifier: Apache-2.0 55bd8deadSopenharmony_ci 65bd8deadSopenharmony_ciimport sys, time, pdb, string, cProfile 75bd8deadSopenharmony_cifrom reg import * 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ci# debug - start header generation in debugger 105bd8deadSopenharmony_ci# dump - dump registry after loading 115bd8deadSopenharmony_ci# profile - enable Python profiling 125bd8deadSopenharmony_ci# protect - whether to use #ifndef protections 135bd8deadSopenharmony_ci# registry <filename> - use specified XML registry instead of gl.xml 145bd8deadSopenharmony_ci# target - string name of target header, or all targets if None 155bd8deadSopenharmony_ci# timeit - time length of registry loading & header generation 165bd8deadSopenharmony_ci# validate - validate return & parameter group tags against <group> 175bd8deadSopenharmony_cidebug = False 185bd8deadSopenharmony_cidump = False 195bd8deadSopenharmony_ciprofile = False 205bd8deadSopenharmony_ciprotect = True 215bd8deadSopenharmony_citarget = None 225bd8deadSopenharmony_citimeit = False 235bd8deadSopenharmony_civalidate= False 245bd8deadSopenharmony_ci# Default input / log files 255bd8deadSopenharmony_cierrFilename = None 265bd8deadSopenharmony_cidiagFilename = 'diag.txt' 275bd8deadSopenharmony_ciregFilename = 'gl.xml' 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci# Simple timer functions 305bd8deadSopenharmony_cistartTime = None 315bd8deadSopenharmony_cidef startTimer(): 325bd8deadSopenharmony_ci global startTime 335bd8deadSopenharmony_ci startTime = time.process_time() 345bd8deadSopenharmony_cidef endTimer(msg): 355bd8deadSopenharmony_ci global startTime 365bd8deadSopenharmony_ci endTime = time.process_time() 375bd8deadSopenharmony_ci if (timeit): 385bd8deadSopenharmony_ci write(msg, endTime - startTime) 395bd8deadSopenharmony_ci startTime = None 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci# Turn a list of strings into a regexp string matching exactly those strings 425bd8deadSopenharmony_cidef makeREstring(list): 435bd8deadSopenharmony_ci return '^(' + '|'.join(list) + ')$' 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci# These are "mandatory" OpenGL ES 1 extensions, to 465bd8deadSopenharmony_ci# be included in the core GLES/gl.h header. 475bd8deadSopenharmony_cies1CoreList = [ 485bd8deadSopenharmony_ci 'GL_OES_read_format', 495bd8deadSopenharmony_ci 'GL_OES_compressed_paletted_texture', 505bd8deadSopenharmony_ci 'GL_OES_point_size_array', 515bd8deadSopenharmony_ci 'GL_OES_point_sprite' 525bd8deadSopenharmony_ci] 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci# Descriptive names for various regexp patterns used to select 555bd8deadSopenharmony_ci# versions and extensions 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ciallVersions = allExtensions = '.*' 585bd8deadSopenharmony_cinoVersions = noExtensions = None 595bd8deadSopenharmony_cigl12andLaterPat = '1\.[2-9]|[234]\.[0-9]' 605bd8deadSopenharmony_cigles2onlyPat = '2\.[0-9]' 615bd8deadSopenharmony_cigles2through30Pat = '2\.[0-9]|3\.0' 625bd8deadSopenharmony_cigles2through31Pat = '2\.[0-9]|3\.[01]' 635bd8deadSopenharmony_cigles2through32Pat = '2\.[0-9]|3\.[012]' 645bd8deadSopenharmony_cies1CorePat = makeREstring(es1CoreList) 655bd8deadSopenharmony_ci# Extensions in old glcorearb.h but not yet tagged accordingly in gl.xml 665bd8deadSopenharmony_ciglCoreARBPat = None 675bd8deadSopenharmony_ciglx13andLaterPat = '1\.[3-9]' 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ci# Copyright text prefixing all headers (list of strings). 705bd8deadSopenharmony_ciprefixStrings = [ 715bd8deadSopenharmony_ci '/*', 725bd8deadSopenharmony_ci '** Copyright 2013-2020 The Khronos Group Inc.', 735bd8deadSopenharmony_ci '** SPDX-' + 'License-Identifier: MIT', 745bd8deadSopenharmony_ci '**', 755bd8deadSopenharmony_ci '** This header is generated from the Khronos OpenGL / OpenGL ES XML', 765bd8deadSopenharmony_ci '** API Registry. The current version of the Registry, generator scripts', 775bd8deadSopenharmony_ci '** used to make the header, and the header can be found at', 785bd8deadSopenharmony_ci '** https://github.com/KhronosGroup/OpenGL-Registry', 795bd8deadSopenharmony_ci '*/', 805bd8deadSopenharmony_ci '' 815bd8deadSopenharmony_ci] 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci# glext.h / glcorearb.h define calling conventions inline (no GL *platform.h) 845bd8deadSopenharmony_ciglExtPlatformStrings = [ 855bd8deadSopenharmony_ci '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)', 865bd8deadSopenharmony_ci '#ifndef WIN32_LEAN_AND_MEAN', 875bd8deadSopenharmony_ci '#define WIN32_LEAN_AND_MEAN 1', 885bd8deadSopenharmony_ci '#endif', 895bd8deadSopenharmony_ci '#include <windows.h>', 905bd8deadSopenharmony_ci '#endif', 915bd8deadSopenharmony_ci '', 925bd8deadSopenharmony_ci '#ifndef APIENTRY', 935bd8deadSopenharmony_ci '#define APIENTRY', 945bd8deadSopenharmony_ci '#endif', 955bd8deadSopenharmony_ci '#ifndef APIENTRYP', 965bd8deadSopenharmony_ci '#define APIENTRYP APIENTRY *', 975bd8deadSopenharmony_ci '#endif', 985bd8deadSopenharmony_ci '#ifndef GLAPI', 995bd8deadSopenharmony_ci '#define GLAPI extern', 1005bd8deadSopenharmony_ci '#endif', 1015bd8deadSopenharmony_ci '' 1025bd8deadSopenharmony_ci] 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ciglCorearbPlatformStrings = glExtPlatformStrings + [ 1055bd8deadSopenharmony_ci '/* glcorearb.h is for use with OpenGL core profile implementations.', 1065bd8deadSopenharmony_ci '** It should should be placed in the same directory as gl.h and', 1075bd8deadSopenharmony_ci '** included as <GL/glcorearb.h>.', 1085bd8deadSopenharmony_ci '**', 1095bd8deadSopenharmony_ci '** glcorearb.h includes only APIs in the latest OpenGL core profile', 1105bd8deadSopenharmony_ci '** implementation together with APIs in newer ARB extensions which ', 1115bd8deadSopenharmony_ci '** can be supported by the core profile. It does not, and never will', 1125bd8deadSopenharmony_ci '** include functionality removed from the core profile, such as', 1135bd8deadSopenharmony_ci '** fixed-function vertex and fragment processing.', 1145bd8deadSopenharmony_ci '**', 1155bd8deadSopenharmony_ci '** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or', 1165bd8deadSopenharmony_ci '** <GL/glext.h> in the same source file.', 1175bd8deadSopenharmony_ci '*/', 1185bd8deadSopenharmony_ci '' 1195bd8deadSopenharmony_ci] 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci# wglext.h needs Windows include 1225bd8deadSopenharmony_ciwglPlatformStrings = [ 1235bd8deadSopenharmony_ci '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)', 1245bd8deadSopenharmony_ci '#define WIN32_LEAN_AND_MEAN 1', 1255bd8deadSopenharmony_ci '#include <windows.h>', 1265bd8deadSopenharmony_ci '#endif', 1275bd8deadSopenharmony_ci '', 1285bd8deadSopenharmony_ci] 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci# Different APIs use different *platform.h files to define calling 1315bd8deadSopenharmony_ci# conventions 1325bd8deadSopenharmony_cigles1PlatformStrings = [ '#include <GLES/glplatform.h>', '' ] 1335bd8deadSopenharmony_cigles2PlatformStrings = [ '#include <GLES2/gl2platform.h>', '' ] 1345bd8deadSopenharmony_cigles3PlatformStrings = [ '#include <GLES3/gl3platform.h>', '' ] 1355bd8deadSopenharmony_ciglsc2PlatformStrings = [ '#include <GLSC2/gl2platform.h>', '' ] 1365bd8deadSopenharmony_cieglPlatformStrings = [ '#include <EGL/eglplatform.h>', '' ] 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci# GLES headers have a small addition to calling convention headers for function pointer typedefs 1395bd8deadSopenharmony_ciapiEntryPrefixStrings = [ 1405bd8deadSopenharmony_ci '#ifndef GL_APIENTRYP', 1415bd8deadSopenharmony_ci '#define GL_APIENTRYP GL_APIENTRY*', 1425bd8deadSopenharmony_ci '#endif', 1435bd8deadSopenharmony_ci '' 1445bd8deadSopenharmony_ci] 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci# GLES 2/3 core API headers use a different protection mechanism for 1475bd8deadSopenharmony_ci# prototypes, per bug 14206. 1485bd8deadSopenharmony_ciglesProtoPrefixStrings = [ 1495bd8deadSopenharmony_ci '#ifndef GL_GLES_PROTOTYPES', 1505bd8deadSopenharmony_ci '#define GL_GLES_PROTOTYPES 1', 1515bd8deadSopenharmony_ci '#endif', 1525bd8deadSopenharmony_ci '' 1535bd8deadSopenharmony_ci] 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci# Insert generation date in a comment for headers not having *GLEXT_VERSION macros 1565bd8deadSopenharmony_cigenDateCommentString = [ 1575bd8deadSopenharmony_ci format('/* Generated on date %s */' % time.strftime('%Y%m%d')), 1585bd8deadSopenharmony_ci '' 1595bd8deadSopenharmony_ci] 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci# GL_GLEXT_VERSION is defined only in glext.h 1625bd8deadSopenharmony_ciglextVersionStrings = [ 1635bd8deadSopenharmony_ci format('#define GL_GLEXT_VERSION %s' % time.strftime('%Y%m%d')), 1645bd8deadSopenharmony_ci '' 1655bd8deadSopenharmony_ci] 1665bd8deadSopenharmony_ci# WGL_WGLEXT_VERSION is defined only in wglext.h 1675bd8deadSopenharmony_ciwglextVersionStrings = [ 1685bd8deadSopenharmony_ci format('#define WGL_WGLEXT_VERSION %s' % time.strftime('%Y%m%d')), 1695bd8deadSopenharmony_ci '' 1705bd8deadSopenharmony_ci] 1715bd8deadSopenharmony_ci# GLX_GLXEXT_VERSION is defined only in glxext.h 1725bd8deadSopenharmony_ciglxextVersionStrings = [ 1735bd8deadSopenharmony_ci format('#define GLX_GLXEXT_VERSION %s' % time.strftime('%Y%m%d')), 1745bd8deadSopenharmony_ci '' 1755bd8deadSopenharmony_ci] 1765bd8deadSopenharmony_ci# This is a bad but functional workaround for a structural problem in the scripts 1775bd8deadSopenharmony_ci# identified in https://github.com/KhronosGroup/OpenGL-Registry/pull/186#issuecomment-416196246 1785bd8deadSopenharmony_ciglextKHRplatformStrings = [ 1795bd8deadSopenharmony_ci '#include <KHR/khrplatform.h>', 1805bd8deadSopenharmony_ci '' 1815bd8deadSopenharmony_ci] 1825bd8deadSopenharmony_ci# EGL_EGLEXT_VERSION is defined only in eglext.h 1835bd8deadSopenharmony_cieglextVersionStrings = [ 1845bd8deadSopenharmony_ci format('#define EGL_EGLEXT_VERSION %s' % time.strftime('%Y%m%d')), 1855bd8deadSopenharmony_ci '' 1865bd8deadSopenharmony_ci] 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci# Defaults for generating re-inclusion protection wrappers (or not) 1895bd8deadSopenharmony_ciprotectFile = protect 1905bd8deadSopenharmony_ciprotectFeature = protect 1915bd8deadSopenharmony_ciprotectProto = protect 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_cibuildList = [ 1945bd8deadSopenharmony_ci # GL API 1.2+ + extensions - GL/glext.h 1955bd8deadSopenharmony_ci CGeneratorOptions( 1965bd8deadSopenharmony_ci filename = '../api/GL/glext.h', 1975bd8deadSopenharmony_ci apiname = 'gl', 1985bd8deadSopenharmony_ci profile = 'compatibility', 1995bd8deadSopenharmony_ci versions = allVersions, 2005bd8deadSopenharmony_ci emitversions = gl12andLaterPat, 2015bd8deadSopenharmony_ci defaultExtensions = 'gl', # Default extensions for GL 2025bd8deadSopenharmony_ci addExtensions = None, 2035bd8deadSopenharmony_ci removeExtensions = None, 2045bd8deadSopenharmony_ci prefixText = prefixStrings + glExtPlatformStrings + glextVersionStrings + glextKHRplatformStrings, 2055bd8deadSopenharmony_ci genFuncPointers = True, 2065bd8deadSopenharmony_ci protectFile = protectFile, 2075bd8deadSopenharmony_ci protectFeature = protectFeature, 2085bd8deadSopenharmony_ci protectProto = protectProto, 2095bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 2105bd8deadSopenharmony_ci apicall = 'GLAPI ', 2115bd8deadSopenharmony_ci apientry = 'APIENTRY ', 2125bd8deadSopenharmony_ci apientryp = 'APIENTRYP '), 2135bd8deadSopenharmony_ci # GL core profile + extensions - GL/glcorearb.h 2145bd8deadSopenharmony_ci CGeneratorOptions( 2155bd8deadSopenharmony_ci filename = '../api/GL/glcorearb.h', 2165bd8deadSopenharmony_ci apiname = 'gl', 2175bd8deadSopenharmony_ci profile = 'core', 2185bd8deadSopenharmony_ci versions = allVersions, 2195bd8deadSopenharmony_ci emitversions = allVersions, 2205bd8deadSopenharmony_ci defaultExtensions = 'glcore', # Default extensions for GL core profile (only) 2215bd8deadSopenharmony_ci addExtensions = glCoreARBPat, 2225bd8deadSopenharmony_ci removeExtensions = None, 2235bd8deadSopenharmony_ci prefixText = prefixStrings + glCorearbPlatformStrings, 2245bd8deadSopenharmony_ci genFuncPointers = True, 2255bd8deadSopenharmony_ci protectFile = protectFile, 2265bd8deadSopenharmony_ci protectFeature = protectFeature, 2275bd8deadSopenharmony_ci protectProto = protectProto, 2285bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 2295bd8deadSopenharmony_ci apicall = 'GLAPI ', 2305bd8deadSopenharmony_ci apientry = 'APIENTRY ', 2315bd8deadSopenharmony_ci apientryp = 'APIENTRYP '), 2325bd8deadSopenharmony_ci # GLES 1.x API + mandatory extensions - GLES/gl.h (no function pointers) 2335bd8deadSopenharmony_ci CGeneratorOptions( 2345bd8deadSopenharmony_ci filename = '../api/GLES/gl.h', 2355bd8deadSopenharmony_ci apiname = 'gles1', 2365bd8deadSopenharmony_ci profile = 'common', 2375bd8deadSopenharmony_ci versions = allVersions, 2385bd8deadSopenharmony_ci emitversions = allVersions, 2395bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 2405bd8deadSopenharmony_ci addExtensions = es1CorePat, # Add mandatory ES1 extensions in GLES1/gl.h 2415bd8deadSopenharmony_ci removeExtensions = None, 2425bd8deadSopenharmony_ci prefixText = prefixStrings + gles1PlatformStrings + genDateCommentString, 2435bd8deadSopenharmony_ci genFuncPointers = False, 2445bd8deadSopenharmony_ci protectFile = protectFile, 2455bd8deadSopenharmony_ci protectFeature = protectFeature, 2465bd8deadSopenharmony_ci protectProto = False, # Core ES API functions are in the static link libraries 2475bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 2485bd8deadSopenharmony_ci apicall = 'GL_API ', 2495bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 2505bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 2515bd8deadSopenharmony_ci # GLES 1.x extensions - GLES/glext.h 2525bd8deadSopenharmony_ci CGeneratorOptions( 2535bd8deadSopenharmony_ci filename = '../api/GLES/glext.h', 2545bd8deadSopenharmony_ci apiname = 'gles1', 2555bd8deadSopenharmony_ci profile = 'common', 2565bd8deadSopenharmony_ci versions = allVersions, 2575bd8deadSopenharmony_ci emitversions = noVersions, 2585bd8deadSopenharmony_ci defaultExtensions = 'gles1', # Default extensions for GLES 1 2595bd8deadSopenharmony_ci addExtensions = None, 2605bd8deadSopenharmony_ci removeExtensions = es1CorePat, # Remove mandatory ES1 extensions in GLES1/glext.h 2615bd8deadSopenharmony_ci prefixText = prefixStrings + apiEntryPrefixStrings + genDateCommentString, 2625bd8deadSopenharmony_ci genFuncPointers = True, 2635bd8deadSopenharmony_ci protectFile = protectFile, 2645bd8deadSopenharmony_ci protectFeature = protectFeature, 2655bd8deadSopenharmony_ci protectProto = protectProto, 2665bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 2675bd8deadSopenharmony_ci apicall = 'GL_API ', 2685bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 2695bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 2705bd8deadSopenharmony_ci # GLES 2.0 API - GLES2/gl2.h (now with function pointers) 2715bd8deadSopenharmony_ci CGeneratorOptions( 2725bd8deadSopenharmony_ci filename = '../api/GLES2/gl2.h', 2735bd8deadSopenharmony_ci apiname = 'gles2', 2745bd8deadSopenharmony_ci profile = 'common', 2755bd8deadSopenharmony_ci versions = gles2onlyPat, 2765bd8deadSopenharmony_ci emitversions = allVersions, 2775bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 2785bd8deadSopenharmony_ci addExtensions = None, 2795bd8deadSopenharmony_ci removeExtensions = None, 2805bd8deadSopenharmony_ci prefixText = prefixStrings + gles2PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString, 2815bd8deadSopenharmony_ci genFuncPointers = True, 2825bd8deadSopenharmony_ci protectFile = protectFile, 2835bd8deadSopenharmony_ci protectFeature = protectFeature, 2845bd8deadSopenharmony_ci protectProto = 'nonzero', # Core ES API functions are in the static link libraries 2855bd8deadSopenharmony_ci protectProtoStr = 'GL_GLES_PROTOTYPES', 2865bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 2875bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 2885bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 2895bd8deadSopenharmony_ci # GLES 3.1 / 3.0 / 2.0 extensions - GLES2/gl2ext.h 2905bd8deadSopenharmony_ci CGeneratorOptions( 2915bd8deadSopenharmony_ci filename = '../api/GLES2/gl2ext.h', 2925bd8deadSopenharmony_ci apiname = 'gles2', 2935bd8deadSopenharmony_ci profile = 'common', 2945bd8deadSopenharmony_ci versions = gles2onlyPat, 2955bd8deadSopenharmony_ci emitversions = None, 2965bd8deadSopenharmony_ci defaultExtensions = 'gles2', # Default extensions for GLES 2 2975bd8deadSopenharmony_ci addExtensions = None, 2985bd8deadSopenharmony_ci removeExtensions = None, 2995bd8deadSopenharmony_ci prefixText = prefixStrings + apiEntryPrefixStrings + genDateCommentString, 3005bd8deadSopenharmony_ci genFuncPointers = True, 3015bd8deadSopenharmony_ci protectFile = protectFile, 3025bd8deadSopenharmony_ci protectFeature = protectFeature, 3035bd8deadSopenharmony_ci protectProto = protectProto, 3045bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 3055bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 3065bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 3075bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 3085bd8deadSopenharmony_ci # GLES 3.2 API - GLES3/gl32.h (now with function pointers) 3095bd8deadSopenharmony_ci CGeneratorOptions( 3105bd8deadSopenharmony_ci filename = '../api/GLES3/gl32.h', 3115bd8deadSopenharmony_ci apiname = 'gles2', 3125bd8deadSopenharmony_ci profile = 'common', 3135bd8deadSopenharmony_ci versions = gles2through32Pat, 3145bd8deadSopenharmony_ci emitversions = allVersions, 3155bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 3165bd8deadSopenharmony_ci addExtensions = None, 3175bd8deadSopenharmony_ci removeExtensions = None, 3185bd8deadSopenharmony_ci prefixText = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString, 3195bd8deadSopenharmony_ci genFuncPointers = True, 3205bd8deadSopenharmony_ci protectFile = protectFile, 3215bd8deadSopenharmony_ci protectFeature = protectFeature, 3225bd8deadSopenharmony_ci protectProto = 'nonzero', # Core ES API functions are in the static link libraries 3235bd8deadSopenharmony_ci protectProtoStr = 'GL_GLES_PROTOTYPES', 3245bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 3255bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 3265bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 3275bd8deadSopenharmony_ci # GLES 3.1 API - GLES3/gl31.h (now with function pointers) 3285bd8deadSopenharmony_ci CGeneratorOptions( 3295bd8deadSopenharmony_ci filename = '../api/GLES3/gl31.h', 3305bd8deadSopenharmony_ci apiname = 'gles2', 3315bd8deadSopenharmony_ci profile = 'common', 3325bd8deadSopenharmony_ci versions = gles2through31Pat, 3335bd8deadSopenharmony_ci emitversions = allVersions, 3345bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 3355bd8deadSopenharmony_ci addExtensions = None, 3365bd8deadSopenharmony_ci removeExtensions = None, 3375bd8deadSopenharmony_ci prefixText = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString, 3385bd8deadSopenharmony_ci genFuncPointers = True, 3395bd8deadSopenharmony_ci protectFile = protectFile, 3405bd8deadSopenharmony_ci protectFeature = protectFeature, 3415bd8deadSopenharmony_ci protectProto = 'nonzero', # Core ES API functions are in the static link libraries 3425bd8deadSopenharmony_ci protectProtoStr = 'GL_GLES_PROTOTYPES', 3435bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 3445bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 3455bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 3465bd8deadSopenharmony_ci # GLES 3.0 API - GLES3/gl3.h (now with function pointers) 3475bd8deadSopenharmony_ci CGeneratorOptions( 3485bd8deadSopenharmony_ci filename = '../api/GLES3/gl3.h', 3495bd8deadSopenharmony_ci apiname = 'gles2', 3505bd8deadSopenharmony_ci profile = 'common', 3515bd8deadSopenharmony_ci versions = gles2through30Pat, 3525bd8deadSopenharmony_ci emitversions = allVersions, 3535bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 3545bd8deadSopenharmony_ci addExtensions = None, 3555bd8deadSopenharmony_ci removeExtensions = None, 3565bd8deadSopenharmony_ci prefixText = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString, 3575bd8deadSopenharmony_ci genFuncPointers = True, 3585bd8deadSopenharmony_ci protectFile = protectFile, 3595bd8deadSopenharmony_ci protectFeature = protectFeature, 3605bd8deadSopenharmony_ci protectProto = 'nonzero', # Core ES API functions are in the static link libraries 3615bd8deadSopenharmony_ci protectProtoStr = 'GL_GLES_PROTOTYPES', 3625bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 3635bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 3645bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 3655bd8deadSopenharmony_ci # GLSC 2.0 API - GLSC2/glsc2.h 3665bd8deadSopenharmony_ci CGeneratorOptions( 3675bd8deadSopenharmony_ci filename = '../api/GLSC2/glsc2.h', 3685bd8deadSopenharmony_ci apiname = 'glsc2', 3695bd8deadSopenharmony_ci profile = 'common', 3705bd8deadSopenharmony_ci versions = gles2onlyPat, 3715bd8deadSopenharmony_ci emitversions = allVersions, 3725bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 3735bd8deadSopenharmony_ci addExtensions = None, 3745bd8deadSopenharmony_ci removeExtensions = None, 3755bd8deadSopenharmony_ci prefixText = prefixStrings + glsc2PlatformStrings + apiEntryPrefixStrings + genDateCommentString, 3765bd8deadSopenharmony_ci genFuncPointers = False, 3775bd8deadSopenharmony_ci protectFile = protectFile, 3785bd8deadSopenharmony_ci protectFeature = protectFeature, 3795bd8deadSopenharmony_ci protectProto = False, 3805bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 3815bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 3825bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 3835bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 3845bd8deadSopenharmony_ci # GLSC 2.0 extensions - GLSC2/gl2ext.h 3855bd8deadSopenharmony_ci CGeneratorOptions( 3865bd8deadSopenharmony_ci filename = '../api/GLSC2/glsc2ext.h', 3875bd8deadSopenharmony_ci apiname = 'glsc2', 3885bd8deadSopenharmony_ci profile = 'common', 3895bd8deadSopenharmony_ci versions = gles2onlyPat, 3905bd8deadSopenharmony_ci emitversions = None, 3915bd8deadSopenharmony_ci defaultExtensions = 'glsc2', # Default extensions for GLSC 2 3925bd8deadSopenharmony_ci addExtensions = None, 3935bd8deadSopenharmony_ci removeExtensions = None, 3945bd8deadSopenharmony_ci prefixText = prefixStrings + apiEntryPrefixStrings + genDateCommentString, 3955bd8deadSopenharmony_ci genFuncPointers = False, 3965bd8deadSopenharmony_ci protectFile = protectFile, 3975bd8deadSopenharmony_ci protectFeature = protectFeature, 3985bd8deadSopenharmony_ci protectProto = False, 3995bd8deadSopenharmony_ci protectProtoStr = 'GL_GLEXT_PROTOTYPES', 4005bd8deadSopenharmony_ci apicall = 'GL_APICALL ', 4015bd8deadSopenharmony_ci apientry = 'GL_APIENTRY ', 4025bd8deadSopenharmony_ci apientryp = 'GL_APIENTRYP '), 4035bd8deadSopenharmony_ci # GLX 1.* API - GL/glx.h (experimental) 4045bd8deadSopenharmony_ci CGeneratorOptions( 4055bd8deadSopenharmony_ci filename = '../api/GL/glx.h', 4065bd8deadSopenharmony_ci apiname = 'glx', 4075bd8deadSopenharmony_ci profile = None, 4085bd8deadSopenharmony_ci versions = allVersions, 4095bd8deadSopenharmony_ci emitversions = allVersions, 4105bd8deadSopenharmony_ci defaultExtensions = None, # No default extensions 4115bd8deadSopenharmony_ci addExtensions = None, 4125bd8deadSopenharmony_ci removeExtensions = None, 4135bd8deadSopenharmony_ci # add glXPlatformStrings? 4145bd8deadSopenharmony_ci prefixText = prefixStrings + genDateCommentString, 4155bd8deadSopenharmony_ci genFuncPointers = True, 4165bd8deadSopenharmony_ci protectFile = protectFile, 4175bd8deadSopenharmony_ci protectFeature = protectFeature, 4185bd8deadSopenharmony_ci protectProto = protectProto, 4195bd8deadSopenharmony_ci protectProtoStr = 'GLX_GLXEXT_PROTOTYPES', 4205bd8deadSopenharmony_ci apicall = '', 4215bd8deadSopenharmony_ci apientry = '', 4225bd8deadSopenharmony_ci apientryp = ' *'), 4235bd8deadSopenharmony_ci # GLX 1.3+ API + extensions - GL/glxext.h (no function pointers, yet @@@) 4245bd8deadSopenharmony_ci CGeneratorOptions( 4255bd8deadSopenharmony_ci filename = '../api/GL/glxext.h', 4265bd8deadSopenharmony_ci apiname = 'glx', 4275bd8deadSopenharmony_ci profile = None, 4285bd8deadSopenharmony_ci versions = allVersions, 4295bd8deadSopenharmony_ci emitversions = glx13andLaterPat, 4305bd8deadSopenharmony_ci defaultExtensions = 'glx', # Default extensions for GLX 4315bd8deadSopenharmony_ci addExtensions = None, 4325bd8deadSopenharmony_ci removeExtensions = None, 4335bd8deadSopenharmony_ci # add glXPlatformStrings? 4345bd8deadSopenharmony_ci prefixText = prefixStrings + glxextVersionStrings, 4355bd8deadSopenharmony_ci genFuncPointers = True, 4365bd8deadSopenharmony_ci protectFile = protectFile, 4375bd8deadSopenharmony_ci protectFeature = protectFeature, 4385bd8deadSopenharmony_ci protectProto = protectProto, 4395bd8deadSopenharmony_ci protectProtoStr = 'GLX_GLXEXT_PROTOTYPES', 4405bd8deadSopenharmony_ci apicall = '', 4415bd8deadSopenharmony_ci apientry = '', 4425bd8deadSopenharmony_ci apientryp = ' *'), 4435bd8deadSopenharmony_ci # WGL API + extensions - GL/wgl.h (experimenta; no function pointers, yet @@@) 4445bd8deadSopenharmony_ci CGeneratorOptions( 4455bd8deadSopenharmony_ci filename = '../api/GL/wgl.h', 4465bd8deadSopenharmony_ci apiname = 'wgl', 4475bd8deadSopenharmony_ci profile = None, 4485bd8deadSopenharmony_ci versions = allVersions, 4495bd8deadSopenharmony_ci emitversions = allVersions, 4505bd8deadSopenharmony_ci defaultExtensions = 'wgl', # Default extensions for WGL 4515bd8deadSopenharmony_ci addExtensions = None, 4525bd8deadSopenharmony_ci removeExtensions = None, 4535bd8deadSopenharmony_ci prefixText = prefixStrings + wglPlatformStrings + genDateCommentString, 4545bd8deadSopenharmony_ci genFuncPointers = True, 4555bd8deadSopenharmony_ci protectFile = protectFile, 4565bd8deadSopenharmony_ci protectFeature = protectFeature, 4575bd8deadSopenharmony_ci protectProto = protectProto, 4585bd8deadSopenharmony_ci protectProtoStr = 'WGL_WGLEXT_PROTOTYPES', 4595bd8deadSopenharmony_ci apicall = '', 4605bd8deadSopenharmony_ci apientry = 'WINAPI ', 4615bd8deadSopenharmony_ci apientryp = 'WINAPI * '), 4625bd8deadSopenharmony_ci # WGL extensions - GL/wglext.h (no function pointers, yet @@@) 4635bd8deadSopenharmony_ci CGeneratorOptions( 4645bd8deadSopenharmony_ci filename = '../api/GL/wglext.h', 4655bd8deadSopenharmony_ci apiname = 'wgl', 4665bd8deadSopenharmony_ci profile = None, 4675bd8deadSopenharmony_ci versions = allVersions, 4685bd8deadSopenharmony_ci emitversions = None, 4695bd8deadSopenharmony_ci defaultExtensions = 'wgl', # Default extensions for WGL 4705bd8deadSopenharmony_ci addExtensions = None, 4715bd8deadSopenharmony_ci removeExtensions = None, 4725bd8deadSopenharmony_ci prefixText = prefixStrings + wglPlatformStrings + wglextVersionStrings, 4735bd8deadSopenharmony_ci genFuncPointers = True, 4745bd8deadSopenharmony_ci protectFile = protectFile, 4755bd8deadSopenharmony_ci protectFeature = protectFeature, 4765bd8deadSopenharmony_ci protectProto = protectProto, 4775bd8deadSopenharmony_ci protectProtoStr = 'WGL_WGLEXT_PROTOTYPES', 4785bd8deadSopenharmony_ci apicall = '', 4795bd8deadSopenharmony_ci apientry = 'WINAPI ', 4805bd8deadSopenharmony_ci apientryp = 'WINAPI * '), 4815bd8deadSopenharmony_ci # End of list 4825bd8deadSopenharmony_ci None 4835bd8deadSopenharmony_ci] 4845bd8deadSopenharmony_ci 4855bd8deadSopenharmony_cidef genHeaders(): 4865bd8deadSopenharmony_ci # Loop over targets, building each 4875bd8deadSopenharmony_ci generated = 0 4885bd8deadSopenharmony_ci for genOpts in buildList: 4895bd8deadSopenharmony_ci if (genOpts == None): 4905bd8deadSopenharmony_ci break 4915bd8deadSopenharmony_ci if (target and target != genOpts.filename): 4925bd8deadSopenharmony_ci # write('*** Skipping', genOpts.filename) 4935bd8deadSopenharmony_ci continue 4945bd8deadSopenharmony_ci write('*** Building', genOpts.filename) 4955bd8deadSopenharmony_ci generated = generated + 1 4965bd8deadSopenharmony_ci startTimer() 4975bd8deadSopenharmony_ci gen = COutputGenerator(errFile=errWarn, 4985bd8deadSopenharmony_ci warnFile=errWarn, 4995bd8deadSopenharmony_ci diagFile=diag) 5005bd8deadSopenharmony_ci reg.setGenerator(gen) 5015bd8deadSopenharmony_ci reg.apiGen(genOpts) 5025bd8deadSopenharmony_ci write('** Generated', genOpts.filename) 5035bd8deadSopenharmony_ci endTimer('Time to generate ' + genOpts.filename + ' =') 5045bd8deadSopenharmony_ci if (target and generated == 0): 5055bd8deadSopenharmony_ci write('Failed to generate target:', target) 5065bd8deadSopenharmony_ci 5075bd8deadSopenharmony_ci 5085bd8deadSopenharmony_ciif __name__ == '__main__': 5095bd8deadSopenharmony_ci i = 1 5105bd8deadSopenharmony_ci while (i < len(sys.argv)): 5115bd8deadSopenharmony_ci arg = sys.argv[i] 5125bd8deadSopenharmony_ci i = i + 1 5135bd8deadSopenharmony_ci if (arg == '-debug'): 5145bd8deadSopenharmony_ci write('Enabling debug (-debug)', file=sys.stderr) 5155bd8deadSopenharmony_ci debug = True 5165bd8deadSopenharmony_ci elif (arg == '-dump'): 5175bd8deadSopenharmony_ci write('Enabling dump (-dump)', file=sys.stderr) 5185bd8deadSopenharmony_ci dump = True 5195bd8deadSopenharmony_ci elif (arg == '-noprotect'): 5205bd8deadSopenharmony_ci write('Disabling inclusion protection in output headers', file=sys.stderr) 5215bd8deadSopenharmony_ci protect = False 5225bd8deadSopenharmony_ci elif (arg == '-profile'): 5235bd8deadSopenharmony_ci write('Enabling profiling (-profile)', file=sys.stderr) 5245bd8deadSopenharmony_ci profile = True 5255bd8deadSopenharmony_ci elif (arg == '-registry'): 5265bd8deadSopenharmony_ci regFilename = sys.argv[i] 5275bd8deadSopenharmony_ci i = i+1 5285bd8deadSopenharmony_ci write('Using registry ', regFilename, file=sys.stderr) 5295bd8deadSopenharmony_ci elif (arg == '-time'): 5305bd8deadSopenharmony_ci write('Enabling timing (-time)', file=sys.stderr) 5315bd8deadSopenharmony_ci timeit = True 5325bd8deadSopenharmony_ci elif (arg == '-validate'): 5335bd8deadSopenharmony_ci write('Enabling group validation (-validate)', file=sys.stderr) 5345bd8deadSopenharmony_ci validate = True 5355bd8deadSopenharmony_ci elif (arg[0:1] == '-'): 5365bd8deadSopenharmony_ci write('Unrecognized argument:', arg, file=sys.stderr) 5375bd8deadSopenharmony_ci exit(1) 5385bd8deadSopenharmony_ci else: 5395bd8deadSopenharmony_ci target = arg 5405bd8deadSopenharmony_ci write('Using target', target, file=sys.stderr) 5415bd8deadSopenharmony_ci 5425bd8deadSopenharmony_ci # Load & parse registry 5435bd8deadSopenharmony_ci reg = Registry() 5445bd8deadSopenharmony_ci 5455bd8deadSopenharmony_ci startTimer() 5465bd8deadSopenharmony_ci tree = etree.parse(regFilename) 5475bd8deadSopenharmony_ci endTimer('Time to make ElementTree =') 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ci startTimer() 5505bd8deadSopenharmony_ci reg.loadElementTree(tree) 5515bd8deadSopenharmony_ci endTimer('Time to parse ElementTree =') 5525bd8deadSopenharmony_ci 5535bd8deadSopenharmony_ci if (validate): 5545bd8deadSopenharmony_ci reg.validateGroups() 5555bd8deadSopenharmony_ci 5565bd8deadSopenharmony_ci if (dump): 5575bd8deadSopenharmony_ci write('***************************************') 5585bd8deadSopenharmony_ci write('Performing Registry dump to regdump.txt') 5595bd8deadSopenharmony_ci write('***************************************') 5605bd8deadSopenharmony_ci reg.dumpReg(filehandle = open('regdump.txt','w')) 5615bd8deadSopenharmony_ci 5625bd8deadSopenharmony_ci # create error/warning & diagnostic files 5635bd8deadSopenharmony_ci if (errFilename): 5645bd8deadSopenharmony_ci errWarn = open(errFilename,'w') 5655bd8deadSopenharmony_ci else: 5665bd8deadSopenharmony_ci errWarn = sys.stderr 5675bd8deadSopenharmony_ci diag = open(diagFilename, 'w') 5685bd8deadSopenharmony_ci 5695bd8deadSopenharmony_ci if (debug): 5705bd8deadSopenharmony_ci pdb.run('genHeaders()') 5715bd8deadSopenharmony_ci elif (profile): 5725bd8deadSopenharmony_ci import cProfile, pstats 5735bd8deadSopenharmony_ci cProfile.run('genHeaders()', 'profile.txt') 5745bd8deadSopenharmony_ci p = pstats.Stats('profile.txt') 5755bd8deadSopenharmony_ci p.strip_dirs().sort_stats('time').print_stats(50) 5765bd8deadSopenharmony_ci else: 5775bd8deadSopenharmony_ci genHeaders() 578