diff options
author | nyorain <nyorain@gmail.com> | 2017-07-25 23:20:05 +0200 |
---|---|---|
committer | nyorain <nyorain@gmail.com> | 2017-07-25 23:20:05 +0200 |
commit | 005e0416452c980ef350371db56612a0f12f99dd (patch) | |
tree | c11cc0cb0f04cb166c4cd557b3ce1425fe96c9bb | |
parent | 0c2ef49dc504368dd4ff80545b38c2380391cd65 (diff) | |
download | meson-005e0416452c980ef350371db56612a0f12f99dd.zip meson-005e0416452c980ef350371db56612a0f12f99dd.tar.gz meson-005e0416452c980ef350371db56612a0f12f99dd.tar.bz2 |
Fix vulkan module for linux
Rework the vulkan module:
- adopt the VULKAN_SDK paths for its linux version
- add sanity tests for the VULKAN_SDK path
- add guessing as last fallback, needed on linux systems
on which no vulkan pkgconfig is installed [ubuntu atm]
- restructure exception handling/branching
Not tested on windows yet.
-rw-r--r-- | mesonbuild/dependencies/ui.py | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index d639285..1de7438 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -498,49 +498,71 @@ class VulkanDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('vulkan', environment, None, kwargs) + 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 + 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.') + except KeyError: + self.vulkan_sdk = None + if self.vulkan_sdk: # TODO: this config might not work on some platforms, fix bugs as reported # we should at least detect other 64-bit platforms (e.g. armv8) lib_name = 'vulkan' if mesonlib.is_windows(): lib_name = 'vulkan-1' + lib_dir = 'Lib32' + inc_dir = 'Include' + if detect_cpu({}) == 'x86_64': + lib_dir = 'Lib' + else: + lib_name = 'vulkan' + lib_dir = 'lib' + inc_dir = 'include' - lib_dir = 'Lib32' - if detect_cpu({}) == 'x86_64': - lib_dir = 'Lib' + # make sure header and lib are valid + inc_path = os.path.join(self.vulkan_sdk, inc_dir) + header = os.path.join(inc_path, 'vulkan', 'vulkan.h') + lib_path = os.path.join(self.vulkan_sdk, lib_dir) + find_lib = self.compiler.find_library('vulkan', environment, lib_path) + + if not (find_lib and os.path.isfile(header)): + raise DependencyException('VULKAN_SDK point to invalid directory') 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.compile_args.append('-I' + inc_path) + self.link_args.append('-L' + lib_path) self.link_args.append('-l' + lib_name) # TODO: find a way to retrieve the version 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 + # Usually it is a part of the path to it (but does not have to be) 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' + else: + # simply try to guess it, usually works on linux + libs = self.compiler.find_library('vulkan', environment, []) + if libs != None and self.compiler.has_header('vulkan/vulkan.h', '', environment): + self.type_name = 'system' self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() + self.version = 1 # TODO + for lib in libs: + self.link_args.append(lib) return - except Exception: - pass def get_methods(self): return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] |