diff options
| author | Chia-I Wu <olv@lunarg.com> | 2015-04-11 10:56:50 +0800 |
|---|---|---|
| committer | Chia-I Wu <olv@lunarg.com> | 2015-04-11 13:12:45 +0800 |
| commit | a781a7013d166b5bd42cd96ac7e0502c804ef15b (patch) | |
| tree | c9d3416c6f7d2227421ac499537efba81f65c20b | |
| parent | 13d4c3303ee6bbbe87e29dcf4a65f19597d2a12c (diff) | |
| download | usermoji-a781a7013d166b5bd42cd96ac7e0502c804ef15b.tar.xz | |
xgl-generate.py: add WinDefFileSubcommand
It replaces xgl-win-def-file-generate.py and is able to generate loader's
XGL.def.
| -rw-r--r-- | layers/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | loader/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | loader/XGL.def | 154 | ||||
| -rwxr-xr-x | xgl-generate.py | 70 | ||||
| -rwxr-xr-x | xgl-win-def-file-generate.py | 112 |
5 files changed, 76 insertions, 268 deletions
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index ae4222cf..47070aa1 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -17,8 +17,8 @@ endmacro() if (WIN32) macro(add_xgl_layer target) add_custom_command(OUTPUT XGLLayer${target}.def - COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/xgl-win-def-file-generate.py ${target} > XGLLayer${target}.def - DEPENDS ${PROJECT_SOURCE_DIR}/xgl-win-def-file-generate.py + COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/xgl-generate.py win-def-file XGLLayer${target} layer > XGLLayer${target}.def + DEPENDS ${PROJECT_SOURCE_DIR}/xgl-generate.py ${PROJECT_SOURCE_DIR}/xgl.py ) add_library(XGLLayer${target} SHARED ${ARGN} XGLLayer${target}.def) target_link_Libraries(XGLLayer${target} layer_utils) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 66c80186..23195110 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -7,6 +7,10 @@ add_custom_command(OUTPUT table_ops.h COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/xgl-generate.py dispatch-table-ops loader > table_ops.h DEPENDS ${PROJECT_SOURCE_DIR}/xgl-generate.py ${PROJECT_SOURCE_DIR}/xgl.py) +add_custom_command(OUTPUT XGL.def + COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/xgl-generate.py win-def-file XGL all > XGL.def + DEPENDS ${PROJECT_SOURCE_DIR}/xgl-generate.py ${PROJECT_SOURCE_DIR}/xgl.py) + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} diff --git a/loader/XGL.def b/loader/XGL.def deleted file mode 100644 index 4d1877ea..00000000 --- a/loader/XGL.def +++ /dev/null @@ -1,154 +0,0 @@ -;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; XGL -; -; Copyright (C) 2015 LunarG, Inc. -; -; Permission is hereby granted, free of charge, to any person obtaining a -; copy of this software and associated documentation files (the "Software"), -; to deal in the Software without restriction, including without limitation -; the rights to use, copy, modify, merge, publish, distribute, sublicense, -; and/or sell copies of the Software, and to permit persons to whom the -; Software is furnished to do so, subject to the following conditions: -; -; The above copyright notice and this permission notice shall be included -; in all copies or substantial portions of the Software. -; -; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -; DEALINGS IN THE SOFTWARE. -;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; The following is required on Windows, for exporting symbols from the DLL - -LIBRARY XGL -EXPORTS - xglCreateInstance - xglDestroyInstance - xglEnumerateGpus - xglGetGpuInfo - xglGetProcAddr - xglCreateDevice - xglDestroyDevice - xglGetExtensionSupport - xglEnumerateLayers - xglGetDeviceQueue - xglQueueSubmit - xglQueueSetGlobalMemReferences - xglQueueWaitIdle - xglDeviceWaitIdle - xglAllocMemory - xglFreeMemory - xglSetMemoryPriority - xglMapMemory - xglUnmapMemory - xglPinSystemMemory - xglGetMultiGpuCompatibility - xglOpenSharedMemory - xglOpenSharedQueueSemaphore - xglOpenPeerMemory - xglOpenPeerImage - xglDestroyObject - xglGetObjectInfo - xglBindObjectMemory - xglBindObjectMemoryRange - xglBindImageMemoryRange - xglCreateFence - xglGetFenceStatus - xglWaitForFences - xglCreateQueueSemaphore - xglSignalQueueSemaphore - xglWaitQueueSemaphore - xglCreateEvent - xglGetEventStatus - xglSetEvent - xglResetEvent - xglCreateQueryPool - xglGetQueryPoolResults - xglGetFormatInfo - xglCreateBuffer - xglCreateBufferView - xglCreateImage - xglSetFastClearColor - xglSetFastClearDepth - xglGetImageSubresourceInfo - xglCreateImageView - xglCreateColorAttachmentView - xglCreateDepthStencilView - xglCreateShader - xglCreateGraphicsPipeline - xglCreateComputePipeline - xglStorePipeline - xglLoadPipeline - xglCreatePipelineDelta - xglCreateSampler - xglCreateDescriptorSetLayout - xglBeginDescriptorRegionUpdate - xglEndDescriptorRegionUpdate - xglCreateDescriptorRegion - xglClearDescriptorRegion - xglAllocDescriptorSets - xglClearDescriptorSets - xglUpdateDescriptors - xglCreateDynamicViewportState - xglCreateDynamicRasterState - xglCreateDynamicColorBlendState - xglCreateDynamicDepthStencilState - xglCreateCommandBuffer - xglBeginCommandBuffer - xglEndCommandBuffer - xglResetCommandBuffer - xglCmdBindPipeline - xglCmdBindPipelineDelta - xglCmdBindDynamicStateObject - xglCmdBindDescriptorSet - xglCmdBindVertexBuffer - xglCmdBindIndexBuffer - xglCmdDraw - xglCmdDrawIndexed - xglCmdDrawIndirect - xglCmdDrawIndexedIndirect - xglCmdDispatch - xglCmdDispatchIndirect - xglCmdCopyBuffer - xglCmdCopyImage - xglCmdCopyBufferToImage - xglCmdCopyImageToBuffer - xglCmdCloneImageData - xglCmdUpdateBuffer - xglCmdFillBuffer - xglCmdClearColorImage - xglCmdClearColorImageRaw - xglCmdClearDepthStencil - xglCmdResolveImage - xglCmdSetEvent - xglCmdResetEvent - xglCmdWaitEvents - xglCmdPipelineBarrier - xglCmdBeginQuery - xglCmdEndQuery - xglCmdResetQueryPool - xglCmdWriteTimestamp - xglCmdInitAtomicCounters - xglCmdLoadAtomicCounters - xglCmdSaveAtomicCounters - xglCreateFramebuffer - xglCreateRenderPass - xglCmdBeginRenderPass - xglCmdEndRenderPass - xglDbgSetValidationLevel - xglDbgRegisterMsgCallback - xglDbgUnregisterMsgCallback - xglDbgSetMessageFilter - xglDbgSetObjectTag - xglDbgSetGlobalOption - xglDbgSetDeviceOption - xglCmdDbgMarkerBegin - xglCmdDbgMarkerEnd - xglWsiX11AssociateConnection - xglWsiX11GetMSC - xglWsiX11CreatePresentableImage - xglWsiX11QueuePresent diff --git a/xgl-generate.py b/xgl-generate.py index 44ba04c2..262c73df 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -432,6 +432,75 @@ class LayerInterceptProcSubcommand(Subcommand): return "\n".join(body) +class WinDefFileSubcommand(Subcommand): + def run(self): + library_exports = { + "all": [], + "icd": [ + "EnumerateGpus", + "CreateInstance", + "DestroyInstance", + "GetProcAddr", + ], + "layer": [ + "GetProcAddr", + "EnumerateLayers", + ], + } + + if len(self.argv) != 2 or self.argv[1] not in library_exports: + print("WinDefFileSubcommand: <library-name> {%s}" % + "|".join(library_exports.keys())) + return + + self.library = self.argv[0] + self.exports = library_exports[self.argv[1]] + + super().run() + + def generate_copyright(self): + return """; THIS FILE IS GENERATED. DO NOT EDIT. + +;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; XGL +; +; Copyright (C) 2015 LunarG, Inc. +; +; Permission is hereby granted, free of charge, to any person obtaining a +; copy of this software and associated documentation files (the "Software"), +; to deal in the Software without restriction, including without limitation +; the rights to use, copy, modify, merge, publish, distribute, sublicense, +; and/or sell copies of the Software, and to permit persons to whom the +; Software is furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included +; in all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +; DEALINGS IN THE SOFTWARE. +;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;""" + + def generate_header(self): + return "; The following is required on Windows, for exporting symbols from the DLL" + + def generate_body(self): + body = [] + + body.append("LIBRARY " + self.library) + body.append("EXPORTS") + + for proto in self.protos: + if self.exports and proto.name not in self.exports: + continue + body.append(" xgl" + proto.name) + + return "\n".join(body) + def main(): subcommands = { "loader-entrypoints": LoaderEntrypointsSubcommand, @@ -439,6 +508,7 @@ def main(): "icd-dummy-entrypoints": IcdDummyEntrypointsSubcommand, "icd-get-proc-addr": IcdGetProcAddrSubcommand, "layer-intercept-proc": LayerInterceptProcSubcommand, + "win-def-file": WinDefFileSubcommand, } if len(sys.argv) < 2 or sys.argv[1] not in subcommands: diff --git a/xgl-win-def-file-generate.py b/xgl-win-def-file-generate.py deleted file mode 100755 index 9d66caec..00000000 --- a/xgl-win-def-file-generate.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python3 -# -# XGL -# -# Copyright (C) 2015 LunarG, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -# Authors: -# Chia-I Wu <olv@lunarg.com> -# Ian Elliott <ian@lunarg.com> - -import sys - -import xgl - -def generate_get_proc_addr_check(name): - return " if (!%s || %s[0] != 'x' || %s[1] != 'g' || %s[2] != 'l')\n" \ - " return NULL;" % ((name,) * 4) - -class Subcommand(object): - def __init__(self, argv): - self.argv = argv - self.headers = xgl.headers - self.protos = xgl.protos - - def run(self): - print(self.generate()) - - def generate(self): - copyright = self.generate_copyright() - header = self.generate_header() - body = self.generate_body() - footer = self.generate_footer() - - contents = [] - if copyright: - contents.append(copyright) - if header: - contents.append(header) - if body: - contents.append(body) - if footer: - contents.append(footer) - - return "\n\n".join(contents) - - def generate_copyright(self): - return """; THIS FILE IS GENERATED. DO NOT EDIT. - -;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; XGL -; -; Copyright (C) 2015 LunarG, Inc. -; -; Permission is hereby granted, free of charge, to any person obtaining a -; copy of this software and associated documentation files (the "Software"), -; to deal in the Software without restriction, including without limitation -; the rights to use, copy, modify, merge, publish, distribute, sublicense, -; and/or sell copies of the Software, and to permit persons to whom the -; Software is furnished to do so, subject to the following conditions: -; -; The above copyright notice and this permission notice shall be included -; in all copies or substantial portions of the Software. -; -; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -; DEALINGS IN THE SOFTWARE. -;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; The following is required on Windows, for exporting symbols from the DLL""" - - def generate_header(self): - pass - - def generate_body(self): - return "LIBRARY XGLLayer" + sys.argv[1] - - def generate_footer(self): - return "EXPORTS\n xglGetProcAddr\n xglEnumerateLayers" - -def main(): - - if len(sys.argv) < 1: - print("Usage: %s <file>" % sys.argv[0]) - exit(1) - - subcmd = Subcommand(sys.argv[1:]) - subcmd.run() - -if __name__ == "__main__": - main() |
