102f4aeb0Sopenharmony_ci#!/usr/bin/python -i
202f4aeb0Sopenharmony_ci#
302f4aeb0Sopenharmony_ci# Copyright 2013-2020 The Khronos Group Inc.
402f4aeb0Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0
502f4aeb0Sopenharmony_ci
602f4aeb0Sopenharmony_ciimport sys, time, pdb, string, cProfile
702f4aeb0Sopenharmony_cifrom reg import *
802f4aeb0Sopenharmony_ci
902f4aeb0Sopenharmony_ci# debug - start header generation in debugger
1002f4aeb0Sopenharmony_ci# dump - dump registry after loading
1102f4aeb0Sopenharmony_ci# profile - enable Python profiling
1202f4aeb0Sopenharmony_ci# protect - whether to use #ifndef protections
1302f4aeb0Sopenharmony_ci# registry <filename> - use specified XML registry instead of gl.xml
1402f4aeb0Sopenharmony_ci# target - string name of target header, or all targets if None
1502f4aeb0Sopenharmony_ci# timeit - time length of registry loading & header generation
1602f4aeb0Sopenharmony_ci# validate - validate return & parameter group tags against <group>
1702f4aeb0Sopenharmony_cidebug   = False
1802f4aeb0Sopenharmony_cidump    = False
1902f4aeb0Sopenharmony_ciprofile = False
2002f4aeb0Sopenharmony_ciprotect = True
2102f4aeb0Sopenharmony_citarget  = None
2202f4aeb0Sopenharmony_citimeit  = False
2302f4aeb0Sopenharmony_civalidate= False
2402f4aeb0Sopenharmony_ci# Default input / log files
2502f4aeb0Sopenharmony_cierrFilename = None
2602f4aeb0Sopenharmony_cidiagFilename = 'diag.txt'
2702f4aeb0Sopenharmony_ciregFilename = 'gl.xml'
2802f4aeb0Sopenharmony_ci
2902f4aeb0Sopenharmony_ci
3002f4aeb0Sopenharmony_ci# Simple timer functions
3102f4aeb0Sopenharmony_cistartTime = None
3202f4aeb0Sopenharmony_cidef startTimer():
3302f4aeb0Sopenharmony_ci    global startTime
3402f4aeb0Sopenharmony_ci    startTime = time.process_time()
3502f4aeb0Sopenharmony_cidef endTimer(msg):
3602f4aeb0Sopenharmony_ci    global startTime
3702f4aeb0Sopenharmony_ci    endTime = time.process_time()
3802f4aeb0Sopenharmony_ci    if (timeit):
3902f4aeb0Sopenharmony_ci        write(msg, endTime - startTime)
4002f4aeb0Sopenharmony_ci        startTime = None
4102f4aeb0Sopenharmony_ci
4202f4aeb0Sopenharmony_ci# Turn a list of strings into a regexp string matching exactly those strings
4302f4aeb0Sopenharmony_cidef makeREstring(list):
4402f4aeb0Sopenharmony_ci    return '^(' + '|'.join(list) + ')$'
4502f4aeb0Sopenharmony_ci
4602f4aeb0Sopenharmony_ci# These are "mandatory" OpenGL ES 1 extensions, to
4702f4aeb0Sopenharmony_ci# be included in the core GLES/gl.h header.
4802f4aeb0Sopenharmony_cies1CoreList = [
4902f4aeb0Sopenharmony_ci    'GL_OES_read_format',
5002f4aeb0Sopenharmony_ci    'GL_OES_compressed_paletted_texture',
5102f4aeb0Sopenharmony_ci    'GL_OES_point_size_array',
5202f4aeb0Sopenharmony_ci    'GL_OES_point_sprite'
5302f4aeb0Sopenharmony_ci]
5402f4aeb0Sopenharmony_ci
5502f4aeb0Sopenharmony_ci# Descriptive names for various regexp patterns used to select
5602f4aeb0Sopenharmony_ci# versions and extensions
5702f4aeb0Sopenharmony_ci
5802f4aeb0Sopenharmony_ciallVersions       = allExtensions = '.*'
5902f4aeb0Sopenharmony_cinoVersions        = noExtensions = None
6002f4aeb0Sopenharmony_cigl12andLaterPat   = '1\.[2-9]|[234]\.[0-9]'
6102f4aeb0Sopenharmony_cigles2onlyPat      = '2\.[0-9]'
6202f4aeb0Sopenharmony_cigles2through30Pat = '2\.[0-9]|3\.0'
6302f4aeb0Sopenharmony_cigles2through31Pat = '2\.[0-9]|3\.[01]'
6402f4aeb0Sopenharmony_cigles2through32Pat = '2\.[0-9]|3\.[012]'
6502f4aeb0Sopenharmony_cies1CorePat        = makeREstring(es1CoreList)
6602f4aeb0Sopenharmony_ci# Extensions in old glcorearb.h but not yet tagged accordingly in gl.xml
6702f4aeb0Sopenharmony_ciglCoreARBPat      = None
6802f4aeb0Sopenharmony_ciglx13andLaterPat  = '1\.[3-9]'
6902f4aeb0Sopenharmony_ci
7002f4aeb0Sopenharmony_ci# Copyright text prefixing all headers (list of strings).
7102f4aeb0Sopenharmony_ciprefixStrings = [
7202f4aeb0Sopenharmony_ci    '/*',
7302f4aeb0Sopenharmony_ci    '** Copyright 2013-2020 The Khronos Group Inc.',
7402f4aeb0Sopenharmony_ci    '** SPDX-' + 'License-Identifier: Apache-2.0',
7502f4aeb0Sopenharmony_ci    '**',
7602f4aeb0Sopenharmony_ci    '** This header is generated from the Khronos EGL XML API Registry.',
7702f4aeb0Sopenharmony_ci    '** The current version of the Registry, generator scripts',
7802f4aeb0Sopenharmony_ci    '** used to make the header, and the header can be found at',
7902f4aeb0Sopenharmony_ci    '**   http://www.khronos.org/registry/egl',
8002f4aeb0Sopenharmony_ci    '**',
8102f4aeb0Sopenharmony_ci    '** Khronos $' + 'Revision$ on $' + 'Date$',
8202f4aeb0Sopenharmony_ci    '*/',
8302f4aeb0Sopenharmony_ci    ''
8402f4aeb0Sopenharmony_ci]
8502f4aeb0Sopenharmony_ci
8602f4aeb0Sopenharmony_ci# glext.h / glcorearb.h define calling conventions inline (no GL *platform.h)
8702f4aeb0Sopenharmony_ciglExtPlatformStrings = [
8802f4aeb0Sopenharmony_ci    '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
8902f4aeb0Sopenharmony_ci    '#ifndef WIN32_LEAN_AND_MEAN',
9002f4aeb0Sopenharmony_ci    '#define WIN32_LEAN_AND_MEAN 1',
9102f4aeb0Sopenharmony_ci    '#endif',
9202f4aeb0Sopenharmony_ci    '#include <windows.h>',
9302f4aeb0Sopenharmony_ci    '#endif',
9402f4aeb0Sopenharmony_ci    '',
9502f4aeb0Sopenharmony_ci    '#ifndef APIENTRY',
9602f4aeb0Sopenharmony_ci    '#define APIENTRY',
9702f4aeb0Sopenharmony_ci    '#endif',
9802f4aeb0Sopenharmony_ci    '#ifndef APIENTRYP',
9902f4aeb0Sopenharmony_ci    '#define APIENTRYP APIENTRY *',
10002f4aeb0Sopenharmony_ci    '#endif',
10102f4aeb0Sopenharmony_ci    '#ifndef GLAPI',
10202f4aeb0Sopenharmony_ci    '#define GLAPI extern',
10302f4aeb0Sopenharmony_ci    '#endif',
10402f4aeb0Sopenharmony_ci    ''
10502f4aeb0Sopenharmony_ci]
10602f4aeb0Sopenharmony_ci
10702f4aeb0Sopenharmony_ciglCorearbPlatformStrings = glExtPlatformStrings + [
10802f4aeb0Sopenharmony_ci    '/* glcorearb.h is for use with OpenGL core profile implementations.',
10902f4aeb0Sopenharmony_ci    '** It should should be placed in the same directory as gl.h and',
11002f4aeb0Sopenharmony_ci    '** included as <GL/glcorearb.h>.',
11102f4aeb0Sopenharmony_ci    '**',
11202f4aeb0Sopenharmony_ci    '** glcorearb.h includes only APIs in the latest OpenGL core profile',
11302f4aeb0Sopenharmony_ci    '** implementation together with APIs in newer ARB extensions which ',
11402f4aeb0Sopenharmony_ci    '** can be supported by the core profile. It does not, and never will',
11502f4aeb0Sopenharmony_ci    '** include functionality removed from the core profile, such as',
11602f4aeb0Sopenharmony_ci    '** fixed-function vertex and fragment processing.',
11702f4aeb0Sopenharmony_ci    '**',
11802f4aeb0Sopenharmony_ci    '** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or',
11902f4aeb0Sopenharmony_ci    '** <GL/glext.h> in the same source file.',
12002f4aeb0Sopenharmony_ci    '*/',
12102f4aeb0Sopenharmony_ci    ''
12202f4aeb0Sopenharmony_ci]
12302f4aeb0Sopenharmony_ci
12402f4aeb0Sopenharmony_ci# wglext.h needs Windows include
12502f4aeb0Sopenharmony_ciwglPlatformStrings = [
12602f4aeb0Sopenharmony_ci    '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
12702f4aeb0Sopenharmony_ci    '#define WIN32_LEAN_AND_MEAN 1',
12802f4aeb0Sopenharmony_ci    '#include <windows.h>',
12902f4aeb0Sopenharmony_ci    '#endif',
13002f4aeb0Sopenharmony_ci    '',
13102f4aeb0Sopenharmony_ci]
13202f4aeb0Sopenharmony_ci
13302f4aeb0Sopenharmony_ci# Different APIs use different *platform.h files to define calling
13402f4aeb0Sopenharmony_ci# conventions
13502f4aeb0Sopenharmony_cigles1PlatformStrings = [ '#include <GLES/glplatform.h>', '' ]
13602f4aeb0Sopenharmony_cigles2PlatformStrings = [ '#include <GLES2/gl2platform.h>', '' ]
13702f4aeb0Sopenharmony_cigles3PlatformStrings = [ '#include <GLES3/gl3platform.h>', '' ]
13802f4aeb0Sopenharmony_ciglsc2PlatformStrings = [ '#include <GLSC2/gl2platform.h>', '' ]
13902f4aeb0Sopenharmony_cieglPlatformStrings   = [ '#include <EGL/eglplatform.h>', '' ]
14002f4aeb0Sopenharmony_ci
14102f4aeb0Sopenharmony_ci# GLES headers have a small addition to calling convention headers for function pointer typedefs
14202f4aeb0Sopenharmony_ciapiEntryPrefixStrings = [
14302f4aeb0Sopenharmony_ci    '#ifndef GL_APIENTRYP',
14402f4aeb0Sopenharmony_ci    '#define GL_APIENTRYP GL_APIENTRY*',
14502f4aeb0Sopenharmony_ci    '#endif',
14602f4aeb0Sopenharmony_ci    ''
14702f4aeb0Sopenharmony_ci]
14802f4aeb0Sopenharmony_ci
14902f4aeb0Sopenharmony_ci# GLES 2/3 core API headers use a different protection mechanism for
15002f4aeb0Sopenharmony_ci# prototypes, per bug 14206.
15102f4aeb0Sopenharmony_ciglesProtoPrefixStrings = [
15202f4aeb0Sopenharmony_ci    '#ifndef GL_GLES_PROTOTYPES',
15302f4aeb0Sopenharmony_ci    '#define GL_GLES_PROTOTYPES 1',
15402f4aeb0Sopenharmony_ci    '#endif',
15502f4aeb0Sopenharmony_ci    ''
15602f4aeb0Sopenharmony_ci]
15702f4aeb0Sopenharmony_ci
15802f4aeb0Sopenharmony_ci# EGL headers use a protection mechanism similar to GLES.
15902f4aeb0Sopenharmony_cieglProtoPrefixStrings = [
16002f4aeb0Sopenharmony_ci    '#ifndef EGL_EGL_PROTOTYPES',
16102f4aeb0Sopenharmony_ci    '#define EGL_EGL_PROTOTYPES 1',
16202f4aeb0Sopenharmony_ci    '#endif',
16302f4aeb0Sopenharmony_ci    ''
16402f4aeb0Sopenharmony_ci]
16502f4aeb0Sopenharmony_ci
16602f4aeb0Sopenharmony_ci# Insert generation date in a comment for headers not having *GLEXT_VERSION macros
16702f4aeb0Sopenharmony_cigenDateCommentString = [
16802f4aeb0Sopenharmony_ci    format('/* Generated on date %s */' % time.strftime('%Y%m%d')),
16902f4aeb0Sopenharmony_ci    ''
17002f4aeb0Sopenharmony_ci]
17102f4aeb0Sopenharmony_ci
17202f4aeb0Sopenharmony_ci# GL_GLEXT_VERSION is defined only in glext.h
17302f4aeb0Sopenharmony_ciglextVersionStrings = [
17402f4aeb0Sopenharmony_ci    format('#define GL_GLEXT_VERSION %s' % time.strftime('%Y%m%d')),
17502f4aeb0Sopenharmony_ci    ''
17602f4aeb0Sopenharmony_ci]
17702f4aeb0Sopenharmony_ci# WGL_WGLEXT_VERSION is defined only in wglext.h
17802f4aeb0Sopenharmony_ciwglextVersionStrings = [
17902f4aeb0Sopenharmony_ci    format('#define WGL_WGLEXT_VERSION %s' % time.strftime('%Y%m%d')),
18002f4aeb0Sopenharmony_ci    ''
18102f4aeb0Sopenharmony_ci]
18202f4aeb0Sopenharmony_ci# GLX_GLXEXT_VERSION is defined only in glxext.h
18302f4aeb0Sopenharmony_ciglxextVersionStrings = [
18402f4aeb0Sopenharmony_ci    format('#define GLX_GLXEXT_VERSION %s' % time.strftime('%Y%m%d')),
18502f4aeb0Sopenharmony_ci    ''
18602f4aeb0Sopenharmony_ci]
18702f4aeb0Sopenharmony_ci# EGL_EGLEXT_VERSION is defined only in eglext.h
18802f4aeb0Sopenharmony_cieglextVersionStrings = [
18902f4aeb0Sopenharmony_ci    format('#define EGL_EGLEXT_VERSION %s' % time.strftime('%Y%m%d')),
19002f4aeb0Sopenharmony_ci    ''
19102f4aeb0Sopenharmony_ci]
19202f4aeb0Sopenharmony_ci
19302f4aeb0Sopenharmony_ci# Defaults for generating re-inclusion protection wrappers (or not)
19402f4aeb0Sopenharmony_ciprotectFile = protect
19502f4aeb0Sopenharmony_ciprotectFeature = protect
19602f4aeb0Sopenharmony_ciprotectProto = protect
19702f4aeb0Sopenharmony_ci
19802f4aeb0Sopenharmony_cibuildList = [
19902f4aeb0Sopenharmony_ci    # GL API 1.2+ + extensions - GL/glext.h
20002f4aeb0Sopenharmony_ci    CGeneratorOptions(
20102f4aeb0Sopenharmony_ci        filename          = 'GL/glext.h',
20202f4aeb0Sopenharmony_ci        apiname           = 'gl',
20302f4aeb0Sopenharmony_ci        profile           = 'compatibility',
20402f4aeb0Sopenharmony_ci        versions          = allVersions,
20502f4aeb0Sopenharmony_ci        emitversions      = gl12andLaterPat,
20602f4aeb0Sopenharmony_ci        defaultExtensions = 'gl',                   # Default extensions for GL
20702f4aeb0Sopenharmony_ci        addExtensions     = None,
20802f4aeb0Sopenharmony_ci        removeExtensions  = None,
20902f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + glExtPlatformStrings + glextVersionStrings,
21002f4aeb0Sopenharmony_ci        genFuncPointers   = True,
21102f4aeb0Sopenharmony_ci        protectFile       = protectFile,
21202f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
21302f4aeb0Sopenharmony_ci        protectProto      = protectProto,
21402f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
21502f4aeb0Sopenharmony_ci        apicall           = 'GLAPI ',
21602f4aeb0Sopenharmony_ci        apientry          = 'APIENTRY ',
21702f4aeb0Sopenharmony_ci        apientryp         = 'APIENTRYP '),
21802f4aeb0Sopenharmony_ci    # GL core profile + extensions - GL/glcorearb.h
21902f4aeb0Sopenharmony_ci    CGeneratorOptions(
22002f4aeb0Sopenharmony_ci        filename          = 'GL/glcorearb.h',
22102f4aeb0Sopenharmony_ci        apiname           = 'gl',
22202f4aeb0Sopenharmony_ci        profile           = 'core',
22302f4aeb0Sopenharmony_ci        versions          = allVersions,
22402f4aeb0Sopenharmony_ci        emitversions      = allVersions,
22502f4aeb0Sopenharmony_ci        defaultExtensions = 'glcore',               # Default extensions for GL core profile (only)
22602f4aeb0Sopenharmony_ci        addExtensions     = glCoreARBPat,
22702f4aeb0Sopenharmony_ci        removeExtensions  = None,
22802f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + glCorearbPlatformStrings,
22902f4aeb0Sopenharmony_ci        genFuncPointers   = True,
23002f4aeb0Sopenharmony_ci        protectFile       = protectFile,
23102f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
23202f4aeb0Sopenharmony_ci        protectProto      = protectProto,
23302f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
23402f4aeb0Sopenharmony_ci        apicall           = 'GLAPI ',
23502f4aeb0Sopenharmony_ci        apientry          = 'APIENTRY ',
23602f4aeb0Sopenharmony_ci        apientryp         = 'APIENTRYP '),
23702f4aeb0Sopenharmony_ci    # GLES 1.x API + mandatory extensions - GLES/gl.h (no function pointers)
23802f4aeb0Sopenharmony_ci    CGeneratorOptions(
23902f4aeb0Sopenharmony_ci        filename          = 'GLES/gl.h',
24002f4aeb0Sopenharmony_ci        apiname           = 'gles1',
24102f4aeb0Sopenharmony_ci        profile           = 'common',
24202f4aeb0Sopenharmony_ci        versions          = allVersions,
24302f4aeb0Sopenharmony_ci        emitversions      = allVersions,
24402f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
24502f4aeb0Sopenharmony_ci        addExtensions     = es1CorePat,             # Add mandatory ES1 extensions in GLES1/gl.h
24602f4aeb0Sopenharmony_ci        removeExtensions  = None,
24702f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + gles1PlatformStrings + genDateCommentString,
24802f4aeb0Sopenharmony_ci        genFuncPointers   = False,
24902f4aeb0Sopenharmony_ci        protectFile       = protectFile,
25002f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
25102f4aeb0Sopenharmony_ci        protectProto      = False,                  # Core ES API functions are in the static link libraries
25202f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
25302f4aeb0Sopenharmony_ci        apicall           = 'GL_API ',
25402f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
25502f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
25602f4aeb0Sopenharmony_ci    # GLES 1.x extensions - GLES/glext.h
25702f4aeb0Sopenharmony_ci    CGeneratorOptions(
25802f4aeb0Sopenharmony_ci        filename          = 'GLES/glext.h',
25902f4aeb0Sopenharmony_ci        apiname           = 'gles1',
26002f4aeb0Sopenharmony_ci        profile           = 'common',
26102f4aeb0Sopenharmony_ci        versions          = allVersions,
26202f4aeb0Sopenharmony_ci        emitversions      = noVersions,
26302f4aeb0Sopenharmony_ci        defaultExtensions = 'gles1',                # Default extensions for GLES 1
26402f4aeb0Sopenharmony_ci        addExtensions     = None,
26502f4aeb0Sopenharmony_ci        removeExtensions  = es1CorePat,             # Remove mandatory ES1 extensions in GLES1/glext.h
26602f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + apiEntryPrefixStrings + genDateCommentString,
26702f4aeb0Sopenharmony_ci        genFuncPointers   = True,
26802f4aeb0Sopenharmony_ci        protectFile       = protectFile,
26902f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
27002f4aeb0Sopenharmony_ci        protectProto      = protectProto,
27102f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
27202f4aeb0Sopenharmony_ci        apicall           = 'GL_API ',
27302f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
27402f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
27502f4aeb0Sopenharmony_ci    # GLES 2.0 API - GLES2/gl2.h (now with function pointers)
27602f4aeb0Sopenharmony_ci    CGeneratorOptions(
27702f4aeb0Sopenharmony_ci        filename          = 'GLES2/gl2.h',
27802f4aeb0Sopenharmony_ci        apiname           = 'gles2',
27902f4aeb0Sopenharmony_ci        profile           = 'common',
28002f4aeb0Sopenharmony_ci        versions          = gles2onlyPat,
28102f4aeb0Sopenharmony_ci        emitversions      = allVersions,
28202f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
28302f4aeb0Sopenharmony_ci        addExtensions     = None,
28402f4aeb0Sopenharmony_ci        removeExtensions  = None,
28502f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + gles2PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString,
28602f4aeb0Sopenharmony_ci        genFuncPointers   = True,
28702f4aeb0Sopenharmony_ci        protectFile       = protectFile,
28802f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
28902f4aeb0Sopenharmony_ci        protectProto      = 'nonzero',              # Core ES API functions are in the static link libraries
29002f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLES_PROTOTYPES',
29102f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
29202f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
29302f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
29402f4aeb0Sopenharmony_ci    # GLES 3.1 / 3.0 / 2.0 extensions - GLES2/gl2ext.h
29502f4aeb0Sopenharmony_ci    CGeneratorOptions(
29602f4aeb0Sopenharmony_ci        filename          = 'GLES2/gl2ext.h',
29702f4aeb0Sopenharmony_ci        apiname           = 'gles2',
29802f4aeb0Sopenharmony_ci        profile           = 'common',
29902f4aeb0Sopenharmony_ci        versions          = gles2onlyPat,
30002f4aeb0Sopenharmony_ci        emitversions      = None,
30102f4aeb0Sopenharmony_ci        defaultExtensions = 'gles2',                # Default extensions for GLES 2
30202f4aeb0Sopenharmony_ci        addExtensions     = None,
30302f4aeb0Sopenharmony_ci        removeExtensions  = None,
30402f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + apiEntryPrefixStrings + genDateCommentString,
30502f4aeb0Sopenharmony_ci        genFuncPointers   = True,
30602f4aeb0Sopenharmony_ci        protectFile       = protectFile,
30702f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
30802f4aeb0Sopenharmony_ci        protectProto      = protectProto,
30902f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
31002f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
31102f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
31202f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
31302f4aeb0Sopenharmony_ci    # GLES 3.2 API - GLES3/gl32.h (now with function pointers)
31402f4aeb0Sopenharmony_ci    CGeneratorOptions(
31502f4aeb0Sopenharmony_ci        filename          = 'GLES3/gl32.h',
31602f4aeb0Sopenharmony_ci        apiname           = 'gles2',
31702f4aeb0Sopenharmony_ci        profile           = 'common',
31802f4aeb0Sopenharmony_ci        versions          = gles2through32Pat,
31902f4aeb0Sopenharmony_ci        emitversions      = allVersions,
32002f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
32102f4aeb0Sopenharmony_ci        addExtensions     = None,
32202f4aeb0Sopenharmony_ci        removeExtensions  = None,
32302f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString,
32402f4aeb0Sopenharmony_ci        genFuncPointers   = True,
32502f4aeb0Sopenharmony_ci        protectFile       = protectFile,
32602f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
32702f4aeb0Sopenharmony_ci        protectProto      = 'nonzero',              # Core ES API functions are in the static link libraries
32802f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLES_PROTOTYPES',
32902f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
33002f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
33102f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
33202f4aeb0Sopenharmony_ci    # GLES 3.1 API - GLES3/gl31.h (now with function pointers)
33302f4aeb0Sopenharmony_ci    CGeneratorOptions(
33402f4aeb0Sopenharmony_ci        filename          = 'GLES3/gl31.h',
33502f4aeb0Sopenharmony_ci        apiname           = 'gles2',
33602f4aeb0Sopenharmony_ci        profile           = 'common',
33702f4aeb0Sopenharmony_ci        versions          = gles2through31Pat,
33802f4aeb0Sopenharmony_ci        emitversions      = allVersions,
33902f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
34002f4aeb0Sopenharmony_ci        addExtensions     = None,
34102f4aeb0Sopenharmony_ci        removeExtensions  = None,
34202f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString,
34302f4aeb0Sopenharmony_ci        genFuncPointers   = True,
34402f4aeb0Sopenharmony_ci        protectFile       = protectFile,
34502f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
34602f4aeb0Sopenharmony_ci        protectProto      = 'nonzero',              # Core ES API functions are in the static link libraries
34702f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLES_PROTOTYPES',
34802f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
34902f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
35002f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
35102f4aeb0Sopenharmony_ci    # GLES 3.0 API - GLES3/gl3.h (now with function pointers)
35202f4aeb0Sopenharmony_ci    CGeneratorOptions(
35302f4aeb0Sopenharmony_ci        filename          = 'GLES3/gl3.h',
35402f4aeb0Sopenharmony_ci        apiname           = 'gles2',
35502f4aeb0Sopenharmony_ci        profile           = 'common',
35602f4aeb0Sopenharmony_ci        versions          = gles2through30Pat,
35702f4aeb0Sopenharmony_ci        emitversions      = allVersions,
35802f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
35902f4aeb0Sopenharmony_ci        addExtensions     = None,
36002f4aeb0Sopenharmony_ci        removeExtensions  = None,
36102f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + gles3PlatformStrings + apiEntryPrefixStrings + glesProtoPrefixStrings + genDateCommentString,
36202f4aeb0Sopenharmony_ci        genFuncPointers   = True,
36302f4aeb0Sopenharmony_ci        protectFile       = protectFile,
36402f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
36502f4aeb0Sopenharmony_ci        protectProto      = 'nonzero',              # Core ES API functions are in the static link libraries
36602f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLES_PROTOTYPES',
36702f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
36802f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
36902f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
37002f4aeb0Sopenharmony_ci    # GLSC 2.0 API - GLSC2/glsc2.h
37102f4aeb0Sopenharmony_ci    CGeneratorOptions(
37202f4aeb0Sopenharmony_ci        filename          = 'GLSC2/glsc2.h',
37302f4aeb0Sopenharmony_ci        apiname           = 'glsc2',
37402f4aeb0Sopenharmony_ci        profile           = 'common',
37502f4aeb0Sopenharmony_ci        versions          = gles2onlyPat,
37602f4aeb0Sopenharmony_ci        emitversions      = allVersions,
37702f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
37802f4aeb0Sopenharmony_ci        addExtensions     = None,
37902f4aeb0Sopenharmony_ci        removeExtensions  = None,
38002f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + glsc2PlatformStrings + apiEntryPrefixStrings + genDateCommentString,
38102f4aeb0Sopenharmony_ci        genFuncPointers   = False,
38202f4aeb0Sopenharmony_ci        protectFile       = protectFile,
38302f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
38402f4aeb0Sopenharmony_ci        protectProto      = False,
38502f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
38602f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
38702f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
38802f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
38902f4aeb0Sopenharmony_ci    # GLSC 2.0 extensions - GLSC2/gl2ext.h
39002f4aeb0Sopenharmony_ci    CGeneratorOptions(
39102f4aeb0Sopenharmony_ci        filename          = 'GLSC2/glsc2ext.h',
39202f4aeb0Sopenharmony_ci        apiname           = 'glsc2',
39302f4aeb0Sopenharmony_ci        profile           = 'common',
39402f4aeb0Sopenharmony_ci        versions          = gles2onlyPat,
39502f4aeb0Sopenharmony_ci        emitversions      = None,
39602f4aeb0Sopenharmony_ci        defaultExtensions = 'glsc2',                # Default extensions for GLSC 2
39702f4aeb0Sopenharmony_ci        addExtensions     = None,
39802f4aeb0Sopenharmony_ci        removeExtensions  = None,
39902f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + apiEntryPrefixStrings + genDateCommentString,
40002f4aeb0Sopenharmony_ci        genFuncPointers   = False,
40102f4aeb0Sopenharmony_ci        protectFile       = protectFile,
40202f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
40302f4aeb0Sopenharmony_ci        protectProto      = False,
40402f4aeb0Sopenharmony_ci        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
40502f4aeb0Sopenharmony_ci        apicall           = 'GL_APICALL ',
40602f4aeb0Sopenharmony_ci        apientry          = 'GL_APIENTRY ',
40702f4aeb0Sopenharmony_ci        apientryp         = 'GL_APIENTRYP '),
40802f4aeb0Sopenharmony_ci    # EGL API - EGL/egl.h (no function pointers, yet @@@)
40902f4aeb0Sopenharmony_ci    CGeneratorOptions(
41002f4aeb0Sopenharmony_ci        filename          = 'EGL/egl.h',
41102f4aeb0Sopenharmony_ci        apiname           = 'egl',
41202f4aeb0Sopenharmony_ci        profile           = None,
41302f4aeb0Sopenharmony_ci        versions          = allVersions,
41402f4aeb0Sopenharmony_ci        emitversions      = allVersions,
41502f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
41602f4aeb0Sopenharmony_ci        addExtensions     = None,
41702f4aeb0Sopenharmony_ci        removeExtensions  = None,
41802f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + eglPlatformStrings + eglProtoPrefixStrings + genDateCommentString,
41902f4aeb0Sopenharmony_ci        genFuncPointers   = True,
42002f4aeb0Sopenharmony_ci        protectFile       = protectFile,
42102f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
42202f4aeb0Sopenharmony_ci        protectProto      = 'nonzero',
42302f4aeb0Sopenharmony_ci        protectProtoStr   = 'EGL_EGL_PROTOTYPES',
42402f4aeb0Sopenharmony_ci        apicall           = 'EGLAPI ',
42502f4aeb0Sopenharmony_ci        apientry          = 'EGLAPIENTRY ',
42602f4aeb0Sopenharmony_ci        apientryp         = 'EGLAPIENTRYP '),
42702f4aeb0Sopenharmony_ci    # EGL extensions - EGL/eglext.h (no function pointers, yet @@@)
42802f4aeb0Sopenharmony_ci    CGeneratorOptions(
42902f4aeb0Sopenharmony_ci        filename          = 'EGL/eglext.h',
43002f4aeb0Sopenharmony_ci        apiname           = 'egl',
43102f4aeb0Sopenharmony_ci        profile           = None,
43202f4aeb0Sopenharmony_ci        versions          = allVersions,
43302f4aeb0Sopenharmony_ci        emitversions      = None,
43402f4aeb0Sopenharmony_ci        defaultExtensions = 'egl',                  # Default extensions for EGL
43502f4aeb0Sopenharmony_ci        addExtensions     = None,
43602f4aeb0Sopenharmony_ci        removeExtensions  = None,
43702f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + eglPlatformStrings + eglextVersionStrings,
43802f4aeb0Sopenharmony_ci        genFuncPointers   = True,
43902f4aeb0Sopenharmony_ci        protectFile       = protectFile,
44002f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
44102f4aeb0Sopenharmony_ci        protectProto      = protectProto,
44202f4aeb0Sopenharmony_ci        protectProtoStr   = 'EGL_EGLEXT_PROTOTYPES',
44302f4aeb0Sopenharmony_ci        apicall           = 'EGLAPI ',
44402f4aeb0Sopenharmony_ci        apientry          = 'EGLAPIENTRY ',
44502f4aeb0Sopenharmony_ci        apientryp         = 'EGLAPIENTRYP '),
44602f4aeb0Sopenharmony_ci    # GLX 1.* API - GL/glx.h
44702f4aeb0Sopenharmony_ci    CGeneratorOptions(
44802f4aeb0Sopenharmony_ci        filename          = 'GL/glx.h',
44902f4aeb0Sopenharmony_ci        apiname           = 'glx',
45002f4aeb0Sopenharmony_ci        profile           = None,
45102f4aeb0Sopenharmony_ci        versions          = allVersions,
45202f4aeb0Sopenharmony_ci        emitversions      = allVersions,
45302f4aeb0Sopenharmony_ci        defaultExtensions = None,                   # No default extensions
45402f4aeb0Sopenharmony_ci        addExtensions     = None,
45502f4aeb0Sopenharmony_ci        removeExtensions  = None,
45602f4aeb0Sopenharmony_ci        # add glXPlatformStrings?
45702f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + genDateCommentString,
45802f4aeb0Sopenharmony_ci        genFuncPointers   = True,
45902f4aeb0Sopenharmony_ci        protectFile       = protectFile,
46002f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
46102f4aeb0Sopenharmony_ci        protectProto      = protectProto,
46202f4aeb0Sopenharmony_ci        protectProtoStr   = 'GLX_GLXEXT_PROTOTYPES',
46302f4aeb0Sopenharmony_ci        apicall           = '',
46402f4aeb0Sopenharmony_ci        apientry          = '',
46502f4aeb0Sopenharmony_ci        apientryp         = ' *'),
46602f4aeb0Sopenharmony_ci    # GLX 1.3+ API + extensions - GL/glxext.h (no function pointers, yet @@@)
46702f4aeb0Sopenharmony_ci    CGeneratorOptions(
46802f4aeb0Sopenharmony_ci        filename          = 'GL/glxext.h',
46902f4aeb0Sopenharmony_ci        apiname           = 'glx',
47002f4aeb0Sopenharmony_ci        profile           = None,
47102f4aeb0Sopenharmony_ci        versions          = allVersions,
47202f4aeb0Sopenharmony_ci        emitversions      = glx13andLaterPat,
47302f4aeb0Sopenharmony_ci        defaultExtensions = 'glx',                  # Default extensions for GLX
47402f4aeb0Sopenharmony_ci        addExtensions     = None,
47502f4aeb0Sopenharmony_ci        removeExtensions  = None,
47602f4aeb0Sopenharmony_ci        # add glXPlatformStrings?
47702f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + glxextVersionStrings,
47802f4aeb0Sopenharmony_ci        genFuncPointers   = True,
47902f4aeb0Sopenharmony_ci        protectFile       = protectFile,
48002f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
48102f4aeb0Sopenharmony_ci        protectProto      = protectProto,
48202f4aeb0Sopenharmony_ci        protectProtoStr   = 'GLX_GLXEXT_PROTOTYPES',
48302f4aeb0Sopenharmony_ci        apicall           = '',
48402f4aeb0Sopenharmony_ci        apientry          = '',
48502f4aeb0Sopenharmony_ci        apientryp         = ' *'),
48602f4aeb0Sopenharmony_ci    # WGL API + extensions - GL/wgl.h (no function pointers, yet @@@)
48702f4aeb0Sopenharmony_ci    CGeneratorOptions(
48802f4aeb0Sopenharmony_ci        filename          = 'GL/wgl.h',
48902f4aeb0Sopenharmony_ci        apiname           = 'wgl',
49002f4aeb0Sopenharmony_ci        profile           = None,
49102f4aeb0Sopenharmony_ci        versions          = allVersions,
49202f4aeb0Sopenharmony_ci        emitversions      = allVersions,
49302f4aeb0Sopenharmony_ci        defaultExtensions = 'wgl',                  # Default extensions for WGL
49402f4aeb0Sopenharmony_ci        addExtensions     = None,
49502f4aeb0Sopenharmony_ci        removeExtensions  = None,
49602f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + wglPlatformStrings + genDateCommentString,
49702f4aeb0Sopenharmony_ci        genFuncPointers   = True,
49802f4aeb0Sopenharmony_ci        protectFile       = protectFile,
49902f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
50002f4aeb0Sopenharmony_ci        protectProto      = protectProto,
50102f4aeb0Sopenharmony_ci        protectProtoStr   = 'WGL_WGLEXT_PROTOTYPES',
50202f4aeb0Sopenharmony_ci        apicall           = '',
50302f4aeb0Sopenharmony_ci        apientry          = 'WINAPI ',
50402f4aeb0Sopenharmony_ci        apientryp         = 'WINAPI * '),
50502f4aeb0Sopenharmony_ci    # WGL extensions - GL/wglext.h (no function pointers, yet @@@)
50602f4aeb0Sopenharmony_ci    CGeneratorOptions(
50702f4aeb0Sopenharmony_ci        filename          = 'GL/wglext.h',
50802f4aeb0Sopenharmony_ci        apiname           = 'wgl',
50902f4aeb0Sopenharmony_ci        profile           = None,
51002f4aeb0Sopenharmony_ci        versions          = allVersions,
51102f4aeb0Sopenharmony_ci        emitversions      = None,
51202f4aeb0Sopenharmony_ci        defaultExtensions = 'wgl',                  # Default extensions for WGL
51302f4aeb0Sopenharmony_ci        addExtensions     = None,
51402f4aeb0Sopenharmony_ci        removeExtensions  = None,
51502f4aeb0Sopenharmony_ci        prefixText        = prefixStrings + wglPlatformStrings + wglextVersionStrings,
51602f4aeb0Sopenharmony_ci        genFuncPointers   = True,
51702f4aeb0Sopenharmony_ci        protectFile       = protectFile,
51802f4aeb0Sopenharmony_ci        protectFeature    = protectFeature,
51902f4aeb0Sopenharmony_ci        protectProto      = protectProto,
52002f4aeb0Sopenharmony_ci        protectProtoStr   = 'WGL_WGLEXT_PROTOTYPES',
52102f4aeb0Sopenharmony_ci        apicall           = '',
52202f4aeb0Sopenharmony_ci        apientry          = 'WINAPI ',
52302f4aeb0Sopenharmony_ci        apientryp         = 'WINAPI * '),
52402f4aeb0Sopenharmony_ci    # End of list
52502f4aeb0Sopenharmony_ci    None
52602f4aeb0Sopenharmony_ci]
52702f4aeb0Sopenharmony_ci
52802f4aeb0Sopenharmony_cidef genHeaders():
52902f4aeb0Sopenharmony_ci    # Loop over targets, building each
53002f4aeb0Sopenharmony_ci    generated = 0
53102f4aeb0Sopenharmony_ci    for genOpts in buildList:
53202f4aeb0Sopenharmony_ci        if (genOpts == None):
53302f4aeb0Sopenharmony_ci            break
53402f4aeb0Sopenharmony_ci        if (target and target != genOpts.filename):
53502f4aeb0Sopenharmony_ci            # write('*** Skipping', genOpts.filename)
53602f4aeb0Sopenharmony_ci            continue
53702f4aeb0Sopenharmony_ci        write('*** Building', genOpts.filename)
53802f4aeb0Sopenharmony_ci        generated = generated + 1
53902f4aeb0Sopenharmony_ci        startTimer()
54002f4aeb0Sopenharmony_ci        gen = COutputGenerator(errFile=errWarn,
54102f4aeb0Sopenharmony_ci                               warnFile=errWarn,
54202f4aeb0Sopenharmony_ci                               diagFile=diag)
54302f4aeb0Sopenharmony_ci        reg.setGenerator(gen)
54402f4aeb0Sopenharmony_ci        reg.apiGen(genOpts)
54502f4aeb0Sopenharmony_ci        write('** Generated', genOpts.filename)
54602f4aeb0Sopenharmony_ci        endTimer('Time to generate ' + genOpts.filename + ' =')
54702f4aeb0Sopenharmony_ci    if (target and generated == 0):
54802f4aeb0Sopenharmony_ci        write('Failed to generate target:', target)
54902f4aeb0Sopenharmony_ci
55002f4aeb0Sopenharmony_ciif __name__ == '__main__':
55102f4aeb0Sopenharmony_ci    i = 1
55202f4aeb0Sopenharmony_ci    while (i < len(sys.argv)):
55302f4aeb0Sopenharmony_ci        arg = sys.argv[i]
55402f4aeb0Sopenharmony_ci        i = i + 1
55502f4aeb0Sopenharmony_ci        if (arg == '-debug'):
55602f4aeb0Sopenharmony_ci            write('Enabling debug (-debug)', file=sys.stderr)
55702f4aeb0Sopenharmony_ci            debug = True
55802f4aeb0Sopenharmony_ci        elif (arg == '-dump'):
55902f4aeb0Sopenharmony_ci            write('Enabling dump (-dump)', file=sys.stderr)
56002f4aeb0Sopenharmony_ci            dump = True
56102f4aeb0Sopenharmony_ci        elif (arg == '-noprotect'):
56202f4aeb0Sopenharmony_ci            write('Disabling inclusion protection in output headers', file=sys.stderr)
56302f4aeb0Sopenharmony_ci            protect = False
56402f4aeb0Sopenharmony_ci        elif (arg == '-profile'):
56502f4aeb0Sopenharmony_ci            write('Enabling profiling (-profile)', file=sys.stderr)
56602f4aeb0Sopenharmony_ci            profile = True
56702f4aeb0Sopenharmony_ci        elif (arg == '-registry'):
56802f4aeb0Sopenharmony_ci            regFilename = sys.argv[i]
56902f4aeb0Sopenharmony_ci            i = i+1
57002f4aeb0Sopenharmony_ci            write('Using registry ', regFilename, file=sys.stderr)
57102f4aeb0Sopenharmony_ci        elif (arg == '-time'):
57202f4aeb0Sopenharmony_ci            write('Enabling timing (-time)', file=sys.stderr)
57302f4aeb0Sopenharmony_ci            timeit = True
57402f4aeb0Sopenharmony_ci        elif (arg == '-validate'):
57502f4aeb0Sopenharmony_ci            write('Enabling group validation (-validate)', file=sys.stderr)
57602f4aeb0Sopenharmony_ci            validate = True
57702f4aeb0Sopenharmony_ci        elif (arg[0:1] == '-'):
57802f4aeb0Sopenharmony_ci            write('Unrecognized argument:', arg, file=sys.stderr)
57902f4aeb0Sopenharmony_ci            exit(1)
58002f4aeb0Sopenharmony_ci        else:
58102f4aeb0Sopenharmony_ci            target = arg
58202f4aeb0Sopenharmony_ci            write('Using target', target, file=sys.stderr)
58302f4aeb0Sopenharmony_ci
58402f4aeb0Sopenharmony_ci    # Load & parse registry
58502f4aeb0Sopenharmony_ci    reg = Registry()
58602f4aeb0Sopenharmony_ci
58702f4aeb0Sopenharmony_ci    startTimer()
58802f4aeb0Sopenharmony_ci    tree = etree.parse(regFilename)
58902f4aeb0Sopenharmony_ci    endTimer('Time to make ElementTree =')
59002f4aeb0Sopenharmony_ci
59102f4aeb0Sopenharmony_ci    startTimer()
59202f4aeb0Sopenharmony_ci    reg.loadElementTree(tree)
59302f4aeb0Sopenharmony_ci    endTimer('Time to parse ElementTree =')
59402f4aeb0Sopenharmony_ci
59502f4aeb0Sopenharmony_ci    if (validate):
59602f4aeb0Sopenharmony_ci        reg.validateGroups()
59702f4aeb0Sopenharmony_ci
59802f4aeb0Sopenharmony_ci    if (dump):
59902f4aeb0Sopenharmony_ci        write('***************************************')
60002f4aeb0Sopenharmony_ci        write('Performing Registry dump to regdump.txt')
60102f4aeb0Sopenharmony_ci        write('***************************************')
60202f4aeb0Sopenharmony_ci        reg.dumpReg(filehandle = open('regdump.txt','w'))
60302f4aeb0Sopenharmony_ci
60402f4aeb0Sopenharmony_ci    # create error/warning & diagnostic files
60502f4aeb0Sopenharmony_ci    if (errFilename):
60602f4aeb0Sopenharmony_ci        errWarn = open(errFilename,'w')
60702f4aeb0Sopenharmony_ci    else:
60802f4aeb0Sopenharmony_ci        errWarn = sys.stderr
60902f4aeb0Sopenharmony_ci    diag = open(diagFilename, 'w')
61002f4aeb0Sopenharmony_ci
61102f4aeb0Sopenharmony_ci    if (debug):
61202f4aeb0Sopenharmony_ci        pdb.run('genHeaders()')
61302f4aeb0Sopenharmony_ci    elif (profile):
61402f4aeb0Sopenharmony_ci        import cProfile, pstats
61502f4aeb0Sopenharmony_ci        cProfile.run('genHeaders()', 'profile.txt')
61602f4aeb0Sopenharmony_ci        p = pstats.Stats('profile.txt')
61702f4aeb0Sopenharmony_ci        p.strip_dirs().sort_stats('time').print_stats(50)
61802f4aeb0Sopenharmony_ci    else:
61902f4aeb0Sopenharmony_ci        genHeaders()
620