aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/dependencies/__init__.py3
-rw-r--r--mesonbuild/dependencies/ui.py55
-rw-r--r--test cases/frameworks/17 vulkan/meson.build7
-rw-r--r--test cases/frameworks/17 vulkan/vulkanprog.c35
4 files changed, 98 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index 3d41a2b..f153b97 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -19,7 +19,7 @@ from .base import ( # noqa: F401
from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency
from .misc import BoostDependency, Python3Dependency, ThreadDependency
from .platform import AppleFrameworks
-from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency
+from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency
packages.update({
@@ -44,4 +44,5 @@ packages.update({
'qt5': Qt5Dependency,
'sdl2': SDL2Dependency,
'wxwidgets': WxDependency,
+ 'vulkan': VulkanDependency,
})
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index 1c59a41..18a7996 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -24,7 +24,7 @@ from collections import OrderedDict
from .. import mlog
from .. import mesonlib
from ..mesonlib import MesonException, Popen_safe, version_compare
-from ..environment import for_windows
+from ..environment import for_windows, detect_cpu
from .base import DependencyException, DependencyMethods
from .base import ExternalDependency, ExternalProgram
@@ -493,3 +493,56 @@ class WxDependency(ExternalDependency):
pass
WxDependency.wxconfig_found = False
mlog.log('Found wx-config:', mlog.red('NO'))
+
+class VulkanDependency(ExternalDependency):
+ def __init__(self, environment, kwargs):
+ super().__init__('vulkan', environment, None, kwargs)
+
+ if DependencyMethods.SYSTEM in self.methods:
+ try:
+ self.vulkan_sdk = os.environ['VULKAN_SDK']
+ if not os.path.isabs(self.vulkan_sdk):
+ raise DependencyException('VULKAN_SDK must be an absolute path.')
+
+ # TODO: this config might not work on some platforms, fix bugs as reported
+ # we at least have to detect other 64-bit platforms (e.g. armv8)
+ lib_name = 'vulkan'
+ if mesonlib.is_windows():
+ lib_name = 'vulkan-1'
+
+ lib_dir = 'Lib32'
+ if detect_cpu({}) == 'x86_64':
+ lib_dir = 'Lib'
+
+ self.type_name = 'vulkan_sdk'
+ self.is_found = True
+ self.compile_args.append('-I' + os.path.join(self.vulkan_sdk, 'Include'))
+ self.link_args.append('-L' + os.path.join(self.vulkan_sdk, lib_dir))
+ self.link_args.append('-l' + lib_name)
+
+ # TODO: find a way to retrieve this from the sdk
+ # we could try go guess it depending on the vulkan_sdk path
+ # usually the paths last component is the vulkan version
+ # but this might be modified at installation
+ self.version = '1'
+ return
+ except KeyError:
+ self.vulkan_sdk = None
+
+ if DependencyMethods.PKGCONFIG in self.methods:
+ try:
+ pcdep = PkgConfigDependency('vulkan', environment, kwargs)
+ if pcdep.found():
+ self.type_name = 'pkgconfig'
+ self.is_found = True
+ self.compile_args = pcdep.get_compile_args()
+ self.link_args = pcdep.get_link_args()
+ self.version = pcdep.get_version()
+ return
+ except Exception:
+ pass
+
+ def get_methods(self):
+ return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM]
+
+
diff --git a/test cases/frameworks/17 vulkan/meson.build b/test cases/frameworks/17 vulkan/meson.build
new file mode 100644
index 0000000..05e6ce7
--- /dev/null
+++ b/test cases/frameworks/17 vulkan/meson.build
@@ -0,0 +1,7 @@
+project('vulkan test', 'c')
+
+sdl2_dep = dependency('vulkan')
+
+e = executable('vulkanprog', 'vulkanprog.c', dependencies : sdl2_dep)
+
+test('vulkantest', e)
diff --git a/test cases/frameworks/17 vulkan/vulkanprog.c b/test cases/frameworks/17 vulkan/vulkanprog.c
new file mode 100644
index 0000000..86a3a20
--- /dev/null
+++ b/test cases/frameworks/17 vulkan/vulkanprog.c
@@ -0,0 +1,35 @@
+#include <vulkan/vulkan.h>
+#include <stdio.h>
+
+int main()
+{
+ VkApplicationInfo application_info = {
+ VK_STRUCTURE_TYPE_APPLICATION_INFO,
+ NULL,
+ "sway",
+ VK_MAKE_VERSION(1,0,0),
+ "wlroots",
+ VK_MAKE_VERSION(1,0,0),
+ VK_MAKE_VERSION(1,0,0)
+ };
+
+ VkInstanceCreateInfo instance_create_info = {
+ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+ NULL,
+ 0,
+ &application_info,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ };
+
+ VkInstance instance;
+ VkResult ret = vkCreateInstance(&instance_create_info, NULL, &instance);
+ if(ret != VK_SUCCESS) {
+ printf("Could not create vulkan instance: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+} \ No newline at end of file