示例#1
0
def makeGenOpts(args):
    global genOpts
    genOpts = {}

    # Extensions to emit (list of extensions)
    emitExtensions = args.emitExtensions

    # Features to include (list of features)
    features = args.feature

    # Output target directory
    directory = args.directory

    # Descriptive names for various regexp patterns used to select
    # versions and extensions
    allFeatures = allExtensions = '.*'

    # Turn lists of names/patterns into matching regular expressions
    emitExtensionsPat = makeREstring(emitExtensions, allExtensions)
    featuresPat = makeREstring(features, allFeatures)

    # Copyright text prefixing all headers (list of strings).
    prefixStrings = [
        '/*', '** Copyright (c) 2017-2022, The Khronos Group Inc.', '**',
        '** Licensed under the Apache License, Version 2.0 (the "License");',
        '** you may not use this file except in compliance with the License.',
        '** You may obtain a copy of the License at', '**',
        '**     http://www.apache.org/licenses/LICENSE-2.0', '**',
        '** Unless required by applicable law or agreed to in writing, software',
        '** distributed under the License is distributed on an "AS IS" BASIS,',
        '** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
        '** See the License for the specific language governing permissions and',
        '** limitations under the License.', '*/', ''
    ]

    # Text specific to OpenXR headers
    xrPrefixStrings = [
        '/*',
        '** This header is generated from the Khronos OpenXR XML API Registry.',
        '**', '*/', ''
    ]

    # An API style conventions object
    conventions = OpenXRConventions()

    if HAVE_CONFORMANCE:
        genOpts['function_info.cpp'] = [
            ConformanceGenerator,
            AutomaticSourceGeneratorOptions(conventions=conventions,
                                            filename='function_info.cpp',
                                            directory=directory,
                                            apiname='openxr',
                                            profile=None,
                                            versions=featuresPat,
                                            emitversions=featuresPat,
                                            defaultExtensions='openxr',
                                            addExtensions=None,
                                            removeExtensions=None,
                                            emitExtensions=emitExtensionsPat,
                                            prefixText=prefixStrings +
                                            xrPrefixStrings,
                                            protectFeature=False,
                                            protectProto='#ifndef',
                                            protectProtoStr='XR_NO_PROTOTYPES',
                                            apicall='XRAPI_ATTR ',
                                            apientry='XRAPI_CALL ',
                                            apientryp='XRAPI_PTR *',
                                            alignFuncParam=48)
        ]

        genOpts['gen_dispatch.cpp'] = [
            ConformanceLayerGenerator,
            AutomaticSourceGeneratorOptions(
                conventions=conventions,
                filename='gen_dispatch.cpp',
                directory=directory,
                apiname='openxr',
                profile=None,
                versions=featuresPat,
                emitversions=featuresPat,
                defaultExtensions='openxr',
                addExtensions=None,
                removeExtensions=None,
                emitExtensions=emitExtensionsPat,
                apicall='XRAPI_ATTR ',
                apientry='XRAPI_CALL ',
                apientryp='XRAPI_PTR *',
            )
        ]

        genOpts['gen_dispatch.h'] = [
            ConformanceLayerGenerator,
            AutomaticSourceGeneratorOptions(
                conventions=conventions,
                filename='gen_dispatch.h',
                directory=directory,
                apiname='openxr',
                profile=None,
                versions=featuresPat,
                emitversions=featuresPat,
                defaultExtensions='openxr',
                addExtensions=None,
                removeExtensions=None,
                emitExtensions=emitExtensionsPat,
                apicall='XRAPI_ATTR ',
                apientry='XRAPI_CALL ',
                apientryp='XRAPI_PTR *',
            )
        ]

    genOpts['xr_generated_dispatch_table.h'] = [
        UtilitySourceOutputGenerator,
        AutomaticSourceGeneratorOptions(
            conventions=conventions,
            filename='xr_generated_dispatch_table.h',
            directory=directory,
            apiname='openxr',
            profile=None,
            versions=featuresPat,
            emitversions=featuresPat,
            defaultExtensions='openxr',
            addExtensions=None,
            removeExtensions=None,
            emitExtensions=emitExtensionsPat)
    ]

    genOpts['xr_generated_dispatch_table.c'] = [
        UtilitySourceOutputGenerator,
        AutomaticSourceGeneratorOptions(
            conventions=conventions,
            filename='xr_generated_dispatch_table.c',
            directory=directory,
            apiname='openxr',
            profile=None,
            versions=featuresPat,
            emitversions=featuresPat,
            defaultExtensions='openxr',
            addExtensions=None,
            removeExtensions=None,
            emitExtensions=emitExtensionsPat)
    ]

    genOpts['xr_generated_loader.hpp'] = [
        LoaderSourceOutputGenerator,
        AutomaticSourceGeneratorOptions(conventions=conventions,
                                        filename='xr_generated_loader.hpp',
                                        directory=directory,
                                        apiname='openxr',
                                        profile=None,
                                        versions=featuresPat,
                                        emitversions=featuresPat,
                                        defaultExtensions='openxr',
                                        addExtensions=None,
                                        removeExtensions=None,
                                        emitExtensions=emitExtensionsPat,
                                        prefixText=prefixStrings +
                                        xrPrefixStrings,
                                        protectFeature=False,
                                        protectProto='#ifndef',
                                        protectProtoStr='XR_NO_PROTOTYPES',
                                        apicall='XRAPI_ATTR ',
                                        apientry='XRAPI_CALL ',
                                        apientryp='XRAPI_PTR *',
                                        alignFuncParam=48)
    ]

    genOpts['xr_generated_loader.cpp'] = [
        LoaderSourceOutputGenerator,
        AutomaticSourceGeneratorOptions(conventions=conventions,
                                        filename='xr_generated_loader.cpp',
                                        directory=directory,
                                        apiname='openxr',
                                        profile=None,
                                        versions=featuresPat,
                                        emitversions=featuresPat,
                                        defaultExtensions='openxr',
                                        addExtensions=None,
                                        removeExtensions=None,
                                        emitExtensions=emitExtensionsPat,
                                        prefixText=prefixStrings +
                                        xrPrefixStrings,
                                        protectFeature=False,
                                        protectProto='#ifndef',
                                        protectProtoStr='XR_NO_PROTOTYPES',
                                        apicall='XRAPI_ATTR ',
                                        apientry='XRAPI_CALL ',
                                        apientryp='XRAPI_PTR *',
                                        alignFuncParam=48)
    ]

    # Source files generated for the api_dump layer
    genOpts['xr_generated_api_dump.cpp'] = [
        ApiDumpOutputGenerator,
        AutomaticSourceGeneratorOptions(conventions=conventions,
                                        filename='xr_generated_api_dump.cpp',
                                        directory=directory,
                                        apiname='openxr',
                                        profile=None,
                                        versions=featuresPat,
                                        emitversions=featuresPat,
                                        defaultExtensions='openxr',
                                        addExtensions=None,
                                        removeExtensions=None,
                                        emitExtensions=emitExtensionsPat,
                                        apicall='XRAPI_ATTR ',
                                        apientry='XRAPI_CALL ',
                                        apientryp='XRAPI_PTR *')
    ]

    genOpts['xr_generated_api_dump.hpp'] = [
        ApiDumpOutputGenerator,
        AutomaticSourceGeneratorOptions(conventions=conventions,
                                        filename='xr_generated_api_dump.hpp',
                                        directory=directory,
                                        apiname='openxr',
                                        profile=None,
                                        versions=featuresPat,
                                        emitversions=featuresPat,
                                        defaultExtensions='openxr',
                                        addExtensions=None,
                                        removeExtensions=None,
                                        emitExtensions=emitExtensionsPat,
                                        apicall='XRAPI_ATTR ',
                                        apientry='XRAPI_CALL ',
                                        apientryp='XRAPI_PTR *')
    ]

    # Source files generated for the core validation layer
    genOpts['xr_generated_core_validation.hpp'] = [
        ValidationSourceOutputGenerator,
        AutomaticSourceGeneratorOptions(
            conventions=conventions,
            filename='xr_generated_core_validation.hpp',
            directory=directory,
            apiname='openxr',
            profile=None,
            versions=featuresPat,
            emitversions=featuresPat,
            defaultExtensions='openxr',
            addExtensions=None,
            removeExtensions=None,
            emitExtensions=emitExtensionsPat,
            apicall='XRAPI_ATTR ',
            apientry='XRAPI_CALL ',
            apientryp='XRAPI_PTR *')
    ]

    genOpts['xr_generated_core_validation.cpp'] = [
        ValidationSourceOutputGenerator,
        AutomaticSourceGeneratorOptions(
            conventions=conventions,
            filename='xr_generated_core_validation.cpp',
            directory=directory,
            apiname='openxr',
            profile=None,
            versions=featuresPat,
            emitversions=featuresPat,
            defaultExtensions='openxr',
            addExtensions=None,
            removeExtensions=None,
            emitExtensions=emitExtensionsPat,
            apicall='XRAPI_ATTR ',
            apientry='XRAPI_CALL ',
            apientryp='XRAPI_PTR *')
    ]
