tools/spec: specify target platforms via command line argument
This commit is contained in:
parent
0a15b518b1
commit
4bd6cc648e
@ -18,6 +18,15 @@ endif ()
|
||||
include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
|
||||
if (WIN32)
|
||||
set(VK_PLATFORM "win32")
|
||||
elseif(LINUX)
|
||||
set(VK_PLATFORM "xcb")
|
||||
else()
|
||||
message(FATAL_ERROR "unhandled platform")
|
||||
endif()
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
add_custom_command (
|
||||
OUTPUT
|
||||
@ -27,8 +36,9 @@ COMMENT
|
||||
COMMAND
|
||||
"${PYTHON_EXECUTABLE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/vk.hpp"
|
||||
"--src" "${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
||||
"--dst" "${CMAKE_CURRENT_BINARY_DIR}/vk.hpp"
|
||||
"--platform" "${VK_PLATFORM}"
|
||||
DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
||||
|
@ -42,7 +42,7 @@ class registry:
|
||||
|
||||
return result
|
||||
|
||||
def serialise(self, platform:str):
|
||||
def serialise(self, platform:Set[str]):
|
||||
required = []
|
||||
|
||||
for (_,f) in self.features.items():
|
||||
@ -490,12 +490,12 @@ class extension(type):
|
||||
else:
|
||||
raise "Unknown extension node"
|
||||
|
||||
def apply(self, reg:registry, platform:str):
|
||||
def apply(self, reg:registry, platform:Set[str]):
|
||||
if self.name in reg.applied:
|
||||
return []
|
||||
reg.applied.add(self.name)
|
||||
|
||||
if self.platform and self.platform != platform:
|
||||
if self.platform and self.platform not in platform:
|
||||
return []
|
||||
|
||||
required = []
|
||||
@ -650,8 +650,14 @@ if __name__ == '__main__':
|
||||
logging.getLogger().setLevel(logging.WARNING)
|
||||
|
||||
parser = argparse.ArgumentParser(description='Transform XML API specification into C++ headers')
|
||||
parser.add_argument('src', type=str, help='the path to the XML file to transform')
|
||||
parser.add_argument('dst', type=str, help='the output path for the result')
|
||||
parser.add_argument('--src', type=str, help='the path to the XML file to transform')
|
||||
parser.add_argument('--dst', type=str, help='the output path for the result')
|
||||
parser.add_argument(
|
||||
'--platform',
|
||||
type=str,
|
||||
action='append',
|
||||
help='a platform to generate output for. may be specific multiple times"'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -681,7 +687,7 @@ if __name__ == '__main__':
|
||||
|
||||
#reg.extensions['VK_KHR_surface'].apply(reg, platform='xcb')
|
||||
extensions = ["VK_KHR_swapchain", "VK_EXT_debug_report", "VK_KHR_external_memory"]
|
||||
q = reg.serialise(platform='xcb')
|
||||
q = reg.serialise(args.platform)
|
||||
|
||||
|
||||
dst.write("#pragma once\n")
|
||||
|
Loading…
Reference in New Issue
Block a user