From 70d0e81c3644c25e2d144de91beb8d6c6802dabc Mon Sep 17 00:00:00 2001 From: jackun Date: Thu, 13 Feb 2020 23:33:04 +0200 Subject: [PATCH] Clone vulkan headers if needed --- .gitmodules | 3 --- meson.build | 11 +++-------- modules/Vulkan-Headers | 1 - modules/Vulkan-Headers/clone_headers.sh | 11 +++++++++++ modules/Vulkan-Headers/meson.build | 12 ++++++++++++ src/meson.build | 2 +- 6 files changed, 27 insertions(+), 13 deletions(-) delete mode 160000 modules/Vulkan-Headers create mode 100755 modules/Vulkan-Headers/clone_headers.sh create mode 100644 modules/Vulkan-Headers/meson.build diff --git a/.gitmodules b/.gitmodules index 289685c..2bc3d68 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "modules/ImGui/src"] path = modules/ImGui/src url = https://github.com/flightlessmango/ImGui.git -[submodule "modules/Vulkan-Headers"] - path = modules/Vulkan-Headers - url = https://github.com/KhronosGroup/Vulkan-Headers.git diff --git a/meson.build b/meson.build index f20b3e2..6a55ce6 100644 --- a/meson.build +++ b/meson.build @@ -111,11 +111,6 @@ inc_common = [ ] dep_vulkan = dependency('vulkan', required: get_option('use_system_vulkan')) -if not dep_vulkan.found() - inc_common += [ - include_directories('modules/Vulkan-Headers/include') - ] -endif # Check for generic C arguments c_args = [] @@ -191,17 +186,17 @@ endif dep_pthread = cc.find_library('pthread') if dep_vulkan.found() + vulkan_headers = [] datadir = get_option('datadir') if not datadir.startswith('/') datadir = get_option('prefix') / datadir endif vk_api_xml = files(datadir / 'vulkan/registry/vk.xml') else - vk_api_xml = files('modules/Vulkan-Headers/registry/vk.xml') + subdir('modules/Vulkan-Headers') + vulkan_headers = vk_api_xml endif -vk_layer_table_helpers = [] - vk_enum_to_str = custom_target( 'vk_enum_to_str', input : ['bin/gen_enum_to_str.py', vk_api_xml], diff --git a/modules/Vulkan-Headers b/modules/Vulkan-Headers deleted file mode 160000 index 7264358..0000000 --- a/modules/Vulkan-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7264358702061d3ed819d62d3d6fd66ab1da33c3 diff --git a/modules/Vulkan-Headers/clone_headers.sh b/modules/Vulkan-Headers/clone_headers.sh new file mode 100755 index 0000000..5ae20a5 --- /dev/null +++ b/modules/Vulkan-Headers/clone_headers.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +GIT="$1" +BUILD_DIR="$2" + +if [ ! -f "$BUILD_DIR/registry/vk.xml" ]; then + "$GIT" clone --depth 1 https://github.com/KhronosGroup/Vulkan-Headers.git "$BUILD_DIR" +fi + +ln -sf "registry/vk.xml" modules/Vulkan-Headers/ +ln -sf "include/vulkan" modules/Vulkan-Headers/ diff --git a/modules/Vulkan-Headers/meson.build b/modules/Vulkan-Headers/meson.build new file mode 100644 index 0000000..da666de --- /dev/null +++ b/modules/Vulkan-Headers/meson.build @@ -0,0 +1,12 @@ +prog_git = find_program('git') +prog_sh = find_program('sh') +script_clone_hdrs = files('clone_headers.sh') + +vk_api_xml = custom_target( + 'vk_api_xml', + input : [], + output : ['vk.xml'], # because output can't have segments, link vk.xml to this subdir dir in build prefix + command : [ + prog_sh, script_clone_hdrs, prog_git, meson.current_build_dir() + ], +) diff --git a/src/meson.build b/src/meson.build index 3095632..cf52db6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -50,7 +50,7 @@ vklayer_mesa_overlay = shared_library( vk_enum_to_str, vklayer_files, overlay_spv, - vk_layer_table_helpers, + vulkan_headers, c_args : [ pre_args, c_vis_args,