示例#2
0
def makeGenOpts(args):
    """Returns a directory of [ generator function, generator options ] indexed
    by specified short names. The generator options incorporate the following
    parameters:

    args is an parsed argument object; see below for the fields that are used."""
    global genOpts
    genOpts = {}

    # Default class of extensions to include, or None
    defaultExtensions = args.defaultExtensions

    # Additional extensions to include (list of extensions)
    extensions = args.extension

    # Extensions to remove (list of extensions)
    removeExtensions = args.removeExtensions

    # Extensions to emit (list of extensions)
    emitExtensions = args.emitExtensions

    # Features to include (list of features)
    features = args.feature

    # Whether to disable inclusion protect in headers
    protect = args.protect

    # Output target directory
    directory = args.directory

    # Descriptive names for various regexp patterns used to select
    # versions and extensions
    allFeatures = allExtensions = r'.*'

    # Turn lists of names/patterns into matching regular expressions
    addExtensionsPat = makeREstring(extensions, None)
    removeExtensionsPat = makeREstring(removeExtensions, None)
    emitExtensionsPat = makeREstring(emitExtensions, allExtensions)
    featuresPat = makeREstring(features, allFeatures)

    # Copyright text prefixing all headers (list of strings).
    prefixStrings = [
        '/*', '** Copyright (c) 2017-2020 The Khronos Group Inc.', '**',
        '** SPDX-License-Identifier: Apache-2.0', '**',
        '** Licensed under the Apache License, Version 2.0 (the "License");',
        '** you may not use this file except in compliance with the License.',
        '** You may obtain a copy of the License at', '**',
        '**     http://www.apache.org/licenses/LICENSE-2.0', '**',
        '** Unless required by applicable law or agreed to in writing, software',
        '** distributed under the License is distributed on an "AS IS" BASIS,',
        '** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
        '** See the License for the specific language governing permissions and',
        '** limitations under the License.', '*/', ''
    ]

    # Text specific to OpenXR headers
    xrPrefixStrings = [
        '/*',
        '** This header is generated from the Khronos OpenXR XML API Registry.',
        '**', '*/', ''
    ]

    # Include the non-platform openxr header in the platform header.
    platformPrefixStrings = ['#include "openxr.h"']

    # Defaults for generating re-inclusion protection wrappers (or not)
    protectFile = protect

    # An API style conventions object
    conventions = OpenXRConventions()

    # OpenXR 1.0 - header for core API + extensions.
    # To generate just the core API,
    # change to 'defaultExtensions = None' below.
    genOpts['openxr.h'] = [
        COutputGenerator,
        CGeneratorOptions(conventions=conventions,
                          filename='openxr.h',
                          directory=directory,
                          apiname='openxr',
                          profile=None,
                          versions=featuresPat,
                          emitversions=featuresPat,
                          defaultExtensions='openxr',
                          addExtensions=None,
                          removeExtensions=None,
                          emitExtensions=emitExtensionsPat,
                          prefixText=prefixStrings + xrPrefixStrings,
                          genFuncPointers=True,
                          protectFile=protectFile,
                          protectFeature=False,
                          protectProto='#ifndef',
                          protectProtoStr='XR_NO_PROTOTYPES',
                          apicall='XRAPI_ATTR ',
                          apientry='XRAPI_CALL ',
                          apientryp='XRAPI_PTR *',
                          alignFuncParam=48,
                          genAliasMacro=True,
                          aliasMacro='XR_MAY_ALIAS')
    ]

    # OpenXR platform header for Graphics API and Platform extensions.
    genOpts['openxr_platform.h'] = [
        COutputGenerator,
        CGeneratorOptions(conventions=conventions,
                          filename='openxr_platform.h',
                          directory=directory,
                          apiname='openxr',
                          profile=None,
                          versions=featuresPat,
                          emitversions=featuresPat,
                          defaultExtensions='openxr',
                          addExtensions=None,
                          removeExtensions=None,
                          emitExtensions=emitExtensionsPat,
                          prefixText=prefixStrings + xrPrefixStrings +
                          platformPrefixStrings,
                          genFuncPointers=True,
                          protectFile=protectFile,
                          protectFeature=False,
                          protectProto='#ifndef',
                          protectProtoStr='XR_NO_PROTOTYPES',
                          apicall='XRAPI_ATTR ',
                          apientry='XRAPI_CALL ',
                          apientryp='XRAPI_PTR *',
                          alignFuncParam=48,
                          genAliasMacro=True,
                          aliasMacro='XR_MAY_ALIAS')
    ]

    # OpenXR platform header for Graphics API and Platform extensions.
    genOpts['openxr_reflection.h'] = [
        CReflectionOutputGenerator,
        CGeneratorOptions(conventions=conventions,
                          filename='openxr_reflection.h',
                          directory=directory,
                          apiname='openxr',
                          profile=None,
                          versions=featuresPat,
                          emitversions=featuresPat,
                          defaultExtensions='openxr',
                          addExtensions=None,
                          removeExtensions=None,
                          emitExtensions=emitExtensionsPat,
                          prefixText=prefixStrings + xrPrefixStrings +
                          platformPrefixStrings,
                          genFuncPointers=True,
                          protectFile=protectFile,
                          protectFeature=False,
                          protectProto='#ifndef',
                          protectProtoStr='XR_NO_PROTOTYPES',
                          apicall='XRAPI_ATTR ',
                          apientry='XRAPI_CALL ',
                          apientryp='XRAPI_PTR *',
                          alignFuncParam=48,
                          genAliasMacro=True,
                          aliasMacro='XR_MAY_ALIAS')
    ]

    # OpenXR 1.0 - API include files for spec and ref pages
    # Overwrites include subdirectories in spec source tree
    # The generated include files do not include the calling convention
    # macros (apientry etc.), unlike the header files.
    # Because the 1.0 core branch includes ref pages for extensions,
    # all the extension interfaces need to be generated, even though
    # none are used by the core spec itself.
    genOpts['apiinc'] = [
        DocOutputGenerator,
        DocGeneratorOptions(conventions=conventions,
                            filename='apiinc',
                            directory=directory,
                            apiname='openxr',
                            profile=None,
                            versions=featuresPat,
                            emitversions=featuresPat,
                            defaultExtensions=None,
                            addExtensions=addExtensionsPat,
                            removeExtensions=removeExtensionsPat,
                            emitExtensions=emitExtensionsPat,
                            prefixText=prefixStrings + xrPrefixStrings,
                            apicall='',
                            apientry='',
                            apientryp='*',
                            alignFuncParam=48,
                            secondaryInclude=True,
                            expandEnumerants=False,
                            extEnumerantAdditions=True)
    ]

    # API names to validate man/api spec includes & links
    genOpts['xrapi.py'] = [
        PyOutputGenerator,
        DocGeneratorOptions(conventions=conventions,
                            filename='xrapi.py',
                            directory=directory,
                            apiname='openxr',
                            profile=None,
                            versions=featuresPat,
                            emitversions=featuresPat,
                            defaultExtensions=None,
                            addExtensions=addExtensionsPat,
                            removeExtensions=removeExtensionsPat,
                            emitExtensions=emitExtensionsPat)
    ]

    # Index chapter
    genOpts['index.adoc'] = [
        DocIndexOutputGenerator,
        DocGeneratorOptions(conventions=conventions,
                            filename='index.adoc',
                            directory=directory,
                            apiname='openxr',
                            profile=None,
                            versions=featuresPat,
                            emitversions=featuresPat,
                            defaultExtensions=None,
                            addExtensions=addExtensionsPat,
                            removeExtensions=removeExtensionsPat,
                            emitExtensions=emitExtensionsPat)
    ]

    # Core API validity files for spec
    genOpts['validinc'] = [
        ValidityOutputGenerator,
        DocGeneratorOptions(conventions=conventions,
                            filename='validinc',
                            directory=directory,
                            apiname='openxr',
                            profile=None,
                            versions=featuresPat,
                            emitversions=featuresPat,
                            defaultExtensions=None,
                            addExtensions=addExtensionsPat,
                            removeExtensions=removeExtensionsPat,
                            emitExtensions=emitExtensionsPat)
    ]

    # Core API host sync table files for spec
    genOpts['hostsyncinc'] = [
        HostSynchronizationOutputGenerator,
        DocGeneratorOptions(conventions=conventions,
                            filename='hostsyncinc',
                            directory=directory,
                            apiname='openxr',
                            profile=None,
                            versions=featuresPat,
                            emitversions=featuresPat,
                            defaultExtensions=None,
                            addExtensions=addExtensionsPat,
                            removeExtensions=removeExtensionsPat,
                            emitExtensions=emitExtensionsPat)
    ]

    # Extension metainformation for spec extension appendices
    genOpts['extinc'] = [
        ExtensionMetaDocOutputGenerator,
        ExtensionMetaDocGeneratorOptions(conventions=conventions,
                                         filename='extinc',
                                         directory=directory,
                                         apiname='openxr',
                                         profile=None,
                                         versions=featuresPat,
                                         emitversions=None,
                                         defaultExtensions=defaultExtensions,
                                         addExtensions=None,
                                         removeExtensions=None,
                                         emitExtensions=emitExtensionsPat)
    ]
示例#3
0
                 sections=sections,
                 tail_content=makeExtensionInclude(name))
    refPageTail(pageName=name,
                specType=None,
                specAnchor=name,
                seeAlso=seeAlsoList(name, declares),
                fp=fp,
                auto=True)
    fp.close()


if __name__ == '__main__':
    global genDict, extensions, conventions, apiName
    genDict = {}
    extensions = OrderedDict()
    conventions = APIConventions()
    apiName = conventions.api_name('api')

    parser = argparse.ArgumentParser()

    parser.add_argument('-diag',
                        action='store',
                        dest='diagFile',
                        help='Set the diagnostic file')
    parser.add_argument('-warn',
                        action='store',
                        dest='warnFile',
                        help='Set the warning file')
    parser.add_argument(
        '-log',
        action='store',
示例#4
0
def genTarget(args):
    """
    Generate a target based on the options in the matching genOpts{} object.

    This is encapsulated in a function so it can be profiled and/or timed.
    The args parameter is an parsed argument object containing the following
    fields that are used:
    target - target to generate
    directory - directory to generate it in
    protect - True if re-inclusion wrappers should be created
    extensions - list of additional extensions to include in generated
    interfaces
    """
    # Create generator options with specified parameters
    header = args.target
    if 'dispatch' in args.target:
        # Don't omit anything when generating dispatchers.
        removeExtensions = None
    else:
        removeExtensions = makeREstring((
            # Atom not projecting right?
            "XR_MSFT_controller_model",
            # Projection of static string fails
            "XR_MSFT_spatial_graph_bridge",
        ))

    # Turn lists of names/patterns into matching regular expressions
    emitExtensionsPat = makeREstring(args.emitExtensions, '.*')
    featuresPat = makeREstring(args.feature, '.*')
    options = AutomaticSourceGeneratorOptions(
        conventions=OpenXRConventions(),
        filename=header,
        directory=args.directory,
        apiname='openxr',
        profile=None,
        versions=featuresPat,
        emitversions=featuresPat,
        defaultExtensions='openxr',
        addExtensions=None,
        removeExtensions=removeExtensions,
        emitExtensions=emitExtensionsPat)

    if not args.quiet:
        write('* Building', options.filename, file=sys.stderr)
        write('* options.versions          =',
              options.versions,
              file=sys.stderr)
        write('* options.emitversions      =',
              options.emitversions,
              file=sys.stderr)
        write('* options.defaultExtensions =',
              options.defaultExtensions,
              file=sys.stderr)
        write('* options.addExtensions     =',
              options.addExtensions,
              file=sys.stderr)
        write('* options.removeExtensions  =',
              options.removeExtensions,
              file=sys.stderr)
        write('* options.emitExtensions    =',
              options.emitExtensions,
              file=sys.stderr)

    startTimer(args.time)
    gen = CppGenerator(errFile=errWarn,
                       warnFile=errWarn,
                       diagFile=diag,
                       quiet=args.quiet)
    reg.setGenerator(gen)
    reg.apiGen(options)

    if not args.quiet:
        write('* Generated', options.filename, file=sys.stderr)
    endTimer(args.time, '* Time to generate ' + options.filename + ' =')